intel / FdtBusPkg

Device Tree-based Platform Device Driver Development for Tiano UEFI
https://wiki.riseproject.dev/display/HOME/EDK2_00_03+-+FdtBusDxe+support
11 stars 1 forks source link

Consider a GetPropName DtIo call #75

Open andreiw opened 7 months ago

andreiw commented 7 months ago

...with a signature like the following. This has no use in a driver, but it would be super-useful for the DtProp tool, to be able to explore a Devicetree in a UEFI system.

typedef
EFI_STATUS
(EFIAPI *EFI_DT_IO_PROTOCOL_GET_PROP_NAME)(
  IN  EFI_DT_IO_PROTOCOL *This,
  IN  UINTN              Index,
  OUT CONST CHAR8        **String
  );

Implementation-wise, this could do something like. Of course it would be terribly inefficient... but this shouldn't matter for a debug aid.

do {
    tag = fdt_next_tag(fdt, offset, &nextoffset);
    if (tag == FDT_END) {
        return;
    }

    if (tag == FDT_PROP) {
        prop = _fdt_offset_ptr(fdt, offset);
        n = fdt_string(fdt, fdt32_to_cpu(prop->nameoff));

        for  (i = 0; i < depth; i++) {
            printk(" ");
        }
        printk("%s: 0x%x@0x%x\n", n,
               fdt32_to_cpu(prop->len),
               prop->data);
    }

    offset = nextoffset;
} while ((tag != FDT_BEGIN_NODE) && (tag != FDT_END_NODE));