summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDhaval <dhaval@rivosinc.com>2024-06-05 10:00:32 +0530
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2024-09-14 03:38:47 +0000
commit043045cd6eb318451948f5fba7f9ef9e585a184f (patch)
tree04ee50040cfebb51304b064b790f23d1db370056
parent099aff91375f0bbe6aaca259f3c8eb3ba119b7a2 (diff)
downloadedk2-043045cd6eb318451948f5fba7f9ef9e585a184f.tar.gz
edk2-043045cd6eb318451948f5fba7f9ef9e585a184f.tar.bz2
edk2-043045cd6eb318451948f5fba7f9ef9e585a184f.zip
MdePkg: Add reserved mem fdt helpers
Devicetree defines a short hand way of defining reserved memory ranges. Add APIs to access such nodes Signed-off-by: Dhaval Sharma <dhaval@rivosinc.com>
-rw-r--r--MdePkg/Include/Library/FdtLib.h34
-rw-r--r--MdePkg/Library/BaseFdtLib/FdtLib.c41
2 files changed, 75 insertions, 0 deletions
diff --git a/MdePkg/Include/Library/FdtLib.h b/MdePkg/Include/Library/FdtLib.h
index 89aa1e00f9..ffff40d8fe 100644
--- a/MdePkg/Include/Library/FdtLib.h
+++ b/MdePkg/Include/Library/FdtLib.h
@@ -248,6 +248,40 @@ FdtSubnodeOffsetNameLen (
);
/**
+ 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.
@param[in] Fdt The pointer to FDT blob.
diff --git a/MdePkg/Library/BaseFdtLib/FdtLib.c b/MdePkg/Library/BaseFdtLib/FdtLib.c
index 9b1ceac551..5ff06111b7 100644
--- a/MdePkg/Library/BaseFdtLib/FdtLib.c
+++ b/MdePkg/Library/BaseFdtLib/FdtLib.c
@@ -7,6 +7,7 @@
**/
#include <libfdt/libfdt/libfdt.h>
+#include <Uefi/UefiBaseType.h>
/**
Convert UINT16 data of the FDT blob to little-endian
@@ -206,6 +207,46 @@ FdtNextSubnode (
}
/**
+ 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.
@param[in] Fdt The pointer to FDT blob.