diff --git a/MdePkg/Include/Library/FdtLib.h b/MdePkg/Include/Library/FdtLib.h index 89aa1e00f92d..ffff40d8fe27 100644 --- a/MdePkg/Include/Library/FdtLib.h +++ b/MdePkg/Include/Library/FdtLib.h @@ -247,6 +247,40 @@ FdtSubnodeOffsetNameLen ( IN INT32 NameLength ); +/** + Returns number of reserved ranges. + + @param[in] Fdt The pointer to FDT blob. + + @return The number of reserved ranges. + +**/ +INTN +EFIAPI +FdtNumRsv ( + IN CONST VOID *Fdt + ); + +/** + Returns reserved ranges. + + @param[in] *Fdt The pointer to FDT blob. + @param[in] Index Reserved entry index in the table. + @param[out] Addr Address returned + @param[out] *Size Pointer to size of the address range + + @return Returns reserved range. + +**/ +INTN +EFIAPI +FdtGetMemRsv ( + IN CONST VOID *Fdt, + IN INTN Index, + OUT UINT64 *Addr, + OUT UINT64 *Size + ); + /** Returns a offset of first node which includes the given property name and value. diff --git a/MdePkg/Library/BaseFdtLib/FdtLib.c b/MdePkg/Library/BaseFdtLib/FdtLib.c index 9b1ceac551e0..5ff06111b7f4 100644 --- a/MdePkg/Library/BaseFdtLib/FdtLib.c +++ b/MdePkg/Library/BaseFdtLib/FdtLib.c @@ -7,6 +7,7 @@ **/ #include +#include /** Convert UINT16 data of the FDT blob to little-endian @@ -205,6 +206,46 @@ FdtNextSubnode ( return fdt_next_subnode (Fdt, Offset); } +/** + Returns number of reserved mem nodes + + @param[in] Fdt The pointer to FDT blob. + + @return total reserved mem nodes + +**/ +INTN +EFIAPI +FdtNumRsv ( + IN CONST VOID *Fdt + ) +{ + return fdt_num_mem_rsv (Fdt); +} + +/** + Returns reserved ranges. + + @param[in] *Fdt The pointer to FDT blob. + @param[in] Index Reserved entry index in the table. + @param[out] Addr Address returned + @param[out] *Size Pointer to size of the address range + + @return Returns reserved range. + +**/ +INTN +EFIAPI +FdtGetMemRsv ( + IN CONST VOID *Fdt, + IN INTN Index, + OUT EFI_PHYSICAL_ADDRESS *Addr, + OUT UINT64 *Size + ) +{ + return fdt_get_mem_rsv (Fdt, Index, Addr, Size); +} + /** Returns a offset of first node which includes the given name.