dev_mem: Fix config judgment

Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
This commit is contained in:
wangjianyu3 2024-07-24 20:39:45 +08:00 committed by Xiang Xiao
parent 3c0befbdbd
commit 6013591cb1

View File

@ -218,38 +218,41 @@ int devmem_register(void)
return -ENOMEM; return -ENOMEM;
} }
#ifdef CONFIG_BOARD_MEMORY_RANGE if (CONFIG_BOARD_MEMORY_RANGE[0] != '\0')
len = parse_memory_region(CONFIG_BOARD_MEMORY_RANGE, region,
DEVMEM_REGION - 1);
if (len < 0)
{ {
kmm_free(region); len = parse_memory_region(CONFIG_BOARD_MEMORY_RANGE, region,
return len; DEVMEM_REGION - 1);
} if (len < 0)
#else {
if (len + (4 - merge) > DEVMEM_REGION) kmm_free(region);
{ return len;
len = DEVMEM_REGION - (4 - merge); }
}
region[len].flags = PROT_EXEC | PROT_READ;
region[len].start = (uintptr_t)_stext;
region[len++].end = (uintptr_t)_etext;
region[len].flags = PROT_WRITE | PROT_READ;
region[len].start = (uintptr_t)_sdata;
region[len++].end = (uintptr_t)_edata;
if (merge)
{
region[len - 1].end = (uintptr_t)_ebss;
} }
else else
{ {
if (len + (4 - merge) > DEVMEM_REGION)
{
len = DEVMEM_REGION - (4 - merge);
}
region[len].flags = PROT_EXEC | PROT_READ;
region[len].start = (uintptr_t)_stext;
region[len++].end = (uintptr_t)_etext;
region[len].flags = PROT_WRITE | PROT_READ; region[len].flags = PROT_WRITE | PROT_READ;
region[len].start = (uintptr_t)_sbss; region[len].start = (uintptr_t)_sdata;
region[len++].end = (uintptr_t)_ebss; region[len++].end = (uintptr_t)_edata;
if (merge)
{
region[len - 1].end = (uintptr_t)_ebss;
}
else
{
region[len].flags = PROT_WRITE | PROT_READ;
region[len].start = (uintptr_t)_sbss;
region[len++].end = (uintptr_t)_ebss;
}
} }
#endif
/* register the new MEM driver */ /* register the new MEM driver */