37UINT8 mPhysMemAddressWidth;
39STATIC UINT32 mS3AcpiReservedMemoryBase;
40STATIC UINT32 mS3AcpiReservedMemorySize;
42STATIC UINT16 mQ35TsegMbytes;
45Q35TsegMbytesInitialization (
49 UINT16 ExtendedTsegMbytes;
50 RETURN_STATUS PcdStatus;
52 if (mHostBridgeDevId != INTEL_Q35_MCH_DEVICE_ID) {
55 "%a: no TSEG (SMRAM) on host bridge DID=0x%04x; "
56 "only DID=0x%04x (Q35) is supported\n",
59 INTEL_Q35_MCH_DEVICE_ID
81 PciWrite16 (DRAMC_REGISTER_Q35 (MCH_EXT_TSEG_MB), MCH_EXT_TSEG_MB_QUERY);
82 ExtendedTsegMbytes =
PciRead16 (DRAMC_REGISTER_Q35 (MCH_EXT_TSEG_MB));
83 if (ExtendedTsegMbytes == MCH_EXT_TSEG_MB_QUERY) {
84 mQ35TsegMbytes =
PcdGet16 (PcdQ35TsegMbytes);
90 "%a: QEMU offers an extended TSEG (%d MB)\n",
94 PcdStatus =
PcdSet16S (PcdQ35TsegMbytes, ExtendedTsegMbytes);
96 mQ35TsegMbytes = ExtendedTsegMbytes;
101GetHighestSystemMemoryAddress (
106 UINT32 E820EntriesCount;
110 UINT64 HighestAddress;
118 for (Loop = 0; Loop < E820EntriesCount; Loop++) {
119 Entry = E820Map + Loop;
120 EntryEnd = Entry->BaseAddr + Entry->Length;
122 if ((Entry->Type == EfiAcpiAddressRangeMemory) &&
123 (EntryEnd > HighestAddress))
125 if (Below4gb && (EntryEnd <= BASE_4GB)) {
126 HighestAddress = EntryEnd;
127 }
else if (!Below4gb && (EntryEnd >= BASE_4GB)) {
128 HighestAddress = EntryEnd;
136 return HighestAddress & ~(UINT64)EFI_PAGE_MASK;
140GetSystemMemorySizeBelow4gb (
152 UINT64 HighestAddress;
154 HighestAddress = GetHighestSystemMemoryAddress (
TRUE);
155 ASSERT (HighestAddress > 0 && HighestAddress <= BASE_4GB);
157 return (UINT32)HighestAddress;
172 return (UINT32)(((
UINTN)((Cmos0x35 << 8) + Cmos0x34) << 16) + SIZE_16MB);
186 if (RegEax >= 0x80000008) {
188 mPhysMemAddressWidth = (UINT8)RegEax;
190 mPhysMemAddressWidth = 36;
196 ASSERT (mPhysMemAddressWidth <= 52);
197 if (mPhysMemAddressWidth > 48) {
198 mPhysMemAddressWidth = 48;
211 BOOLEAN Page1GSupport;
234 Page1GSupport =
FALSE;
237 if (RegEax >= 0x80000001) {
239 if ((RegEdx & BIT26) != 0) {
240 Page1GSupport =
TRUE;
245 if (mPhysMemAddressWidth <= 39) {
247 PdpEntries = 1 << (mPhysMemAddressWidth - 30);
248 ASSERT (PdpEntries <= 0x200);
250 Pml4Entries = 1 << (mPhysMemAddressWidth - 39);
251 ASSERT (Pml4Entries <= 0x200);
255 TotalPages = Page1GSupport ? Pml4Entries + 1 :
256 (PdpEntries + 1) * Pml4Entries + 1;
257 ASSERT (TotalPages <= 0x40201);
281 UINT32 LowerMemorySize;
284 LowerMemorySize = GetSystemMemorySizeBelow4gb ();
286 if (mBootMode == BOOT_ON_S3_RESUME) {
287 MemoryBase = mS3AcpiReservedMemoryBase;
288 MemorySize = mS3AcpiReservedMemorySize;
293 "%a: mPhysMemAddressWidth=%d PeiMemoryCap=%u KB\n",
295 mPhysMemAddressWidth,
304 MemorySize = LowerMemorySize - MemoryBase;
305 if (MemorySize > PeiMemoryCap) {
306 MemoryBase = LowerMemorySize - PeiMemoryCap;
307 MemorySize = PeiMemoryCap;
329 XenPublishRamRegions ();
331 if (mBootMode != BOOT_ON_S3_RESUME) {
VOID EFIAPI BuildMemoryAllocationHob(IN EFI_PHYSICAL_ADDRESS BaseAddress, IN UINT64 Length, IN EFI_MEMORY_TYPE MemoryType)
VOID EFIAPI CpuDeadLoop(VOID)
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
#define ASSERT_EFI_ERROR(StatusParameter)
#define ASSERT_RETURN_ERROR(StatusParameter)
#define DEBUG(Expression)
UINT16 EFIAPI PciWrite16(IN UINTN Address, IN UINT16 Value)
UINT16 EFIAPI PciRead16(IN UINTN Address)
UINT32 EFIAPI AsmCpuid(IN UINT32 Index, OUT UINT32 *RegisterEax OPTIONAL, OUT UINT32 *RegisterEbx OPTIONAL, OUT UINT32 *RegisterEcx OPTIONAL, OUT UINT32 *RegisterEdx OPTIONAL)
#define PcdGet16(TokenName)
#define PcdGet32(TokenName)
#define PcdGetBool(TokenName)
#define PcdSet16S(TokenName, Value)
#define FeaturePcdGet(TokenName)
RETURN_STATUS EFIAPI PublishSystemMemory(IN PHYSICAL_ADDRESS MemoryBegin, IN UINT64 MemoryLength)
UINT64 EFI_PHYSICAL_ADDRESS
#define EFI_PAGES_TO_SIZE(Pages)