summaryrefslogtreecommitdiff
path: root/MdeModulePkg/Core
diff options
context:
space:
mode:
authorklu2 <klu2@6f19259b-4bc3-4df7-8a09-765794883524>2007-09-14 07:01:26 +0000
committerklu2 <klu2@6f19259b-4bc3-4df7-8a09-765794883524>2007-09-14 07:01:26 +0000
commitb98c2ab738c71c344c7f03ecf885fdd0a4545cdb (patch)
treeee09d37111e65ee7a44a0b0c556c6dfaeaca1735 /MdeModulePkg/Core
parenta81a35fe2a2e51069036b958380ab91575bd8410 (diff)
downloadedk2-platforms-b98c2ab738c71c344c7f03ecf885fdd0a4545cdb.tar.xz
Add InvokePeiCore function to invoke the PeiCore in new stack.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@3844 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdeModulePkg/Core')
-rw-r--r--MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c66
-rw-r--r--MdeModulePkg/Core/Pei/Dispatcher/Stack.c26
-rw-r--r--MdeModulePkg/Core/Pei/Ipf/Stack.c16
-rw-r--r--MdeModulePkg/Core/Pei/Ipf/SwitchStack.s52
-rw-r--r--MdeModulePkg/Core/Pei/PeiMain.h13
-rw-r--r--MdeModulePkg/Core/Pei/PeiMain.inf1
6 files changed, 70 insertions, 104 deletions
diff --git a/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c b/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
index 335fe9fc5d..900e1d2d50 100644
--- a/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
+++ b/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
@@ -29,6 +29,13 @@ TransferOldDataToNewDataRange (
IN PEI_CORE_INSTANCE *PrivateData
);
+STATIC
+VOID
+InvokePeiCore (
+ VOID *Context1,
+ VOID *Context2
+ );
+
EFI_STATUS
PeiDispatcher (
IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData,
@@ -59,11 +66,12 @@ Returns:
{
EFI_STATUS Status;
PEI_CORE_TEMP_POINTERS TempPtr;
- UINTN PrivateDataInMem;
BOOLEAN NextFvFound;
EFI_FIRMWARE_VOLUME_HEADER *NextFvAddress;
EFI_FIRMWARE_VOLUME_HEADER *DefaultFvAddress;
VOID *TopOfStack;
+ PEI_CORE_PARAMETERS PeiCoreParameters;
+
//
// Debug data for uninstalled Peim list
//
@@ -205,20 +213,21 @@ Returns:
// nobody else should have any data on the stack.
//
if (PrivateData->SwitchStackSignal) {
- TempPtr.PeiCore = (PEI_CORE_ENTRY_POINT)PeiCore;
- PrivateDataInMem = (UINTN) TransferOldDataToNewDataRange (PrivateData);
- ASSERT (PrivateDataInMem != 0);
//
// Adjust the top of stack to be aligned at CPU_STACK_ALIGNMENT
//
TopOfStack = (VOID *)((UINTN)PrivateData->StackBase + (UINTN)PrivateData->StackSize - CPU_STACK_ALIGNMENT);
TopOfStack = ALIGN_POINTER (TopOfStack, CPU_STACK_ALIGNMENT);
+
+ PeiCoreParameters.SecCoreData = SecCoreData;
+ PeiCoreParameters.PpiList = NULL;
+ PeiCoreParameters.Data = TransferOldDataToNewDataRange (PrivateData);
+ ASSERT (PeiCoreParameters.Data != 0);
PeiSwitchStacks (
- (SWITCH_STACK_ENTRY_POINT)(UINTN)TempPtr.Raw,
- (VOID*) SecCoreData,
- NULL,
- (VOID*)PrivateDataInMem,
+ InvokePeiCore,
+ (VOID*) (UINTN) PeiCore,
+ (VOID*) &PeiCoreParameters,
TopOfStack,
(VOID*)(UINTN)PrivateData->StackBase
);
@@ -580,4 +589,45 @@ PeiRegisterForShadow (
return EFI_SUCCESS;
}
+/**
+ This routine invoke the PeiCore's entry in new stack environment.
+
+ @param Context1 The first context parameter is entry of PeiCore
+ @param Context2 The second context parameter is parameter structure point for PeiCore
+
+**/
+STATIC
+VOID
+InvokePeiCore (
+ VOID *Context1,
+ VOID *Context2
+ )
+{
+ PEI_CORE_ENTRY_POINT PeiCoreEntryPoint;
+ PEI_CORE_PARAMETERS *PeiCoreParameters;
+
+ //
+ // Running on new stack in SEC Core
+ //
+
+ PeiCoreEntryPoint = (PEI_CORE_ENTRY_POINT) (UINTN) Context1;
+ PeiCoreParameters = (PEI_CORE_PARAMETERS *)Context2;
+
+ //
+ // Call PEI Core using new stack
+ //
+ PeiCoreEntryPoint (
+ PeiCoreParameters->SecCoreData,
+ PeiCoreParameters->PpiList,
+ PeiCoreParameters->Data
+ );
+
+ //
+ // Never returns
+ //
+ ASSERT_EFI_ERROR (FALSE);
+}
+
+
+
diff --git a/MdeModulePkg/Core/Pei/Dispatcher/Stack.c b/MdeModulePkg/Core/Pei/Dispatcher/Stack.c
index 551e23826c..9e74eee587 100644
--- a/MdeModulePkg/Core/Pei/Dispatcher/Stack.c
+++ b/MdeModulePkg/Core/Pei/Dispatcher/Stack.c
@@ -47,33 +47,9 @@ 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
)
{
- 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);
+ SwitchStack (EntryPoint, Context1, Context2, NewStack);
}
diff --git a/MdeModulePkg/Core/Pei/Ipf/Stack.c b/MdeModulePkg/Core/Pei/Ipf/Stack.c
index 7ffdac54c7..56a876df15 100644
--- a/MdeModulePkg/Core/Pei/Ipf/Stack.c
+++ b/MdeModulePkg/Core/Pei/Ipf/Stack.c
@@ -16,17 +16,6 @@
#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.
@@ -55,18 +44,15 @@ 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
)
{
- InternalSwitchStack(
+ SwitchStack (
EntryPoint,
Context1,
Context2,
- Context3,
NewStack,
NewBsp
);
-
}
diff --git a/MdeModulePkg/Core/Pei/Ipf/SwitchStack.s b/MdeModulePkg/Core/Pei/Ipf/SwitchStack.s
deleted file mode 100644
index 2f20703913..0000000000
--- a/MdeModulePkg/Core/Pei/Ipf/SwitchStack.s
+++ /dev/null
@@ -1,52 +0,0 @@
-/// @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/PeiMain.h b/MdeModulePkg/Core/Pei/PeiMain.h
index b4d2462116..50fd40a00e 100644
--- a/MdeModulePkg/Core/Pei/PeiMain.h
+++ b/MdeModulePkg/Core/Pei/PeiMain.h
@@ -153,8 +153,9 @@ typedef struct{
typedef
EFI_STATUS
(EFIAPI *PEI_CORE_ENTRY_POINT)(
- IN EFI_PEI_STARTUP_DESCRIPTOR *PeiStartupDescriptor,
- IN PEI_CORE_INSTANCE *OldCoreData
+ IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData,
+ IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList,
+ IN PEI_CORE_INSTANCE *OldCoreData
);
//
@@ -171,6 +172,13 @@ typedef union {
} PEI_CORE_TEMP_POINTERS;
+
+typedef struct {
+ CONST EFI_SEC_PEI_HAND_OFF *SecCoreData;
+ EFI_PEI_PPI_DESCRIPTOR *PpiList;
+ VOID *Data;
+} PEI_CORE_PARAMETERS;
+
//
// PeiCore function
//
@@ -1209,7 +1217,6 @@ 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 df9ca825c7..b8e188d5fb 100644
--- a/MdeModulePkg/Core/Pei/PeiMain.inf
+++ b/MdeModulePkg/Core/Pei/PeiMain.inf
@@ -60,7 +60,6 @@
Ipf/IpfCpuCore.i
Ipf/SwitchToCacheMode.c
Ipf/InternalSwitchStack.c
- Ipf/SwitchStack.s
[Sources.EBC]
Dispatcher/Stack.c