summaryrefslogtreecommitdiff
path: root/InOsEmuPkg/Library
diff options
context:
space:
mode:
authorandrewfish <andrewfish@6f19259b-4bc3-4df7-8a09-765794883524>2011-06-08 21:52:21 +0000
committerandrewfish <andrewfish@6f19259b-4bc3-4df7-8a09-765794883524>2011-06-08 21:52:21 +0000
commit946bfba2c321425f22fecb53349b779594543919 (patch)
treeedfc9766a6eadf3fd14f0d5555d92ffd43505d46 /InOsEmuPkg/Library
parentf65dc3bebd97e5b9951fa44bb6365275f7f00791 (diff)
downloadedk2-platforms-946bfba2c321425f22fecb53349b779594543919.tar.xz
InOsEmuPkg: Make XIP work properly
Update the InOsEmuPkg to properly function with XIP. Make the Recovery FV read only. Remove the use of global variable writes from XIP code. Add a new global page that can be used in place of writting to the FD by XIP code. Think of this global page as a system SRAM. igned-off-by: andrewfish git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11771 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'InOsEmuPkg/Library')
-rw-r--r--InOsEmuPkg/Library/PeiEmuPeCoffExtraActionLib/PeiEmuPeCoffExtraActionLib.c11
-rw-r--r--InOsEmuPkg/Library/PeiEmuPeCoffExtraActionLib/PeiEmuPeCoffExtraActionLib.inf3
-rw-r--r--InOsEmuPkg/Library/PeiServicesTablePointerLibMagicPage/PeiServicesTablePointer.c75
-rw-r--r--InOsEmuPkg/Library/PeiServicesTablePointerLibMagicPage/PeiServicesTablePointerLibMagicPage.inf44
-rw-r--r--InOsEmuPkg/Library/SecPeiServicesLib/PeiServicesLib.c6
-rw-r--r--InOsEmuPkg/Library/SecPeiServicesLib/SecPeiServicesLib.inf4
6 files changed, 134 insertions, 9 deletions
diff --git a/InOsEmuPkg/Library/PeiEmuPeCoffExtraActionLib/PeiEmuPeCoffExtraActionLib.c b/InOsEmuPkg/Library/PeiEmuPeCoffExtraActionLib/PeiEmuPeCoffExtraActionLib.c
index b88bd009fe..b398b53e51 100644
--- a/InOsEmuPkg/Library/PeiEmuPeCoffExtraActionLib/PeiEmuPeCoffExtraActionLib.c
+++ b/InOsEmuPkg/Library/PeiEmuPeCoffExtraActionLib/PeiEmuPeCoffExtraActionLib.c
@@ -23,6 +23,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Library/DebugLib.h>
#include <Library/BaseLib.h>
#include <Library/PeCoffExtraActionLib.h>
+#include <Library/EmuMagicPageLib.h>
//
// Cache of UnixThunk protocol
@@ -56,7 +57,7 @@ EmuPeCoffGetThunkStucture (
);
ASSERT_EFI_ERROR (Status);
- mThunk = (EMU_THUNK_PROTOCOL *) ThunkPpi->Thunk ();
+ EMU_MAGIC_PAGE()->Thunk = (EMU_THUNK_PROTOCOL *) ThunkPpi->Thunk ();
return EFI_SUCCESS;
}
@@ -76,10 +77,10 @@ PeCoffLoaderRelocateImageExtraAction (
IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
)
{
- if (mThunk == NULL) {
+ if (EMU_MAGIC_PAGE()->Thunk == NULL) {
EmuPeCoffGetThunkStucture ();
}
- mThunk->PeCoffRelocateImageExtraAction (ImageContext);
+ EMU_MAGIC_PAGE()->Thunk->PeCoffRelocateImageExtraAction (ImageContext);
}
@@ -99,8 +100,8 @@ PeCoffLoaderUnloadImageExtraAction (
IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
)
{
- if (mThunk == NULL) {
+ if (EMU_MAGIC_PAGE()->Thunk == NULL) {
EmuPeCoffGetThunkStucture ();
}
- mThunk->PeCoffUnloadImageExtraAction (ImageContext);
+ EMU_MAGIC_PAGE()->Thunk->PeCoffUnloadImageExtraAction (ImageContext);
}
diff --git a/InOsEmuPkg/Library/PeiEmuPeCoffExtraActionLib/PeiEmuPeCoffExtraActionLib.inf b/InOsEmuPkg/Library/PeiEmuPeCoffExtraActionLib/PeiEmuPeCoffExtraActionLib.inf
index 3fd4a8aefe..e4a3fa7df6 100644
--- a/InOsEmuPkg/Library/PeiEmuPeCoffExtraActionLib/PeiEmuPeCoffExtraActionLib.inf
+++ b/InOsEmuPkg/Library/PeiEmuPeCoffExtraActionLib/PeiEmuPeCoffExtraActionLib.inf
@@ -44,3 +44,6 @@
[Ppis]
gEmuThunkPpiGuid # PPI ALWAYS_CONSUMED
+
+[Pcd]
+ gInOsEmuPkgTokenSpaceGuid.PcdPeiServicesTablePage
diff --git a/InOsEmuPkg/Library/PeiServicesTablePointerLibMagicPage/PeiServicesTablePointer.c b/InOsEmuPkg/Library/PeiServicesTablePointerLibMagicPage/PeiServicesTablePointer.c
new file mode 100644
index 0000000000..3f15403c72
--- /dev/null
+++ b/InOsEmuPkg/Library/PeiServicesTablePointerLibMagicPage/PeiServicesTablePointer.c
@@ -0,0 +1,75 @@
+/** @file
+ PEI Services Table Pointer Library.
+
+ Store PEI Services Table pointer via gInOsEmuPkgTokenSpaceGuid.PcdPeiServicesTablePage.
+ This emulates a platform SRAM. The PI mechaism does not work in the emulator due to
+ lack of privledge.
+
+ Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
+ Portiions copyrigth (c) 2011, Apple Inc. All rights reserved.
+ 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
+ http://opensource.org/licenses/bsd-license.php.
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include <PiPei.h>
+#include <Library/PeiServicesTablePointerLib.h>
+#include <Library/DebugLib.h>
+#include <Library/EmuMagicPageLib.h>
+
+
+/**
+ Caches a pointer PEI Services Table.
+
+ Caches the pointer to the PEI Services Table specified by PeiServicesTablePointer
+ in a CPU specific manner as specified in the CPU binding section of the Platform Initialization
+ Pre-EFI Initialization Core Interface Specification.
+
+ If PeiServicesTablePointer is NULL, then ASSERT().
+
+ @param PeiServicesTablePointer The address of PeiServices pointer.
+**/
+VOID
+EFIAPI
+SetPeiServicesTablePointer (
+ IN CONST EFI_PEI_SERVICES ** PeiServicesTablePointer
+ )
+{
+ ASSERT (PeiServicesTablePointer != NULL);
+ ASSERT (*PeiServicesTablePointer != NULL);
+ EMU_MAGIC_PAGE()->PeiServicesTablePointer = PeiServicesTablePointer;
+}
+
+/**
+ Retrieves the cached value of the PEI Services Table pointer.
+
+ Returns the cached value of the PEI Services Table pointer in a CPU specific manner
+ as specified in the CPU binding section of the Platform Initialization Pre-EFI
+ Initialization Core Interface Specification.
+
+ If the cached PEI Services Table pointer is NULL, then ASSERT().
+
+ @return The pointer to PeiServices.
+
+**/
+CONST EFI_PEI_SERVICES **
+EFIAPI
+GetPeiServicesTablePointer (
+ VOID
+ )
+{
+ CONST EFI_PEI_SERVICES **PeiServicesTablePointer;
+
+ PeiServicesTablePointer = EMU_MAGIC_PAGE()->PeiServicesTablePointer;
+ ASSERT (PeiServicesTablePointer != NULL);
+ ASSERT (*PeiServicesTablePointer != NULL);
+ return PeiServicesTablePointer;
+}
+
+
+
diff --git a/InOsEmuPkg/Library/PeiServicesTablePointerLibMagicPage/PeiServicesTablePointerLibMagicPage.inf b/InOsEmuPkg/Library/PeiServicesTablePointerLibMagicPage/PeiServicesTablePointerLibMagicPage.inf
new file mode 100644
index 0000000000..d16b845a8b
--- /dev/null
+++ b/InOsEmuPkg/Library/PeiServicesTablePointerLibMagicPage/PeiServicesTablePointerLibMagicPage.inf
@@ -0,0 +1,44 @@
+## @file
+# PEI Services Table Pointer Library.
+#
+# Store PEI Services Table pointer via gInOsEmuPkgTokenSpaceGuid.PcdPeiServicesTablePage.
+# This emulates a platform SRAM. The PI mechaism does not work in the emulator due to
+# lack of privledge.
+#
+# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
+# Portions copyright (c) 2011, Apple Inc. All rights reserved.
+#
+# 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
+# http://opensource.org/licenses/bsd-license.php.
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = InOsEmuPkgPeiServicesTablePointerLib
+ FILE_GUID = 7488FC06-370A-1C41-B05C-7395559A535A
+ MODULE_TYPE = PEIM
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = PeiServicesTablePointerLib|PEIM PEI_CORE SEC
+
+#
+# VALID_ARCHITECTURES = IA32 X64 IPF EBC (EBC is for build only)
+#
+
+[Sources]
+ PeiServicesTablePointer.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ InOsEmuPkg/InOsEmuPkg.dec
+
+[LibraryClasses]
+ DebugLib
+
+[Pcd]
+ gInOsEmuPkgTokenSpaceGuid.PcdPeiServicesTablePage
diff --git a/InOsEmuPkg/Library/SecPeiServicesLib/PeiServicesLib.c b/InOsEmuPkg/Library/SecPeiServicesLib/PeiServicesLib.c
index cee715d876..bdbf6875c9 100644
--- a/InOsEmuPkg/Library/SecPeiServicesLib/PeiServicesLib.c
+++ b/InOsEmuPkg/Library/SecPeiServicesLib/PeiServicesLib.c
@@ -14,11 +14,10 @@
#include <PiPei.h>
-
+#include <Library/EmuMagicPageLib.h>
#include <Library/PeiServicesLib.h>
#include <Library/DebugLib.h>
#include <Library/BaseMemoryLib.h>
-#include <Library/PpiListLib.h>
@@ -116,8 +115,7 @@ PeiServicesLocatePpi (
return EFI_NOT_FOUND;
}
-
- for (PpiList = (EFI_PEI_PPI_DESCRIPTOR *)gPpiList; ; PpiList++) {
+ for (PpiList = EMU_MAGIC_PAGE()->PpiList; ; PpiList++) {
if (CompareGuid (PpiList->Guid, Guid)) {
if (PpiDescriptor != NULL) {
*PpiDescriptor = PpiList;
diff --git a/InOsEmuPkg/Library/SecPeiServicesLib/SecPeiServicesLib.inf b/InOsEmuPkg/Library/SecPeiServicesLib/SecPeiServicesLib.inf
index 6e9cf3a226..3fc6271b08 100644
--- a/InOsEmuPkg/Library/SecPeiServicesLib/SecPeiServicesLib.inf
+++ b/InOsEmuPkg/Library/SecPeiServicesLib/SecPeiServicesLib.inf
@@ -40,6 +40,10 @@
BaseMemoryLib
PpiListLib
+[Pcd]
+ gInOsEmuPkgTokenSpaceGuid.PcdPeiServicesTablePage
+
+