EFI: get address-cells and size-cells from the device tree
They were hardcoded to 2, which is not correct on all devices. As a result, getting addresses and sizes on pure 32bit devices would fail. Change-Id: Icf542c9e8d6b7136219014fe08dd601387de4762 Reviewed-on: https://review.haiku-os.org/c/haiku/+/5102 Reviewed-by: Fredrik Holmqvist <[email protected]> Reviewed-by: waddlesplash <[email protected]> Tested-by: Commit checker robot <[email protected]>
This commit is contained in:
committed by
waddlesplash
parent
f37f79066c
commit
ef41059432
@@ -298,11 +298,11 @@ dtb_get_reg(const void* fdt, int node, uint32 addressCells, uint32 sizeCells, si
|
|||||||
if (prop == NULL)
|
if (prop == NULL)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
size_t entrySize = 4*(addressCells + sizeCells);
|
size_t entrySize = 4 * (addressCells + sizeCells);
|
||||||
if ((idx + 1)*entrySize > (size_t)propSize)
|
if ((idx + 1) * entrySize > (size_t)propSize)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
prop += idx*entrySize;
|
prop += idx * entrySize;
|
||||||
|
|
||||||
switch (addressCells) {
|
switch (addressCells) {
|
||||||
case 1: range.start = fdt32_to_cpu(*(uint32*)prop); prop += 4; break;
|
case 1: range.start = fdt32_to_cpu(*(uint32*)prop); prop += 4; break;
|
||||||
@@ -471,8 +471,20 @@ dtb_init()
|
|||||||
|
|
||||||
int node = -1;
|
int node = -1;
|
||||||
int depth = -1;
|
int depth = -1;
|
||||||
|
uint32 addressCells = 0;
|
||||||
|
uint32 sizeCells = 0;
|
||||||
while ((node = fdt_next_node(sDtbTable, node, &depth)) >= 0 && depth >= 0) {
|
while ((node = fdt_next_node(sDtbTable, node, &depth)) >= 0 && depth >= 0) {
|
||||||
dtb_handle_fdt(sDtbTable, node, 2, 2);
|
if (addressCells == 0) {
|
||||||
|
uint32* prop = (uint32*)fdt_getprop(sDtbTable, node, "#address-cells", NULL);
|
||||||
|
addressCells = fdt32_to_cpu(*prop);
|
||||||
|
INFO("Address cells at %p: %u\n", prop, addressCells);
|
||||||
|
}
|
||||||
|
if (sizeCells == 0) {
|
||||||
|
uint32* prop = (uint32*)fdt_getprop(sDtbTable, node, "#size-cells", NULL);
|
||||||
|
sizeCells = fdt32_to_cpu(*prop);
|
||||||
|
INFO("Size cells at %p: %u\n", prop, sizeCells);
|
||||||
|
}
|
||||||
|
dtb_handle_fdt(sDtbTable, node, addressCells, sizeCells);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user