Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jordan Justen <[email protected]>
---
OvmfPkg/PlatformPei/MemDetect.c | 6 +--
OvmfPkg/PlatformPei/Platform.c | 88 +++++++++++++----------------------------
OvmfPkg/PlatformPei/Platform.h | 5 +++
3 files changed, 35 insertions(+), 64 deletions(-)
diff --git a/OvmfPkg/PlatformPei/MemDetect.c b/OvmfPkg/PlatformPei/MemDetect.c
index dcfe952..851850b 100644
--- a/OvmfPkg/PlatformPei/MemDetect.c
+++ b/OvmfPkg/PlatformPei/MemDetect.c
@@ -1,7 +1,7 @@
/**@file
Memory Detection for Virtual Machines.
- Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD
License
which accompanies this distribution. The full text of the license may be
found at
@@ -35,9 +35,9 @@ Module Name:
#include "Platform.h"
#include "Cmos.h"
-STATIC
-UINTN
+UINT32
GetSystemMemorySizeBelow4gb (
+ VOID
)
{
UINT8 Cmos0x34;
diff --git a/OvmfPkg/PlatformPei/Platform.c b/OvmfPkg/PlatformPei/Platform.c
index f47489c..395ffaf 100644
--- a/OvmfPkg/PlatformPei/Platform.c
+++ b/OvmfPkg/PlatformPei/Platform.c
@@ -163,45 +163,10 @@ AddUntestedMemoryRangeHob (
AddUntestedMemoryBaseSizeHob (MemoryBase, (UINT64)(MemoryLimit -
MemoryBase));
}
-VOID
-XenMemMapInitialization (
- VOID
- )
-{
- DEBUG ((EFI_D_INFO, "Using memory map provided by Xen\n"));
-
- //
- // Create Memory Type Information HOB
- //
- BuildGuidDataHob (
- &gEfiMemoryTypeInformationGuid,
- mDefaultMemoryTypeInformation,
- sizeof(mDefaultMemoryTypeInformation)
- );
-
- //
- // Add PCI IO Port space available for PCI resource allocations.
- //
- BuildResourceDescriptorHob (
- EFI_RESOURCE_IO,
- EFI_RESOURCE_ATTRIBUTE_PRESENT |
- EFI_RESOURCE_ATTRIBUTE_INITIALIZED,
- 0xC000,
- 0x4000
- );
-
- //
- // Video memory + Legacy BIOS region
- //
- AddIoMemoryRangeHob (0x0A0000, BASE_1MB);
-
- XenPublishRamRegions ();
-}
-
VOID
MemMapInitialization (
- EFI_PHYSICAL_ADDRESS TopOfMemory
+ VOID
)
{
//
@@ -229,21 +194,30 @@ MemMapInitialization (
//
AddIoMemoryRangeHob (0x0A0000, BASE_1MB);
- //
- // address purpose size
- // ------------ -------- -------------------------
- // max(top, 2g) PCI MMIO 0xFC000000 - max(top, 2g)
- // 0xFC000000 gap 44 MB
- // 0xFEC00000 IO-APIC 4 KB
- // 0xFEC01000 gap 1020 KB
- // 0xFED00000 HPET 1 KB
- // 0xFED00400 gap 1023 KB
- // 0xFEE00000 LAPIC 1 MB
- //
- AddIoMemoryRangeHob (TopOfMemory < BASE_2GB ? BASE_2GB : TopOfMemory,
0xFC000000);
- AddIoMemoryBaseSizeHob (0xFEC00000, SIZE_4KB);
- AddIoMemoryBaseSizeHob (0xFED00000, SIZE_1KB);
- AddIoMemoryBaseSizeHob (PcdGet32(PcdCpuLocalApicBaseAddress), SIZE_1MB);
+ if (!mXen) {
+ UINT32 TopOfLowRam;
+ TopOfLowRam = GetSystemMemorySizeBelow4gb ();
+
+ //
+ // address purpose size
+ // ------------ -------- -------------------------
+ // max(top, 2g) PCI MMIO 0xFC000000 - max(top, 2g)
+ // 0xFC000000 gap 44 MB
+ // 0xFEC00000 IO-APIC 4 KB
+ // 0xFEC01000 gap 1020 KB
+ // 0xFED00000 HPET 1 KB
+ // 0xFED00400 gap 1023 KB
+ // 0xFEE00000 LAPIC 1 MB
+ //
+ AddIoMemoryRangeHob (TopOfLowRam < BASE_2GB ?
+ BASE_2GB : TopOfLowRam, 0xFC000000);
+ AddIoMemoryBaseSizeHob (0xFEC00000, SIZE_4KB);
+ AddIoMemoryBaseSizeHob (0xFED00000, SIZE_1KB);
+ AddIoMemoryBaseSizeHob (PcdGet32(PcdCpuLocalApicBaseAddress), SIZE_1MB);
+ } else {
+ DEBUG ((EFI_D_INFO, "Using memory map provided by Xen\n"));
+ XenPublishRamRegions ();
+ }
}
@@ -372,10 +346,6 @@ InitializePlatform (
IN CONST EFI_PEI_SERVICES **PeiServices
)
{
- EFI_PHYSICAL_ADDRESS TopOfMemory;
-
- TopOfMemory = 0;
-
DEBUG ((EFI_D_ERROR, "Platform PEIM Loaded\n"));
DebugDumpCmos ();
@@ -385,7 +355,7 @@ InitializePlatform (
PublishPeiMemory ();
if (!mXen) {
- TopOfMemory = MemDetect ();
+ MemDetect ();
}
if (mXen) {
@@ -397,11 +367,7 @@ InitializePlatform (
PeiFvInitialization ();
- if (mXen) {
- XenMemMapInitialization ();
- } else {
- MemMapInitialization (TopOfMemory);
- }
+ MemMapInitialization ();
MiscInitialization ();
diff --git a/OvmfPkg/PlatformPei/Platform.h b/OvmfPkg/PlatformPei/Platform.h
index fa1a4bf..48996ab 100644
--- a/OvmfPkg/PlatformPei/Platform.h
+++ b/OvmfPkg/PlatformPei/Platform.h
@@ -64,6 +64,11 @@ PublishPeiMemory (
VOID
);
+UINT32
+GetSystemMemorySizeBelow4gb (
+ VOID
+ );
+
EFI_PHYSICAL_ADDRESS
MemDetect (
VOID
--
1.8.5.3
------------------------------------------------------------------------------
WatchGuard Dimension instantly turns raw network data into actionable
security intelligence. It gives you real-time visual feedback on key
security issues and trends. Skip the complicated setup - simply import
a virtual appliance and go from zero to informed in seconds.
http://pubads.g.doubleclick.net/gampad/clk?id=123612991&iu=/4140/ostg.clktrk
_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-devel