diff options
author | jljusten <jljusten@6f19259b-4bc3-4df7-8a09-765794883524> | 2011-01-21 16:51:00 +0000 |
---|---|---|
committer | jljusten <jljusten@6f19259b-4bc3-4df7-8a09-765794883524> | 2011-01-21 16:51:00 +0000 |
commit | c0e1097656ae0f1f48e0e6538ff448bd1d1fbd90 (patch) | |
tree | d48d5420390a296798662428b84c66a36bf686ad /OvmfPkg/PlatformPei/MemDetect.c | |
parent | 999a815e9ff362f1f473415d476d937df4f0552c (diff) | |
download | edk2-platforms-c0e1097656ae0f1f48e0e6538ff448bd1d1fbd90.tar.xz |
OvmfPkg: Add support for memory above 4GB
When QEMU has more than 3.5GB of RAM, it will map the
additional memory above 4GB. This change will make that
RAM accessible to OVMF.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11266 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'OvmfPkg/PlatformPei/MemDetect.c')
-rw-r--r-- | OvmfPkg/PlatformPei/MemDetect.c | 45 |
1 files changed, 38 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;
}
|