[DM/FDT] Fixup memory address reserved and translate in early

1.Fixup `fdt_reserved_memory_reg` loop time.
2.Fixup `rt_fdt_translate_address` cells value reader.

Signed-off-by: GuEe-GUI <2991707448@qq.com>
This commit is contained in:
GuEe-GUI 2024-06-04 15:46:24 +08:00 committed by Rbb666
parent 992e79a0f8
commit 87906499a3
1 changed files with 8 additions and 8 deletions

View File

@ -85,15 +85,15 @@ rt_uint64_t rt_fdt_translate_address(void *fdt, int nodeoffset, rt_uint64_t addr
if (parent >= 0) if (parent >= 0)
{ {
ranges = fdt_getprop(fdt, nodeoffset, "ranges", &length); ranges = fdt_getprop(fdt, parent, "ranges", &length);
} }
if (ranges && length > 0) if (ranges && length > 0)
{ {
local.addr_cells = fdt_address_cells(fdt, nodeoffset); local.addr_cells = fdt_address_cells(fdt, parent);
local.size_cells = fdt_size_cells(fdt, nodeoffset); local.size_cells = fdt_size_cells(fdt, parent);
cpu.addr_cells = fdt_io_addr_cells(fdt, nodeoffset); cpu.addr_cells = fdt_io_addr_cells(fdt, parent);
cpu.size_cells = fdt_io_size_cells(fdt, nodeoffset); cpu.size_cells = fdt_io_size_cells(fdt, parent);
group_len = local.addr_cells + cpu.addr_cells + local.size_cells; group_len = local.addr_cells + cpu.addr_cells + local.size_cells;
@ -105,7 +105,7 @@ rt_uint64_t rt_fdt_translate_address(void *fdt, int nodeoffset, rt_uint64_t addr
if (local.addr <= address && local.addr + local.size > address) if (local.addr <= address && local.addr + local.size > address)
{ {
ret += address - cpu.addr; ret = address - local.addr + cpu.addr;
break; break;
} }
@ -247,9 +247,9 @@ static rt_err_t fdt_reserved_memory_reg(int nodeoffset, const char *uname)
rt_bool_t is_nomap = fdt_getprop(_fdt, nodeoffset, "no-map", RT_NULL) ? RT_TRUE : RT_FALSE; rt_bool_t is_nomap = fdt_getprop(_fdt, nodeoffset, "no-map", RT_NULL) ? RT_TRUE : RT_FALSE;
base = rt_fdt_translate_address(_fdt, nodeoffset, base); base = rt_fdt_translate_address(_fdt, nodeoffset, base);
rt_memblock_reserve_memory(uname, base, base + size, is_nomap);
len -= t_len; rt_memblock_reserve_memory(fdt_get_name(_fdt, nodeoffset, RT_NULL),
base, base + size, is_nomap);
} }
} }
} }