diff options
-rw-r--r-- | OvmfPkg/PlatformPei/MemDetect.c | 45 | ||||
-rw-r--r-- | OvmfPkg/PlatformPei/Platform.c | 31 | ||||
-rw-r--r-- | OvmfPkg/PlatformPei/Platform.h | 12 |
3 files changed, 81 insertions, 7 deletions
diff --git a/OvmfPkg/PlatformPei/MemDetect.c b/OvmfPkg/PlatformPei/MemDetect.c index 9a82cc79d0..78b43d22b7 100644 --- a/OvmfPkg/PlatformPei/MemDetect.c +++ b/OvmfPkg/PlatformPei/MemDetect.c @@ -36,7 +36,7 @@ Module Name: STATIC
UINTN
-GetSystemMemorySize (
+GetSystemMemorySizeBelow4gb (
)
{
UINT8 Cmos0x34;
@@ -58,6 +58,31 @@ GetSystemMemorySize ( }
+STATIC
+UINT64
+GetSystemMemorySizeAbove4gb (
+ )
+{
+ UINT32 Size;
+ UINTN CmosIndex;
+
+ //
+ // CMOS 0x5b-0x5d specifies the system memory above 4GB MB.
+ // * CMOS(0x5d) is the most significant size byte
+ // * CMOS(0x5c) is the middle size byte
+ // * CMOS(0x5b) is the least significant size byte
+ // * The size is specified in 64kb chunks
+ //
+
+ Size = 0;
+ for (CmosIndex = 0x5d; CmosIndex >= 0x5b; CmosIndex--) {
+ Size = (UINT32) (Size << 8) + (UINT32) CmosRead8 (CmosIndex);
+ }
+
+ return LShiftU64 (Size, 16);
+}
+
+
/**
Peform Memory Detection
@@ -71,23 +96,25 @@ MemDetect ( EFI_STATUS Status;
EFI_PHYSICAL_ADDRESS MemoryBase;
UINT64 MemorySize;
- UINT64 TotalMemorySize;
+ UINT64 LowerMemorySize;
+ UINT64 UpperMemorySize;
DEBUG ((EFI_D_ERROR, "MemDetect called\n"));
//
// Determine total memory size available
//
- TotalMemorySize = (UINT64)GetSystemMemorySize ();
+ LowerMemorySize = GetSystemMemorySizeBelow4gb ();
+ UpperMemorySize = GetSystemMemorySizeAbove4gb ();
//
// Determine the range of memory to use during PEI
//
MemoryBase = PcdGet32 (PcdOvmfMemFvBase) + PcdGet32 (PcdOvmfMemFvSize);
- MemorySize = TotalMemorySize - MemoryBase;
- if (MemorySize > SIZE_16MB) {
- MemoryBase = TotalMemorySize - SIZE_16MB;
- MemorySize = SIZE_16MB;
+ MemorySize = LowerMemorySize - MemoryBase;
+ if (MemorySize > SIZE_64MB) {
+ MemoryBase = LowerMemorySize - SIZE_64MB;
+ MemorySize = SIZE_64MB;
}
//
@@ -103,6 +130,10 @@ MemDetect ( AddMemoryRangeHob (BASE_1MB, MemoryBase);
AddMemoryRangeHob (0, BASE_512KB + BASE_128KB);
+ if (UpperMemorySize != 0) {
+ AddUntestedMemoryBaseSizeHob (BASE_4GB, UpperMemorySize);
+ }
+
return MemoryBase + MemorySize;
}
diff --git a/OvmfPkg/PlatformPei/Platform.c b/OvmfPkg/PlatformPei/Platform.c index 66bb0984c8..fe25486fa4 100644 --- a/OvmfPkg/PlatformPei/Platform.c +++ b/OvmfPkg/PlatformPei/Platform.c @@ -103,6 +103,37 @@ AddMemoryRangeHob ( AddMemoryBaseSizeHob (MemoryBase, (UINT64)(MemoryLimit - MemoryBase));
}
+
+VOID
+AddUntestedMemoryBaseSizeHob (
+ EFI_PHYSICAL_ADDRESS MemoryBase,
+ UINT64 MemorySize
+ )
+{
+ BuildResourceDescriptorHob (
+ EFI_RESOURCE_SYSTEM_MEMORY,
+ EFI_RESOURCE_ATTRIBUTE_PRESENT |
+ EFI_RESOURCE_ATTRIBUTE_INITIALIZED |
+ EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE |
+ EFI_RESOURCE_ATTRIBUTE_WRITE_COMBINEABLE |
+ EFI_RESOURCE_ATTRIBUTE_WRITE_THROUGH_CACHEABLE |
+ EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE,
+ MemoryBase,
+ MemorySize
+ );
+}
+
+
+VOID
+AddUntestedMemoryRangeHob (
+ EFI_PHYSICAL_ADDRESS MemoryBase,
+ EFI_PHYSICAL_ADDRESS MemoryLimit
+ )
+{
+ AddUntestedMemoryBaseSizeHob (MemoryBase, (UINT64)(MemoryLimit - MemoryBase));
+}
+
+
VOID
MemMapInitialization (
EFI_PHYSICAL_ADDRESS TopOfMemory
diff --git a/OvmfPkg/PlatformPei/Platform.h b/OvmfPkg/PlatformPei/Platform.h index 0829f89d3b..3e5dca2ce7 100644 --- a/OvmfPkg/PlatformPei/Platform.h +++ b/OvmfPkg/PlatformPei/Platform.h @@ -39,6 +39,18 @@ AddMemoryRangeHob ( EFI_PHYSICAL_ADDRESS MemoryLimit
);
+VOID
+AddUntestedMemoryBaseSizeHob (
+ EFI_PHYSICAL_ADDRESS MemoryBase,
+ UINT64 MemorySize
+ );
+
+VOID
+AddUntestedMemoryRangeHob (
+ EFI_PHYSICAL_ADDRESS MemoryBase,
+ EFI_PHYSICAL_ADDRESS MemoryLimit
+ );
+
EFI_PHYSICAL_ADDRESS
MemDetect (
VOID
|