mirror of https://github.com/acidanthera/audk.git
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
This commit is contained in:
parent
a81a35fe2a
commit
b98c2ab738
|
@ -29,6 +29,13 @@ TransferOldDataToNewDataRange (
|
||||||
IN PEI_CORE_INSTANCE *PrivateData
|
IN PEI_CORE_INSTANCE *PrivateData
|
||||||
);
|
);
|
||||||
|
|
||||||
|
STATIC
|
||||||
|
VOID
|
||||||
|
InvokePeiCore (
|
||||||
|
VOID *Context1,
|
||||||
|
VOID *Context2
|
||||||
|
);
|
||||||
|
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
PeiDispatcher (
|
PeiDispatcher (
|
||||||
IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData,
|
IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData,
|
||||||
|
@ -59,11 +66,12 @@ Returns:
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
PEI_CORE_TEMP_POINTERS TempPtr;
|
PEI_CORE_TEMP_POINTERS TempPtr;
|
||||||
UINTN PrivateDataInMem;
|
|
||||||
BOOLEAN NextFvFound;
|
BOOLEAN NextFvFound;
|
||||||
EFI_FIRMWARE_VOLUME_HEADER *NextFvAddress;
|
EFI_FIRMWARE_VOLUME_HEADER *NextFvAddress;
|
||||||
EFI_FIRMWARE_VOLUME_HEADER *DefaultFvAddress;
|
EFI_FIRMWARE_VOLUME_HEADER *DefaultFvAddress;
|
||||||
VOID *TopOfStack;
|
VOID *TopOfStack;
|
||||||
|
PEI_CORE_PARAMETERS PeiCoreParameters;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Debug data for uninstalled Peim list
|
// Debug data for uninstalled Peim list
|
||||||
//
|
//
|
||||||
|
@ -205,20 +213,21 @@ Returns:
|
||||||
// nobody else should have any data on the stack.
|
// nobody else should have any data on the stack.
|
||||||
//
|
//
|
||||||
if (PrivateData->SwitchStackSignal) {
|
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
|
// Adjust the top of stack to be aligned at CPU_STACK_ALIGNMENT
|
||||||
//
|
//
|
||||||
TopOfStack = (VOID *)((UINTN)PrivateData->StackBase + (UINTN)PrivateData->StackSize - CPU_STACK_ALIGNMENT);
|
TopOfStack = (VOID *)((UINTN)PrivateData->StackBase + (UINTN)PrivateData->StackSize - CPU_STACK_ALIGNMENT);
|
||||||
TopOfStack = ALIGN_POINTER (TopOfStack, 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 (
|
PeiSwitchStacks (
|
||||||
(SWITCH_STACK_ENTRY_POINT)(UINTN)TempPtr.Raw,
|
InvokePeiCore,
|
||||||
(VOID*) SecCoreData,
|
(VOID*) (UINTN) PeiCore,
|
||||||
NULL,
|
(VOID*) &PeiCoreParameters,
|
||||||
(VOID*)PrivateDataInMem,
|
|
||||||
TopOfStack,
|
TopOfStack,
|
||||||
(VOID*)(UINTN)PrivateData->StackBase
|
(VOID*)(UINTN)PrivateData->StackBase
|
||||||
);
|
);
|
||||||
|
@ -580,4 +589,45 @@ PeiRegisterForShadow (
|
||||||
return EFI_SUCCESS;
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -47,33 +47,9 @@ PeiSwitchStacks (
|
||||||
IN SWITCH_STACK_ENTRY_POINT EntryPoint,
|
IN SWITCH_STACK_ENTRY_POINT EntryPoint,
|
||||||
IN VOID *Context1, OPTIONAL
|
IN VOID *Context1, OPTIONAL
|
||||||
IN VOID *Context2, OPTIONAL
|
IN VOID *Context2, OPTIONAL
|
||||||
IN VOID *Context3, OPTIONAL
|
|
||||||
IN VOID *NewStack,
|
IN VOID *NewStack,
|
||||||
IN VOID *NewBsp
|
IN VOID *NewBsp
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
BASE_LIBRARY_JUMP_BUFFER JumpBuffer;
|
SwitchStack (EntryPoint, Context1, Context2, NewStack);
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,17 +16,6 @@
|
||||||
|
|
||||||
#include <PeiMain.h>
|
#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.
|
Transfers control to a function starting with a new stack.
|
||||||
|
|
||||||
|
@ -55,18 +44,15 @@ PeiSwitchStacks (
|
||||||
IN SWITCH_STACK_ENTRY_POINT EntryPoint,
|
IN SWITCH_STACK_ENTRY_POINT EntryPoint,
|
||||||
IN VOID *Context1, OPTIONAL
|
IN VOID *Context1, OPTIONAL
|
||||||
IN VOID *Context2, OPTIONAL
|
IN VOID *Context2, OPTIONAL
|
||||||
IN VOID *Context3, OPTIONAL
|
|
||||||
IN VOID *NewStack,
|
IN VOID *NewStack,
|
||||||
IN VOID *NewBsp
|
IN VOID *NewBsp
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
InternalSwitchStack(
|
SwitchStack (
|
||||||
EntryPoint,
|
EntryPoint,
|
||||||
Context1,
|
Context1,
|
||||||
Context2,
|
Context2,
|
||||||
Context3,
|
|
||||||
NewStack,
|
NewStack,
|
||||||
NewBsp
|
NewBsp
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
|
|
@ -153,8 +153,9 @@ typedef struct{
|
||||||
typedef
|
typedef
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
(EFIAPI *PEI_CORE_ENTRY_POINT)(
|
(EFIAPI *PEI_CORE_ENTRY_POINT)(
|
||||||
IN EFI_PEI_STARTUP_DESCRIPTOR *PeiStartupDescriptor,
|
IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData,
|
||||||
IN PEI_CORE_INSTANCE *OldCoreData
|
IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList,
|
||||||
|
IN PEI_CORE_INSTANCE *OldCoreData
|
||||||
);
|
);
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -171,6 +172,13 @@ typedef union {
|
||||||
} PEI_CORE_TEMP_POINTERS;
|
} 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
|
// PeiCore function
|
||||||
//
|
//
|
||||||
|
@ -1209,7 +1217,6 @@ PeiSwitchStacks (
|
||||||
IN SWITCH_STACK_ENTRY_POINT EntryPoint,
|
IN SWITCH_STACK_ENTRY_POINT EntryPoint,
|
||||||
IN VOID *Context1, OPTIONAL
|
IN VOID *Context1, OPTIONAL
|
||||||
IN VOID *Context2, OPTIONAL
|
IN VOID *Context2, OPTIONAL
|
||||||
IN VOID *Context3, OPTIONAL
|
|
||||||
IN VOID *NewStack,
|
IN VOID *NewStack,
|
||||||
IN VOID *NewBsp
|
IN VOID *NewBsp
|
||||||
);
|
);
|
||||||
|
|
|
@ -60,7 +60,6 @@
|
||||||
Ipf/IpfCpuCore.i
|
Ipf/IpfCpuCore.i
|
||||||
Ipf/SwitchToCacheMode.c
|
Ipf/SwitchToCacheMode.c
|
||||||
Ipf/InternalSwitchStack.c
|
Ipf/InternalSwitchStack.c
|
||||||
Ipf/SwitchStack.s
|
|
||||||
|
|
||||||
[Sources.EBC]
|
[Sources.EBC]
|
||||||
Dispatcher/Stack.c
|
Dispatcher/Stack.c
|
||||||
|
|
Loading…
Reference in New Issue