In chronological order (see InitializePlatform()):
normal boot path S3 Resume boot path
---------------------- ----------------------
value of "S3Resume" FALSE TRUE
PublishPeiMemory NO, YES
/ MemDetect: PEI core memory is
PEI core memory located above
installed from decompressed fw image
pre-reserved NVRAM or NVRAM (if present)
ReserveEmuVariableNvStore: YES NO,
EfiRuntimeServicesData DXE phase is never
type allocation reached
from permanent PEI core
memory, for disk-based
NvVars emulation
PeiFvInitialization: YES, NO,
NVRAM is protected preparing for alloc HOB would
with ACPI NVS memory suspend & resume conflict with PEI core
allocation HOB memory; plus DXE is
never reached; plus OS
EFI memmap cannot
change
For now the S3Resume boolean is constant false.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <[email protected]>
---
OvmfPkg/PlatformPei/PlatformPei.inf | 1 +
OvmfPkg/PlatformPei/Platform.h | 6 +++---
OvmfPkg/PlatformPei/Fv.c | 14 +++++++++++++-
OvmfPkg/PlatformPei/MemDetect.c | 30 +++++++++++++++++++++---------
OvmfPkg/PlatformPei/Platform.c | 12 ++++++++----
5 files changed, 46 insertions(+), 17 deletions(-)
diff --git a/OvmfPkg/PlatformPei/PlatformPei.inf
b/OvmfPkg/PlatformPei/PlatformPei.inf
index 7fe9d47..93ffa68 100644
--- a/OvmfPkg/PlatformPei/PlatformPei.inf
+++ b/OvmfPkg/PlatformPei/PlatformPei.inf
@@ -56,6 +56,7 @@
PeimEntryPoint
MtrrLib
PcdLib
+ EmuNvramLib
[Pcd]
gUefiOvmfPkgTokenSpaceGuid.PcdOvmfMemFvBase
diff --git a/OvmfPkg/PlatformPei/Platform.h b/OvmfPkg/PlatformPei/Platform.h
index 5378b9d..8e3256d 100644
--- a/OvmfPkg/PlatformPei/Platform.h
+++ b/OvmfPkg/PlatformPei/Platform.h
@@ -61,17 +61,17 @@ AddUntestedMemoryRangeHob (
EFI_STATUS
PublishPeiMemory (
- VOID
+ BOOLEAN S3Resume
);
EFI_PHYSICAL_ADDRESS
MemDetect (
- VOID
+ BOOLEAN S3Resume
);
EFI_STATUS
PeiFvInitialization (
- VOID
+ BOOLEAN S3Resume
);
EFI_STATUS
diff --git a/OvmfPkg/PlatformPei/Fv.c b/OvmfPkg/PlatformPei/Fv.c
index f389e27..66343b3 100644
--- a/OvmfPkg/PlatformPei/Fv.c
+++ b/OvmfPkg/PlatformPei/Fv.c
@@ -17,6 +17,7 @@
#include <Library/HobLib.h>
#include <Library/PeiServicesLib.h>
#include <Library/PcdLib.h>
+#include <Library/EmuNvramLib.h>
/**
@@ -30,7 +31,7 @@
**/
EFI_STATUS
PeiFvInitialization (
- VOID
+ BOOLEAN S3Resume
)
{
DEBUG ((EFI_D_ERROR, "Platform PEI Firmware Volume Initialization\n"));
@@ -53,6 +54,17 @@ PeiFvInitialization (
EfiBootServicesData
);
+ //
+ // Reserve the emulated NVRAM by covering it with a memory allocation HOB.
+ // During S3 Resume we don't need to reserve this range, we'll run the PEI
+ // core in a part of it.
+ //
+ if (!S3Resume && EmuNvramSize() != 0) {
+ BuildMemoryAllocationHob (EmuNvramBase(), EmuNvramSize(),
+ EfiACPIMemoryNVS);
+ DEBUG ((DEBUG_INFO, "Emulated NVRAM at 0x%08x, size 0x%08x\n",
+ EmuNvramBase(), EmuNvramSize()));
+ }
return EFI_SUCCESS;
}
diff --git a/OvmfPkg/PlatformPei/MemDetect.c b/OvmfPkg/PlatformPei/MemDetect.c
index a1de762..40c073e 100644
--- a/OvmfPkg/PlatformPei/MemDetect.c
+++ b/OvmfPkg/PlatformPei/MemDetect.c
@@ -31,6 +31,7 @@ Module Name:
#include <Library/PeimEntryPoint.h>
#include <Library/ResourcePublicationLib.h>
#include <Library/MtrrLib.h>
+#include <Library/EmuNvramLib.h>
#include "Platform.h"
#include "Cmos.h"
@@ -91,7 +92,7 @@ GetSystemMemorySizeAbove4gb (
**/
EFI_STATUS
PublishPeiMemory (
- VOID
+ BOOLEAN S3Resume
)
{
EFI_STATUS Status;
@@ -99,16 +100,26 @@ PublishPeiMemory (
UINT64 MemorySize;
UINT64 LowerMemorySize;
- LowerMemorySize = GetSystemMemorySizeBelow4gb ();
-
//
// Determine the range of memory to use during PEI
//
- MemoryBase = PcdGet32 (PcdOvmfMemFvBase) + PcdGet32 (PcdOvmfMemFvSize);
- MemorySize = LowerMemorySize - MemoryBase;
- if (MemorySize > SIZE_64MB) {
- MemoryBase = LowerMemorySize - SIZE_64MB;
- MemorySize = SIZE_64MB;
+ if (S3Resume) {
+ MemorySize = EmuNvramS3ResumePoolSize ();
+ ASSERT (MemorySize != 0);
+ MemoryBase = EmuNvramS3ResumePoolBase ();
+ } else {
+ LowerMemorySize = GetSystemMemorySizeBelow4gb ();
+
+ if (EmuNvramSize () == 0) {
+ MemoryBase = PcdGet32 (PcdOvmfMemFvBase) + PcdGet32 (PcdOvmfMemFvSize);
+ } else {
+ MemoryBase = EmuNvramBase () + EmuNvramSize ();
+ }
+ MemorySize = LowerMemorySize - MemoryBase;
+ if (MemorySize > SIZE_64MB) {
+ MemoryBase = LowerMemorySize - SIZE_64MB;
+ MemorySize = SIZE_64MB;
+ }
}
//
@@ -129,6 +140,7 @@ PublishPeiMemory (
**/
EFI_PHYSICAL_ADDRESS
MemDetect (
+ BOOLEAN S3Resume
)
{
UINT64 LowerMemorySize;
@@ -142,7 +154,7 @@ MemDetect (
LowerMemorySize = GetSystemMemorySizeBelow4gb ();
UpperMemorySize = GetSystemMemorySizeAbove4gb ();
- PublishPeiMemory ();
+ PublishPeiMemory (S3Resume);
//
// Create memory HOBs
diff --git a/OvmfPkg/PlatformPei/Platform.c b/OvmfPkg/PlatformPei/Platform.c
index 7363702..c271349 100644
--- a/OvmfPkg/PlatformPei/Platform.c
+++ b/OvmfPkg/PlatformPei/Platform.c
@@ -409,9 +409,11 @@ InitializePlatform (
IN CONST EFI_PEI_SERVICES **PeiServices
)
{
+ BOOLEAN S3Resume;
EFI_PHYSICAL_ADDRESS TopOfMemory;
UINT32 XenLeaf;
+ S3Resume = FALSE;
TopOfMemory = 0;
DEBUG ((EFI_D_ERROR, "Platform PEIM Loaded\n"));
@@ -421,10 +423,10 @@ InitializePlatform (
XenLeaf = XenDetect ();
if (XenLeaf != 0) {
- PublishPeiMemory ();
+ PublishPeiMemory (S3Resume);
PcdSetBool (PcdPciDisableBusEnumeration, TRUE);
} else {
- TopOfMemory = MemDetect ();
+ TopOfMemory = MemDetect (S3Resume);
}
if (XenLeaf != 0) {
@@ -432,9 +434,11 @@ InitializePlatform (
InitializeXen (XenLeaf);
}
- ReserveEmuVariableNvStore ();
+ if (!S3Resume) {
+ ReserveEmuVariableNvStore ();
+ }
- PeiFvInitialization ();
+ PeiFvInitialization (S3Resume);
if (XenLeaf != 0) {
XenMemMapInitialization ();
--
1.8.3.1
------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT
organizations don't have a clear picture of how application performance
affects their revenue. With AppDynamics, you get 100% visibility into your
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-devel