]> git.proxmox.com Git - mirror_edk2.git/commitdiff
PI Enable:
authorklu2 <klu2@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 12 Sep 2007 09:52:37 +0000 (09:52 +0000)
committerklu2 <klu2@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 12 Sep 2007 09:52:37 +0000 (09:52 +0000)
1) The entry point of PeiCore has been changed to EFI_PEI_CORE_ENTRY_POINT defined in PI.
2) Nt32, Tiger and lakeport platform's SecCore has been updated.
3) Autogen tools also has been updated.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@3804 6f19259b-4bc3-4df7-8a09-765794883524

12 files changed:
BaseTools/Bin/Win32/build.exe
MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
MdeModulePkg/Core/Pei/Dispatcher/Stack.c
MdeModulePkg/Core/Pei/Ipf/InternalSwitchStack.c [new file with mode: 0644]
MdeModulePkg/Core/Pei/Ipf/Stack.c
MdeModulePkg/Core/Pei/Ipf/SwitchStack.s [new file with mode: 0644]
MdeModulePkg/Core/Pei/Memory/MemoryServices.c
MdeModulePkg/Core/Pei/PeiMain.h
MdeModulePkg/Core/Pei/PeiMain.inf
MdeModulePkg/Core/Pei/PeiMain/PeiMain.c
Nt32Pkg/Sec/SecMain.c
Nt32Pkg/Sec/SecMain.inf

