Andrew Geissler | 80d4184 | 2023-09-11 08:36:15 -0400 | [diff] [blame] | 1 | From 44b69c8d7c8ed665b4f8d8a9953ea23a731d221f Mon Sep 17 00:00:00 2001 |
| 2 | From: Your Name <you@example.com> |
| 3 | Date: Fri, 10 Mar 2023 18:46:49 +0000 |
| 4 | Subject: [PATCH] Revert "ArmVirtPkg/QemuVirtMemInfoLib: use HOB not PCD to |
| 5 | record the memory size" |
| 6 | |
| 7 | This reverts commit 7136d5491e225c57f1d73e4a1b7ac27ed656ff72. |
| 8 | |
| 9 | Upstream-Status: Inappropriate [other] |
| 10 | Signed-off-by: Jon Mason <jon.mason@arm.com> |
| 11 | |
| 12 | --- |
| 13 | ArmVirtPkg/ArmVirtPkg.dec | 1 - |
| 14 | ArmVirtPkg/ArmVirtQemu.dsc | 6 ++-- |
| 15 | .../ArmVirtMemoryInitPeiLib.c | 14 ++------ |
| 16 | .../ArmVirtMemoryInitPeiLib.inf | 1 - |
| 17 | .../QemuVirtMemInfoLib/QemuVirtMemInfoLib.c | 35 ++----------------- |
| 18 | .../QemuVirtMemInfoLib/QemuVirtMemInfoLib.inf | 5 +-- |
| 19 | .../QemuVirtMemInfoPeiLib.inf | 8 ++--- |
| 20 | .../QemuVirtMemInfoPeiLibConstructor.c | 30 +++++++--------- |
| 21 | 8 files changed, 25 insertions(+), 75 deletions(-) |
| 22 | |
| 23 | diff --git a/ArmVirtPkg/ArmVirtPkg.dec b/ArmVirtPkg/ArmVirtPkg.dec |
| 24 | index 4645c91a83..d2d325d71e 100644 |
| 25 | --- a/ArmVirtPkg/ArmVirtPkg.dec |
| 26 | +++ b/ArmVirtPkg/ArmVirtPkg.dec |
| 27 | @@ -32,7 +32,6 @@ |
| 28 | gArmVirtTokenSpaceGuid = { 0x0B6F5CA7, 0x4F53, 0x445A, { 0xB7, 0x6E, 0x2E, 0x36, 0x5B, 0x80, 0x63, 0x66 } }
|
| 29 | gEarlyPL011BaseAddressGuid = { 0xB199DEA9, 0xFD5C, 0x4A84, { 0x80, 0x82, 0x2F, 0x41, 0x70, 0x78, 0x03, 0x05 } }
|
| 30 | gEarly16550UartBaseAddressGuid = { 0xea67ca3e, 0x1f54, 0x436b, { 0x97, 0x88, 0xd4, 0xeb, 0x29, 0xc3, 0x42, 0x67 } }
|
| 31 | - gArmVirtSystemMemorySizeGuid = { 0x504eccb9, 0x1bf0, 0x4420, { 0x86, 0x5d, 0xdc, 0x66, 0x06, 0xd4, 0x13, 0xbf } }
|
| 32 |
|
| 33 | [PcdsFeatureFlag]
|
| 34 | #
|
| 35 | diff --git a/ArmVirtPkg/ArmVirtQemu.dsc b/ArmVirtPkg/ArmVirtQemu.dsc |
| 36 | index 72a0cacab4..2e786dad12 100644 |
| 37 | --- a/ArmVirtPkg/ArmVirtQemu.dsc |
| 38 | +++ b/ArmVirtPkg/ArmVirtQemu.dsc |
| 39 | @@ -226,9 +226,6 @@ |
| 40 | # Shadowing PEI modules is absolutely pointless when the NOR flash is emulated
|
| 41 | gEfiMdeModulePkgTokenSpaceGuid.PcdShadowPeimOnBoot|FALSE
|
| 42 |
|
| 43 | - # System Memory Size -- 128 MB initially, actual size will be fetched from DT
|
| 44 | - gArmTokenSpaceGuid.PcdSystemMemorySize|0x8000000
|
| 45 | -
|
| 46 | [PcdsFixedAtBuild.AARCH64]
|
| 47 | # Clearing BIT0 in this PCD prevents installing a 32-bit SMBIOS entry point,
|
| 48 | # if the entry point version is >= 3.0. AARCH64 OSes cannot assume the
|
| 49 | @@ -245,6 +242,9 @@ |
| 50 | # enumeration to complete before installing ACPI tables.
|
| 51 | gEfiMdeModulePkgTokenSpaceGuid.PcdPciDisableBusEnumeration|TRUE
|
| 52 |
|
| 53 | + # System Memory Size -- 1 MB initially, actual size will be fetched from DT
|
| 54 | + gArmTokenSpaceGuid.PcdSystemMemorySize|0x00100000
|
| 55 | +
|
| 56 | gArmTokenSpaceGuid.PcdArmArchTimerSecIntrNum|0x0
|
| 57 | gArmTokenSpaceGuid.PcdArmArchTimerIntrNum|0x0
|
| 58 | gArmTokenSpaceGuid.PcdArmArchTimerVirtIntrNum|0x0
|
| 59 | diff --git a/ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.c b/ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.c |
| 60 | index 72e5c65af7..98d90ad420 100644 |
| 61 | --- a/ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.c |
| 62 | +++ b/ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.c |
| 63 | @@ -52,19 +52,10 @@ MemoryPeim ( |
| 64 | {
|
| 65 | EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttributes;
|
| 66 | UINT64 SystemMemoryTop;
|
| 67 | - UINT64 SystemMemorySize;
|
| 68 | - VOID *Hob;
|
| 69 |
|
| 70 | // Ensure PcdSystemMemorySize has been set
|
| 71 | ASSERT (PcdGet64 (PcdSystemMemorySize) != 0);
|
| 72 |
|
| 73 | - SystemMemorySize = PcdGet64 (PcdSystemMemorySize);
|
| 74 | -
|
| 75 | - Hob = GetFirstGuidHob (&gArmVirtSystemMemorySizeGuid);
|
| 76 | - if (Hob != NULL) {
|
| 77 | - SystemMemorySize = *(UINT64 *)GET_GUID_HOB_DATA (Hob);
|
| 78 | - }
|
| 79 | -
|
| 80 | //
|
| 81 | // Now, the permanent memory has been installed, we can call AllocatePages()
|
| 82 | //
|
| 83 | @@ -75,7 +66,8 @@ MemoryPeim ( |
| 84 | EFI_RESOURCE_ATTRIBUTE_TESTED
|
| 85 | );
|
| 86 |
|
| 87 | - SystemMemoryTop = PcdGet64 (PcdSystemMemoryBase) + SystemMemorySize;
|
| 88 | + SystemMemoryTop = PcdGet64 (PcdSystemMemoryBase) +
|
| 89 | + PcdGet64 (PcdSystemMemorySize);
|
| 90 |
|
| 91 | if (SystemMemoryTop - 1 > MAX_ALLOC_ADDRESS) {
|
| 92 | BuildResourceDescriptorHob (
|
| 93 | @@ -95,7 +87,7 @@ MemoryPeim ( |
| 94 | EFI_RESOURCE_SYSTEM_MEMORY,
|
| 95 | ResourceAttributes,
|
| 96 | PcdGet64 (PcdSystemMemoryBase),
|
| 97 | - SystemMemorySize
|
| 98 | + PcdGet64 (PcdSystemMemorySize)
|
| 99 | );
|
| 100 | }
|
| 101 |
|
| 102 | diff --git a/ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.inf b/ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.inf |
| 103 | index 48d9c66b22..21327f79f4 100644 |
| 104 | --- a/ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.inf |
| 105 | +++ b/ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.inf |
| 106 | @@ -34,7 +34,6 @@ |
| 107 | CacheMaintenanceLib
|
| 108 |
|
| 109 | [Guids]
|
| 110 | - gArmVirtSystemMemorySizeGuid
|
| 111 | gEfiMemoryTypeInformationGuid
|
| 112 |
|
| 113 | [FeaturePcd]
|
| 114 | diff --git a/ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoLib.c b/ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoLib.c |
| 115 | index 9cf43f06c0..cf569bed99 100644 |
| 116 | --- a/ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoLib.c |
| 117 | +++ b/ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoLib.c |
| 118 | @@ -6,12 +6,10 @@ |
| 119 |
|
| 120 | **/
|
| 121 |
|
| 122 | -#include <Uefi.h>
|
| 123 | -#include <Pi/PiMultiPhase.h>
|
| 124 | +#include <Base.h>
|
| 125 | #include <Library/ArmLib.h>
|
| 126 | #include <Library/BaseMemoryLib.h>
|
| 127 | #include <Library/DebugLib.h>
|
| 128 | -#include <Library/HobLib.h>
|
| 129 | #include <Library/MemoryAllocationLib.h>
|
| 130 |
|
| 131 | // Number of Virtual Memory Map Descriptors
|
| 132 | @@ -26,28 +24,6 @@ |
| 133 | #define MACH_VIRT_PERIPH_BASE 0x08000000
|
| 134 | #define MACH_VIRT_PERIPH_SIZE SIZE_128MB
|
| 135 |
|
| 136 | -/**
|
| 137 | - Default library constructur that obtains the memory size from a PCD.
|
| 138 | -
|
| 139 | - @return Always returns RETURN_SUCCESS
|
| 140 | -
|
| 141 | -**/
|
| 142 | -RETURN_STATUS
|
| 143 | -EFIAPI
|
| 144 | -QemuVirtMemInfoLibConstructor (
|
| 145 | - VOID
|
| 146 | - )
|
| 147 | -{
|
| 148 | - UINT64 Size;
|
| 149 | - VOID *Hob;
|
| 150 | -
|
| 151 | - Size = PcdGet64 (PcdSystemMemorySize);
|
| 152 | - Hob = BuildGuidDataHob (&gArmVirtSystemMemorySizeGuid, &Size, sizeof Size);
|
| 153 | - ASSERT (Hob != NULL);
|
| 154 | -
|
| 155 | - return RETURN_SUCCESS;
|
| 156 | -}
|
| 157 | -
|
| 158 | /**
|
| 159 | Return the Virtual Memory Map of your platform
|
| 160 |
|
| 161 | @@ -67,16 +43,9 @@ ArmVirtGetMemoryMap ( |
| 162 | )
|
| 163 | {
|
| 164 | ARM_MEMORY_REGION_DESCRIPTOR *VirtualMemoryTable;
|
| 165 | - VOID *MemorySizeHob;
|
| 166 |
|
| 167 | ASSERT (VirtualMemoryMap != NULL);
|
| 168 |
|
| 169 | - MemorySizeHob = GetFirstGuidHob (&gArmVirtSystemMemorySizeGuid);
|
| 170 | - ASSERT (MemorySizeHob != NULL);
|
| 171 | - if (MemorySizeHob == NULL) {
|
| 172 | - return;
|
| 173 | - }
|
| 174 | -
|
| 175 | VirtualMemoryTable = AllocatePool (
|
| 176 | sizeof (ARM_MEMORY_REGION_DESCRIPTOR) *
|
| 177 | MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS
|
| 178 | @@ -90,7 +59,7 @@ ArmVirtGetMemoryMap ( |
| 179 | // System DRAM
|
| 180 | VirtualMemoryTable[0].PhysicalBase = PcdGet64 (PcdSystemMemoryBase);
|
| 181 | VirtualMemoryTable[0].VirtualBase = VirtualMemoryTable[0].PhysicalBase;
|
| 182 | - VirtualMemoryTable[0].Length = *(UINT64 *)GET_GUID_HOB_DATA (MemorySizeHob);
|
| 183 | + VirtualMemoryTable[0].Length = PcdGet64 (PcdSystemMemorySize);
|
| 184 | VirtualMemoryTable[0].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK;
|
| 185 |
|
| 186 | DEBUG ((
|
| 187 | diff --git a/ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoLib.inf b/ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoLib.inf |
| 188 | index 6acad8bbd7..7150de6c10 100644 |
| 189 | --- a/ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoLib.inf |
| 190 | +++ b/ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoLib.inf |
| 191 | @@ -14,7 +14,6 @@ |
| 192 | MODULE_TYPE = BASE
|
| 193 | VERSION_STRING = 1.0
|
| 194 | LIBRARY_CLASS = ArmVirtMemInfoLib
|
| 195 | - CONSTRUCTOR = QemuVirtMemInfoLibConstructor
|
| 196 |
|
| 197 | [Sources]
|
| 198 | QemuVirtMemInfoLib.c
|
| 199 | @@ -31,9 +30,7 @@ |
| 200 | BaseMemoryLib
|
| 201 | DebugLib
|
| 202 | MemoryAllocationLib
|
| 203 | -
|
| 204 | -[Guids]
|
| 205 | - gArmVirtSystemMemorySizeGuid
|
| 206 | + PcdLib
|
| 207 |
|
| 208 | [Pcd]
|
| 209 | gArmTokenSpaceGuid.PcdFvBaseAddress
|
| 210 | diff --git a/ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoPeiLib.inf b/ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoPeiLib.inf |
| 211 | index f045e39a41..7ecf6dfbb7 100644 |
| 212 | --- a/ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoPeiLib.inf |
| 213 | +++ b/ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoPeiLib.inf |
| 214 | @@ -32,16 +32,16 @@ |
| 215 | BaseMemoryLib
|
| 216 | DebugLib
|
| 217 | FdtLib
|
| 218 | + PcdLib
|
| 219 | MemoryAllocationLib
|
| 220 |
|
| 221 | -[Guids]
|
| 222 | - gArmVirtSystemMemorySizeGuid
|
| 223 | -
|
| 224 | -[FixedPcd]
|
| 225 | +[Pcd]
|
| 226 | gArmTokenSpaceGuid.PcdFdBaseAddress
|
| 227 | gArmTokenSpaceGuid.PcdFvBaseAddress
|
| 228 | gArmTokenSpaceGuid.PcdSystemMemoryBase
|
| 229 | gArmTokenSpaceGuid.PcdSystemMemorySize
|
| 230 | +
|
| 231 | +[FixedPcd]
|
| 232 | gArmTokenSpaceGuid.PcdFdSize
|
| 233 | gArmTokenSpaceGuid.PcdFvSize
|
| 234 | gArmVirtTokenSpaceGuid.PcdDeviceTreeInitialBaseAddress
|
| 235 | diff --git a/ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoPeiLibConstructor.c b/ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoPeiLibConstructor.c |
| 236 | index c47ab82966..33d3597d57 100644 |
| 237 | --- a/ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoPeiLibConstructor.c |
| 238 | +++ b/ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoPeiLibConstructor.c |
| 239 | @@ -6,10 +6,9 @@ |
| 240 |
|
| 241 | **/
|
| 242 |
|
| 243 | -#include <Uefi.h>
|
| 244 | -#include <Pi/PiMultiPhase.h>
|
| 245 | +#include <Base.h>
|
| 246 | #include <Library/DebugLib.h>
|
| 247 | -#include <Library/HobLib.h>
|
| 248 | +#include <Library/PcdLib.h>
|
| 249 | #include <libfdt.h>
|
| 250 |
|
| 251 | RETURN_STATUS
|
| 252 | @@ -18,14 +17,14 @@ QemuVirtMemInfoPeiLibConstructor ( |
| 253 | VOID
|
| 254 | )
|
| 255 | {
|
| 256 | - VOID *DeviceTreeBase;
|
| 257 | - INT32 Node, Prev;
|
| 258 | - UINT64 NewBase, CurBase;
|
| 259 | - UINT64 NewSize, CurSize;
|
| 260 | - CONST CHAR8 *Type;
|
| 261 | - INT32 Len;
|
| 262 | - CONST UINT64 *RegProp;
|
| 263 | - VOID *Hob;
|
| 264 | + VOID *DeviceTreeBase;
|
| 265 | + INT32 Node, Prev;
|
| 266 | + UINT64 NewBase, CurBase;
|
| 267 | + UINT64 NewSize, CurSize;
|
| 268 | + CONST CHAR8 *Type;
|
| 269 | + INT32 Len;
|
| 270 | + CONST UINT64 *RegProp;
|
| 271 | + RETURN_STATUS PcdStatus;
|
| 272 |
|
| 273 | NewBase = 0;
|
| 274 | NewSize = 0;
|
| 275 | @@ -87,13 +86,8 @@ QemuVirtMemInfoPeiLibConstructor ( |
| 276 | // Make sure the start of DRAM matches our expectation
|
| 277 | //
|
| 278 | ASSERT (FixedPcdGet64 (PcdSystemMemoryBase) == NewBase);
|
| 279 | -
|
| 280 | - Hob = BuildGuidDataHob (
|
| 281 | - &gArmVirtSystemMemorySizeGuid,
|
| 282 | - &NewSize,
|
| 283 | - sizeof NewSize
|
| 284 | - );
|
| 285 | - ASSERT (Hob != NULL);
|
| 286 | + PcdStatus = PcdSet64S (PcdSystemMemorySize, NewSize);
|
| 287 | + ASSERT_RETURN_ERROR (PcdStatus);
|
| 288 |
|
| 289 | //
|
| 290 | // We need to make sure that the machine we are running on has at least
|