Attention is currently required from: Alper Nebi Yasak, Julius Werner.
5 comments:
File src/lib/device_tree.c:
Patch Set #3, Line 181: if (be32_to_cpu(header->magic) != FDT_HEADER_MAGIC)
I assume that you're going to be needing more from that FDT blob in your boot model and this won't remain the only bit of code you need to access that wants to extract properties from a flattened DT blob? In that case I think we should start right away with adding more high-level access routines for use on FDT blobs. For the header check here it could be an `fdt_is_valid(void *blob)` that checks the magic number and maybe some of the other things `fdt_unflatten()` currently does as well (like compatible version). To read a node could have an `fdt_find_node()` analogous to our existing `dt_find_node()`... or, if you're worried about the inefficiencies of walking the tree multiple times, you could come up with some kind of API that finds multiple nodes at once:
```
struct fdt_lookup {
// fill out before passing into fdt_find_nodes()
const char *path;
// filled out by fdt_find_nodes()
void *fdt_node;
uint32_t addr_cells;
uint32_t size_cells;
}
enum cb_err fdt_find_nodes(struct fdt_lookup *lookups, size_t num_lookups);
```
Anyway, point being I think we should factor out and reuse the things we're going to need multiple times.
Patch Set #3, Line 203: offset
Aren't you hardcoding an assumption here that the `memory` node will come after the `#address-cells` and `#size-cells` nodes if you don't reset `offset` to 0?
Patch Set #3, Line 205: if (!strncmp(name, "memory", sizeof("memory")) ||
`strncmp(a, "literal", sizeof("literal"))` is just a more complicated way to write `strcmp(a, "literal")`.
Patch Set #3, Line 220: while ((size = fdt_next_property(blob, offset, &prop))) {
Same for properties, we should probably write an `fdt_find_prop()` helper rather than having to code this while loop again every time.
Patch Set #3, Line 234: uintptr_t mem_size = 0;
I would recommend using uint64_t when dealing with physical addresses and sizes. (For arm64 it doesn't make a difference, but e.g. arm32 systems can have more memory than they can physically address with a uintptr_t.)
To view, visit change 80322. To unsubscribe, or for help writing mail filters, visit settings.