]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Added generic EFIABI SEC to InOsEmuPkg. Add library to abstract FV cracking and remov...
authorandrewfish <andrewfish@6f19259b-4bc3-4df7-8a09-765794883524>
Sat, 14 May 2011 16:00:22 +0000 (16:00 +0000)
committerandrewfish <andrewfish@6f19259b-4bc3-4df7-8a09-765794883524>
Sat, 14 May 2011 16:00:22 +0000 (16:00 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11646 6f19259b-4bc3-4df7-8a09-765794883524

28 files changed:
InOsEmuPkg/InOsEmuPkg.dec
InOsEmuPkg/Include/Library/PpiListLib.h [new file with mode: 0644]
InOsEmuPkg/Include/Ppi/EmuPeiServicesTableUpdate.h [deleted file]
InOsEmuPkg/Include/Ppi/EmuThunk.h
InOsEmuPkg/Library/PeiCoreServicesTablePointerLib/PeiCoreServicesTablePointerLib.inf
InOsEmuPkg/Library/PeiCoreServicesTablePointerLib/PeiServicesTablePointer.c
InOsEmuPkg/Library/PeiEmuPeCoffGetEntryPointLib/PeiEmuPeCoffGetEntryPointLib.c
InOsEmuPkg/Library/PeiEmuSerialPortLib/PeiEmuSerialPortLib.inf
InOsEmuPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointer.c
InOsEmuPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf
InOsEmuPkg/Library/SecPeiServicesLib/FwVol.c [new file with mode: 0644]
InOsEmuPkg/Library/SecPeiServicesLib/PeiServicesLib.c [new file with mode: 0644]
InOsEmuPkg/Library/SecPeiServicesLib/SecPeiServicesLib.inf [new file with mode: 0644]
InOsEmuPkg/Library/SecPpiListLib/PpiListLib.c [new file with mode: 0644]
InOsEmuPkg/Library/SecPpiListLib/SecPpiListLib.inf [new file with mode: 0644]
InOsEmuPkg/Sec/Sec.c [new file with mode: 0644]
InOsEmuPkg/Sec/Sec.h [new file with mode: 0644]
InOsEmuPkg/Sec/Sec.inf [new file with mode: 0644]
InOsEmuPkg/Sec/X64/SwitchRam.S [new file with mode: 0644]
InOsEmuPkg/Unix/Sec/FwVol.c [deleted file]
InOsEmuPkg/Unix/Sec/Gasket.h
InOsEmuPkg/Unix/Sec/SecMain.c
InOsEmuPkg/Unix/Sec/SecMain.h
InOsEmuPkg/Unix/Sec/SecMain.inf
InOsEmuPkg/Unix/Sec/X64/Gasket.S
InOsEmuPkg/Unix/Sec/X64/SwitchStack.S
InOsEmuPkg/Unix/UnixX64.dsc
InOsEmuPkg/Unix/UnixX64.fdf

index 6b4aca28c2cf51b9f3d0beaf35fad7716daec82b..f49b2c73e73dd975e56e96c2cb4bff8809b92c88 100644 (file)
@@ -29,6 +29,7 @@
   ThunkProtocolList|Include/Library/ThunkProtocolList.h\r
   EmuThunkLib|Include/Library/EmuThunkLib.h\r
   KeyMap|Include/Library/KeyMapLib.h\r
+  PpiListLib|Include/Library/PpiListLib.h\r
 \r
 [Protocols]\r
   gEmuThunkProtocolGuid          = { 0x398DCA31, 0x3505, 0xDB47, { 0xBD, 0x93, 0x1D, 0x38, 0x5F, 0x79, 0x13, 0x15 } }\r
@@ -38,8 +39,6 @@
 \r
 [Ppis]\r
   gEmuThunkPpiGuid                  = { 0xE113F896, 0x75CF, 0xF640, { 0x81, 0x7F, 0xC8, 0x5A, 0x79, 0xE8, 0xAE, 0x67 } }\r
-  gEmuPeiServicesTableUpdatePpiGuid =  { 0xFA93020C, 0x6CDF, 0x1946, { 0x86, 0x35, 0x72, 0xCB, 0x51, 0x9E, 0xCF, 0xFD } }\r
-\r
 \r
 [Guids]\r
   gInOsEmuPkgTokenSpaceGuid  = { 0x4F792E68, 0xE8C8, 0x794E, { 0xB1, 0xD8, 0x37, 0x03, 0xF3, 0xF2, 0xD5, 0xA5 } }\r
diff --git a/InOsEmuPkg/Include/Library/PpiListLib.h b/InOsEmuPkg/Include/Library/PpiListLib.h
new file mode 100644 (file)
index 0000000..061cfca
--- /dev/null
@@ -0,0 +1,21 @@
+/*++ @file
+
+Copyright (c) 2011, Apple Inc. 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        
+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.             
+
+**/
+
+#ifndef __PPI_LIST_LIB_H__
+#define __PPI_LIST_LIB_H__
+
+
+extern CONST EFI_PEI_PPI_DESCRIPTOR  *gPpiList;
+
+
+#endif
diff --git a/InOsEmuPkg/Include/Ppi/EmuPeiServicesTableUpdate.h b/InOsEmuPkg/Include/Ppi/EmuPeiServicesTableUpdate.h
deleted file mode 100644 (file)
index f706eac..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-/** @file\r
-  Emulator Thunk to abstract OS services from pure EFI code\r
-\r
-  Copyright (c) 2008 - 2011, Apple Inc. All rights reserved.<BR>\r
-  \r
-  This program and the accompanying materials\r
-  are licensed and made available under the terms and conditions of the BSD License\r
-  which accompanies this distribution.  The full text of the license may be found at\r
-  http://opensource.org/licenses/bsd-license.php\r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#ifndef __EMU_PEI_SERVICE_TABLE_UPDATE_PPI_H__\r
-#define __EMU_PEI_SERVICE_TABLE_UPDATE_PPI_H__\r
-\r
-#define _EMU_PEI_SERVICE_TABLE_UPDATE_PPI_GUID  \\r
- { 0xFA93020C, 0x6CDF, 0x1946, { 0x86, 0x35, 0x72, 0xCB, 0x51, 0x9E, 0xCF, 0xFD } }\r
-\r
-\r
-\r
-\r
-extern EFI_GUID gEmuPeiServicesTableUpdatePpiGuid;\r
-\r
-#endif\r
index 61047e3bfdc8e45f9e6d61c92bd0d1b21dcc3f0f..20cdc462f9cb2bcd588d8fc208a18cdcca8d87f7 100644 (file)
@@ -120,7 +120,6 @@ typedef struct {
   EMU_PEI_AUTOSCAN                  MemoryAutoScan;\r
   EMU_PEI_FD_INFORMATION            FirmwareDevices;\r
   EMU_PEI_THUNK_INTERFACE           Thunk;\r
-  EMU_PEI_LOAD_FILE                 LoadFile;\r
 } EMU_THUNK_PPI;\r
 \r
 extern EFI_GUID gEmuThunkPpiGuid;\r
index 2510d690e2a67a3ad981e2b4dffd3cbff22e5a69..279e088dff2de8dcdb204fa62aaa9616409832a9 100644 (file)
 \r
 [Packages]\r
   MdePkg/MdePkg.dec\r
-  InOsEmuPkg/InOsEmuPkg.dec\r
 \r
 [LibraryClasses]\r
   DebugLib\r
 \r
-[Ppis]\r
-  gEmuPeiServicesTableUpdatePpiGuid\r
-\r
index 1c689390f82851cf11005e24bc7194015eae0ccd..9b02316af4545eb572b0361568749a1c8a544a9e 100644 (file)
@@ -1,13 +1,10 @@
 /** @file\r
-  PEI Services Table Pointer Library for PEI Core.\r
+  PEI Services Table Pointer Library.\r
   \r
-  This library is used for PEI Core which does executed from flash device directly but\r
-  executed in memory. When the PEI Core does a Set of the PEI Service table pointer \r
-  a PPI is reinstalled so that PEIMs can update the copy of the PEI Services table \r
-  they have cached. \r
+  This library is used for PEIM which does executed from flash device directly but\r
+  executed in memory.\r
 \r
   Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
-  Portiions copyrigth (c) 2011, Apple Inc. All rights reserved. \r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
 #include <Library/PeiServicesTablePointerLib.h>\r
 #include <Library/DebugLib.h>\r
 \r
-#include <Ppi/EmuPeiServicesTableUpdate.h>\r
-\r
-\r
-CONST EFI_PEI_SERVICES  **gPeiServices = NULL;\r
+CONST EFI_PEI_SERVICES  **gPeiServices;\r
 \r
 /**\r
   Caches a pointer PEI Services Table. \r
@@ -41,39 +35,11 @@ CONST EFI_PEI_SERVICES  **gPeiServices = NULL;
 VOID\r
 EFIAPI\r
 SetPeiServicesTablePointer (\r
-  IN CONST EFI_PEI_SERVICES **PeiServicesTablePointer\r
+  IN CONST EFI_PEI_SERVICES ** PeiServicesTablePointer\r
   )\r
 {\r
-  EFI_STATUS              Status;\r
-  EFI_PEI_PPI_DESCRIPTOR  *PpiDescriptor;\r
-  VOID                    *NotUsed;\r
-\r
-  gPeiServices = PeiServicesTablePointer; \r
-  \r
-  Status = (*PeiServicesTablePointer)->LocatePpi (\r
-                                        PeiServicesTablePointer,\r
-                                        &gEmuPeiServicesTableUpdatePpiGuid, // GUID\r
-                                        0,                 // INSTANCE\r
-                                        &PpiDescriptor,    // EFI_PEI_PPI_DESCRIPTOR\r
-                                        &NotUsed           // PPI\r
-                                        );\r
-  if (!EFI_ERROR (Status)) {\r
-    //\r
-    // Standard PI Mechanism is to use negative offset from IDT. \r
-    // We can't do that in the emulator, so we make up a constant location\r
-    // that every one can use. The first try may fail as the PEI Core is still\r
-    // initializing its self, but that is OK. \r
-    //\r
-\r
-    // Reinstall PPI to consumers know to update PEI Services pointer\r
-    Status = (*PeiServicesTablePointer)->ReInstallPpi (\r
-                                            PeiServicesTablePointer,\r
-                                            PpiDescriptor,\r
-                                            PpiDescriptor\r
-                                            );\r
-\r
-  }\r
-\r
+  ASSERT (PeiServicesTablePointer != NULL);\r
+  gPeiServices = PeiServicesTablePointer;\r
 }\r
 \r
 /**\r
@@ -95,8 +61,31 @@ GetPeiServicesTablePointer (
   )\r
 {\r
   ASSERT (gPeiServices != NULL);\r
-  ASSERT (*gPeiServices != NULL);\r
   return gPeiServices;\r
 }\r
 \r
 \r
+/**\r
+  The constructor function caches the pointer to PEI services.\r
+  \r
+  The constructor function caches the pointer to PEI services.\r
+  It will always return EFI_SUCCESS.\r
+\r
+  @param  FileHandle   The handle of FFS header the loaded driver.\r
+  @param  PeiServices  The pointer to the PEI services.\r
+\r
+  @retval EFI_SUCCESS  The constructor always returns EFI_SUCCESS.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiServicesTablePointerLibConstructor (\r
+  IN EFI_PEI_FILE_HANDLE        FileHandle,\r
+  IN CONST EFI_PEI_SERVICES     **PeiServices\r
+  )\r
+{\r
+  gPeiServices = PeiServices;\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
index 0b4be07ce66741846f12860ee517169ea0553f48..e229805cfedb321e75c8daf9c849898caa8ed4b0 100644 (file)
@@ -56,7 +56,7 @@ PeCoffLoaderGetEntryPoint (
   //\r
   Status = PeiServicesLocatePpi (\r
               &gEmuThunkPpiGuid,\r
-             0,\r
+              0,\r
               NULL,\r
               (VOID **) &ThunkPpi\r
              );\r
index 663967ddd9aeab811d3e931f021880d2b545d68d..911957ce3a694feded20c51b47cb3163e4cf16a4 100644 (file)
@@ -20,7 +20,7 @@
   FILE_GUID                      = E4541241-8897-411a-91F8-7D7E45837146\r
   MODULE_TYPE                    = PEIM\r
   VERSION_STRING                 = 1.0\r
-  LIBRARY_CLASS                  = SerialPortLib| PEI_CORE PEIM\r
+  LIBRARY_CLASS                  = SerialPortLib| PEI_CORE PEIM SEC\r
 \r
 #\r
 #  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
index 6a58a74f8720f4e49d5c7b02f3b2cd1bf08e1262..3454660fecc91d48cdbb5bdbbc237149a6196119 100644 (file)
@@ -20,7 +20,7 @@
 #include <Library/PeiServicesTablePointerLib.h>\r
 #include <Library/DebugLib.h>\r
 \r
-#include <Ppi/EmuPeiServicesTableUpdate.h>\r
+#include <Ppi/MemoryDiscovered.h>\r
 \r
 \r
 CONST EFI_PEI_SERVICES  **gPeiServices = NULL;\r
@@ -100,7 +100,7 @@ PeiServicesTablePointerNotifyCallback (
 \r
 EFI_PEI_NOTIFY_DESCRIPTOR mNotifyOnThunkList = {\r
   (EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),\r
-  &gEmuPeiServicesTableUpdatePpiGuid,\r
+  &gEfiPeiMemoryDiscoveredPpiGuid,\r
   PeiServicesTablePointerNotifyCallback \r
 };\r
 \r
@@ -125,6 +125,8 @@ PeiServicesTablePointerLibConstructor (
 {\r
   EFI_STATUS              Status;\r
 \r
+  gPeiServices = (CONST EFI_PEI_SERVICES  **)PeiServices;\r
+\r
   // register to be told when PeiServices pointer is updated\r
   Status = (*PeiServices)->NotifyPpi (PeiServices, &mNotifyOnThunkList);\r
   ASSERT_EFI_ERROR (Status);\r
index 29d790a32aefcb6134bea67a55caebb6721f5779..b5e9949e0f3c6814b0fb548f91d488d66021f506 100644 (file)
 \r
 [Packages]\r
   MdePkg/MdePkg.dec\r
-  InOsEmuPkg/InOsEmuPkg.dec\r
 \r
 [LibraryClasses]\r
   DebugLib\r
 \r
 [Ppis]\r
-  gEmuPeiServicesTableUpdatePpiGuid\r
+  gEfiPeiMemoryDiscoveredPpiGuid\r
 \r
diff --git a/InOsEmuPkg/Library/SecPeiServicesLib/FwVol.c b/InOsEmuPkg/Library/SecPeiServicesLib/FwVol.c
new file mode 100644 (file)
index 0000000..ae4ebfb
--- /dev/null
@@ -0,0 +1,281 @@
+/*++ @file
+  A simple FV stack so the SEC can extract the SEC Core from an
+  FV.
+
+Copyright (c) 2006, 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        
+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>
+
+
+#define GET_OCCUPIED_SIZE(ActualSize, Alignment) \
+  (ActualSize) + (((Alignment) - ((ActualSize) & ((Alignment) - 1))) & ((Alignment) - 1))
+
+EFI_FFS_FILE_STATE
+GetFileState (
+  IN UINT8                ErasePolarity,
+  IN EFI_FFS_FILE_HEADER  *FfsHeader
+  )
+/*++
+
+Routine Description:
+  Returns the highest bit set of the State field
+
+Arguments:
+  ErasePolarity   - Erase Polarity  as defined by EFI_FVB2_ERASE_POLARITY
+                    in the Attributes field.
+  FfsHeader       - Pointer to FFS File Header.
+
+Returns:
+  Returns the highest bit in the State field
+
+**/
+{
+  EFI_FFS_FILE_STATE  FileState;
+  EFI_FFS_FILE_STATE  HighestBit;
+
+  FileState = FfsHeader->State;
+
+  if (ErasePolarity != 0) {
+    FileState = (EFI_FFS_FILE_STATE)~FileState;
+  }
+
+  HighestBit = 0x80;
+  while (HighestBit != 0 && (HighestBit & FileState) == 0) {
+    HighestBit >>= 1;
+  }
+
+  return HighestBit;
+}
+
+UINT8
+CalculateHeaderChecksum (
+  IN EFI_FFS_FILE_HEADER  *FileHeader
+  )
+/*++
+
+Routine Description:
+  Calculates the checksum of the header of a file.
+
+Arguments:
+  FileHeader       - Pointer to FFS File Header.
+
+Returns:
+  Checksum of the header.
+  
+**/
+{
+  UINT8 *ptr;
+  UINTN Index;
+  UINT8 Sum;
+
+  Sum = 0;
+  ptr = (UINT8 *) FileHeader;
+
+  for (Index = 0; Index < sizeof (EFI_FFS_FILE_HEADER) - 3; Index += 4) {
+    Sum = (UINT8) (Sum + ptr[Index]);
+    Sum = (UINT8) (Sum + ptr[Index + 1]);
+    Sum = (UINT8) (Sum + ptr[Index + 2]);
+    Sum = (UINT8) (Sum + ptr[Index + 3]);
+  }
+
+  for (; Index < sizeof (EFI_FFS_FILE_HEADER); Index++) {
+    Sum = (UINT8) (Sum + ptr[Index]);
+  }
+  //
+  // State field (since this indicates the different state of file).
+  //
+  Sum = (UINT8) (Sum - FileHeader->State);
+  //
+  // Checksum field of the file is not part of the header checksum.
+  //
+  Sum = (UINT8) (Sum - FileHeader->IntegrityCheck.Checksum.File);
+
+  return Sum;
+}
+
+EFI_STATUS
+SecFfsFindNextFile (
+  IN EFI_FV_FILETYPE             SearchType,
+  IN EFI_PEI_FV_HANDLE           FvHandle,
+  IN OUT EFI_PEI_FILE_HANDLE     *FileHandle
+  )
+/*++
+
+Routine Description:
+    Given the input file pointer, search for the next matching file in the
+    FFS volume as defined by SearchType. The search starts from FileHeader inside
+    the Firmware Volume defined by FwVolHeader.
+
+Arguments:
+    SearchType - Filter to find only files of this type.
+                 Type EFI_FV_FILETYPE_ALL causes no filtering to be done.
+    FwVolHeader - Pointer to the FV header of the volume to search.
+                  This parameter must point to a valid FFS volume.
+    FileHeader  - Pointer to the current file from which to begin searching.
+                  This pointer will be updated upon return to reflect the file
+                  found.
+
+Returns:
+    EFI_NOT_FOUND - No files matching the search criteria were found
+    EFI_SUCCESS
+
+**/
+{
+  EFI_FFS_FILE_HEADER *FfsFileHeader;
+  UINT32              FileLength;
+  UINT32              FileOccupiedSize;
+  UINT32              FileOffset;
+  UINT64              FvLength;
+  UINT8               ErasePolarity;
+  UINT8               FileState;
+  EFI_FIRMWARE_VOLUME_HEADER  *FwVolHeader;
+  EFI_FFS_FILE_HEADER         **FileHeader;
+
+  //
+  // Convert the handle of FV to FV header for memory-mapped firmware volume
+  //
+  FwVolHeader = (EFI_FIRMWARE_VOLUME_HEADER *) FvHandle;
+  FileHeader  = (EFI_FFS_FILE_HEADER **)FileHandle;
+
+  FvLength = FwVolHeader->FvLength;
+  if (FwVolHeader->Attributes & EFI_FVB2_ERASE_POLARITY) {
+    ErasePolarity = 1;
+  } else {
+    ErasePolarity = 0;
+  }
+  //
+  // If FileHeader is not specified (NULL) start with the first file in the
+  // firmware volume.  Otherwise, start from the FileHeader.
+  //
+  if (*FileHeader == NULL) {
+    FfsFileHeader = (EFI_FFS_FILE_HEADER *) ((UINT8 *) FwVolHeader + FwVolHeader->HeaderLength);
+  } else {
+    //
+    // Length is 24 bits wide so mask upper 8 bits
+    // FileLength is adjusted to FileOccupiedSize as it is 8 byte aligned.
+    //
+    FileLength        = *(UINT32 *) (*FileHeader)->Size & 0x00FFFFFF;
+    FileOccupiedSize  = GET_OCCUPIED_SIZE (FileLength, 8);
+    FfsFileHeader     = (EFI_FFS_FILE_HEADER *) ((UINT8 *) *FileHeader + FileOccupiedSize);
+  }
+
+  FileOffset = (UINT32) ((UINT8 *) FfsFileHeader - (UINT8 *) FwVolHeader);
+
+  while (FileOffset < (FvLength - sizeof (EFI_FFS_FILE_HEADER))) {
+    //
+    // Get FileState which is the highest bit of the State
+    //
+    FileState = GetFileState (ErasePolarity, FfsFileHeader);
+
+    switch (FileState) {
+
+    case EFI_FILE_HEADER_INVALID:
+      FileOffset += sizeof (EFI_FFS_FILE_HEADER);
+      FfsFileHeader = (EFI_FFS_FILE_HEADER *) ((UINT8 *) FfsFileHeader + sizeof (EFI_FFS_FILE_HEADER));
+      break;
+
+    case EFI_FILE_DATA_VALID:
+    case EFI_FILE_MARKED_FOR_UPDATE:
+      if (CalculateHeaderChecksum (FfsFileHeader) == 0) {
+        FileLength        = *(UINT32 *) (FfsFileHeader->Size) & 0x00FFFFFF;
+        FileOccupiedSize  = GET_OCCUPIED_SIZE (FileLength, 8);
+
+        if ((SearchType == FfsFileHeader->Type) || (SearchType == EFI_FV_FILETYPE_ALL)) {
+
+          *FileHeader = FfsFileHeader;
+
+          return EFI_SUCCESS;
+        }
+
+        FileOffset += FileOccupiedSize;
+        FfsFileHeader = (EFI_FFS_FILE_HEADER *) ((UINT8 *) FfsFileHeader + FileOccupiedSize);
+      } else {
+        return EFI_NOT_FOUND;
+      }
+      break;
+
+    case EFI_FILE_DELETED:
+      FileLength        = *(UINT32 *) (FfsFileHeader->Size) & 0x00FFFFFF;
+      FileOccupiedSize  = GET_OCCUPIED_SIZE (FileLength, 8);
+      FileOffset += FileOccupiedSize;
+      FfsFileHeader = (EFI_FFS_FILE_HEADER *) ((UINT8 *) FfsFileHeader + FileOccupiedSize);
+      break;
+
+    default:
+      return EFI_NOT_FOUND;
+
+    }
+  }
+
+  return EFI_NOT_FOUND;
+}
+
+EFI_STATUS
+SecFfsFindSectionData (
+  IN EFI_SECTION_TYPE      SectionType,
+  IN EFI_FFS_FILE_HEADER   *FfsFileHeader,
+  IN OUT VOID              **SectionData
+  )
+/*++
+
+Routine Description:
+    Given the input file pointer, search for the next matching section in the
+    FFS volume.
+
+Arguments:
+    SearchType    - Filter to find only sections of this type.
+    FfsFileHeader - Pointer to the current file to search.
+    SectionData   - Pointer to the Section matching SectionType in FfsFileHeader.
+                     NULL if section not found
+
+Returns:
+    EFI_NOT_FOUND - No files matching the search criteria were found
+    EFI_SUCCESS
+
+**/
+{
+  UINT32                    FileSize;
+  EFI_COMMON_SECTION_HEADER *Section;
+  UINT32                    SectionLength;
+  UINT32                    ParsedLength;
+
+  //
+  // Size is 24 bits wide so mask upper 8 bits.
+  //    Does not include FfsFileHeader header size
+  // FileSize is adjusted to FileOccupiedSize as it is 8 byte aligned.
+  //
+  Section   = (EFI_COMMON_SECTION_HEADER *) (FfsFileHeader + 1);
+  FileSize  = *(UINT32 *) (FfsFileHeader->Size) & 0x00FFFFFF;
+  FileSize -= sizeof (EFI_FFS_FILE_HEADER);
+
+  *SectionData  = NULL;
+  ParsedLength  = 0;
+  while (ParsedLength < FileSize) {
+    if (Section->Type == SectionType) {
+      *SectionData = (VOID *) (Section + 1);
+      return EFI_SUCCESS;
+    }
+    //
+    // Size is 24 bits wide so mask upper 8 bits.
+    // SectionLength is adjusted it is 4 byte aligned.
+    // Go to the next section
+    //
+    SectionLength = *(UINT32 *) Section->Size & 0x00FFFFFF;
+    SectionLength = GET_OCCUPIED_SIZE (SectionLength, 4);
+
+    ParsedLength += SectionLength;
+    Section = (EFI_COMMON_SECTION_HEADER *) ((UINT8 *) Section + SectionLength);
+  }
+
+  return EFI_NOT_FOUND;
+}
+
diff --git a/InOsEmuPkg/Library/SecPeiServicesLib/PeiServicesLib.c b/InOsEmuPkg/Library/SecPeiServicesLib/PeiServicesLib.c
new file mode 100644 (file)
index 0000000..cee715d
--- /dev/null
@@ -0,0 +1,569 @@
+/** @file\r
+  Implementation for PEI Services Library.\r
+\r
+  Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+  This program and the accompanying materials\r
+  are licensed and made available under the terms and conditions of the BSD License\r
+  which accompanies this distribution.  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php.\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+\r
+#include <PiPei.h>\r
+\r
+#include <Library/PeiServicesLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/PpiListLib.h>\r
+\r
+\r
+\r
+EFI_STATUS\r
+SecFfsFindNextFile (\r
+  IN EFI_FV_FILETYPE            SearchType,\r
+  IN EFI_PEI_FV_HANDLE          VolumeHandle,\r
+  IN OUT EFI_PEI_FILE_HANDLE    *FileHandle\r
+  );\r
+\r
+EFI_STATUS\r
+SecFfsFindSectionData (\r
+  IN EFI_SECTION_TYPE           SectionType,\r
+  IN EFI_PEI_FILE_HANDLE        FileHandle,\r
+  OUT VOID                      **SectionData\r
+  );\r
+\r
+\r
+/**\r
+  This service enables a given PEIM to register an interface into the PEI Foundation.\r
+\r
+  @param  PpiList               A pointer to the list of interfaces that the caller shall install.\r
+\r
+  @retval EFI_SUCCESS           The interface was successfully installed.\r
+  @retval EFI_INVALID_PARAMETER The PpiList pointer is NULL.\r
+  @retval EFI_INVALID_PARAMETER Any of the PEI PPI descriptors in the list do not have the\r
+                                EFI_PEI_PPI_DESCRIPTOR_PPI bit set in the Flags field.\r
+  @retval EFI_OUT_OF_RESOURCES  There is no additional space in the PPI database.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiServicesInstallPpi (\r
+  IN CONST EFI_PEI_PPI_DESCRIPTOR     *PpiList\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return EFI_OUT_OF_RESOURCES;\r
+}\r
+\r
+/**\r
+  This service enables PEIMs to replace an entry in the PPI database with an alternate entry.\r
+\r
+  @param  OldPpi                The pointer to the old PEI PPI Descriptors.\r
+  @param  NewPpi                The pointer to the new PEI PPI Descriptors.\r
+\r
+  @retval EFI_SUCCESS           The interface was successfully installed.\r
+  @retval EFI_INVALID_PARAMETER The OldPpi or NewPpi is NULL.\r
+  @retval EFI_INVALID_PARAMETER Any of the PEI PPI descriptors in the list do not have the\r
+                                EFI_PEI_PPI_DESCRIPTOR_PPI bit set in the Flags field.\r
+  @retval EFI_OUT_OF_RESOURCES  There is no additional space in the PPI database.\r
+  @retval EFI_NOT_FOUND         The PPI for which the reinstallation was requested has not been\r
+                                installed.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiServicesReInstallPpi (\r
+  IN CONST EFI_PEI_PPI_DESCRIPTOR     *OldPpi,\r
+  IN CONST EFI_PEI_PPI_DESCRIPTOR     *NewPpi\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return EFI_OUT_OF_RESOURCES;\r
+}\r
+\r
+/**\r
+  This service enables PEIMs to discover a given instance of an interface.\r
+\r
+  So this is, well a hack, so we can reuse the same libraries as the PEI Core \r
+  for XIP modules.... \r
+\r
+  @param  Guid                  A pointer to the GUID whose corresponding interface needs to be\r
+                                found.\r
+  @param  Instance              The N-th instance of the interface that is required.\r
+  @param  PpiDescriptor         A pointer to instance of the EFI_PEI_PPI_DESCRIPTOR.\r
+  @param  Ppi                   A pointer to the instance of the interface.\r
+\r
+  @retval EFI_SUCCESS           The interface was successfully returned.\r
+  @retval EFI_NOT_FOUND         The PPI descriptor is not found in the database.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiServicesLocatePpi (\r
+  IN CONST EFI_GUID             *Guid,\r
+  IN UINTN                      Instance,\r
+  IN OUT EFI_PEI_PPI_DESCRIPTOR **PpiDescriptor,\r
+  IN OUT VOID                   **Ppi\r
+  )\r
+{\r
+  EFI_PEI_PPI_DESCRIPTOR *PpiList;\r
+   \r
+  if (Instance != 0) {\r
+    return EFI_NOT_FOUND;\r
+  }\r
+  \r
+  \r
+  for (PpiList = (EFI_PEI_PPI_DESCRIPTOR *)gPpiList; ; PpiList++) {\r
+    if (CompareGuid (PpiList->Guid, Guid)) {\r
+      if (PpiDescriptor != NULL) {\r
+        *PpiDescriptor = PpiList;\r
+      }\r
+      if (Ppi != NULL) {\r
+        *Ppi = PpiList->Ppi;\r
+      }\r
+      return EFI_SUCCESS;\r
+    }\r
+    \r
+    if ((PpiList->Flags & EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST) == EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST) {\r
+      break;\r
+    }\r
+  } \r
+  \r
+  \r
+  return EFI_NOT_FOUND;\r
+}\r
+\r
+/**\r
+  This service enables PEIMs to register a given service to be invoked when another service is\r
+  installed or reinstalled.\r
+\r
+  @param  NotifyList            A pointer to the list of notification interfaces \r
+                                that the caller shall install.\r
+\r
+  @retval EFI_SUCCESS           The interface was successfully installed.\r
+  @retval EFI_INVALID_PARAMETER The NotifyList pointer is NULL.\r
+  @retval EFI_INVALID_PARAMETER Any of the PEI notify descriptors in the list do\r
+                                 not have the EFI_PEI_PPI_DESCRIPTOR_NOTIFY_TYPES\r
+                                 bit set in the Flags field.\r
+  @retval EFI_OUT_OF_RESOURCES  There is no additional space in the PPI database.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiServicesNotifyPpi (\r
+  IN CONST EFI_PEI_NOTIFY_DESCRIPTOR  *NotifyList\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return EFI_OUT_OF_RESOURCES;\r
+}\r
+\r
+/**\r
+  This service enables PEIMs to ascertain the present value of the boot mode.\r
+\r
+  @param  BootMode              A pointer to contain the value of the boot mode.\r
+\r
+  @retval EFI_SUCCESS           The boot mode was returned successfully.\r
+  @retval EFI_INVALID_PARAMETER BootMode is NULL.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiServicesGetBootMode (\r
+  OUT EFI_BOOT_MODE          *BootMode\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return EFI_OUT_OF_RESOURCES;\r
+}\r
+\r
+/**\r
+  This service enables PEIMs to update the boot mode variable.\r
+\r
+  @param  BootMode              The value of the boot mode to set.\r
+\r
+  @retval EFI_SUCCESS           The value was successfully updated\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiServicesSetBootMode (\r
+  IN EFI_BOOT_MODE              BootMode\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return EFI_OUT_OF_RESOURCES;\r
+}\r
+\r
+/**\r
+  This service enables a PEIM to ascertain the address of the list of HOBs in memory.\r
+\r
+  @param  HobList               A pointer to the list of HOBs that the PEI Foundation \r
+                                will initialize.\r
+  \r
+  @retval EFI_SUCCESS           The list was successfully returned.\r
+  @retval EFI_NOT_AVAILABLE_YET The HOB list is not yet published.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiServicesGetHobList (\r
+  OUT VOID                      **HobList\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return EFI_OUT_OF_RESOURCES;\r
+}\r
+\r
+/**\r
+  This service enables PEIMs to create various types of HOBs.\r
+\r
+  @param  Type                  The type of HOB to be installed.\r
+  @param  Length                The length of the HOB to be added.\r
+  @param  Hob                   The address of a pointer that will contain the \r
+                                HOB header.\r
+\r
+  @retval EFI_SUCCESS           The HOB was successfully created.\r
+  @retval EFI_OUT_OF_RESOURCES  There is no additional space for HOB creation.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiServicesCreateHob (\r
+  IN UINT16                     Type,\r
+  IN UINT16                     Length,\r
+  OUT VOID                      **Hob\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return EFI_OUT_OF_RESOURCES;\r
+}\r
+\r
+/**\r
+  This service enables PEIMs to discover additional firmware volumes.\r
+\r
+  @param  Instance              This instance of the firmware volume to find.  The \r
+                                value 0 is the Boot Firmware Volume (BFV).\r
+  @param  VolumeHandle          Handle of the firmware volume header of the volume\r
+                                to return.\r
+\r
+  @retval EFI_SUCCESS           The volume was found.\r
+  @retval EFI_NOT_FOUND         The volume was not found.\r
+  @retval EFI_INVALID_PARAMETER FwVolHeader is NULL.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiServicesFfsFindNextVolume (\r
+  IN UINTN                          Instance,\r
+  IN OUT EFI_PEI_FV_HANDLE          *VolumeHandle\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return EFI_OUT_OF_RESOURCES;\r
+}\r
+\r
+/**\r
+  This service enables PEIMs to discover additional firmware files.\r
+\r
+  @param  SearchType            A filter to find files only of this type.\r
+  @param  VolumeHandle          The pointer to the firmware volume header of the \r
+                                volume to search. This parameter must point to a \r
+                                valid FFS volume. \r
+  @param  FileHandle            Handle of the current file from which to begin searching.\r
+\r
+  @retval EFI_SUCCESS           The file was found.\r
+  @retval EFI_NOT_FOUND         The file was not found.\r
+  @retval EFI_NOT_FOUND         The header checksum was not zero.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiServicesFfsFindNextFile (\r
+  IN EFI_FV_FILETYPE            SearchType,\r
+  IN EFI_PEI_FV_HANDLE          VolumeHandle,\r
+  IN OUT EFI_PEI_FILE_HANDLE    *FileHandle\r
+  )\r
+{\r
+  return SecFfsFindNextFile (SearchType, VolumeHandle, FileHandle);\r
+}\r
+\r
+/**\r
+  This service enables PEIMs to discover sections of a given type within a valid FFS file.\r
+\r
+  @param  SectionType           The value of the section type to find.\r
+  @param  FileHandle            A pointer to the file header that contains the set \r
+                                of sections to be searched.\r
+  @param  SectionData           A pointer to the discovered section, if successful.\r
+\r
+  @retval EFI_SUCCESS           The section was found.\r
+  @retval EFI_NOT_FOUND         The section was not found.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiServicesFfsFindSectionData (\r
+  IN EFI_SECTION_TYPE           SectionType,\r
+  IN EFI_PEI_FILE_HANDLE        FileHandle,\r
+  OUT VOID                      **SectionData\r
+  )\r
+{\r
+  return SecFfsFindSectionData (SectionType, FileHandle, SectionData);\r
+}\r
+\r
+/**\r
+  This service enables PEIMs to register the permanent memory configuration\r
+  that has been initialized with the PEI Foundation.\r
+\r
+  @param  MemoryBegin           The value of a region of installed memory.\r
+  @param  MemoryLength          The corresponding length of a region of installed memory.\r
+\r
+  @retval EFI_SUCCESS           The region was successfully installed in a HOB.\r
+  @retval EFI_INVALID_PARAMETER MemoryBegin and MemoryLength are illegal for this system.\r
+  @retval EFI_OUT_OF_RESOURCES  There is no additional space for HOB creation.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiServicesInstallPeiMemory (\r
+  IN EFI_PHYSICAL_ADDRESS       MemoryBegin,\r
+  IN UINT64                     MemoryLength\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return EFI_OUT_OF_RESOURCES;\r
+}\r
+\r
+/**\r
+  This service enables PEIMs to allocate memory after the permanent memory has been\r
+   installed by a PEIM.\r
+\r
+  @param  MemoryType            Type of memory to allocate.\r
+  @param  Pages                 The number of pages to allocate.\r
+  @param  Memory                Pointer of memory allocated.\r
+\r
+  @retval EFI_SUCCESS           The memory range was successfully allocated.\r
+  @retval EFI_INVALID_PARAMETER Type is not equal to AllocateAnyPages.\r
+  @retval EFI_NOT_AVAILABLE_YET Called with permanent memory not available.\r
+  @retval EFI_OUT_OF_RESOURCES  The pages could not be allocated.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiServicesAllocatePages (\r
+  IN EFI_MEMORY_TYPE            MemoryType,\r
+  IN UINTN                      Pages,\r
+  OUT EFI_PHYSICAL_ADDRESS      *Memory\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return EFI_OUT_OF_RESOURCES;\r
+}\r
+\r
+/**\r
+  This service allocates memory from the Hand-Off Block (HOB) heap.\r
+\r
+  @param  Size                  The number of bytes to allocate from the pool.\r
+  @param  Buffer                If the call succeeds, a pointer to a pointer to \r
+                                the allocate buffer; otherwise, undefined.\r
+\r
+  @retval EFI_SUCCESS           The allocation was successful\r
+  @retval EFI_OUT_OF_RESOURCES  There is not enough heap to allocate the requested size.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiServicesAllocatePool (\r
+  IN UINTN                      Size,\r
+  OUT VOID                      **Buffer\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return EFI_OUT_OF_RESOURCES;\r
+}\r
+\r
+/**\r
+  Resets the entire platform.\r
+\r
+  @retval EFI_SUCCESS           The function completed successfully.\r
+  @retval EFI_NOT_AVAILABLE_YET The service has not been installed yet.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiServicesResetSystem (\r
+  VOID\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return EFI_OUT_OF_RESOURCES;\r
+}\r
+\r
+/**\r
+  This service is a wrapper for the PEI Service RegisterForShadow(), except the \r
+  pointer to the PEI Services Table has been removed.  See the Platform \r
+  Initialization Pre-EFI Initialization Core Interface Specification for details. \r
+\r
+  @param FileHandle             PEIM's file handle. Must be the currently\r
+                                executing PEIM.\r
+  \r
+  @retval EFI_SUCCESS           The PEIM was successfully registered for\r
+                                shadowing.\r
+\r
+  @retval EFI_ALREADY_STARTED   The PEIM was previously\r
+                                registered for shadowing.\r
+\r
+  @retval EFI_NOT_FOUND         The FileHandle does not refer to a\r
+                                valid file handle.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiServicesRegisterForShadow (\r
+  IN  EFI_PEI_FILE_HANDLE FileHandle\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return EFI_OUT_OF_RESOURCES;\r
+}\r
+\r
+/**\r
+  This service is a wrapper for the PEI Service FfsGetFileInfo(), except the pointer to the PEI Services \r
+  Table has been removed.  See the Platform Initialization Pre-EFI Initialization Core Interface \r
+  Specification for details. \r
+\r
+  @param FileHandle              The handle of the file.\r
+\r
+  @param FileInfo                 Upon exit, points to the file's\r
+                                  information.\r
+\r
+  @retval EFI_SUCCESS             File information returned.\r
+  \r
+  @retval EFI_INVALID_PARAMETER   If FileHandle does not\r
+                                  represent a valid file.\r
+  \r
+  @retval EFI_INVALID_PARAMETER   FileInfo is NULL.\r
+  \r
+**/\r
+EFI_STATUS\r
+EFIAPI \r
+PeiServicesFfsGetFileInfo (\r
+  IN CONST  EFI_PEI_FILE_HANDLE   FileHandle,\r
+  OUT EFI_FV_FILE_INFO            *FileInfo\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return EFI_OUT_OF_RESOURCES;\r
+}\r
+\r
+\r
+/**\r
+  This service is a wrapper for the PEI Service FfsFindByName(), except the pointer to the PEI Services \r
+  Table has been removed.  See the Platform Initialization Pre-EFI Initialization Core Interface \r
+  Specification for details. \r
+\r
+  @param FileName                 A pointer to the name of the file to\r
+                                  find within the firmware volume.\r
+\r
+  @param VolumeHandle             The firmware volume to search FileHandle\r
+                                  Upon exit, points to the found file's\r
+                                  handle or NULL if it could not be found.\r
+  @param FileHandle               The pointer to found file handle \r
+\r
+  @retval EFI_SUCCESS             File was found.\r
+\r
+  @retval EFI_NOT_FOUND           File was not found.\r
+\r
+  @retval EFI_INVALID_PARAMETER   VolumeHandle or FileHandle or\r
+                                  FileName was NULL.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiServicesFfsFindFileByName (\r
+  IN CONST  EFI_GUID            *FileName,\r
+  IN CONST  EFI_PEI_FV_HANDLE   VolumeHandle,\r
+  OUT       EFI_PEI_FILE_HANDLE *FileHandle\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return EFI_OUT_OF_RESOURCES;\r
+}\r
+\r
+\r
+/**\r
+  This service is a wrapper for the PEI Service FfsGetVolumeInfo(), except the pointer to the PEI Services \r
+  Table has been removed.  See the Platform Initialization Pre-EFI Initialization Core Interface \r
+  Specification for details. \r
+\r
+  @param VolumeHandle             Handle of the volume.\r
+\r
+  @param VolumeInfo               Upon exit, points to the volume's\r
+                                  information.\r
+\r
+  @retval EFI_SUCCESS             File information returned.\r
+  \r
+  @retval EFI_INVALID_PARAMETER   If FileHandle does not\r
+                                  represent a valid file.\r
+  \r
+  @retval EFI_INVALID_PARAMETER   If FileInfo is NULL.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiServicesFfsGetVolumeInfo (\r
+  IN  EFI_PEI_FV_HANDLE       VolumeHandle,\r
+  OUT EFI_FV_INFO             *VolumeInfo\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return EFI_OUT_OF_RESOURCES;\r
+}\r
+\r
+/**\r
+  Install a EFI_PEI_FIRMWARE_VOLUME_INFO_PPI instance so the PEI Core will be notified about a new firmware volume.\r
+  \r
+  This function allocates, initializes, and installs a new EFI_PEI_FIRMWARE_VOLUME_INFO_PPI using \r
+  the parameters passed in to initialize the fields of the EFI_PEI_FIRMWARE_VOLUME_INFO_PPI instance.\r
+  If the resources can not be allocated for EFI_PEI_FIRMWARE_VOLUME_INFO_PPI, then ASSERT().\r
+  If the EFI_PEI_FIRMWARE_VOLUME_INFO_PPI can not be installed, then ASSERT().\r
+\r
+  \r
+  @param  FvFormat             Unique identifier of the format of the memory-mapped \r
+                               firmware volume.  This parameter is optional and \r
+                               may be NULL.  If NULL is specified, the \r
+                               EFI_FIRMWARE_FILE_SYSTEM2_GUID format is assumed.\r
+  @param  FvInfo               Points to a buffer which allows the \r
+                               EFI_PEI_FIRMWARE_VOLUME_PPI to process the volume. \r
+                               The format of this buffer is specific to the FvFormat. \r
+                               For memory-mapped firmware volumes, this typically \r
+                               points to the first byte of the firmware volume.\r
+  @param  FvInfoSize           The size, in bytes, of FvInfo. For memory-mapped \r
+                               firmware volumes, this is typically the size of \r
+                               the firmware volume.\r
+  @param  ParentFvName         If the new firmware volume originated from a file \r
+                               in a different firmware volume, then this parameter \r
+                               specifies the GUID name of the originating firmware\r
+                               volume. Otherwise, this parameter must be NULL.\r
+  @param  ParentFileName       If the new firmware volume originated from a file \r
+                               in a different firmware volume, then this parameter \r
+                               specifies the GUID file name of the originating \r
+                               firmware file. Otherwise, this parameter must be NULL.\r
+**/\r
+VOID\r
+EFIAPI\r
+PeiServicesInstallFvInfoPpi (\r
+  IN CONST EFI_GUID                *FvFormat, OPTIONAL\r
+  IN CONST VOID                    *FvInfo,\r
+  IN       UINT32                  FvInfoSize,\r
+  IN CONST EFI_GUID                *ParentFvName, OPTIONAL\r
+  IN CONST EFI_GUID                *ParentFileName OPTIONAL\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return;\r
+}\r
+\r
diff --git a/InOsEmuPkg/Library/SecPeiServicesLib/SecPeiServicesLib.inf b/InOsEmuPkg/Library/SecPeiServicesLib/SecPeiServicesLib.inf
new file mode 100644 (file)
index 0000000..6e9cf3a
--- /dev/null
@@ -0,0 +1,45 @@
+## @file\r
+# PEI Services Library implementation.\r
+#\r
+# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>\r
+#\r
+#  This program and the accompanying materials\r
+#  are licensed and made available under the terms and conditions of the BSD License\r
+#  which accompanies this distribution. The full text of the license may be found at\r
+#  http://opensource.org/licenses/bsd-license.php.\r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+#\r
+##\r
+\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = SecPeiServicesLib\r
+  FILE_GUID                      = E3E4A441-8465-0F41-8AF4-F67EBE984099\r
+  MODULE_TYPE                    = PEIM\r
+  VERSION_STRING                 = 1.0\r
+  LIBRARY_CLASS                  = PeiServicesLib|SEC PEIM PEI_CORE \r
+  PI_SPECIFICATION_VERSION       = 0x0001000A\r
+\r
+#\r
+#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC (EBC is for build only)\r
+#\r
+\r
+[Sources]\r
+  PeiServicesLib.c\r
+  FwVol.c\r
+\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  InOsEmuPkg/InOsEmuPkg.dec\r
+\r
+[LibraryClasses]\r
+  DebugLib\r
+  BaseMemoryLib\r
+  PpiListLib\r
+\r
+\r
+\r
+\r
diff --git a/InOsEmuPkg/Library/SecPpiListLib/PpiListLib.c b/InOsEmuPkg/Library/SecPpiListLib/PpiListLib.c
new file mode 100644 (file)
index 0000000..42c0d97
--- /dev/null
@@ -0,0 +1,17 @@
+/*++ @file
+
+Copyright (c) 2011, Apple Inc. 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        
+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>
+
+CONST EFI_PEI_PPI_DESCRIPTOR  *gPpiList = NULL;
+
diff --git a/InOsEmuPkg/Library/SecPpiListLib/SecPpiListLib.inf b/InOsEmuPkg/Library/SecPpiListLib/SecPpiListLib.inf
new file mode 100644 (file)
index 0000000..07c2c35
--- /dev/null
@@ -0,0 +1,31 @@
+## @file\r
+# Place thunk PPI in HOB.\r
+#\r
+# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>\r
+# Portions copyright (c) 2011, Apple Inc. All rights reserved. \r
+#\r
+#  This program and the accompanying materials\r
+#  are licensed and made available under the terms and conditions of the BSD License\r
+#  which accompanies this distribution. The full text of the license may be found at\r
+#  http://opensource.org/licenses/bsd-license.php.\r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+#\r
+##\r
+\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = SecPpiListLib\r
+  FILE_GUID                      = F950E820-0457-8143-86AD-30E4A45FD4BF\r
+  MODULE_TYPE                    = BASE\r
+  VERSION_STRING                 = 1.0\r
+  LIBRARY_CLASS                  = PpiListLib|SEC BASE USER_DEFINED\r
+\r
+[Sources]\r
+  PpiListLib.c\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  InOsEmuPkg/InOsEmuPkg.dec\r
+\r
diff --git a/InOsEmuPkg/Sec/Sec.c b/InOsEmuPkg/Sec/Sec.c
new file mode 100644 (file)
index 0000000..4e350f1
--- /dev/null
@@ -0,0 +1,149 @@
+/*++ @file
+  Stub SEC that is called from the OS appliation that is the root of the emulator.
+  
+  The OS application will call the SEC with the PEI Entry Point API.  
+
+Copyright (c) 2011, Apple Inc. 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
+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 "Sec.h"
+
+
+
+EFI_PEI_TEMPORARY_RAM_SUPPORT_PPI mSecTemporaryRamSupportPpi = { 
+  SecTemporaryRamSupport
+};
+
+
+EFI_PEI_PPI_DESCRIPTOR  gPrivateDispatchTable[] = {
+  {
+    EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,
+    &gEfiTemporaryRamSupportPpiGuid,
+    &mSecTemporaryRamSupportPpi
+  }
+};
+
+
+
+/**
+  The entry point of PE/COFF Image for the PEI Core, that has been hijacked by this
+  SEC that sits on top of an OS application. So the entry and exit of this module 
+  has the same API. 
+
+  This function is the entry point for the PEI Foundation, which allows the SEC phase
+  to pass information about the stack, temporary RAM and the Boot Firmware Volume.
+  In addition, it also allows the SEC phase to pass services and data forward for use
+  during the PEI phase in the form of one or more PPIs.
+  There is no limit to the number of additional PPIs that can be passed from SEC into
+  the PEI Foundation. As part of its initialization phase, the PEI Foundation will add
+  these SEC-hosted PPIs to its PPI database such that both the PEI Foundation and any
+  modules can leverage the associated service calls and/or code in these early PPIs.
+  This function is required to call ProcessModuleEntryPointList() with the Context
+  parameter set to NULL.  ProcessModuleEntryPoint() is never expected to return.
+  The PEI Core is responsible for calling ProcessLibraryConstructorList() as soon as
+  the PEI Services Table and the file handle for the PEI Core itself have been established.
+  If ProcessModuleEntryPointList() returns, then ASSERT() and halt the system.
+
+  @param SecCoreData  Points to a data structure containing information about the PEI
+                      core's operating environment, such as the size and location of
+                      temporary RAM, the stack location and the BFV location. 
+
+  @param PpiList      Points to a list of one or more PPI descriptors to be installed
+                      initially by the PEI core. An empty PPI list consists of a single
+                      descriptor with the end-tag EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST.
+                      As part of its initialization phase, the PEI Foundation will add
+                      these SEC-hosted PPIs to its PPI database such that both the PEI
+                      Foundation and any modules can leverage the associated service calls
+                      and/or code in these early PPIs.
+
+**/
+VOID 
+EFIAPI
+_ModuleEntryPoint (
+  IN EFI_SEC_PEI_HAND_OFF   *SecCoreData,
+  IN EFI_PEI_PPI_DESCRIPTOR *PpiList 
+  )
+{
+  EFI_STATUS                Status;
+  EFI_PEI_FV_HANDLE         VolumeHandle;
+  EFI_PEI_FILE_HANDLE       FileHandle;
+  VOID                      *PeCoffImage;
+  EFI_PEI_CORE_ENTRY_POINT  EntryPoint;
+  EFI_PEI_PPI_DESCRIPTOR    *Ppi;
+  EFI_PEI_PPI_DESCRIPTOR    *SecPpiList;
+  UINTN                     SecReseveredMemorySize;
+  UINTN                     Index;
+  
+  gPpiList = PpiList;
+  ProcessLibraryConstructorList ();
+  
+  DEBUG ((EFI_D_ERROR, "SEC Has Started\n"));
+  
+  //
+  // Add Our PPIs to the list
+  //
+  SecReseveredMemorySize = sizeof (gPrivateDispatchTable);
+  for (Ppi = PpiList, Index = 1; ; Ppi++, Index++) {
+    SecReseveredMemorySize += sizeof (EFI_PEI_PPI_DESCRIPTOR);
+  
+    if ((Ppi->Flags & EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST) == EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST) {
+      // Since we are appending, need to clear out privious list terminator.
+      Ppi->Flags &= ~EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST; 
+      break;
+    }
+  }
+  
+  // Keep everything on a good alignment
+  SecReseveredMemorySize = ALIGN_VALUE (SecReseveredMemorySize, CPU_STACK_ALIGNMENT);
+  
+#if 0
+  // Tell the PEI Core to not use our buffer in temp RAM
+  SecPpiList = (EFI_PEI_PPI_DESCRIPTOR *)SecCoreData->PeiTemporaryRamBase;
+  SecCoreData->PeiTemporaryRamBase = (VOID *)((UINTN)SecCoreData->PeiTemporaryRamBase + SecReseveredMemorySize);
+  SecCoreData->PeiTemporaryRamSize -= SecReseveredMemorySize;
+#else
+  {
+    //
+    // When I subtrack from SecCoreData->PeiTemporaryRamBase PEI Core crashes? Either there is a bug
+    // or I don't understand temp RAM correctly?
+    //
+    EFI_PEI_PPI_DESCRIPTOR    PpiArray[10];
+    
+    SecPpiList = &PpiArray[0];
+    ASSERT (sizeof (PpiArray) >= SecReseveredMemorySize);
+  }
+#endif
+  // Copy existing list, and append our entries. 
+  CopyMem (SecPpiList, PpiList, sizeof (EFI_PEI_PPI_DESCRIPTOR) * Index);
+  CopyMem (&SecPpiList[Index], gPrivateDispatchTable, sizeof (gPrivateDispatchTable));
+
+  // Find PEI Core and transfer control
+  VolumeHandle = (EFI_PEI_FV_HANDLE)(UINTN)SecCoreData->BootFirmwareVolumeBase;
+  FileHandle   = NULL;
+  Status = PeiServicesFfsFindNextFile (EFI_FV_FILETYPE_PEI_CORE, VolumeHandle, &FileHandle);
+  ASSERT_EFI_ERROR (Status);
+  
+  Status = PeiServicesFfsFindSectionData (EFI_SECTION_PE32, FileHandle, &PeCoffImage);
+  ASSERT_EFI_ERROR (Status);
+
+  Status = PeCoffLoaderGetEntryPoint (PeCoffImage, (VOID **)&EntryPoint);
+  ASSERT_EFI_ERROR (Status);
+  
+  // Transfer control to PEI Core
+  EntryPoint (SecCoreData, SecPpiList);
+  
+  // PEI Core never returns
+  ASSERT (FALSE);
+  return;
+}
+
+
+
diff --git a/InOsEmuPkg/Sec/Sec.h b/InOsEmuPkg/Sec/Sec.h
new file mode 100644 (file)
index 0000000..d0bc9e1
--- /dev/null
@@ -0,0 +1,51 @@
+/*++ @file
+  Stub SEC that is called from the OS appliation that is the root of the emulator.
+  
+  The OS application will call the SEC with the PEI Entry Point API.  
+
+Copyright (c) 2011, Apple Inc. 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
+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.
+
+**/
+
+#ifndef __SEC_H___
+#define __SEC_H___
+
+
+#include <PiPei.h>
+#include <Library/DebugLib.h>
+#include <Library/PeiServicesLib.h>
+#include <Library/PeCoffGetEntryPointLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/PpiListLib.h>
+
+#include <Ppi/TemporaryRamSupport.h>
+
+
+//
+// I think this shold be defined in a MdePkg include file?
+//
+VOID
+EFIAPI
+ProcessLibraryConstructorList (
+  VOID
+  );
+
+EFI_STATUS
+EFIAPI
+SecTemporaryRamSupport (
+  IN CONST EFI_PEI_SERVICES   **PeiServices,
+  IN EFI_PHYSICAL_ADDRESS     TemporaryMemoryBase,
+  IN EFI_PHYSICAL_ADDRESS     PermanentMemoryBase,
+  IN UINTN                    CopySize
+  );
+
+
+#endif
+
diff --git a/InOsEmuPkg/Sec/Sec.inf b/InOsEmuPkg/Sec/Sec.inf
new file mode 100644 (file)
index 0000000..b09785a
--- /dev/null
@@ -0,0 +1,44 @@
+## @file\r
+# Entry Point of Emu Emulator\r
+#\r
+# Main executable file of Unix Emulator that loads PEI core after initialization finished.\r
+# Portions copyright (c) 2011, Apple Inc. All rights reserved.<BR>\r
+#\r
+#  This program and the accompanying materials\r
+#  are licensed and made available under the terms and conditions of the BSD License\r
+#  which accompanies this distribution. The full text of the license may be found at\r
+#  http://opensource.org/licenses/bsd-license.php\r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+#\r
+##\r
+\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = EmuSec\r
+  FILE_GUID                      = BCAF98C9-22B0-3B4F-9CBD-C8A6B4DBCEE9\r
+  MODULE_TYPE                    = SEC\r
+  VERSION_STRING                 = 1.0\r
+\r
+\r
+[Sources]\r
+  Sec.c\r
+\r
+[Sources.X64]\r
+  X64/SwitchRam.S\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  InOsEmuPkg/InOsEmuPkg.dec\r
+\r
+[LibraryClasses]\r
+  DebugLib\r
+  PeCoffGetEntryPointLib\r
+  PeiServicesLib\r
+  PpiListLib\r
+  BaseMemoryLib\r
+\r
+[Ppis]\r
+  gEfiTemporaryRamSupportPpiGuid\r
+  
\ No newline at end of file
diff --git a/InOsEmuPkg/Sec/X64/SwitchRam.S b/InOsEmuPkg/Sec/X64/SwitchRam.S
new file mode 100644 (file)
index 0000000..6bb2857
--- /dev/null
@@ -0,0 +1,68 @@
+#------------------------------------------------------------------------------\r
+#\r
+# Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>\r
+# Portitions copyright (c) 2011, Apple Inc. All rights reserved.\r
+# This program and the accompanying materials\r
+# are licensed and made available under the terms and conditions of the BSD License\r
+# which accompanies this distribution.  The full text of the license may be found at\r
+# http://opensource.org/licenses/bsd-license.php.\r
+#\r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+#------------------------------------------------------------------------------\r
+\r
+\r
+\r
+//  EFI_STATUS\r
+//  EFIAPI\r
+//  SecTemporaryRamSupport (\r
+//    IN CONST EFI_PEI_SERVICES   **PeiServices,         // %rcx\r
+//    IN EFI_PHYSICAL_ADDRESS     TemporaryMemoryBase,   // %rdx\r
+//    IN EFI_PHYSICAL_ADDRESS     PermanentMemoryBase,   // %r8 \r
+//    IN UINTN                    CopySize               // %r9\r
+//    )\r
+//\r
+ASM_GLOBAL ASM_PFX(SecTemporaryRamSupport)\r
+ASM_PFX(SecTemporaryRamSupport):\r
+  // Adjust callers %rbp to account for stack move\r
+  subq    %rdx, %rbp     // Calc offset of %rbp in Temp Memory\r
+  addq    %r8,  %rbp     // add in permanent base to offset\r
+  \r
+  pushq   %rbp           // stack frame is for the debugger\r
+  movq    %rsp, %rbp\r
+\r
+  pushq   %rdx          // Save TemporaryMemoryBase\r
+  pushq   %r8           // Save PermanentMemoryBase\r
+  pushq   %r9           // Save CopySize\r
+  \r
+  //\r
+  // Copy all of temp RAM to permanent memory, including stack\r
+  //\r
+  // CopyMem (PermanentMemoryBase, TemporaryMemoryBase, CopySize);\r
+  //          %rcx,                %rdx,                %r8\r
+  movq    %r8,  %rcx    // Shift arguments\r
+  movq    %r9,  %r8\r
+  call    ASM_PFX(CopyMem)\r
+  // Temp mem stack now copied to permanent location. %esp still in temp memory\r
+  \r
+  popq    %r9           // CopySize (old stack)\r
+  popq    %r8           // PermanentMemoryBase (old stack)\r
+  popq    %rdx          // TemporaryMemoryBase (old stack)\r
+    \r
+  movq    %rsp, %rcx    // Move to new stack\r
+  subq    %rdx, %rcx    // Calc offset of stack in Temp Memory\r
+  addq    %r8,  %rcx    // Calc PermanentMemoryBase address\r
+  movq    %rcx, %rsp    // Update stack \r
+  // Stack now points to permanent memory\r
+  \r
+  // ZeroMem (TemporaryMemoryBase /* rcx */, CopySize /* rdx */);\r
+  movq    %rdx, %rcx\r
+  movq    %r9,  %rdx\r
+  call    ASM_PFX(ZeroMem)\r
+\r
+  // This data comes off the NEW stack\r
+  popq    %rbp\r
+  ret\r
+\r
+\r
diff --git a/InOsEmuPkg/Unix/Sec/FwVol.c b/InOsEmuPkg/Unix/Sec/FwVol.c
deleted file mode 100644 (file)
index a9a09a4..0000000
+++ /dev/null
@@ -1,309 +0,0 @@
-/*++ @file\r
-  A simple FV stack so the SEC can extract the SEC Core from an\r
-  FV.\r
-\r
-Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-**/\r
-\r
-#include "SecMain.h"\r
-\r
-#define GET_OCCUPIED_SIZE(ActualSize, Alignment) \\r
-  (ActualSize) + (((Alignment) - ((ActualSize) & ((Alignment) - 1))) & ((Alignment) - 1))\r
-\r
-EFI_FFS_FILE_STATE\r
-GetFileState (\r
-  IN UINT8                ErasePolarity,\r
-  IN EFI_FFS_FILE_HEADER  *FfsHeader\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Returns the highest bit set of the State field\r
-\r
-Arguments:\r
-  ErasePolarity   - Erase Polarity  as defined by EFI_FVB2_ERASE_POLARITY\r
-                    in the Attributes field.\r
-  FfsHeader       - Pointer to FFS File Header.\r
-\r
-Returns:\r
-  Returns the highest bit in the State field\r
-\r
-**/\r
-{\r
-  EFI_FFS_FILE_STATE  FileState;\r
-  EFI_FFS_FILE_STATE  HighestBit;\r
-\r
-  FileState = FfsHeader->State;\r
-\r
-  if (ErasePolarity != 0) {\r
-    FileState = (EFI_FFS_FILE_STATE)~FileState;\r
-  }\r
-\r
-  HighestBit = 0x80;\r
-  while (HighestBit != 0 && (HighestBit & FileState) == 0) {\r
-    HighestBit >>= 1;\r
-  }\r
-\r
-  return HighestBit;\r
-}\r
-\r
-UINT8\r
-CalculateHeaderChecksum (\r
-  IN EFI_FFS_FILE_HEADER  *FileHeader\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Calculates the checksum of the header of a file.\r
-\r
-Arguments:\r
-  FileHeader       - Pointer to FFS File Header.\r
-\r
-Returns:\r
-  Checksum of the header.\r
-  \r
-**/\r
-{\r
-  UINT8 *ptr;\r
-  UINTN Index;\r
-  UINT8 Sum;\r
-\r
-  Sum = 0;\r
-  ptr = (UINT8 *) FileHeader;\r
-\r
-  for (Index = 0; Index < sizeof (EFI_FFS_FILE_HEADER) - 3; Index += 4) {\r
-    Sum = (UINT8) (Sum + ptr[Index]);\r
-    Sum = (UINT8) (Sum + ptr[Index + 1]);\r
-    Sum = (UINT8) (Sum + ptr[Index + 2]);\r
-    Sum = (UINT8) (Sum + ptr[Index + 3]);\r
-  }\r
-\r
-  for (; Index < sizeof (EFI_FFS_FILE_HEADER); Index++) {\r
-    Sum = (UINT8) (Sum + ptr[Index]);\r
-  }\r
-  //\r
-  // State field (since this indicates the different state of file).\r
-  //\r
-  Sum = (UINT8) (Sum - FileHeader->State);\r
-  //\r
-  // Checksum field of the file is not part of the header checksum.\r
-  //\r
-  Sum = (UINT8) (Sum - FileHeader->IntegrityCheck.Checksum.File);\r
-\r
-  return Sum;\r
-}\r
-\r
-EFI_STATUS\r
-SecFfsFindNextFile (\r
-  IN EFI_FV_FILETYPE             SearchType,\r
-  IN EFI_FIRMWARE_VOLUME_HEADER  *FwVolHeader,\r
-  IN OUT EFI_FFS_FILE_HEADER     **FileHeader\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-    Given the input file pointer, search for the next matching file in the\r
-    FFS volume as defined by SearchType. The search starts from FileHeader inside\r
-    the Firmware Volume defined by FwVolHeader.\r
-\r
-Arguments:\r
-    SearchType - Filter to find only files of this type.\r
-                 Type EFI_FV_FILETYPE_ALL causes no filtering to be done.\r
-    FwVolHeader - Pointer to the FV header of the volume to search.\r
-                  This parameter must point to a valid FFS volume.\r
-    FileHeader  - Pointer to the current file from which to begin searching.\r
-                  This pointer will be updated upon return to reflect the file\r
-                  found.\r
-\r
-Returns:\r
-    EFI_NOT_FOUND - No files matching the search criteria were found\r
-    EFI_SUCCESS\r
-\r
-**/\r
-{\r
-  EFI_FFS_FILE_HEADER *FfsFileHeader;\r
-  UINT32              FileLength;\r
-  UINT32              FileOccupiedSize;\r
-  UINT32              FileOffset;\r
-  UINT64              FvLength;\r
-  UINT8               ErasePolarity;\r
-  UINT8               FileState;\r
-\r
-  FvLength = FwVolHeader->FvLength;\r
-  if (FwVolHeader->Attributes & EFI_FVB2_ERASE_POLARITY) {\r
-    ErasePolarity = 1;\r
-  } else {\r
-    ErasePolarity = 0;\r
-  }\r
-  //\r
-  // If FileHeader is not specified (NULL) start with the first file in the\r
-  // firmware volume.  Otherwise, start from the FileHeader.\r
-  //\r
-  if (*FileHeader == NULL) {\r
-    FfsFileHeader = (EFI_FFS_FILE_HEADER *) ((UINT8 *) FwVolHeader + FwVolHeader->HeaderLength);\r
-  } else {\r
-    //\r
-    // Length is 24 bits wide so mask upper 8 bits\r
-    // FileLength is adjusted to FileOccupiedSize as it is 8 byte aligned.\r
-    //\r
-    FileLength        = *(UINT32 *) (*FileHeader)->Size & 0x00FFFFFF;\r
-    FileOccupiedSize  = GET_OCCUPIED_SIZE (FileLength, 8);\r
-    FfsFileHeader     = (EFI_FFS_FILE_HEADER *) ((UINT8 *) *FileHeader + FileOccupiedSize);\r
-  }\r
-\r
-  FileOffset = (UINT32) ((UINT8 *) FfsFileHeader - (UINT8 *) FwVolHeader);\r
-\r
-  while (FileOffset < (FvLength - sizeof (EFI_FFS_FILE_HEADER))) {\r
-    //\r
-    // Get FileState which is the highest bit of the State\r
-    //\r
-    FileState = GetFileState (ErasePolarity, FfsFileHeader);\r
-\r
-    switch (FileState) {\r
-\r
-    case EFI_FILE_HEADER_INVALID:\r
-      FileOffset += sizeof (EFI_FFS_FILE_HEADER);\r
-      FfsFileHeader = (EFI_FFS_FILE_HEADER *) ((UINT8 *) FfsFileHeader + sizeof (EFI_FFS_FILE_HEADER));\r
-      break;\r
-\r
-    case EFI_FILE_DATA_VALID:\r
-    case EFI_FILE_MARKED_FOR_UPDATE:\r
-      if (CalculateHeaderChecksum (FfsFileHeader) == 0) {\r
-        FileLength        = *(UINT32 *) (FfsFileHeader->Size) & 0x00FFFFFF;\r
-        FileOccupiedSize  = GET_OCCUPIED_SIZE (FileLength, 8);\r
-\r
-        if ((SearchType == FfsFileHeader->Type) || (SearchType == EFI_FV_FILETYPE_ALL)) {\r
-\r
-          *FileHeader = FfsFileHeader;\r
-\r
-          return EFI_SUCCESS;\r
-        }\r
-\r
-        FileOffset += FileOccupiedSize;\r
-        FfsFileHeader = (EFI_FFS_FILE_HEADER *) ((UINT8 *) FfsFileHeader + FileOccupiedSize);\r
-      } else {\r
-        return EFI_NOT_FOUND;\r
-      }\r
-      break;\r
-\r
-    case EFI_FILE_DELETED:\r
-      FileLength        = *(UINT32 *) (FfsFileHeader->Size) & 0x00FFFFFF;\r
-      FileOccupiedSize  = GET_OCCUPIED_SIZE (FileLength, 8);\r
-      FileOffset += FileOccupiedSize;\r
-      FfsFileHeader = (EFI_FFS_FILE_HEADER *) ((UINT8 *) FfsFileHeader + FileOccupiedSize);\r
-      break;\r
-\r
-    default:\r
-      return EFI_NOT_FOUND;\r
-\r
-    }\r
-  }\r
-\r
-  return EFI_NOT_FOUND;\r
-}\r
-\r
-EFI_STATUS\r
-SecFfsFindSectionData (\r
-  IN EFI_SECTION_TYPE      SectionType,\r
-  IN EFI_FFS_FILE_HEADER   *FfsFileHeader,\r
-  IN OUT VOID              **SectionData\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-    Given the input file pointer, search for the next matching section in the\r
-    FFS volume.\r
-\r
-Arguments:\r
-    SearchType    - Filter to find only sections of this type.\r
-    FfsFileHeader - Pointer to the current file to search.\r
-    SectionData   - Pointer to the Section matching SectionType in FfsFileHeader.\r
-                     NULL if section not found\r
-\r
-Returns:\r
-    EFI_NOT_FOUND - No files matching the search criteria were found\r
-    EFI_SUCCESS\r
-\r
-**/\r
-{\r
-  UINT32                    FileSize;\r
-  EFI_COMMON_SECTION_HEADER *Section;\r
-  UINT32                    SectionLength;\r
-  UINT32                    ParsedLength;\r
-\r
-  //\r
-  // Size is 24 bits wide so mask upper 8 bits.\r
-  //    Does not include FfsFileHeader header size\r
-  // FileSize is adjusted to FileOccupiedSize as it is 8 byte aligned.\r
-  //\r
-  Section   = (EFI_COMMON_SECTION_HEADER *) (FfsFileHeader + 1);\r
-  FileSize  = *(UINT32 *) (FfsFileHeader->Size) & 0x00FFFFFF;\r
-  FileSize -= sizeof (EFI_FFS_FILE_HEADER);\r
-\r
-  *SectionData  = NULL;\r
-  ParsedLength  = 0;\r
-  while (ParsedLength < FileSize) {\r
-    if (Section->Type == SectionType) {\r
-      *SectionData = (VOID *) (Section + 1);\r
-      return EFI_SUCCESS;\r
-    }\r
-    //\r
-    // Size is 24 bits wide so mask upper 8 bits.\r
-    // SectionLength is adjusted it is 4 byte aligned.\r
-    // Go to the next section\r
-    //\r
-    SectionLength = *(UINT32 *) Section->Size & 0x00FFFFFF;\r
-    SectionLength = GET_OCCUPIED_SIZE (SectionLength, 4);\r
-\r
-    ParsedLength += SectionLength;\r
-    Section = (EFI_COMMON_SECTION_HEADER *) ((UINT8 *) Section + SectionLength);\r
-  }\r
-\r
-  return EFI_NOT_FOUND;\r
-}\r
-\r
-EFI_STATUS\r
-SecFfsFindPeiCore (\r
-  IN  EFI_FIRMWARE_VOLUME_HEADER  *FwVolHeader,\r
-  OUT VOID                        **Pe32Data\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Given the pointer to the Firmware Volume Header find the SEC\r
-  core and return it's PE32 image.\r
-\r
-Arguments:\r
-  FwVolHeader - Pointer to memory mapped FV\r
-  Pe32Data - Pointer to SEC PE32 iamge.\r
\r
-Returns:  \r
-  EFI_SUCCESS - Pe32Data is valid\r
-  other       - Failure\r
-\r
-**/\r
-{\r
-  EFI_STATUS          Status;\r
-  EFI_FFS_FILE_HEADER *FileHeader;\r
-  EFI_FV_FILETYPE     SearchType;\r
-\r
-  SearchType  = EFI_FV_FILETYPE_PEI_CORE;\r
-  FileHeader  = NULL;\r
-  do {\r
-    Status = SecFfsFindNextFile (SearchType, FwVolHeader, &FileHeader);\r
-    if (!EFI_ERROR (Status)) {\r
-      Status = SecFfsFindSectionData (EFI_SECTION_PE32, FileHeader, Pe32Data);\r
-      return Status;\r
-    }\r
-  } while (!EFI_ERROR (Status));\r
-\r
-  return Status;\r
-}\r
index 665a075e3f0bcfdae1f5219f2b08387dad08756a..9b74276dcff8e330dee7df8566e3d3a98f470999 100644 (file)
@@ -109,15 +109,6 @@ GasketSecGetNextProtocol (
 \r
 // PPIs produced by SEC  \r
 \r
-\r
-EFI_STATUS\r
-EFIAPI\r
-GasketSecUnixPeiLoadFile (\r
-  IN  VOID                  *Pe32Data,  \r
-  IN  EFI_PHYSICAL_ADDRESS  *ImageAddress,  \r
-  IN  UINT64                *ImageSize,  \r
-  OUT EFI_PHYSICAL_ADDRESS  *EntryPoint  \r
-  );\r
   \r
 EFI_STATUS\r
 EFIAPI\r
index 8677ab59382ff3c4f2316fbd7990ca173d2a8ad3..b67a9f1ca1d24829e04bc3f04b681707ba5264a5 100644 (file)
@@ -27,13 +27,9 @@ char *gGdbWorkingFileName = NULL;
 EMU_THUNK_PPI mSecEmuThunkPpi = {
   GasketSecUnixPeiAutoScan,
   GasketSecUnixFdAddress,
-  GasketSecEmuThunkAddress,
-  GasketSecUnixPeiLoadFile
+  GasketSecEmuThunkAddress
 };
 
-EFI_PEI_TEMPORARY_RAM_SUPPORT_PPI mSecTemporaryRamSupportPpi = { 
-  GasketSecTemporaryRamSupport
-};
 
 
 
@@ -44,8 +40,8 @@ EFI_PEI_TEMPORARY_RAM_SUPPORT_PPI mSecTemporaryRamSupportPpi = {
 //  The number of array elements is allocated base on parsing
 //  EFI_FIRMWARE_VOLUMES and the memory is never freed.
 //
-UINTN                                     gFdInfoCount = 0;
-EMU_FD_INFO                              *gFdInfo;
+UINTN       gFdInfoCount = 0;
+EMU_FD_INFO *gFdInfo;
 
 //
 // Array that supports seperate memory rantes.
@@ -53,8 +49,8 @@ EMU_FD_INFO                              *gFdInfo;
 //  The number of array elements is allocated base on parsing
 //  EFI_MEMORY_SIZE and the memory is never freed.
 //
-UINTN                                     gSystemMemoryCount = 0;
-EMU_SYSTEM_MEMORY                       *gSystemMemory;
+UINTN              gSystemMemoryCount = 0;
+EMU_SYSTEM_MEMORY  *gSystemMemory;
 
 
 
@@ -63,33 +59,6 @@ IMAGE_CONTEXT_TO_MOD_HANDLE  *mImageContextModHandleArray = NULL;
 
 
 
-EFI_PHYSICAL_ADDRESS *
-MapMemory (
-  INTN fd,
-  UINT64 length,
-  INTN   prot,
-  INTN   flags);
-
-EFI_STATUS
-MapFile (
-  IN  CHAR8                     *FileName,
-  IN OUT  EFI_PHYSICAL_ADDRESS  *BaseAddress,
-  OUT UINT64                    *Length
-  );
-
-EFI_STATUS
-EFIAPI
-SecNt32PeCoffRelocateImage (
-  IN OUT PE_COFF_LOADER_IMAGE_CONTEXT         *ImageContext
-  );
-
-
-int
-main (
-  IN  int   Argc,
-  IN  char  **Argv,
-  IN  char  **Envp
-  )
 /*++
 
 Routine Description:
@@ -105,6 +74,12 @@ Returns:
   1 - Abnormal exit
 
 **/
+int
+main (
+  IN  int   Argc,
+  IN  char  **Argv,
+  IN  char  **Envp
+  )
 {
   EFI_STATUS            Status;
   EFI_PHYSICAL_ADDRESS  InitialStackMemory;
@@ -115,25 +90,24 @@ Returns:
   UINTN                 PeiIndex;
   CHAR8                 *FileName;
   BOOLEAN               Done;
-  VOID                  *PeiCoreFile;
+  EFI_PEI_FILE_HANDLE   FileHandle;
+  VOID                  *SecFile;
   CHAR16                *MemorySizeStr;
   CHAR16                *FirmwareVolumesStr;
   UINTN                 *StackPointer;
 
-  setbuf(stdout, 0);
-  setbuf(stderr, 0);
+  setbuf (stdout, 0);
+  setbuf (stderr, 0);
 
   MemorySizeStr      = (CHAR16 *) PcdGetPtr (PcdEmuMemorySize);
   FirmwareVolumesStr = (CHAR16 *) PcdGetPtr (PcdEmuFirmwareVolume);
 
-  printf ("\nEDK SEC Main UNIX Emulation Environment from edk2.sourceforge.net\n");
+  printf ("\nEDK II UNIX Emulation Environment from edk2.sourceforge.net\n");
 
   //
   // PPIs pased into PEI_CORE
   //
-  AddThunkPpi (EFI_PEI_PPI_DESCRIPTOR_PPI, &gEfiTemporaryRamSupportPpiGuid, &mSecTemporaryRamSupportPpi);
   AddThunkPpi (EFI_PEI_PPI_DESCRIPTOR_PPI, &gEmuThunkPpiGuid, &mSecEmuThunkPpi);
-  AddThunkPpi (EFI_PEI_PPI_DESCRIPTOR_PPI, &gEmuPeiServicesTableUpdatePpiGuid, NULL);
 
   SecInitThunkProtocol ();
   
@@ -149,6 +123,10 @@ Returns:
   AddThunkProtocol (&gPthreadThunkIo, (CHAR16 *)PcdGetPtr (PcdEmuApCount), FALSE); 
 
   // EmuSecLibConstructor ();
+  
+  
+  gPpiList = GetThunkPpiList (); 
+
 
 #ifdef __APPLE__
   //
@@ -185,23 +163,24 @@ Returns:
   printf ("  BootMode 0x%02x\n", (unsigned int)PcdGet32 (PcdEmuBootMode));
 
   //
-  // Open up a 128K file to emulate temp memory for PEI.
+  // Open up a 128K file to emulate temp memory for SEC.
   //  on a real platform this would be SRAM, or using the cache as RAM.
   //  Set InitialStackMemory to zero so UnixOpenFile will allocate a new mapping
   //
   InitialStackMemorySize  = STACK_SIZE;
-  InitialStackMemory = (UINTN)MapMemory(0,
-          (UINT32) InitialStackMemorySize,
-          PROT_READ | PROT_WRITE | PROT_EXEC,
-          MAP_ANONYMOUS | MAP_PRIVATE);
+  InitialStackMemory = (UINTN)MapMemory (
+                                0, (UINT32) InitialStackMemorySize,
+                                PROT_READ | PROT_WRITE | PROT_EXEC, MAP_ANONYMOUS | MAP_PRIVATE
+                                );
   if (InitialStackMemory == 0) {
     printf ("ERROR : Can not open SecStack Exiting\n");
     exit (1);
   }
 
-  printf ("  SEC passing in %u KB of temp RAM at 0x%08lx to PEI\n",
+  printf ("  OS Emulator passing in %u KB of temp RAM at 0x%08lx to SEC\n",
     (unsigned int)(InitialStackMemorySize / 1024),
-    (unsigned long)InitialStackMemory);
+    (unsigned long)InitialStackMemory
+    );
 
   for (StackPointer = (UINTN*) (UINTN) InitialStackMemory;
      StackPointer < (UINTN*)(UINTN)((UINTN) InitialStackMemory + (UINT64) InitialStackMemorySize);
@@ -219,40 +198,49 @@ Returns:
   }
 
   Index2 = 0;
-  for (Done = FALSE, Index = 0, PeiIndex = 0, PeiCoreFile = NULL;
+  for (Done = FALSE, Index = 0, PeiIndex = 0, SecFile = NULL;
        FirmwareVolumesStr[Index2] != 0;
        Index++) {
-    for (Index1 = 0; (FirmwareVolumesStr[Index2] != '!') && (FirmwareVolumesStr[Index2] != 0); Index2++)
+    for (Index1 = 0; (FirmwareVolumesStr[Index2] != '!') && (FirmwareVolumesStr[Index2] != 0); Index2++) {
       FileName[Index1++] = FirmwareVolumesStr[Index2];
-    if (FirmwareVolumesStr[Index2] == '!')
+    }
+    if (FirmwareVolumesStr[Index2] == '!') {
       Index2++;
+    }
     FileName[Index1]  = '\0';
 
     //
     // Open the FD and remmeber where it got mapped into our processes address space
     //
     Status = MapFile (
-          FileName,
-          &gFdInfo[Index].Address,
-          &gFdInfo[Index].Size
-          );
+              FileName,
+              &gFdInfo[Index].Address,
+              &gFdInfo[Index].Size
+              );
     if (EFI_ERROR (Status)) {
       printf ("ERROR : Can not open Firmware Device File %s (%x).  Exiting.\n", FileName, (unsigned int)Status);
       exit (1);
     }
 
-    printf ("  FD loaded from %s at 0x%08lx",
-      FileName, (unsigned long)gFdInfo[Index].Address);
+    printf ("  FD loaded from %s at 0x%08lx",FileName, (unsigned long)gFdInfo[Index].Address);
 
-    if (PeiCoreFile == NULL) {
+    if (SecFile == NULL) {
       //
-      // Assume the beginning of the FD is an FV and look for the PEI Core.
+      // Assume the beginning of the FD is an FV and look for the SEC Core.
       // Load the first one we find.
       //
-      Status = SecFfsFindPeiCore ((EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) gFdInfo[Index].Address, &PeiCoreFile);
+      FileHandle = NULL;
+      Status = PeiServicesFfsFindNextFile (
+                  EFI_FV_FILETYPE_SECURITY_CORE, 
+                  (EFI_PEI_FV_HANDLE)(UINTN)gFdInfo[Index].Address, 
+                  &FileHandle
+                  );
       if (!EFI_ERROR (Status)) {
-        PeiIndex = Index;
-        printf (" contains SEC Core");
+        Status = PeiServicesFfsFindSectionData (EFI_SECTION_PE32, FileHandle, &SecFile);
+        if (!EFI_ERROR (Status)) {
+          PeiIndex = Index;
+          printf (" contains SEC Core");
+        }
       }
     }
 
@@ -275,26 +263,28 @@ Returns:
       Index1++;
     }
     gSystemMemory[Index++].Size = val * 0x100000;
-    if (MemorySizeStr[Index1] == 0)
+    if (MemorySizeStr[Index1] == 0) {
       break;
+    }
     Index1++;
   }
 
   printf ("\n");
 
   //
-  // Hand off to PEI Core
+  // Hand off to SEC
   //
-  SecLoadFromCore ((UINTN) InitialStackMemory, (UINTN) InitialStackMemorySize, (UINTN) gFdInfo[0].Address, PeiCoreFile);
+  SecLoadFromCore ((UINTN) InitialStackMemory, (UINTN) InitialStackMemorySize, (UINTN) gFdInfo[0].Address, SecFile);
 
   //
-  // If we get here, then the PEI Core returned. This is an error as PEI should
-  //  always hand off to DXE.
+  // If we get here, then the SEC Core returned. This is an error as SEC should
+  //  always hand off to PEI Core and then on to DXE Core.
   //
-  printf ("ERROR : PEI Core returned\n");
+  printf ("ERROR : SEC returned\n");
   exit (1);
 }
 
+
 EFI_PHYSICAL_ADDRESS *
 MapMemory (
   INTN fd,
@@ -318,8 +308,7 @@ MapMemory (
     }
     if ((((UINTN)res) & ~(align-1)) == (UINTN)res) {
       isAligned=1;
-    }
-    else {
+    } else {
       munmap(res, length);
       base += align;
     }
@@ -327,12 +316,7 @@ MapMemory (
   return res;
 }
 
-EFI_STATUS
-MapFile (
-  IN  CHAR8                     *FileName,
-  IN OUT  EFI_PHYSICAL_ADDRESS  *BaseAddress,
-  OUT UINT64                    *Length
-  )
+
 /*++
 
 Routine Description:
@@ -356,24 +340,32 @@ Returns:
   EFI_DEVICE_ERROR - An error occured attempting to map the opened file
 
 **/
+EFI_STATUS
+MapFile (
+  IN  CHAR8                     *FileName,
+  IN OUT  EFI_PHYSICAL_ADDRESS  *BaseAddress,
+  OUT UINT64                    *Length
+  )
 {
   int fd;
   VOID    *res;
   UINTN   FileSize;
 
   fd = open (FileName, O_RDONLY);
-  if (fd < 0)
+  if (fd < 0) {
     return EFI_NOT_FOUND;
+  }
   FileSize = lseek (fd, 0, SEEK_END);
 
 
-  res = MapMemory(fd, FileSize, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE);
+  res = MapMemory (fd, FileSize, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE);
 
   close (fd);
 
-  if (res == MAP_FAILED)
+  if (res == MAP_FAILED) {
     return EFI_DEVICE_ERROR;
-
+  }
+  
   *Length = (UINT64) FileSize;
   *BaseAddress = (EFI_PHYSICAL_ADDRESS) (UINTN) res;
 
@@ -382,35 +374,33 @@ Returns:
 
 
 
-VOID
-SecLoadFromCore (
-  IN  UINTN   LargestRegion,
-  IN  UINTN   LargestRegionSize,
-  IN  UINTN   BootFirmwareVolumeBase,
-  IN  VOID    *PeiCorePe32File
-  )
 /*++
 
 Routine Description:
-  This is the service to load the PEI Core from the Firmware Volume
+  This is the service to load the SEC Core from the Firmware Volume
 
 Arguments:
-  LargestRegion           - Memory to use for PEI.
+  LargestRegion           - Memory to use for SEC.
   LargestRegionSize       - Size of Memory to use for PEI
   BootFirmwareVolumeBase  - Start of the Boot FV
-  PeiCorePe32File         - PEI Core PE32
+  PeiCorePe32File         - SEC PE32
 
 Returns:
   Success means control is transfered and thus we should never return
 
 **/
+VOID
+SecLoadFromCore (
+  IN  UINTN   LargestRegion,
+  IN  UINTN   LargestRegionSize,
+  IN  UINTN   BootFirmwareVolumeBase,
+  IN  VOID    *PeiCorePe32File
+  )
 {
   EFI_STATUS                  Status;
   EFI_PHYSICAL_ADDRESS        TopOfMemory;
   VOID                        *TopOfStack;
-  UINT64                      PeiCoreSize;
   EFI_PHYSICAL_ADDRESS        PeiCoreEntryPoint;
-  EFI_PHYSICAL_ADDRESS        PeiImageAddress;
   EFI_SEC_PEI_HAND_OFF        *SecCoreData;
   UINTN                       PeiStackSize;
 
@@ -442,7 +432,7 @@ Returns:
   //
   // Bind this information into the SEC hand-off state
   //
-  SecCoreData                        = (EFI_SEC_PEI_HAND_OFF*)(UINTN) TopOfStack;
+  SecCoreData                         = (EFI_SEC_PEI_HAND_OFF*)(UINTN) TopOfStack;
   SecCoreData->DataSize               = sizeof(EFI_SEC_PEI_HAND_OFF);
   SecCoreData->BootFirmwareVolumeBase = (VOID*)BootFirmwareVolumeBase;
   SecCoreData->BootFirmwareVolumeSize = PcdGet32 (PcdEmuFirmwareFdSize);
@@ -454,41 +444,30 @@ Returns:
   SecCoreData->PeiTemporaryRamSize    = STACK_SIZE - PeiStackSize;
 
   //
-  // Load the PEI Core from a Firmware Volume
+  // Find the SEC Core Entry Point
   //
-  Status = SecUnixPeiLoadFile (
-            PeiCorePe32File,
-            &PeiImageAddress,
-            &PeiCoreSize,
-            &PeiCoreEntryPoint
-            );
+  Status = SecPeCoffGetEntryPoint (PeiCorePe32File, (VOID **)&PeiCoreEntryPoint);
   if (EFI_ERROR (Status)) {
     return ;
   }
 
   //
-  // Transfer control to the PEI Core
+  // Transfer control to the SEC Core
   //
   PeiSwitchStacks (
     (SWITCH_STACK_ENTRY_POINT) (UINTN) PeiCoreEntryPoint,
     SecCoreData,
-    (VOID *)GetThunkPpiList (),
+    (VOID *)gPpiList,
     NULL,
     TopOfStack
     );
   //
-  // If we get here, then the PEI Core returned.  This is an error
+  // If we get here, then the SEC Core returned.  This is an error
   //
   return ;
 }
 
-EFI_STATUS
-EFIAPI
-SecUnixPeiAutoScan (
-  IN  UINTN                 Index,
-  OUT EFI_PHYSICAL_ADDRESS  *MemoryBase,
-  OUT UINT64                *MemorySize
-  )
+
 /*++
 
 Routine Description:
@@ -509,6 +488,13 @@ Returns:
   EFI_UNSUPPORTED - If Index is not supported
 
 **/
+EFI_STATUS
+EFIAPI
+SecUnixPeiAutoScan (
+  IN  UINTN                 Index,
+  OUT EFI_PHYSICAL_ADDRESS  *MemoryBase,
+  OUT UINT64                *MemorySize
+  )
 {
   void *res;
 
@@ -517,11 +503,14 @@ Returns:
   }
 
   *MemoryBase = 0;
-  res = MapMemory(0, gSystemMemory[Index].Size,
-      PROT_READ | PROT_WRITE | PROT_EXEC,
-      MAP_PRIVATE | MAP_ANONYMOUS);
-  if (res == MAP_FAILED)
+  res = MapMemory (
+          0, gSystemMemory[Index].Size,
+          PROT_READ | PROT_WRITE | PROT_EXEC,
+          MAP_PRIVATE | MAP_ANONYMOUS
+          );
+  if (res == MAP_FAILED) {
     return EFI_DEVICE_ERROR;
+  }
   *MemorySize = gSystemMemory[Index].Size;
   *MemoryBase = (UINTN)res;
   gSystemMemory[Index].Memory = *MemoryBase;
@@ -529,11 +518,7 @@ Returns:
   return EFI_SUCCESS;
 }
 
-VOID *
-EFIAPI
-SecEmuThunkAddress (
-  VOID
-  )
+
 /*++
 
 Routine Description:
@@ -548,93 +533,16 @@ Returns:
   EFI_SUCCESS - Data returned
 
 **/
+VOID *
+EFIAPI
+SecEmuThunkAddress (
+  VOID
+  )
 {
   return &gEmuThunkProtocol;
 }
 
 
-EFI_STATUS
-SecUnixPeiLoadFile (
-  IN  VOID                    *Pe32Data,
-  OUT EFI_PHYSICAL_ADDRESS    *ImageAddress,
-  OUT UINT64                  *ImageSize,
-  OUT EFI_PHYSICAL_ADDRESS    *EntryPoint
-  )
-/*++
-
-Routine Description:
-  Loads and relocates a PE/COFF image into memory.
-
-Arguments:
-  Pe32Data         - The base address of the PE/COFF file that is to be loaded and relocated
-  ImageAddress     - The base address of the relocated PE/COFF image
-  ImageSize        - The size of the relocated PE/COFF image
-  EntryPoint       - The entry point of the relocated PE/COFF image
-
-Returns:
-  EFI_SUCCESS   - The file was loaded and relocated
-  EFI_OUT_OF_RESOURCES - There was not enough memory to load and relocate the PE/COFF file
-
-**/
-{
-  EFI_STATUS                            Status;
-  PE_COFF_LOADER_IMAGE_CONTEXT          ImageContext;
-
-  ZeroMem (&ImageContext, sizeof (ImageContext));
-  ImageContext.Handle     = Pe32Data;
-
-  ImageContext.ImageRead  = (PE_COFF_LOADER_READ_FILE) SecImageRead;
-
-  Status                  = PeCoffLoaderGetImageInfo (&ImageContext);
-  if (EFI_ERROR (Status)) {
-    return Status;
-  }
-
-
-  //
-  // Allocate space in UNIX (not emulator) memory. Extra space is for alignment
-  //
-  ImageContext.ImageAddress = (EFI_PHYSICAL_ADDRESS) (UINTN) MapMemory (
-    0,
-    (UINT32) (ImageContext.ImageSize + (ImageContext.SectionAlignment * 2)),
-    PROT_READ | PROT_WRITE | PROT_EXEC,
-    MAP_ANONYMOUS | MAP_PRIVATE
-    );
-  if (ImageContext.ImageAddress == 0) {
-    return EFI_OUT_OF_RESOURCES;
-  }
-
-  //
-  // Align buffer on section boundry
-  //
-  ImageContext.ImageAddress += ImageContext.SectionAlignment - 1;
-  ImageContext.ImageAddress &= ~((EFI_PHYSICAL_ADDRESS)(ImageContext.SectionAlignment - 1));
-
-
-  Status = PeCoffLoaderLoadImage (&ImageContext);
-  if (EFI_ERROR (Status)) {
-    return Status;
-  }
-
-  Status = PeCoffLoaderRelocateImage (&ImageContext);
-  if (EFI_ERROR (Status)) {
-    return Status;
-  }
-
-
-  SecPeCoffRelocateImageExtraAction (&ImageContext);
-
-  //
-  // BugBug: Flush Instruction Cache Here when CPU Lib is ready
-  //
-
-  *ImageAddress = ImageContext.ImageAddress;
-  *ImageSize    = ImageContext.ImageSize;
-  *EntryPoint   = ImageContext.EntryPoint;
-
-  return EFI_SUCCESS;
-}
-
 
 RETURN_STATUS
 EFIAPI
@@ -643,27 +551,28 @@ SecPeCoffGetEntryPoint (
   IN OUT VOID  **EntryPoint
   )
 {
-  EFI_STATUS              Status;
-  EFI_PHYSICAL_ADDRESS    ImageAddress;
-  UINT64                  ImageSize;
-  EFI_PHYSICAL_ADDRESS    PhysEntryPoint;
+  EFI_STATUS                    Status;
+  PE_COFF_LOADER_IMAGE_CONTEXT  ImageContext;
+  
+  ImageContext.ImageAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)Pe32Data;
+  ImageContext.SizeOfHeaders = PeCoffGetSizeOfHeaders (Pe32Data);
+  ImageContext.PdbPointer = PeCoffLoaderGetPdbPointer (Pe32Data);
+  Status = PeCoffLoaderGetEntryPoint (Pe32Data, EntryPoint);
+  if (!EFI_ERROR (Status)) {
+    return Status;
+  }
 
-  Status = SecUnixPeiLoadFile (Pe32Data, &ImageAddress, &ImageSize, &PhysEntryPoint);
+  ImageContext.EntryPoint = (UINTN)EntryPoint;
 
-  *EntryPoint = (VOID *)(UINTN)PhysEntryPoint;
+  // On Unix a dlopen is done that will change the entry point
+  SecPeCoffRelocateImageExtraAction (&ImageContext);
+  *EntryPoint = (VOID *)(UINTN)ImageContext.EntryPoint;
+  
   return Status;
 }
 
 
 
-EFI_STATUS
-EFIAPI
-SecUnixFdAddress (
-  IN     UINTN                 Index,
-  IN OUT EFI_PHYSICAL_ADDRESS  *FdBase,
-  IN OUT UINT64                *FdSize,
-  IN OUT EFI_PHYSICAL_ADDRESS  *FixUp
-  )
 /*++
 
 Routine Description:
@@ -681,6 +590,14 @@ Returns:
   EFI_UNSUPPORTED - Index does nto map to an FD in the system
 
 **/
+EFI_STATUS
+EFIAPI
+SecUnixFdAddress (
+  IN     UINTN                 Index,
+  IN OUT EFI_PHYSICAL_ADDRESS  *FdBase,
+  IN OUT UINT64                *FdSize,
+  IN OUT EFI_PHYSICAL_ADDRESS  *FixUp
+  )
 {
   if (Index >= gFdInfoCount) {
     return EFI_UNSUPPORTED;
@@ -706,49 +623,7 @@ Returns:
   return EFI_SUCCESS;
 }
 
-EFI_STATUS
-EFIAPI
-SecImageRead (
-  IN     VOID    *FileHandle,
-  IN     UINTN   FileOffset,
-  IN OUT UINTN   *ReadSize,
-  OUT    VOID    *Buffer
-  )
-/*++
 
-Routine Description:
-  Support routine for the PE/COFF Loader that reads a buffer from a PE/COFF file
-
-Arguments:
-  FileHandle - The handle to the PE/COFF file
-  FileOffset - The offset, in bytes, into the file to read
-  ReadSize   - The number of bytes to read from the file starting at FileOffset
-  Buffer     - A pointer to the buffer to read the data into.
-
-Returns:
-  EFI_SUCCESS - ReadSize bytes of data were read into Buffer from the PE/COFF file starting at FileOffset
-
-**/
-{
-  CHAR8 *Destination8;
-  CHAR8 *Source8;
-  UINTN Length;
-
-  Destination8  = Buffer;
-  Source8       = (CHAR8 *) ((UINTN) FileHandle + FileOffset);
-  Length        = *ReadSize;
-  while (Length--) {
-    *(Destination8++) = *(Source8++);
-  }
-
-  return EFI_SUCCESS;
-}
-
-UINTN
-CountSeperatorsInString (
-  IN  const CHAR16   *String,
-  IN  CHAR16         Seperator
-  )
 /*++
 
 Routine Description:
@@ -762,6 +637,11 @@ Returns:
   Number of Seperator in String
 
 **/
+UINTN
+CountSeperatorsInString (
+  IN  const CHAR16   *String,
+  IN  CHAR16         Seperator
+  )
 {
   UINTN Count;
 
@@ -775,11 +655,6 @@ Returns:
 }
 
 
-EFI_STATUS
-AddHandle (
-  IN  PE_COFF_LOADER_IMAGE_CONTEXT         *ImageContext,
-  IN  VOID                                 *ModHandle
-  )
 /*++
 
 Routine Description:
@@ -796,6 +671,11 @@ Returns:
   EFI_SUCCESS - ModHandle was stored.
 
 **/
+EFI_STATUS
+AddHandle (
+  IN  PE_COFF_LOADER_IMAGE_CONTEXT         *ImageContext,
+  IN  VOID                                 *ModHandle
+  )
 {
   UINTN                       Index;
   IMAGE_CONTEXT_TO_MOD_HANDLE *Array;
@@ -835,10 +715,6 @@ Returns:
 }
 
 
-VOID *
-RemoveHandle (
-  IN  PE_COFF_LOADER_IMAGE_CONTEXT         *ImageContext
-  )
 /*++
 
 Routine Description:
@@ -853,6 +729,10 @@ Returns:
   NULL      - No ModHandle associated with ImageContext
 
 **/
+VOID *
+RemoveHandle (
+  IN  PE_COFF_LOADER_IMAGE_CONTEXT         *ImageContext
+  )
 {
   UINTN                        Index;
   IMAGE_CONTEXT_TO_MOD_HANDLE  *Array;
@@ -890,7 +770,7 @@ Returns:
 // b SecGdbScriptBreak
 // command
 // silent
-// source SecMain.dll.gdb
+// source SecMain.gdb
 // c
 // end
 //
@@ -1057,11 +937,13 @@ SecPeCoffRelocateImageExtraAction (
     return;
   }
 
-  fprintf (stderr,
+  fprintf (
+     stderr,
      "Loading %s 0x%08lx - entry point 0x%08lx\n",
      ImageContext->PdbPointer,
      (unsigned long)ImageContext->ImageAddress,
-     (unsigned long)ImageContext->EntryPoint);
+     (unsigned long)ImageContext->EntryPoint
+     );
 
   Handle = dlopen (ImageContext->PdbPointer, RTLD_NOW);
 
@@ -1073,7 +955,7 @@ SecPeCoffRelocateImageExtraAction (
 
   if (Entry != NULL) {
     ImageContext->EntryPoint = (UINTN)Entry;
-    printf("Change %s Entrypoint to :0x%08lx\n", ImageContext->PdbPointer, (unsigned long)Entry);
+    printf ("Change %s Entrypoint to :0x%08lx\n", ImageContext->PdbPointer, (unsigned long)Entry);
   }
 
   SecUnixLoaderBreak ();
index 6e352b11b580c37b4bd0249f0fe05d4b86f6e80d..317bd5d8b54e6ffb52800f513201476c9012a81c 100644 (file)
@@ -28,11 +28,12 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 #include <Library/ThunkPpiList.h>\r
 #include <Library/ThunkProtocolList.h>\r
+#include <Library/PpiListLib.h>\r
+#include <Library/PeiServicesLib.h>\r
+#include <Library/PeCoffGetEntryPointLib.h>\r
 \r
 #include <Ppi/EmuThunk.h>\r
 #include <Ppi/StatusCode.h>\r
-#include <Ppi/TemporaryRamSupport.h>\r
-#include <Ppi/EmuPeiServicesTableUpdate.h>\r
 \r
 #include <Protocol/SimplePointer.h>\r
 #include <Protocol/SimpleTextIn.h>\r
@@ -289,7 +290,23 @@ VOID
 SecInitThunkProtocol (\r
   VOID\r
   );\r
\r
   \r
+EFI_PHYSICAL_ADDRESS *\r
+MapMemory (\r
+  INTN fd,\r
+  UINT64 length,\r
+  INTN   prot,\r
+  INTN   flags);\r
+\r
+EFI_STATUS\r
+MapFile (\r
+  IN  CHAR8                     *FileName,\r
+  IN OUT  EFI_PHYSICAL_ADDRESS  *BaseAddress,\r
+  OUT UINT64                    *Length\r
+  );\r
+\r
\r
 \r
 VOID SecSleep (UINT64 Milliseconds);\r
 VOID SecEnableInterrupt (VOID);\r
index 24a36be95520c9596a68b2b551d7b3c2a7ded39d..c4b8ad181322b9b59772feec96ec10c3bf4babc5 100644 (file)
@@ -32,7 +32,6 @@
 [Sources]\r
   SecMain.c\r
   EmuThunk.c\r
-  FwVol.c\r
   X11GraphicsWindow.c\r
   Pthreads.c\r
   PosixFileSystem.c\r
@@ -46,7 +45,6 @@
   MdePkg/MdePkg.dec\r
   MdeModulePkg/MdeModulePkg.dec\r
   InOsEmuPkg/InOsEmuPkg.dec\r
-  InOsEmuPkg/InOsEmuPkg.dec\r
 \r
 [LibraryClasses]\r
   DebugLib\r
   PeCoffLib\r
   ThunkPpiList\r
   ThunkProtocolList\r
-\r
+  PpiListLib\r
+  PeiServicesLib\r
+  PeCoffGetEntryPointLib\r
 \r
 [Ppis]\r
   gEfiPeiStatusCodePpiGuid                      # PPI ALWAYS_PRODUCED\r
-  gEfiTemporaryRamSupportPpiGuid\r
   gEmuThunkPpiGuid\r
-  gEmuPeiServicesTableUpdatePpiGuid\r
 \r
 [Protocols]\r
   gEmuIoThunkProtocolGuid\r
index fde3028da9e9d02e2337259e143a92ca80b6109b..3dc0fa1f2829aa7fed446c0c660f202bd9bc1b9d 100644 (file)
@@ -727,30 +727,6 @@ ASM_PFX(ReverseGasketUint64Uint64):
   ret
   
 
-// Sec PPI Callbacks - Check Me
-
-ASM_GLOBAL ASM_PFX(GasketSecUnixPeiLoadFile)
-ASM_PFX(GasketSecUnixPeiLoadFile):
-  pushq   %rbp            // stack frame is for the debugger
-  movq    %rsp, %rbp
-
-  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
-  pushq   %rdi
-
-  movq    %rcx, %rdi    // Swizzle args 
-  movq    %rdx, %rsi     
-  movq    %r8,  %rdx
-  movq    %r9,  %rcx
-
-  call    ASM_PFX(SecUnixPeiLoadFile)
-  
-  popq    %rdi          // restore state
-  popq    %rsi
-  popq    %rbp
-  ret
-
-
-
 ASM_GLOBAL ASM_PFX(GasketSecUnixPeiAutoScan)
 ASM_PFX(GasketSecUnixPeiAutoScan):
   pushq   %rbp            // stack frame is for the debugger
index 0d4e5029c9a7c7e26839d2faf6465ae187c37adf..76567ac0e178f2870105cf046cc99ae71bceb1b9 100644 (file)
@@ -52,61 +52,3 @@ ASM_PFX(PeiSwitchStacks):
 \r
   \r
 \r
-//  EFI_STATUS\r
-//  EFIAPI\r
-//  SecTemporaryRamSupport (\r
-//    IN CONST EFI_PEI_SERVICES   **PeiServices,         // %rcx\r
-//    IN EFI_PHYSICAL_ADDRESS     TemporaryMemoryBase,   // %rdx\r
-//    IN EFI_PHYSICAL_ADDRESS     PermanentMemoryBase,   // %r8 \r
-//    IN UINTN                    CopySize               // %r9\r
-//    )\r
-//\r
-ASM_GLOBAL ASM_PFX(GasketSecTemporaryRamSupport)\r
-ASM_PFX(GasketSecTemporaryRamSupport):\r
-  // Adjust callers %rbp to account for stack move\r
-  subq    %rdx, %rbp     // Calc offset of %rbp in Temp Memory\r
-  addq    %r8,  %rbp     // add in permanent base to offset\r
-  \r
-  pushq   %rbp           // stack frame is for the debugger\r
-  movq    %rsp, %rbp\r
-\r
-  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI\r
-  pushq   %rdi\r
-\r
-  pushq   %rdx          // Save TemporaryMemoryBase\r
-  pushq   %r8           // Save PermanentMemoryBase\r
-  pushq   %r9           // Save CopySize\r
-  \r
-  //\r
-  // Copy all of temp RAM to permanent memory, including stack\r
-  //\r
-  // CopyMem (PermanentMemoryBase, TemporaryMemoryBase, CopySize);\r
-  //          %rdi,                %rsi,                %rdx\r
-  movq    %r8,  %rdi    // Swizzle args  \r
-  movq    %rdx, %rsi\r
-  movq    %r9,  %rdx\r
-  call    ASM_PFX(CopyMem)\r
-  // Temp mem stack now copied to permanent location. %esp still in temp memory\r
-  \r
-  popq    %r9           // CopySize (old stack)\r
-  popq    %r8           // PermanentMemoryBase (old stack)\r
-  popq    %rdx          // TemporaryMemoryBase (old stack)\r
-    \r
-  movq    %rsp, %rcx    // Move to new stack\r
-  subq    %rdx, %rcx    // Calc offset of stack in Temp Memory\r
-  addq    %r8,  %rcx    // Calc PermanentMemoryBase address\r
-  movq    %rcx, %rsp    // Update stack \r
-  // Stack now points to permanent memory\r
-  \r
-  // ZeroMem (TemporaryMemoryBase /* rdi */, CopySize /* rsi */);\r
-  movq    %rdx, %rdi\r
-  movq    %r9,  %rsi\r
-  call    ASM_PFX(ZeroMem)\r
-\r
-  // This data comes off the NEW stack\r
-  popq    %rdi   \r
-  popq    %rsi\r
-  popq    %rbp\r
-  ret\r
-\r
-\r
index 88c4218d2d0ce980d56ea5af7a1204c0cec96742..e9dffb0d90cfc0ddee40cb6ac26959507d24a45e 100644 (file)
   DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf\r
 \r
 \r
+[LibraryClasses.common.SEC]\r
+  PeiServicesLib|InOsEmuPkg/Library/SecPeiServicesLib/SecPeiServicesLib.inf\r
+  PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf\r
+  PeCoffGetEntryPointLib|InOsEmuPkg/Library/PeiEmuPeCoffGetEntryPointLib/PeiEmuPeCoffGetEntryPointLib.inf\r
+  PeCoffExtraActionLib|InOsEmuPkg/Library/PeiEmuPeCoffExtraActionLib/PeiEmuPeCoffExtraActionLib.inf\r
+  SerialPortLib|InOsEmuPkg/Library/PeiEmuSerialPortLib/PeiEmuSerialPortLib.inf\r
+  PpiListLib|InOsEmuPkg/Library/SecPpiListLib/SecPpiListLib.inf\r
+\r
 [LibraryClasses.common.USER_DEFINED, LibraryClasses.common.BASE]\r
   DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf\r
   PeCoffExtraActionLib|MdePkg/Library/BasePeCoffExtraActionLibNull/BasePeCoffExtraActionLibNull.inf\r
   MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf\r
   PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf\r
-  PeiServicesTablePointerLib|MdePkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf\r
-\r
+  PpiListLib|InOsEmuPkg/Library/SecPpiListLib/SecPpiListLib.inf\r
   ThunkPpiList|InOsEmuPkg/Library/ThunkPpiList/ThunkPpiList.inf\r
   ThunkProtocolList|InOsEmuPkg/Library/ThunkProtocolList/ThunkProtocolList.inf\r
+  PeCoffGetEntryPointLib|MdePkg/Library/BasePeCoffGetEntryPointLib/BasePeCoffGetEntryPointLib.inf\r
+  PpiListLib|InOsEmuPkg/Library/SecPpiListLib/SecPpiListLib.inf\r
+  PeiServicesLib|InOsEmuPkg/Library/SecPeiServicesLib/SecPeiServicesLib.inf\r
+\r
+#  PeCoffExtraActionLib|InOsEmuPkg/Library/PeiEmuPeCoffExtraActionLib/PeiEmuPeCoffExtraActionLib.inf\r
 \r
 \r
 [LibraryClasses.common.PEIM, LibraryClasses.common.PEI_CORE]\r
   PeCoffGetEntryPointLib|InOsEmuPkg/Library/PeiEmuPeCoffGetEntryPointLib/PeiEmuPeCoffGetEntryPointLib.inf\r
   PeCoffExtraActionLib|InOsEmuPkg/Library/PeiEmuPeCoffExtraActionLib/PeiEmuPeCoffExtraActionLib.inf\r
   ExtractGuidedSectionLib|MdePkg/Library/PeiExtractGuidedSectionLib/PeiExtractGuidedSectionLib.inf\r
+  SerialPortLib|InOsEmuPkg/Library/PeiEmuSerialPortLib/PeiEmuSerialPortLib.inf\r
 \r
 [LibraryClasses.common.PEI_CORE]\r
   PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf\r
   PeiServicesTablePointerLib|InOsEmuPkg/Library/PeiCoreServicesTablePointerLib/PeiCoreServicesTablePointerLib.inf\r
-  SerialPortLib|InOsEmuPkg/Library/PeiEmuSerialPortLib/PeiEmuSerialPortLib.inf\r
 \r
 [LibraryClasses.common.PEIM]\r
   PcdLib|MdePkg/Library/PeiPcdLib/PeiPcdLib.inf\r
   ##\r
   InOsEmuPkg/Unix/Sec/SecMain.inf\r
 !else\r
+  #\r
+  # Generic SEC\r
+  #\r
+  InOsEmuPkg/Sec/Sec.inf\r
+\r
   ##\r
   #  PEI Phase modules\r
   ##\r
       PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf\r
   }\r
   MdeModulePkg/Universal/ReportStatusCodeRouter/Pei/ReportStatusCodeRouterPei.inf\r
-  MdeModulePkg/Universal/StatusCodeHandler/Pei/StatusCodeHandlerPei.inf {\r
-   <LibraryClasses>\r
-      SerialPortLib|InOsEmuPkg/Library/PeiEmuSerialPortLib/PeiEmuSerialPortLib.inf\r
-  }\r
+  MdeModulePkg/Universal/StatusCodeHandler/Pei/StatusCodeHandlerPei.inf \r
   \r
   IntelFrameworkModulePkg/Universal/StatusCode/Pei/StatusCodePei.inf\r
   InOsEmuPkg/BootModePei/BootModePei.inf\r
index 48d9179c9cbc6ebe4a855725f0c05adfed79aa5f..4b0e683ea0c2c65a890a8d114104670fabfd2f36 100644 (file)
@@ -167,6 +167,7 @@ APRIORI DXE {
   INF  MdeModulePkg/Universal/PCD/Dxe/Pcd.inf\r
   INF  InOsEmuPkg/MetronomeDxe/Metronome.inf\r
   }\r
+INF  InOsEmuPkg/Sec/Sec.inf\r
 INF  MdeModulePkg/Core/Pei/PeiMain.inf\r
 INF  MdeModulePkg/Universal/PCD/Pei/Pcd.inf\r
 INF  MdeModulePkg/Universal/ReportStatusCodeRouter/Pei/ReportStatusCodeRouterPei.inf\r
@@ -293,6 +294,13 @@ FILE FREEFORM = PCD(gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdLogoFile) {
 #  }\r
 #\r
 ############################################################################\r
+[Rule.Common.SEC]\r
+  FILE SEC = $(NAMED_GUID)  {\r
+    PE32     PE32    Align=32       $(INF_OUTPUT)/$(MODULE_NAME).efi\r
+    UI       STRING ="$(MODULE_NAME)" Optional         \r
+    VERSION  STRING ="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)    \r
+  }\r
+\r
 \r
 [Rule.Common.PEI_CORE]\r
   FILE PEI_CORE = $(NAMED_GUID) {\r