diff options
Diffstat (limited to 'ArmVirtPkg/Library')
9 files changed, 103 insertions, 33 deletions
diff --git a/ArmVirtPkg/Library/ArmVirtDxeHobLib/HobLib.c b/ArmVirtPkg/Library/ArmVirtDxeHobLib/HobLib.c index 55f8bdf..68b95fa 100644 --- a/ArmVirtPkg/Library/ArmVirtDxeHobLib/HobLib.c +++ b/ArmVirtPkg/Library/ArmVirtDxeHobLib/HobLib.c @@ -609,3 +609,73 @@ BuildMemoryAllocationHob ( //
ASSERT (FALSE);
}
+
+/**
+ Returns the next instance of the memory allocation HOB with the matched GUID from
+ the starting HOB.
+
+ This function searches the first instance of a HOB from the starting HOB pointer.
+ Such HOB should satisfy two conditions:
+ Its HOB type is EFI_HOB_TYPE_MEMORY_ALLOCATION and its GUID Name equals to input Guid.
+ If there does not exist such HOB from the starting HOB pointer, it will return NULL.
+
+ If Guid is NULL, then ASSERT().
+ If HobStart is NULL, then ASSERT().
+
+ @param Guid The GUID to match with in the HOB list.
+ @param HobStart The starting HOB pointer to search from.
+
+ @retval !NULL The next instance of the Memory Allocation HOB with matched GUID from the starting HOB.
+ @retval NULL NULL is returned if the matching Memory Allocation HOB is not found.
+
+**/
+VOID *
+EFIAPI
+GetNextMemoryAllocationGuidHob (
+ IN CONST EFI_GUID *Guid,
+ IN CONST VOID *HobStart
+ )
+{
+ EFI_PEI_HOB_POINTERS Hob;
+
+ ASSERT (Guid != NULL);
+ ASSERT (HobStart != NULL);
+
+ for (Hob.Raw = (UINT8 *)HobStart; (Hob.Raw = GetNextHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, Hob.Raw)) != NULL;
+ Hob.Raw = GET_NEXT_HOB (Hob))
+ {
+ if (CompareGuid (&Hob.MemoryAllocation->AllocDescriptor.Name, Guid)) {
+ return Hob.Raw;
+ }
+ }
+
+ return NULL;
+}
+
+/**
+ Search the HOB list for the Memory Allocation HOB with a matching base address
+ and set the Name GUID. If there does not exist such Memory Allocation HOB in the
+ HOB list, it will return NULL.
+
+ If Guid is NULL, then ASSERT().
+
+ @param BaseAddress BaseAddress of Memory Allocation HOB to set Name to Guid.
+ @param Guid Pointer to the GUID to set in the matching Memory Allocation GUID.
+
+ @retval !NULL The instance of the tagged Memory Allocation HOB with matched base address.
+ @retval NULL NULL is returned if the matching Memory Allocation HOB is not found.
+
+**/
+VOID *
+EFIAPI
+TagMemoryAllocationHobWithGuid (
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN CONST EFI_GUID *Guid
+ )
+{
+ //
+ // PEI HOB is read only for DXE phase
+ //
+ ASSERT (FALSE);
+ return NULL;
+}
diff --git a/ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.inf b/ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.inf index 48d9c66..6292347 100644 --- a/ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.inf +++ b/ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.inf @@ -24,6 +24,7 @@ ArmPkg/ArmPkg.dec
ArmPlatformPkg/ArmPlatformPkg.dec
ArmVirtPkg/ArmVirtPkg.dec
+ UefiCpuPkg/UefiCpuPkg.dec
[LibraryClasses]
DebugLib
diff --git a/ArmVirtPkg/Library/CloudHvVirtMemInfoLib/CloudHvVirtMemInfoLib.c b/ArmVirtPkg/Library/CloudHvVirtMemInfoLib/CloudHvVirtMemInfoLib.c index 98cc138..9c3672b 100644 --- a/ArmVirtPkg/Library/CloudHvVirtMemInfoLib/CloudHvVirtMemInfoLib.c +++ b/ArmVirtPkg/Library/CloudHvVirtMemInfoLib/CloudHvVirtMemInfoLib.c @@ -9,10 +9,10 @@ #include <PiPei.h>
#include <Base.h>
-#include <libfdt.h>
#include <Library/ArmLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/DebugLib.h>
+#include <Library/FdtLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/PcdLib.h>
@@ -68,7 +68,7 @@ CloudHvVirtMemInfoPeiLibConstructor ( //
// Make sure we have a valid device tree blob
//
- if (fdt_check_header (DeviceTreeBase) != 0) {
+ if (FdtCheckHeader (DeviceTreeBase) != 0) {
return EFI_NOT_FOUND;
}
@@ -76,7 +76,7 @@ CloudHvVirtMemInfoPeiLibConstructor ( // Look for the lowest memory node
//
for (Prev = 0; ; Prev = Node) {
- Node = fdt_next_node (DeviceTreeBase, Prev, NULL);
+ Node = FdtNextNode (DeviceTreeBase, Prev, NULL);
if (Node < 0) {
break;
}
@@ -84,16 +84,16 @@ CloudHvVirtMemInfoPeiLibConstructor ( //
// Check for memory node
//
- Type = fdt_getprop (DeviceTreeBase, Node, "device_type", &Len);
+ Type = FdtGetProp (DeviceTreeBase, Node, "device_type", &Len);
if ((Type != 0) && (AsciiStrnCmp (Type, "memory", Len) == 0)) {
//
// Get the 'reg' property of this node. For now, we will assume
// two 8 byte quantities for base and size, respectively.
//
- RegProp = fdt_getprop (DeviceTreeBase, Node, "reg", &Len);
+ RegProp = FdtGetProp (DeviceTreeBase, Node, "reg", &Len);
if ((RegProp != 0) && (Len == (2 * sizeof (UINT64)))) {
- CurBase = fdt64_to_cpu (ReadUnaligned64 (RegProp));
- CurSize = fdt64_to_cpu (ReadUnaligned64 (RegProp + 1));
+ CurBase = Fdt64ToCpu (ReadUnaligned64 (RegProp));
+ CurSize = Fdt64ToCpu (ReadUnaligned64 (RegProp + 1));
DEBUG ((
DEBUG_INFO,
diff --git a/ArmVirtPkg/Library/CloudHvVirtMemInfoLib/CloudHvVirtMemInfoPeiLib.inf b/ArmVirtPkg/Library/CloudHvVirtMemInfoLib/CloudHvVirtMemInfoPeiLib.inf index 6df26cc..3646ed3 100644 --- a/ArmVirtPkg/Library/CloudHvVirtMemInfoLib/CloudHvVirtMemInfoPeiLib.inf +++ b/ArmVirtPkg/Library/CloudHvVirtMemInfoLib/CloudHvVirtMemInfoPeiLib.inf @@ -35,6 +35,7 @@ FdtLib
MemoryAllocationLib
PcdLib
+ PrePiLib
[Pcd]
gArmTokenSpaceGuid.PcdFdBaseAddress
diff --git a/ArmVirtPkg/Library/KvmtoolPlatformPeiLib/KvmtoolPlatformPeiLib.c b/ArmVirtPkg/Library/KvmtoolPlatformPeiLib/KvmtoolPlatformPeiLib.c index 30e43be..07a7606 100644 --- a/ArmVirtPkg/Library/KvmtoolPlatformPeiLib/KvmtoolPlatformPeiLib.c +++ b/ArmVirtPkg/Library/KvmtoolPlatformPeiLib/KvmtoolPlatformPeiLib.c @@ -14,10 +14,10 @@ #include <Library/MemoryAllocationLib.h>
#include <Library/DebugLib.h>
+#include <Library/FdtLib.h>
#include <Library/HobLib.h>
#include <Library/PcdLib.h>
#include <Library/PeiServicesLib.h>
-#include <libfdt.h>
/** Initialise Platform HOBs
@@ -39,12 +39,12 @@ PlatformPeim ( UINT64 *UartHobData;
Base = (VOID *)(UINTN)PcdGet64 (PcdDeviceTreeInitialBaseAddress);
- if ((Base == NULL) || (fdt_check_header (Base) != 0)) {
+ if ((Base == NULL) || (FdtCheckHeader (Base) != 0)) {
ASSERT (0);
return EFI_INVALID_PARAMETER;
}
- FdtSize = fdt_totalsize (Base) + PcdGet32 (PcdDeviceTreeAllocationPadding);
+ FdtSize = FdtTotalSize (Base) + PcdGet32 (PcdDeviceTreeAllocationPadding);
FdtPages = EFI_SIZE_TO_PAGES (FdtSize);
NewBase = AllocatePages (FdtPages);
if (NewBase == NULL) {
@@ -52,7 +52,7 @@ PlatformPeim ( return EFI_OUT_OF_RESOURCES;
}
- fdt_open_into (Base, NewBase, EFI_PAGES_TO_SIZE (FdtPages));
+ FdtOpenInto (Base, NewBase, EFI_PAGES_TO_SIZE (FdtPages));
FdtHobData = BuildGuidHob (&gFdtHobGuid, sizeof (*FdtHobData));
if (FdtHobData == NULL) {
diff --git a/ArmVirtPkg/Library/KvmtoolPlatformPeiLib/KvmtoolPlatformPeiLib.inf b/ArmVirtPkg/Library/KvmtoolPlatformPeiLib/KvmtoolPlatformPeiLib.inf index 77c0b92..d642cc8 100644 --- a/ArmVirtPkg/Library/KvmtoolPlatformPeiLib/KvmtoolPlatformPeiLib.inf +++ b/ArmVirtPkg/Library/KvmtoolPlatformPeiLib/KvmtoolPlatformPeiLib.inf @@ -21,7 +21,6 @@ [Packages]
ArmPkg/ArmPkg.dec
ArmVirtPkg/ArmVirtPkg.dec
- EmbeddedPkg/EmbeddedPkg.dec
MdeModulePkg/MdeModulePkg.dec
MdePkg/MdePkg.dec
OvmfPkg/OvmfPkg.dec
diff --git a/ArmVirtPkg/Library/PlatformPeiLib/PlatformPeiLib.c b/ArmVirtPkg/Library/PlatformPeiLib/PlatformPeiLib.c index 7ab4aa2..7d3f8c4 100644 --- a/ArmVirtPkg/Library/PlatformPeiLib/PlatformPeiLib.c +++ b/ArmVirtPkg/Library/PlatformPeiLib/PlatformPeiLib.c @@ -12,11 +12,11 @@ #include <Library/BaseMemoryLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/DebugLib.h>
+#include <Library/FdtLib.h>
#include <Library/HobLib.h>
#include <Library/PcdLib.h>
#include <Library/PeiServicesLib.h>
#include <Library/FdtSerialPortAddressLib.h>
-#include <libfdt.h>
#include <Guid/EarlyPL011BaseAddress.h>
#include <Guid/FdtHob.h>
@@ -59,13 +59,13 @@ PlatformPeim ( Base = (VOID *)(UINTN)PcdGet64 (PcdDeviceTreeInitialBaseAddress);
ASSERT (Base != NULL);
- ASSERT (fdt_check_header (Base) == 0);
+ ASSERT (FdtCheckHeader (Base) == 0);
- FdtSize = fdt_totalsize (Base) + PcdGet32 (PcdDeviceTreeAllocationPadding);
+ FdtSize = FdtTotalSize (Base) + PcdGet32 (PcdDeviceTreeAllocationPadding);
FdtPages = EFI_SIZE_TO_PAGES (FdtSize);
NewBase = AllocatePages (FdtPages);
ASSERT (NewBase != NULL);
- fdt_open_into (Base, NewBase, EFI_PAGES_TO_SIZE (FdtPages));
+ FdtOpenInto (Base, NewBase, EFI_PAGES_TO_SIZE (FdtPages));
FdtHobData = BuildGuidHob (&gFdtHobGuid, sizeof *FdtHobData);
ASSERT (FdtHobData != NULL);
@@ -132,7 +132,7 @@ PlatformPeim ( Parent = 0;
for (Prev = Depth = 0; ; Prev = Node) {
- Node = fdt_next_node (Base, Prev, &Depth);
+ Node = FdtNextNode (Base, Prev, &Depth);
if (Node < 0) {
break;
}
@@ -141,7 +141,7 @@ PlatformPeim ( Parent = Node;
}
- Compatible = fdt_getprop (Base, Node, "compatible", &Len);
+ Compatible = FdtGetProp (Base, Node, "compatible", &Len);
//
// Iterate over the NULL-separated items in the compatible string
@@ -152,12 +152,12 @@ PlatformPeim ( if (FeaturePcdGet (PcdTpm2SupportEnabled) &&
(AsciiStrCmp (CompItem, "tcg,tpm-tis-mmio") == 0))
{
- RegProp = fdt_getprop (Base, Node, "reg", &Len);
+ RegProp = FdtGetProp (Base, Node, "reg", &Len);
ASSERT (Len == 8 || Len == 16);
if (Len == 8) {
- TpmBase = fdt32_to_cpu (RegProp[0]);
+ TpmBase = Fdt32ToCpu (RegProp[0]);
} else if (Len == 16) {
- TpmBase = fdt64_to_cpu (ReadUnaligned64 ((UINT64 *)RegProp));
+ TpmBase = Fdt64ToCpu (ReadUnaligned64 ((UINT64 *)RegProp));
}
if (Depth > 1) {
@@ -168,7 +168,7 @@ PlatformPeim ( // tuple, where the child base and the size use the same number of
// cells as the 'reg' property above, and the parent base uses 2 cells
//
- RangesProp = fdt_getprop (Base, Parent, "ranges", &RangesLen);
+ RangesProp = FdtGetProp (Base, Parent, "ranges", &RangesLen);
ASSERT (RangesProp != NULL);
//
@@ -189,16 +189,16 @@ PlatformPeim ( }
if (Len == 8) {
- TpmBase -= fdt32_to_cpu (RangesProp[0]);
+ TpmBase -= Fdt32ToCpu (RangesProp[0]);
} else {
- TpmBase -= fdt64_to_cpu (ReadUnaligned64 ((UINT64 *)RangesProp));
+ TpmBase -= Fdt64ToCpu (ReadUnaligned64 ((UINT64 *)RangesProp));
}
//
// advance RangesProp to the parent bus address
//
RangesProp = (UINT32 *)((UINT8 *)RangesProp + Len / 2);
- TpmBase += fdt64_to_cpu (ReadUnaligned64 ((UINT64 *)RangesProp));
+ TpmBase += Fdt64ToCpu (ReadUnaligned64 ((UINT64 *)RangesProp));
}
}
diff --git a/ArmVirtPkg/Library/PlatformPeiLib/PlatformPeiLib.inf b/ArmVirtPkg/Library/PlatformPeiLib/PlatformPeiLib.inf index e9a34b6..d6c1b13 100644 --- a/ArmVirtPkg/Library/PlatformPeiLib/PlatformPeiLib.inf +++ b/ArmVirtPkg/Library/PlatformPeiLib/PlatformPeiLib.inf @@ -21,7 +21,6 @@ [Packages]
ArmPkg/ArmPkg.dec
ArmVirtPkg/ArmVirtPkg.dec
- EmbeddedPkg/EmbeddedPkg.dec
MdeModulePkg/MdeModulePkg.dec
MdePkg/MdePkg.dec
OvmfPkg/OvmfPkg.dec
diff --git a/ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoPeiLibConstructor.c b/ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoPeiLibConstructor.c index f39df85..b0948ef 100644 --- a/ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoPeiLibConstructor.c +++ b/ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoPeiLibConstructor.c @@ -10,8 +10,8 @@ #include <Pi/PiMultiPhase.h>
#include <Library/BaseLib.h>
#include <Library/DebugLib.h>
+#include <Library/FdtLib.h>
#include <Library/HobLib.h>
-#include <libfdt.h>
RETURN_STATUS
EFIAPI
@@ -37,13 +37,13 @@ QemuVirtMemInfoPeiLibConstructor ( //
// Make sure we have a valid device tree blob
//
- ASSERT (fdt_check_header (DeviceTreeBase) == 0);
+ ASSERT (FdtCheckHeader (DeviceTreeBase) == 0);
//
// Look for the lowest memory node
//
for (Prev = 0; ; Prev = Node) {
- Node = fdt_next_node (DeviceTreeBase, Prev, NULL);
+ Node = FdtNextNode (DeviceTreeBase, Prev, NULL);
if (Node < 0) {
break;
}
@@ -51,16 +51,16 @@ QemuVirtMemInfoPeiLibConstructor ( //
// Check for memory node
//
- Type = fdt_getprop (DeviceTreeBase, Node, "device_type", &Len);
+ Type = FdtGetProp (DeviceTreeBase, Node, "device_type", &Len);
if (Type && (AsciiStrnCmp (Type, "memory", Len) == 0)) {
//
// Get the 'reg' property of this node. For now, we will assume
// two 8 byte quantities for base and size, respectively.
//
- RegProp = fdt_getprop (DeviceTreeBase, Node, "reg", &Len);
+ RegProp = FdtGetProp (DeviceTreeBase, Node, "reg", &Len);
if ((RegProp != 0) && (Len == (2 * sizeof (UINT64)))) {
- CurBase = fdt64_to_cpu (ReadUnaligned64 (RegProp));
- CurSize = fdt64_to_cpu (ReadUnaligned64 (RegProp + 1));
+ CurBase = Fdt64ToCpu (ReadUnaligned64 (RegProp));
+ CurSize = Fdt64ToCpu (ReadUnaligned64 (RegProp + 1));
DEBUG ((
DEBUG_INFO,
|