diff --git a/patterns/fdt.pat b/patterns/fdt.pat index 27fe0ea..04a4071 100644 --- a/patterns/fdt.pat +++ b/patterns/fdt.pat @@ -2,6 +2,7 @@ #include #include +#include #include #include @@ -26,7 +27,7 @@ struct AlignTo { struct FDTReserveEntry { u64 address; type::Size size; - + if (address == 0x00 && size == 0x00) break; }; @@ -51,7 +52,7 @@ struct FDTStructureBlock { u32 nameoff; char value[len]; AlignTo<4>; - char name[] @ parent.header.off_dt_strings + nameoff; + char name[] @ address(parent) + parent.header.off_dt_strings + nameoff; } else if (token == FDTToken::FDT_NOP || token == FDTToken::FDT_END_NODE) { // Nothing to do } else { @@ -62,9 +63,9 @@ struct FDTStructureBlock { struct FDT { FDTHeader header; std::assert(header.version == 17, "Unsupported format version"); - - FDTStructureBlock structureBlocks[while(true)] @ header.off_dt_struct; - FDTReserveEntry reserveEntries[while(true)] @ header.off_mem_rsvmap; + + FDTStructureBlock structureBlocks[while(true)] @ addressof(this) + header.off_dt_struct; + FDTReserveEntry reserveEntries[while(true)] @ addressof(this) + header.off_mem_rsvmap; }; -FDT fdt @ 0x00; \ No newline at end of file +std::mem::MagicSearch<"\xD0\x0D\xFE\xED", FDT> fdt @ std::mem::base_address();