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
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
//\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
//\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
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