[fdt] Remove concept of a device tree cursor

Refactor device tree traversal to operate on the basis of describing
the token at a given offset, with no separate notion of a device tree
cursor.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown
2025-04-14 11:33:27 +01:00
parent b1125007ca
commit d462aeb0ca
3 changed files with 165 additions and 124 deletions

View File

@@ -158,6 +158,7 @@ static const uint8_t sifive_u[] = {
*
*/
static void fdt_test_exec ( void ) {
struct fdt_descriptor desc;
struct fdt_header *hdr;
struct fdt fdt;
const char *string;
@@ -218,6 +219,19 @@ static void fdt_test_exec ( void ) {
ok ( ( string = fdt_string ( &fdt, offset, "compatible" ) ) != NULL );
ok ( strcmp ( string, "sifive,uart0" ) == 0 );
ok ( fdt_alias ( &fdt, "nonexistent0", &offset ) != 0 );
/* Verify node description */
ok ( fdt_path ( &fdt, "/memory@80000000", &offset ) == 0 );
ok ( fdt_describe ( &fdt, offset, &desc ) == 0 );
ok ( desc.offset == offset );
ok ( strcmp ( desc.name, "memory@80000000" ) == 0 );
ok ( desc.data == NULL );
ok ( desc.len == 0 );
ok ( desc.depth == +1 );
ok ( fdt_describe ( &fdt, desc.next, &desc ) == 0 );
ok ( strcmp ( desc.name, "device_type" ) == 0 );
ok ( strcmp ( desc.data, "memory" ) == 0 );
ok ( desc.depth == 0 );
}
/** FDT self-test */