Skip to content

Commit

Permalink
[DM/FDT] Fixup memory address reserved and translate in early
Browse files Browse the repository at this point in the history
1.Fixup `fdt_reserved_memory_reg` loop time.
2.Fixup `rt_fdt_translate_address` cells value reader.

Signed-off-by: GuEe-GUI <[email protected]>
  • Loading branch information
GuEe-GUI authored and Rbb666 committed Sep 19, 2024
1 parent 992e79a commit 8790649
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions components/drivers/ofw/fdt.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,15 @@ rt_uint64_t rt_fdt_translate_address(void *fdt, int nodeoffset, rt_uint64_t addr

if (parent >= 0)
{
ranges = fdt_getprop(fdt, nodeoffset, "ranges", &length);
ranges = fdt_getprop(fdt, parent, "ranges", &length);
}

if (ranges && length > 0)
{
local.addr_cells = fdt_address_cells(fdt, nodeoffset);
local.size_cells = fdt_size_cells(fdt, nodeoffset);
cpu.addr_cells = fdt_io_addr_cells(fdt, nodeoffset);
cpu.size_cells = fdt_io_size_cells(fdt, nodeoffset);
local.addr_cells = fdt_address_cells(fdt, parent);
local.size_cells = fdt_size_cells(fdt, parent);
cpu.addr_cells = fdt_io_addr_cells(fdt, parent);
cpu.size_cells = fdt_io_size_cells(fdt, parent);

group_len = local.addr_cells + cpu.addr_cells + local.size_cells;

Expand All @@ -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)
{
ret += address - cpu.addr;
ret = address - local.addr + cpu.addr;
break;
}

Expand Down Expand Up @@ -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;
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);
}
}
}
Expand Down

0 comments on commit 8790649

Please sign in to comment.