index ee09c625214d39c4476ead3f87e14b989dcc1bff..b72b8d9cf61d4d9c51da48a77d09c5a065481b25 100755 (executable)
Binary files a/BaseTools/Bin/Win32/build.exe and b/BaseTools/Bin/Win32/build.exe differ
index 67aa1bd53520dba24f5b440e9fa2519bb1fd859b..335fe9fc5dfad6561e1c85cc701679dc061cb129 100644 (file)
@@ -31,7 +31,7 @@ TransferOldDataToNewDataRange (
 \r
 EFI_STATUS\r
 PeiDispatcher (\r
-  IN EFI_PEI_STARTUP_DESCRIPTOR  *PeiStartupDescriptor,\r
+  IN CONST EFI_SEC_PEI_HAND_OFF  *SecCoreData,\r
   IN PEI_CORE_INSTANCE           *PrivateData,\r
   IN PEI_CORE_DISPATCH_DATA      *DispatchData\r
   )\r
@@ -44,7 +44,9 @@ Routine Description:
 \r
 Arguments:\r
 \r
-  PeiStartupDescriptor - Pointer to IN EFI_PEI_STARTUP_DESCRIPTOR\r
+  SecCoreData          - Points to a data structure containing information about the PEI core's operating\r
+                         environment, such as the size and location of temporary RAM, the stack location and\r
+                         the BFV location.\r
   PrivateData          - Pointer to the private data passed in from caller\r
   DispatchData         - Pointer to PEI_CORE_DISPATCH_DATA data.\r
 \r
@@ -214,7 +216,8 @@ Returns:
 \r
                 PeiSwitchStacks (\r
                   (SWITCH_STACK_ENTRY_POINT)(UINTN)TempPtr.Raw,\r
-                  PeiStartupDescriptor,\r
+                  (VOID*) SecCoreData,\r
+                  NULL,\r
                   (VOID*)PrivateDataInMem,\r
                   TopOfStack,\r
                   (VOID*)(UINTN)PrivateData->StackBase\r
@@ -360,7 +363,7 @@ VOID
 InitializeDispatcherData (\r
   IN EFI_PEI_SERVICES             **PeiServices,\r
   IN PEI_CORE_INSTANCE            *OldCoreData,\r
-  IN EFI_PEI_STARTUP_DESCRIPTOR   *PeiStartupDescriptor\r
+  IN CONST EFI_SEC_PEI_HAND_OFF   *SecCoreData\r
   )\r
 /*++\r
 \r
@@ -373,7 +376,9 @@ Arguments:
   PeiServices          - The PEI core services table.\r
   OldCoreData          - Pointer to old core data (before switching stack).\r
                          NULL if being run in non-permament memory mode.\r
-  PeiStartupDescriptor - Information and services provided by SEC phase.\r
+  SecCoreData          - Points to a data structure containing information about the PEI core's operating\r
+                         environment, such as the size and location of temporary RAM, the stack location and\r
+                         the BFV location.\r
 \r
 Returns:\r
 \r
@@ -386,8 +391,8 @@ Returns:
   PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS (PeiServices);\r
 \r
   if (OldCoreData == NULL) {\r
-    PrivateData->DispatchData.CurrentFvAddress = (EFI_FIRMWARE_VOLUME_HEADER *) PeiStartupDescriptor->BootFirmwareVolume;\r
-    PrivateData->DispatchData.BootFvAddress = (EFI_FIRMWARE_VOLUME_HEADER *) PeiStartupDescriptor->BootFirmwareVolume;\r
+    PrivateData->DispatchData.CurrentFvAddress = (EFI_FIRMWARE_VOLUME_HEADER *) SecCoreData->BootFirmwareVolumeBase;\r
+    PrivateData->DispatchData.BootFvAddress = (EFI_FIRMWARE_VOLUME_HEADER *) SecCoreData->BootFirmwareVolumeBase;\r
   } else {\r
 \r
     //\r
index 9e74eee5872983b94f9d0de453ccefc9fb00c6a6..551e23826c8a3287cc37a06eb7cc9b550983f63e 100644 (file)
@@ -47,9 +47,33 @@ PeiSwitchStacks (
   IN      SWITCH_STACK_ENTRY_POINT  EntryPoint,\r
   IN      VOID                      *Context1,  OPTIONAL\r
   IN      VOID                      *Context2,  OPTIONAL\r
+  IN      VOID                      *Context3,  OPTIONAL\r
   IN      VOID                      *NewStack,\r
   IN      VOID                      *NewBsp\r
   )\r
 {\r
-  SwitchStack (EntryPoint, Context1, Context2, NewStack);\r
+  BASE_LIBRARY_JUMP_BUFFER  JumpBuffer;\r
+  \r
+  ASSERT (EntryPoint != NULL);\r
+  ASSERT (NewStack != NULL);\r
+\r
+  //\r
+  // Stack should be aligned with CPU_STACK_ALIGNMENT\r
+  //\r
+  ASSERT (((UINTN)NewStack & (CPU_STACK_ALIGNMENT - 1)) == 0);\r
+\r
+  JumpBuffer.Eip = (UINTN)EntryPoint;\r
+  JumpBuffer.Esp = (UINTN)NewStack - sizeof (VOID*);\r
+  JumpBuffer.Esp -= sizeof (Context1) + sizeof (Context2) + sizeof(Context3);\r
+  ((VOID**)JumpBuffer.Esp)[1] = Context1;\r
+  ((VOID**)JumpBuffer.Esp)[2] = Context2;\r
+  ((VOID**)JumpBuffer.Esp)[3] = Context3;\r
+\r
+  LongJump (&JumpBuffer, (UINTN)-1);\r
+  \r
+\r
+  //\r
+  // InternalSwitchStack () will never return\r
+  //\r
+  ASSERT (FALSE);  \r
 }\r
diff --git a/MdeModulePkg/Core/Pei/Ipf/InternalSwitchStack.c b/MdeModulePkg/Core/Pei/Ipf/InternalSwitchStack.c
new file mode 100644 (file)
index 0000000..4e5df1a
--- /dev/null
@@ -0,0 +1,78 @@
+/** @file\r
+  SwitchStack() function for IPF.\r
+\r
+  Copyright (c) 2007, Intel Corporation<BR>\r
+  All rights reserved. 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 <PeiMain.h>\r
+\r
+VOID\r
+EFIAPI\r
+IpfAsmSwitchStack (\r
+    IN  SWITCH_STACK_ENTRY_POINT  EntryPoint,\r
+    IN  VOID                      *ConText1, OPTIONAL\r
+    IN  VOID                      *Context2, OPTIONAL\r
+    IN  VOID                      *Context3, OPTIONAL\r
+    IN  VOID                      *NewStack,\r
+    IN  VOID                      *NewBsp\r
+    );\r
+\r
+/**\r
+  Transfers control to a function starting with a new stack.\r
+\r
+  Transfers control to the function specified by EntryPoint using the\r
+  new stack specified by NewStack and passing in the parameters specified\r
+  by Context1 and Context2.  Context1 and Context2 are optional and may\r
+  be NULL.  The function EntryPoint must never return.\r
+  Marker will be ignored on IA-32, x64, and EBC.\r
+  IPF CPUs expect one additional parameter of type VOID * that specifies\r
+  the new backing store pointer.\r
+\r
+  If EntryPoint is NULL, then ASSERT().\r
+  If NewStack is NULL, then ASSERT().\r
+\r
+  @param  EntryPoint  A pointer to function to call with the new stack.\r
+  @param  Context1    A pointer to the context to pass into the EntryPoint\r
+                      function.\r
+  @param  Context2    A pointer to the context to pass into the EntryPoint\r
+                      function.\r
+  @param  NewStack    A pointer to the new stack to use for the EntryPoint\r
+                      function.\r
+  @param  Marker      VA_LIST marker for the variable argument list.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+InternalSwitchStack (\r
+  IN      SWITCH_STACK_ENTRY_POINT  EntryPoint,\r
+  IN      VOID                      *Context1,   OPTIONAL\r
+  IN      VOID                      *Context2,   OPTIONAL\r
+  IN      VOID                      *Context3,   OPTIONAL\r
+  IN      VOID                      *NewStack,\r
+  IN      VA_LIST                   Marker\r
+  )\r
+\r
+{\r
+  VOID                      *NewBsp;\r
+\r
+  //\r
+  // Get new backing store pointer from variable list\r
+  //\r
+  NewBsp   = VA_ARG (Marker, VOID *);\r
+\r
+  //\r
+  // Stack should be aligned with CPU_STACK_ALIGNMENT\r
+  //\r
+  ASSERT (((UINTN)NewStack & (CPU_STACK_ALIGNMENT - 1)) == 0);\r
+  ASSERT (((UINTN)NewBsp & (CPU_STACK_ALIGNMENT - 1)) == 0);\r
+\r
+  IpfAsmSwitchStack (EntryPoint, Context1, Context2, Context3, NewStack, NewBsp);\r
+}\r
index 56a876df152b64c676d95a1cb7f5e3378e087817..7ffdac54c749227e3d870f7531e350c9c81eb09f 100644 (file)
 \r
 #include <PeiMain.h>\r
 \r
+VOID\r
+EFIAPI\r
+InternalSwitchStack (\r
+  IN      SWITCH_STACK_ENTRY_POINT  EntryPoint,\r
+  IN      VOID                      *Context1,   OPTIONAL\r
+  IN      VOID                      *Context2,   OPTIONAL\r
+  IN      VOID                      *Context3,   OPTIONAL\r
+  IN      VOID                      *NewStack,\r
+  IN      VA_LIST                   Marker\r
+  );\r
+\r
 /**\r
   Transfers control to a function starting with a new stack.\r
 \r
@@ -44,15 +55,18 @@ PeiSwitchStacks (
   IN      SWITCH_STACK_ENTRY_POINT  EntryPoint,\r
   IN      VOID                      *Context1,  OPTIONAL\r
   IN      VOID                      *Context2,  OPTIONAL\r
+  IN      VOID                      *Context3,  OPTIONAL\r
   IN      VOID                      *NewStack,\r
   IN      VOID                      *NewBsp\r
   )\r
 {\r
-  SwitchStack (\r
+  InternalSwitchStack(\r
     EntryPoint,\r
     Context1,\r
     Context2,\r
+    Context3,\r
     NewStack,\r
     NewBsp\r
     );\r
+\r
 }\r
diff --git a/MdeModulePkg/Core/Pei/Ipf/SwitchStack.s b/MdeModulePkg/Core/Pei/Ipf/SwitchStack.s
new file mode 100644 (file)
index 0000000..2f20703
--- /dev/null
@@ -0,0 +1,52 @@
+/// @file\r
+///  IPF specific SwitchStack() function\r
+///\r
+/// Copyright (c) 2006, Intel Corporation\r
+/// All rights reserved. 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
+/// Module Name: SwitchStack.s\r
+///\r
+///\r
+\r
+.auto\r
+.text\r
+\r
+.proc   IpfAsmSwitchStack\r
+.type   IpfAsmSwitchStack, @function\r
+.regstk 6, 0, 0, 0\r
+IpfAsmSwitchStack::\r
+        mov                 r14 = ar.rsc\r
+        movl                r2  = ~((((1 << 14) - 1) << 16) | 3)\r
+\r
+        mov                 r17 = in1\r
+        mov                 r18 = in2\r
+        mov                 r19 = in3\r
+        and                 r2  = r14, r2\r
+\r
+        mov                 ar.rsc = r2\r
+        mov                 sp  = in4\r
+        mov                 r20 = in5\r
+\r
+        ld8.nt1             r16 = [in0], 8\r
+        ld8.nta             gp  = [in0]\r
+        mov                 r3  = -1\r
+\r
+        loadrs\r
+        mov                 ar.bspstore = r20\r
+        mov                 b7  = r16\r
+\r
+        alloc               r2  = ar.pfs, 0, 0, 3, 0\r
+        mov                 out0 = r17\r
+        mov                 out1 = r18\r
+        mov                 out2 = r19\r
+\r
+        mov                 ar.rnat = r3\r
+        mov                 ar.rsc = r14\r
+        br.call.sptk.many   b0  = b7\r
+.endp   IpfAsmSwitchStack\r
index 431084f83bcd3b310c638c1d059ae41020b8421d..49e9f7f5528154c6417d4e1464d11ef79185b1ab 100644 (file)
@@ -24,7 +24,7 @@ Abstract:
 VOID\r
 InitializeMemoryServices (\r
   IN EFI_PEI_SERVICES            **PeiServices,\r
-  IN EFI_PEI_STARTUP_DESCRIPTOR  *PeiStartupDescriptor,\r
+  IN CONST EFI_SEC_PEI_HAND_OFF  *SecCoreData,\r
   IN PEI_CORE_INSTANCE           *OldCoreData\r
   )\r
 /*++\r
@@ -36,7 +36,10 @@ Routine Description:
 Arguments:\r
 \r
   PeiServices          - The PEI core services table.\r
-  PeiStartupDescriptor - Information and services provided by SEC phase.\r
+  SecCoreData          - Points to a data structure containing information about the PEI core's operating\r
+                         environment, such as the size and location of temporary RAM, the stack location and\r
+                         the BFV location.\r
+\r
   OldCoreData          - Pointer to the PEI Core data.\r
                          NULL if being run in non-permament memory mode.\r
 \r
@@ -47,7 +50,6 @@ Returns:
 --*/\r
 {\r
   PEI_CORE_INSTANCE                    *PrivateData;\r
-  UINT64                               SizeOfCarHeap;\r
 \r
   PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS (PeiServices);\r
   PrivateData->SwitchStackSignal = FALSE;\r
@@ -56,18 +58,12 @@ Returns:
 \r
     PrivateData->PeiMemoryInstalled = FALSE;\r
 \r
-    PrivateData->BottomOfCarHeap = (VOID *) (((UINTN)(VOID *)(&PrivateData))\r
-                                   & (~((PeiStartupDescriptor->SizeOfCacheAsRam) - 1))); \r
-    PrivateData->TopOfCarHeap = (VOID *)((UINTN)(PrivateData->BottomOfCarHeap) + PeiStartupDescriptor->SizeOfCacheAsRam);\r
-    //\r
-    // SizeOfCarHeap is 1/2 (arbitrary) of CacheAsRam Size.\r
-    //\r
-    SizeOfCarHeap = (UINT64) PeiStartupDescriptor->SizeOfCacheAsRam;\r
-    SizeOfCarHeap = RShiftU64 (SizeOfCarHeap, 1);\r
+    PrivateData->BottomOfCarHeap = SecCoreData->PeiTemporaryRamBase; \r
+    PrivateData->TopOfCarHeap = (VOID *)((UINTN)(PrivateData->BottomOfCarHeap) + SecCoreData->PeiTemporaryRamSize);\r
  \r
     DEBUG_CODE_BEGIN ();\r
-      PrivateData->SizeOfCacheAsRam = PeiStartupDescriptor->SizeOfCacheAsRam;\r
-      PrivateData->MaxTopOfCarHeap  = (VOID *) ((UINTN) PrivateData->BottomOfCarHeap + (UINTN) SizeOfCarHeap);\r
+      PrivateData->SizeOfCacheAsRam = SecCoreData->PeiTemporaryRamSize + SecCoreData->StackSize;\r
+      PrivateData->MaxTopOfCarHeap  = (VOID *) ((UINTN) PrivateData->BottomOfCarHeap + (UINTN) PrivateData->SizeOfCacheAsRam);\r
     DEBUG_CODE_END ();\r
 \r
     PrivateData->HobList.Raw = PrivateData->BottomOfCarHeap;\r
@@ -75,7 +71,7 @@ Returns:
     PeiCoreBuildHobHandoffInfoTable (\r
       BOOT_WITH_FULL_CONFIGURATION,\r
       (EFI_PHYSICAL_ADDRESS) (UINTN) PrivateData->BottomOfCarHeap,\r
-      (UINTN) SizeOfCarHeap\r
+      (UINTN) SecCoreData->PeiTemporaryRamSize\r
       );\r
     //\r
     // Copy PeiServices from ROM to Cache in PrivateData\r
index 9e0d7a8530e9704c7f0eb4b10addb70943980c46..b4d246211670cf038912e9285d9b5da0eb2f761b 100644 (file)
@@ -177,8 +177,9 @@ typedef union {
 EFI_STATUS\r
 EFIAPI\r
 PeiCore (\r
-  IN EFI_PEI_STARTUP_DESCRIPTOR  *PeiStartupDescriptor,\r
-  IN VOID                        *Data\r
+  IN CONST EFI_SEC_PEI_HAND_OFF        *SecCoreData,\r
+  IN CONST EFI_PEI_PPI_DESCRIPTOR      *PpList,\r
+  IN VOID                              *Data\r
   )\r
 /*++\r
 \r
@@ -248,7 +249,7 @@ Returns:
 \r
 EFI_STATUS\r
 PeiDispatcher (\r
-  IN EFI_PEI_STARTUP_DESCRIPTOR  *PeiStartupDescriptor,\r
+  IN CONST EFI_SEC_PEI_HAND_OFF  *SecCoreData,\r
   IN PEI_CORE_INSTANCE           *PrivateData,\r
   IN PEI_CORE_DISPATCH_DATA      *DispatchData\r
   )\r
@@ -278,7 +279,7 @@ VOID
 InitializeDispatcherData (\r
   IN EFI_PEI_SERVICES             **PeiServices,\r
   IN PEI_CORE_INSTANCE            *OldCoreData,\r
-  IN EFI_PEI_STARTUP_DESCRIPTOR   *PeiStartupDescriptor\r
+  IN CONST EFI_SEC_PEI_HAND_OFF   *SecCoreData\r
   )\r
 /*++\r
 \r
@@ -956,7 +957,7 @@ Returns:
 VOID\r
 InitializeMemoryServices (\r
   IN EFI_PEI_SERVICES            **PeiServices,\r
-  IN EFI_PEI_STARTUP_DESCRIPTOR  *PeiStartupDescriptor,\r
+  IN CONST EFI_SEC_PEI_HAND_OFF  *SecCoreData,\r
   IN PEI_CORE_INSTANCE           *OldCoreData\r
   )\r
 /*++\r
@@ -1208,6 +1209,7 @@ PeiSwitchStacks (
   IN      SWITCH_STACK_ENTRY_POINT  EntryPoint,\r
   IN      VOID                      *Context1,  OPTIONAL\r
   IN      VOID                      *Context2,  OPTIONAL\r
+  IN      VOID                      *Context3,  OPTIONAL\r
   IN      VOID                      *NewStack,\r
   IN      VOID                      *NewBsp\r
   );\r
index 245e979bd69c24b4ccfb19e16f5e465a7fa4b845..df9ca825c701c12b7250071e8e56d6cfe8ce510f 100644 (file)
@@ -59,6 +59,8 @@
   Ipf/IpfCpuCore.s\r
   Ipf/IpfCpuCore.i\r
   Ipf/SwitchToCacheMode.c\r
+  Ipf/InternalSwitchStack.c\r
+  Ipf/SwitchStack.s\r
 \r
 [Sources.EBC]\r
   Dispatcher/Stack.c\r
@@ -77,7 +79,7 @@
   PerformanceLib\r
   HobLib\r
   BaseLib\r
-  OldPeiCoreEntryPoint\r
+  PeiCoreEntryPoint\r
   DebugLib\r
 \r
 [Guids]\r
index b2f7807479af44c2a49149197578f4f7cd287305..a7944e130c2f5a033555d964acf4156d250f99ea 100644 (file)
@@ -81,8 +81,9 @@ static EFI_PEI_SERVICES  mPS = {
 EFI_STATUS\r
 EFIAPI\r
 PeiCore (\r
-  IN EFI_PEI_STARTUP_DESCRIPTOR  *PeiStartupDescriptor,\r
-  IN VOID                        *Data\r
+  IN CONST EFI_SEC_PEI_HAND_OFF        *SecCoreData,\r
+  IN CONST EFI_PEI_PPI_DESCRIPTOR      *PpList,\r
+  IN VOID                              *Data\r
   )\r
 /*++\r
 \r
@@ -94,8 +95,16 @@ Routine Description:
 \r
 Arguments:\r
 \r
-  PeiStartupDescriptor - Information and services provided by SEC phase.\r
-  OldCoreData          - Pointer to old core data that is used to initialize the\r
+  SecCoreData          - Points to a data structure containing information about the PEI core's operating\r
+                         environment, such as the size and location of temporary RAM, the stack location and\r
+                         the BFV location.\r
+  PpiList              - Points to a list of one or more PPI descriptors to be installed initially by the PEI core.\r
+                         An empty PPI list consists of a single descriptor with the end-tag\r
+                         EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST. As part of its initialization\r
+                         phase, the PEI Foundation will add these SEC-hosted PPIs to its PPI database such\r
+                         that both the PEI Foundation and any modules can leverage the associated service\r
+                         calls and/or code in these early PPIs\r
+  Data                 - Pointer to old core data that is used to initialize the\r
                          core's data areas.\r
 \r
 Returns:\r
@@ -142,13 +151,13 @@ Returns:
   //\r
   ProcessLibraryConstructorList (NULL, &PrivateData.PS);\r
 \r
-  InitializeMemoryServices (&PrivateData.PS, PeiStartupDescriptor, OldCoreData);\r
+  InitializeMemoryServices (&PrivateData.PS, SecCoreData, OldCoreData);\r
 \r
   InitializePpiServices (&PrivateData.PS, OldCoreData);\r
 \r
   InitializeSecurityServices (&PrivateData.PS, OldCoreData);\r
 \r
-  InitializeDispatcherData (&PrivateData.PS, OldCoreData, PeiStartupDescriptor);\r
+  InitializeDispatcherData (&PrivateData.PS, OldCoreData, SecCoreData);\r
 \r
   if (OldCoreData != NULL) {\r
 \r
@@ -210,8 +219,8 @@ Returns:
     //\r
     // If SEC provided any PPI services to PEI, install them.\r
     //\r
-    if (PeiStartupDescriptor->DispatchTable != NULL) {\r
-      Status = PeiServicesInstallPpi (PeiStartupDescriptor->DispatchTable);\r
+    if (PpList != NULL) {\r
+      Status = PeiServicesInstallPpi (PpList);\r
       ASSERT_EFI_ERROR (Status);\r
     }\r
   }\r
@@ -221,7 +230,7 @@ Returns:
   //\r
   // Call PEIM dispatcher\r
   //\r
-  PeiDispatcher (PeiStartupDescriptor, &PrivateData, DispatchData);\r
+  PeiDispatcher (SecCoreData, &PrivateData, DispatchData);\r
 \r
   //\r
   // Check if InstallPeiMemory service was called.\r
index ab66dfc52cb94aa393b25b2c863eeac8c4ffff43..a1ab3f20ef818ba4625c1ecccfe8dc0f41ecc7b2 100644 (file)
@@ -484,6 +484,63 @@ Returns:
   return EFI_SUCCESS;\r
 }\r
 \r
+/**\r
+  Transfers control to a function starting with a new stack.\r
+\r
+  Transfers control to the function specified by EntryPoint using the new stack\r
+  specified by NewStack and passing in the parameters specified by Context1 and\r
+  Context2. Context1 and Context2 are optional and may be NULL. The function\r
+  EntryPoint must never return.\r
+\r
+  If EntryPoint is NULL, then ASSERT().\r
+  If NewStack is NULL, then ASSERT().\r
+\r
+  @param  EntryPoint  A pointer to function to call with the new stack.\r
+  @param  Context1    A pointer to the context to pass into the EntryPoint\r
+                      function.\r
+  @param  Context2    A pointer to the context to pass into the EntryPoint\r
+                      function.\r
+  @param  NewStack    A pointer to the new stack to use for the EntryPoint\r
+                      function.\r
+  @param  NewBsp      A pointer to the new BSP for the EntryPoint on IPF. It's\r
+                      Reserved on other architectures.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+PeiSwitchStacks (\r
+  IN      SWITCH_STACK_ENTRY_POINT  EntryPoint,\r
+  IN      VOID                      *Context1,  OPTIONAL\r
+  IN      VOID                      *Context2,  OPTIONAL\r
+  IN      VOID                      *Context3,  OPTIONAL\r
+  IN      VOID                      *NewStack\r
+  )\r
+{\r
+  BASE_LIBRARY_JUMP_BUFFER  JumpBuffer;\r
+  \r
+  ASSERT (EntryPoint != NULL);\r
+  ASSERT (NewStack != NULL);\r
+\r
+  //\r
+  // Stack should be aligned with CPU_STACK_ALIGNMENT\r
+  //\r
+  ASSERT (((UINTN)NewStack & (CPU_STACK_ALIGNMENT - 1)) == 0);\r
+\r
+  JumpBuffer.Eip = (UINTN)EntryPoint;\r
+  JumpBuffer.Esp = (UINTN)NewStack - sizeof (VOID*);\r
+  JumpBuffer.Esp -= sizeof (Context1) + sizeof (Context2) + sizeof(Context3);\r
+  ((VOID**)JumpBuffer.Esp)[1] = Context1;\r
+  ((VOID**)JumpBuffer.Esp)[2] = Context2;\r
+  ((VOID**)JumpBuffer.Esp)[3] = Context3;\r
+\r
+  LongJump (&JumpBuffer, (UINTN)-1);\r
+  \r
+\r
+  //\r
+  // InternalSwitchStack () will never return\r
+  //\r
+  ASSERT (FALSE);  \r
+}\r
 \r
 VOID\r
 SecLoadFromCore (\r
@@ -514,7 +571,7 @@ Returns:
   UINT64                      PeiCoreSize;\r
   EFI_PHYSICAL_ADDRESS        PeiCoreEntryPoint;\r
   EFI_PHYSICAL_ADDRESS        PeiImageAddress;\r
-  EFI_PEI_STARTUP_DESCRIPTOR  *PeiStartup;\r
+  EFI_SEC_PEI_HAND_OFF        *SecCoreData;\r
 \r
   //\r
   // Compute Top Of Memory for Stack and PEI Core Allocations\r
@@ -524,7 +581,7 @@ Returns:
   //\r
   // Allocate 128KB for the Stack\r
   //\r
-  TopOfStack  = (VOID *)((UINTN)TopOfMemory - sizeof (EFI_PEI_STARTUP_DESCRIPTOR) - CPU_STACK_ALIGNMENT);\r
+  TopOfStack  = (VOID *)((UINTN)TopOfMemory - sizeof (EFI_SEC_PEI_HAND_OFF) - CPU_STACK_ALIGNMENT);\r
   TopOfStack  = ALIGN_POINTER (TopOfStack, CPU_STACK_ALIGNMENT);\r
   TopOfMemory = TopOfMemory - STACK_SIZE;\r
 \r
@@ -536,10 +593,16 @@ Returns:
   //\r
   // Bind this information into the SEC hand-off state\r
   //\r
-  PeiStartup = (EFI_PEI_STARTUP_DESCRIPTOR *) (UINTN) TopOfStack;\r
-  PeiStartup->DispatchTable      = (EFI_PEI_PPI_DESCRIPTOR *) &gPrivateDispatchTable;\r
-  PeiStartup->SizeOfCacheAsRam   = STACK_SIZE;\r
-  PeiStartup->BootFirmwareVolume = BootFirmwareVolumeBase;\r
+  SecCoreData                        = (EFI_SEC_PEI_HAND_OFF*)(UINTN) TopOfStack;\r
+  SecCoreData->DataSize               = sizeof(EFI_SEC_PEI_HAND_OFF);\r
+  SecCoreData->BootFirmwareVolumeBase = (VOID*)BootFirmwareVolumeBase;\r
+  SecCoreData->BootFirmwareVolumeSize = FixedPcdGet32(PcdWinNtFirmwareFdSize);\r
+  SecCoreData->TemporaryRamBase       = (VOID*)(UINTN)TopOfMemory; \r
+  SecCoreData->TemporaryRamSize       = STACK_SIZE;\r
+  SecCoreData->PeiTemporaryRamBase    = SecCoreData->TemporaryRamBase;\r
+  SecCoreData->PeiTemporaryRamSize    = (UINTN)RShiftU64((UINT64)STACK_SIZE,1);\r
+  SecCoreData->StackBase              = (VOID*)((UINTN)SecCoreData->TemporaryRamBase + (UINTN)SecCoreData->TemporaryRamSize);\r
+  SecCoreData->StackSize              = (UINTN)RShiftU64((UINT64)STACK_SIZE,1);\r
 \r
   //\r
   // Load the PEI Core from a Firmware Volume\r
@@ -553,12 +616,14 @@ Returns:
   if (EFI_ERROR (Status)) {\r
     return ;\r
   }\r
+  \r
   //\r
   // Transfer control to the PEI Core\r
   //\r
-  SwitchStack (\r
+  PeiSwitchStacks (\r
     (SWITCH_STACK_ENTRY_POINT) (UINTN) PeiCoreEntryPoint,\r
-    PeiStartup,\r
+    SecCoreData,\r
+    (VOID *) (UINTN) ((EFI_PEI_PPI_DESCRIPTOR *) &gPrivateDispatchTable),\r
     NULL,\r
     TopOfStack\r
     );\r
index db891436e23a881bd685a8e48c903050aad88d9e..170e87188d707478ac1cd792f3474ca0e36b1bd0 100644 (file)
@@ -68,6 +68,9 @@
   #gEfiNt32PkgTokenSpaceGuid.PcdWinNtMemorySizeForSecMain\r
   #gEfiNt32PkgTokenSpaceGuid.PcdWinNtFirmwareVolume\r
   \r
+[FixedPcd.common]\r
+  gEfiNt32PkgTokenSpaceGuid.PcdWinNtFirmwareFdSize  \r
+  \r
 [BuildOptions.common]\r
   MSFT:DEBUG_*_IA32_DLINK_FLAGS = /out:"$(BIN_DIR)\SecMain.exe" /base:0x10000000 /pdb:"$(BIN_DIR)\SecMain.pdb" /LIBPATH:"$(VCINSTALLDIR)\Lib" /LIBPATH:"$(VCINSTALLDIR)\PlatformSdk\Lib" /NOLOGO /SUBSYSTEM:CONSOLE /NODEFAULTLIB /IGNORE:4086 /MAP /OPT:REF /DEBUG /MACHINE:I386 /LTCG Kernel32.lib MSVCRTD.lib Gdi32.lib User32.lib Winmm.lib\r
   MSFT:DEBUG_*_IA32_CC_FLAGS = /nologo /W4 /WX /Gy /c /D UNICODE /D EFI32 /Od /DSTRING_ARRAY_NAME=SecMainStrings /FI$(DEST_DIR_DEBUG)/AutoGen.h /EHs-c- /GF /Gs8192 /Zi /Gm\r