summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xBaseTools/Bin/Win32/build.exebin1445951 -> 1468968 bytes
-rw-r--r--MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c19
-rw-r--r--MdeModulePkg/Core/Pei/Dispatcher/Stack.c26
-rw-r--r--MdeModulePkg/Core/Pei/Ipf/InternalSwitchStack.c78
-rw-r--r--MdeModulePkg/Core/Pei/Ipf/Stack.c16
-rw-r--r--MdeModulePkg/Core/Pei/Ipf/SwitchStack.s52
-rw-r--r--MdeModulePkg/Core/Pei/Memory/MemoryServices.c24
-rw-r--r--MdeModulePkg/Core/Pei/PeiMain.h12
-rw-r--r--MdeModulePkg/Core/Pei/PeiMain.inf4
-rw-r--r--MdeModulePkg/Core/Pei/PeiMain/PeiMain.c27
-rw-r--r--Nt32Pkg/Sec/SecMain.c81
-rw-r--r--Nt32Pkg/Sec/SecMain.inf3
12 files changed, 296 insertions, 46 deletions
diff --git a/BaseTools/Bin/Win32/build.exe b/BaseTools/Bin/Win32/build.exe
index ee09c62521..b72b8d9cf6 100755
--- a/BaseTools/Bin/Win32/build.exe
+++ b/BaseTools/Bin/Win32/build.exe
Binary files differ
diff --git a/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c b/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
index 67aa1bd535..335fe9fc5d 100644
--- a/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
+++ b/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
@@ -31,7 +31,7 @@ TransferOldDataToNewDataRange (
EFI_STATUS
PeiDispatcher (
- IN EFI_PEI_STARTUP_DESCRIPTOR *PeiStartupDescriptor,
+ IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData,
IN PEI_CORE_INSTANCE *PrivateData,
IN PEI_CORE_DISPATCH_DATA *DispatchData
)
@@ -44,7 +44,9 @@ Routine Description:
Arguments:
- PeiStartupDescriptor - Pointer to IN EFI_PEI_STARTUP_DESCRIPTOR
+ 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.
PrivateData - Pointer to the private data passed in from caller
DispatchData - Pointer to PEI_CORE_DISPATCH_DATA data.
@@ -214,7 +216,8 @@ Returns:
PeiSwitchStacks (
(SWITCH_STACK_ENTRY_POINT)(UINTN)TempPtr.Raw,
- PeiStartupDescriptor,
+ (VOID*) SecCoreData,
+ NULL,
(VOID*)PrivateDataInMem,
TopOfStack,
(VOID*)(UINTN)PrivateData->StackBase
@@ -360,7 +363,7 @@ VOID
InitializeDispatcherData (
IN EFI_PEI_SERVICES **PeiServices,
IN PEI_CORE_INSTANCE *OldCoreData,
- IN EFI_PEI_STARTUP_DESCRIPTOR *PeiStartupDescriptor
+ IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData
)
/*++
@@ -373,7 +376,9 @@ Arguments:
PeiServices - The PEI core services table.
OldCoreData - Pointer to old core data (before switching stack).
NULL if being run in non-permament memory mode.
- PeiStartupDescriptor - Information and services provided by SEC phase.
+ 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.
Returns:
@@ -386,8 +391,8 @@ Returns:
PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS (PeiServices);
if (OldCoreData == NULL) {
- PrivateData->DispatchData.CurrentFvAddress = (EFI_FIRMWARE_VOLUME_HEADER *) PeiStartupDescriptor->BootFirmwareVolume;
- PrivateData->DispatchData.BootFvAddress = (EFI_FIRMWARE_VOLUME_HEADER *) PeiStartupDescriptor->BootFirmwareVolume;
+ PrivateData->DispatchData.CurrentFvAddress = (EFI_FIRMWARE_VOLUME_HEADER *) SecCoreData->BootFirmwareVolumeBase;
+ PrivateData->DispatchData.BootFvAddress = (EFI_FIRMWARE_VOLUME_HEADER *) SecCoreData->BootFirmwareVolumeBase;
} else {
//
diff --git a/MdeModulePkg/Core/Pei/Dispatcher/Stack.c b/MdeModulePkg/Core/Pei/Dispatcher/Stack.c
index 9e74eee587..551e23826c 100644
--- a/MdeModulePkg/Core/Pei/Dispatcher/Stack.c
+++ b/MdeModulePkg/Core/Pei/Dispatcher/Stack.c
@@ -47,9 +47,33 @@ PeiSwitchStacks (
IN SWITCH_STACK_ENTRY_POINT EntryPoint,
IN VOID *Context1, OPTIONAL
IN VOID *Context2, OPTIONAL
+ IN VOID *Context3, OPTIONAL
IN VOID *NewStack,
IN VOID *NewBsp
)
{
- SwitchStack (EntryPoint, Context1, Context2, NewStack);
+ BASE_LIBRARY_JUMP_BUFFER JumpBuffer;
+
+ ASSERT (EntryPoint != NULL);
+ ASSERT (NewStack != NULL);
+
+ //
+ // Stack should be aligned with CPU_STACK_ALIGNMENT
+ //
+ ASSERT (((UINTN)NewStack & (CPU_STACK_ALIGNMENT - 1)) == 0);
+
+ JumpBuffer.Eip = (UINTN)EntryPoint;
+ JumpBuffer.Esp = (UINTN)NewStack - sizeof (VOID*);
+ JumpBuffer.Esp -= sizeof (Context1) + sizeof (Context2) + sizeof(Context3);
+ ((VOID**)JumpBuffer.Esp)[1] = Context1;
+ ((VOID**)JumpBuffer.Esp)[2] = Context2;
+ ((VOID**)JumpBuffer.Esp)[3] = Context3;
+
+ LongJump (&JumpBuffer, (UINTN)-1);
+
+
+ //
+ // InternalSwitchStack () will never return
+ //
+ ASSERT (FALSE);
}
diff --git a/MdeModulePkg/Core/Pei/Ipf/InternalSwitchStack.c b/MdeModulePkg/Core/Pei/Ipf/InternalSwitchStack.c
new file mode 100644
index 0000000000..4e5df1a44a
--- /dev/null
+++ b/MdeModulePkg/Core/Pei/Ipf/InternalSwitchStack.c
@@ -0,0 +1,78 @@
+/** @file
+ SwitchStack() function for IPF.
+
+ Copyright (c) 2007, Intel Corporation<BR>
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include <PeiMain.h>
+
+VOID
+EFIAPI
+IpfAsmSwitchStack (
+ IN SWITCH_STACK_ENTRY_POINT EntryPoint,
+ IN VOID *ConText1, OPTIONAL
+ IN VOID *Context2, OPTIONAL
+ IN VOID *Context3, OPTIONAL
+ IN VOID *NewStack,
+ IN VOID *NewBsp
+ );
+
+/**
+ Transfers control to a function starting with a new stack.
+
+ Transfers control to the function specified by EntryPoint using the
+ new stack specified by NewStack and passing in the parameters specified
+ by Context1 and Context2. Context1 and Context2 are optional and may
+ be NULL. The function EntryPoint must never return.
+ Marker will be ignored on IA-32, x64, and EBC.
+ IPF CPUs expect one additional parameter of type VOID * that specifies
+ the new backing store pointer.
+
+ If EntryPoint is NULL, then ASSERT().
+ If NewStack is NULL, then ASSERT().
+
+ @param EntryPoint A pointer to function to call with the new stack.
+ @param Context1 A pointer to the context to pass into the EntryPoint
+ function.
+ @param Context2 A pointer to the context to pass into the EntryPoint
+ function.
+ @param NewStack A pointer to the new stack to use for the EntryPoint
+ function.
+ @param Marker VA_LIST marker for the variable argument list.
+
+**/
+VOID
+EFIAPI
+InternalSwitchStack (
+ IN SWITCH_STACK_ENTRY_POINT EntryPoint,
+ IN VOID *Context1, OPTIONAL
+ IN VOID *Context2, OPTIONAL
+ IN VOID *Context3, OPTIONAL
+ IN VOID *NewStack,
+ IN VA_LIST Marker
+ )
+
+{
+ VOID *NewBsp;
+
+ //
+ // Get new backing store pointer from variable list
+ //
+ NewBsp = VA_ARG (Marker, VOID *);
+
+ //
+ // Stack should be aligned with CPU_STACK_ALIGNMENT
+ //
+ ASSERT (((UINTN)NewStack & (CPU_STACK_ALIGNMENT - 1)) == 0);
+ ASSERT (((UINTN)NewBsp & (CPU_STACK_ALIGNMENT - 1)) == 0);
+
+ IpfAsmSwitchStack (EntryPoint, Context1, Context2, Context3, NewStack, NewBsp);
+}
diff --git a/MdeModulePkg/Core/Pei/Ipf/Stack.c b/MdeModulePkg/Core/Pei/Ipf/Stack.c
index 56a876df15..7ffdac54c7 100644
--- a/MdeModulePkg/Core/Pei/Ipf/Stack.c
+++ b/MdeModulePkg/Core/Pei/Ipf/Stack.c
@@ -16,6 +16,17 @@
#include <PeiMain.h>
+VOID
+EFIAPI
+InternalSwitchStack (
+ IN SWITCH_STACK_ENTRY_POINT EntryPoint,
+ IN VOID *Context1, OPTIONAL
+ IN VOID *Context2, OPTIONAL
+ IN VOID *Context3, OPTIONAL
+ IN VOID *NewStack,
+ IN VA_LIST Marker
+ );
+
/**
Transfers control to a function starting with a new stack.
@@ -44,15 +55,18 @@ PeiSwitchStacks (
IN SWITCH_STACK_ENTRY_POINT EntryPoint,
IN VOID *Context1, OPTIONAL
IN VOID *Context2, OPTIONAL
+ IN VOID *Context3, OPTIONAL
IN VOID *NewStack,
IN VOID *NewBsp
)
{
- SwitchStack (
+ InternalSwitchStack(
EntryPoint,
Context1,
Context2,
+ Context3,
NewStack,
NewBsp
);
+
}
diff --git a/MdeModulePkg/Core/Pei/Ipf/SwitchStack.s b/MdeModulePkg/Core/Pei/Ipf/SwitchStack.s
new file mode 100644
index 0000000000..2f20703913
--- /dev/null
+++ b/MdeModulePkg/Core/Pei/Ipf/SwitchStack.s
@@ -0,0 +1,52 @@
+/// @file
+/// IPF specific SwitchStack() function
+///
+/// Copyright (c) 2006, Intel Corporation
+/// All rights reserved. This program and the accompanying materials
+/// are licensed and made available under the terms and conditions of the BSD License
+/// which accompanies this distribution. The full text of the license may be found at
+/// http://opensource.org/licenses/bsd-license.php
+///
+/// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+/// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+///
+/// Module Name: SwitchStack.s
+///
+///
+
+.auto
+.text
+
+.proc IpfAsmSwitchStack
+.type IpfAsmSwitchStack, @function
+.regstk 6, 0, 0, 0
+IpfAsmSwitchStack::
+ mov r14 = ar.rsc
+ movl r2 = ~((((1 << 14) - 1) << 16) | 3)
+
+ mov r17 = in1
+ mov r18 = in2
+ mov r19 = in3
+ and r2 = r14, r2
+
+ mov ar.rsc = r2
+ mov sp = in4
+ mov r20 = in5
+
+ ld8.nt1 r16 = [in0], 8
+ ld8.nta gp = [in0]
+ mov r3 = -1
+
+ loadrs
+ mov ar.bspstore = r20
+ mov b7 = r16
+
+ alloc r2 = ar.pfs, 0, 0, 3, 0
+ mov out0 = r17
+ mov out1 = r18
+ mov out2 = r19
+
+ mov ar.rnat = r3
+ mov ar.rsc = r14
+ br.call.sptk.many b0 = b7
+.endp IpfAsmSwitchStack
diff --git a/MdeModulePkg/Core/Pei/Memory/MemoryServices.c b/MdeModulePkg/Core/Pei/Memory/MemoryServices.c
index 431084f83b..49e9f7f552 100644
--- a/MdeModulePkg/Core/Pei/Memory/MemoryServices.c
+++ b/MdeModulePkg/Core/Pei/Memory/MemoryServices.c
@@ -24,7 +24,7 @@ Abstract:
VOID
InitializeMemoryServices (
IN EFI_PEI_SERVICES **PeiServices,
- IN EFI_PEI_STARTUP_DESCRIPTOR *PeiStartupDescriptor,
+ IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData,
IN PEI_CORE_INSTANCE *OldCoreData
)
/*++
@@ -36,7 +36,10 @@ Routine Description:
Arguments:
PeiServices - The PEI core services table.
- PeiStartupDescriptor - Information and services provided by SEC phase.
+ 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.
+
OldCoreData - Pointer to the PEI Core data.
NULL if being run in non-permament memory mode.
@@ -47,7 +50,6 @@ Returns:
--*/
{
PEI_CORE_INSTANCE *PrivateData;
- UINT64 SizeOfCarHeap;
PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS (PeiServices);
PrivateData->SwitchStackSignal = FALSE;
@@ -56,18 +58,12 @@ Returns:
PrivateData->PeiMemoryInstalled = FALSE;
- PrivateData->BottomOfCarHeap = (VOID *) (((UINTN)(VOID *)(&PrivateData))
- & (~((PeiStartupDescriptor->SizeOfCacheAsRam) - 1)));
- PrivateData->TopOfCarHeap = (VOID *)((UINTN)(PrivateData->BottomOfCarHeap) + PeiStartupDescriptor->SizeOfCacheAsRam);
- //
- // SizeOfCarHeap is 1/2 (arbitrary) of CacheAsRam Size.
- //
- SizeOfCarHeap = (UINT64) PeiStartupDescriptor->SizeOfCacheAsRam;
- SizeOfCarHeap = RShiftU64 (SizeOfCarHeap, 1);
+ PrivateData->BottomOfCarHeap = SecCoreData->PeiTemporaryRamBase;
+ PrivateData->TopOfCarHeap = (VOID *)((UINTN)(PrivateData->BottomOfCarHeap) + SecCoreData->PeiTemporaryRamSize);
DEBUG_CODE_BEGIN ();
- PrivateData->SizeOfCacheAsRam = PeiStartupDescriptor->SizeOfCacheAsRam;
- PrivateData->MaxTopOfCarHeap = (VOID *) ((UINTN) PrivateData->BottomOfCarHeap + (UINTN) SizeOfCarHeap);
+ PrivateData->SizeOfCacheAsRam = SecCoreData->PeiTemporaryRamSize + SecCoreData->StackSize;
+ PrivateData->MaxTopOfCarHeap = (VOID *) ((UINTN) PrivateData->BottomOfCarHeap + (UINTN) PrivateData->SizeOfCacheAsRam);
DEBUG_CODE_END ();
PrivateData->HobList.Raw = PrivateData->BottomOfCarHeap;
@@ -75,7 +71,7 @@ Returns:
PeiCoreBuildHobHandoffInfoTable (
BOOT_WITH_FULL_CONFIGURATION,
(EFI_PHYSICAL_ADDRESS) (UINTN) PrivateData->BottomOfCarHeap,
- (UINTN) SizeOfCarHeap
+ (UINTN) SecCoreData->PeiTemporaryRamSize
);
//
// Copy PeiServices from ROM to Cache in PrivateData
diff --git a/MdeModulePkg/Core/Pei/PeiMain.h b/MdeModulePkg/Core/Pei/PeiMain.h
index 9e0d7a8530..b4d2462116 100644
--- a/MdeModulePkg/Core/Pei/PeiMain.h
+++ b/MdeModulePkg/Core/Pei/PeiMain.h
@@ -177,8 +177,9 @@ typedef union {
EFI_STATUS
EFIAPI
PeiCore (
- IN EFI_PEI_STARTUP_DESCRIPTOR *PeiStartupDescriptor,
- IN VOID *Data
+ IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData,
+ IN CONST EFI_PEI_PPI_DESCRIPTOR *PpList,
+ IN VOID *Data
)
/*++
@@ -248,7 +249,7 @@ Returns:
EFI_STATUS
PeiDispatcher (
- IN EFI_PEI_STARTUP_DESCRIPTOR *PeiStartupDescriptor,
+ IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData,
IN PEI_CORE_INSTANCE *PrivateData,
IN PEI_CORE_DISPATCH_DATA *DispatchData
)
@@ -278,7 +279,7 @@ VOID
InitializeDispatcherData (
IN EFI_PEI_SERVICES **PeiServices,
IN PEI_CORE_INSTANCE *OldCoreData,
- IN EFI_PEI_STARTUP_DESCRIPTOR *PeiStartupDescriptor
+ IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData
)
/*++
@@ -956,7 +957,7 @@ Returns:
VOID
InitializeMemoryServices (
IN EFI_PEI_SERVICES **PeiServices,
- IN EFI_PEI_STARTUP_DESCRIPTOR *PeiStartupDescriptor,
+ IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData,
IN PEI_CORE_INSTANCE *OldCoreData
)
/*++
@@ -1208,6 +1209,7 @@ PeiSwitchStacks (
IN SWITCH_STACK_ENTRY_POINT EntryPoint,
IN VOID *Context1, OPTIONAL
IN VOID *Context2, OPTIONAL
+ IN VOID *Context3, OPTIONAL
IN VOID *NewStack,
IN VOID *NewBsp
);
diff --git a/MdeModulePkg/Core/Pei/PeiMain.inf b/MdeModulePkg/Core/Pei/PeiMain.inf
index 245e979bd6..df9ca825c7 100644
--- a/MdeModulePkg/Core/Pei/PeiMain.inf
+++ b/MdeModulePkg/Core/Pei/PeiMain.inf
@@ -59,6 +59,8 @@
Ipf/IpfCpuCore.s
Ipf/IpfCpuCore.i
Ipf/SwitchToCacheMode.c
+ Ipf/InternalSwitchStack.c
+ Ipf/SwitchStack.s
[Sources.EBC]
Dispatcher/Stack.c
@@ -77,7 +79,7 @@
PerformanceLib
HobLib
BaseLib
- OldPeiCoreEntryPoint
+ PeiCoreEntryPoint
DebugLib
[Guids]
diff --git a/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c b/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c
index b2f7807479..a7944e130c 100644
--- a/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c
+++ b/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c
@@ -81,8 +81,9 @@ static EFI_PEI_SERVICES mPS = {
EFI_STATUS
EFIAPI
PeiCore (
- IN EFI_PEI_STARTUP_DESCRIPTOR *PeiStartupDescriptor,
- IN VOID *Data
+ IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData,
+ IN CONST EFI_PEI_PPI_DESCRIPTOR *PpList,
+ IN VOID *Data
)
/*++
@@ -94,8 +95,16 @@ Routine Description:
Arguments:
- PeiStartupDescriptor - Information and services provided by SEC phase.
- OldCoreData - Pointer to old core data that is used to initialize the
+ 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.
+ 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
+ Data - Pointer to old core data that is used to initialize the
core's data areas.
Returns:
@@ -142,13 +151,13 @@ Returns:
//
ProcessLibraryConstructorList (NULL, &PrivateData.PS);
- InitializeMemoryServices (&PrivateData.PS, PeiStartupDescriptor, OldCoreData);
+ InitializeMemoryServices (&PrivateData.PS, SecCoreData, OldCoreData);
InitializePpiServices (&PrivateData.PS, OldCoreData);
InitializeSecurityServices (&PrivateData.PS, OldCoreData);
- InitializeDispatcherData (&PrivateData.PS, OldCoreData, PeiStartupDescriptor);
+ InitializeDispatcherData (&PrivateData.PS, OldCoreData, SecCoreData);
if (OldCoreData != NULL) {
@@ -210,8 +219,8 @@ Returns:
//
// If SEC provided any PPI services to PEI, install them.
//
- if (PeiStartupDescriptor->DispatchTable != NULL) {
- Status = PeiServicesInstallPpi (PeiStartupDescriptor->DispatchTable);
+ if (PpList != NULL) {
+ Status = PeiServicesInstallPpi (PpList);
ASSERT_EFI_ERROR (Status);
}
}
@@ -221,7 +230,7 @@ Returns:
//
// Call PEIM dispatcher
//
- PeiDispatcher (PeiStartupDescriptor, &PrivateData, DispatchData);
+ PeiDispatcher (SecCoreData, &PrivateData, DispatchData);
//
// Check if InstallPeiMemory service was called.
diff --git a/Nt32Pkg/Sec/SecMain.c b/Nt32Pkg/Sec/SecMain.c
index ab66dfc52c..a1ab3f20ef 100644
--- a/Nt32Pkg/Sec/SecMain.c
+++ b/Nt32Pkg/Sec/SecMain.c
@@ -484,6 +484,63 @@ Returns:
return EFI_SUCCESS;
}
+/**
+ Transfers control to a function starting with a new stack.
+
+ Transfers control to the function specified by EntryPoint using the new stack
+ specified by NewStack and passing in the parameters specified by Context1 and
+ Context2. Context1 and Context2 are optional and may be NULL. The function
+ EntryPoint must never return.
+
+ If EntryPoint is NULL, then ASSERT().
+ If NewStack is NULL, then ASSERT().
+
+ @param EntryPoint A pointer to function to call with the new stack.
+ @param Context1 A pointer to the context to pass into the EntryPoint
+ function.
+ @param Context2 A pointer to the context to pass into the EntryPoint
+ function.
+ @param NewStack A pointer to the new stack to use for the EntryPoint
+ function.
+ @param NewBsp A pointer to the new BSP for the EntryPoint on IPF. It's
+ Reserved on other architectures.
+
+**/
+VOID
+EFIAPI
+PeiSwitchStacks (
+ IN SWITCH_STACK_ENTRY_POINT EntryPoint,
+ IN VOID *Context1, OPTIONAL
+ IN VOID *Context2, OPTIONAL
+ IN VOID *Context3, OPTIONAL
+ IN VOID *NewStack
+ )
+{
+ BASE_LIBRARY_JUMP_BUFFER JumpBuffer;
+
+ ASSERT (EntryPoint != NULL);
+ ASSERT (NewStack != NULL);
+
+ //
+ // Stack should be aligned with CPU_STACK_ALIGNMENT
+ //
+ ASSERT (((UINTN)NewStack & (CPU_STACK_ALIGNMENT - 1)) == 0);
+
+ JumpBuffer.Eip = (UINTN)EntryPoint;
+ JumpBuffer.Esp = (UINTN)NewStack - sizeof (VOID*);
+ JumpBuffer.Esp -= sizeof (Context1) + sizeof (Context2) + sizeof(Context3);
+ ((VOID**)JumpBuffer.Esp)[1] = Context1;
+ ((VOID**)JumpBuffer.Esp)[2] = Context2;
+ ((VOID**)JumpBuffer.Esp)[3] = Context3;
+
+ LongJump (&JumpBuffer, (UINTN)-1);
+
+
+ //
+ // InternalSwitchStack () will never return
+ //
+ ASSERT (FALSE);
+}
VOID
SecLoadFromCore (
@@ -514,7 +571,7 @@ Returns:
UINT64 PeiCoreSize;
EFI_PHYSICAL_ADDRESS PeiCoreEntryPoint;
EFI_PHYSICAL_ADDRESS PeiImageAddress;
- EFI_PEI_STARTUP_DESCRIPTOR *PeiStartup;
+ EFI_SEC_PEI_HAND_OFF *SecCoreData;
//
// Compute Top Of Memory for Stack and PEI Core Allocations
@@ -524,7 +581,7 @@ Returns:
//
// Allocate 128KB for the Stack
//
- TopOfStack = (VOID *)((UINTN)TopOfMemory - sizeof (EFI_PEI_STARTUP_DESCRIPTOR) - CPU_STACK_ALIGNMENT);
+ TopOfStack = (VOID *)((UINTN)TopOfMemory - sizeof (EFI_SEC_PEI_HAND_OFF) - CPU_STACK_ALIGNMENT);
TopOfStack = ALIGN_POINTER (TopOfStack, CPU_STACK_ALIGNMENT);
TopOfMemory = TopOfMemory - STACK_SIZE;
@@ -536,10 +593,16 @@ Returns:
//
// Bind this information into the SEC hand-off state
//
- PeiStartup = (EFI_PEI_STARTUP_DESCRIPTOR *) (UINTN) TopOfStack;
- PeiStartup->DispatchTable = (EFI_PEI_PPI_DESCRIPTOR *) &gPrivateDispatchTable;
- PeiStartup->SizeOfCacheAsRam = STACK_SIZE;
- PeiStartup->BootFirmwareVolume = BootFirmwareVolumeBase;
+ SecCoreData = (EFI_SEC_PEI_HAND_OFF*)(UINTN) TopOfStack;
+ SecCoreData->DataSize = sizeof(EFI_SEC_PEI_HAND_OFF);
+ SecCoreData->BootFirmwareVolumeBase = (VOID*)BootFirmwareVolumeBase;
+ SecCoreData->BootFirmwareVolumeSize = FixedPcdGet32(PcdWinNtFirmwareFdSize);
+ SecCoreData->TemporaryRamBase = (VOID*)(UINTN)TopOfMemory;
+ SecCoreData->TemporaryRamSize = STACK_SIZE;
+ SecCoreData->PeiTemporaryRamBase = SecCoreData->TemporaryRamBase;
+ SecCoreData->PeiTemporaryRamSize = (UINTN)RShiftU64((UINT64)STACK_SIZE,1);
+ SecCoreData->StackBase = (VOID*)((UINTN)SecCoreData->TemporaryRamBase + (UINTN)SecCoreData->TemporaryRamSize);
+ SecCoreData->StackSize = (UINTN)RShiftU64((UINT64)STACK_SIZE,1);
//
// Load the PEI Core from a Firmware Volume
@@ -553,12 +616,14 @@ Returns:
if (EFI_ERROR (Status)) {
return ;
}
+
//
// Transfer control to the PEI Core
//
- SwitchStack (
+ PeiSwitchStacks (
(SWITCH_STACK_ENTRY_POINT) (UINTN) PeiCoreEntryPoint,
- PeiStartup,
+ SecCoreData,
+ (VOID *) (UINTN) ((EFI_PEI_PPI_DESCRIPTOR *) &gPrivateDispatchTable),
NULL,
TopOfStack
);
diff --git a/Nt32Pkg/Sec/SecMain.inf b/Nt32Pkg/Sec/SecMain.inf
index db891436e2..170e87188d 100644
--- a/Nt32Pkg/Sec/SecMain.inf
+++ b/Nt32Pkg/Sec/SecMain.inf
@@ -68,6 +68,9 @@
#gEfiNt32PkgTokenSpaceGuid.PcdWinNtMemorySizeForSecMain
#gEfiNt32PkgTokenSpaceGuid.PcdWinNtFirmwareVolume
+[FixedPcd.common]
+ gEfiNt32PkgTokenSpaceGuid.PcdWinNtFirmwareFdSize
+
[BuildOptions.common]
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
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