PI Enable:

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
This commit is contained in:
klu2 2007-09-12 09:52:37 +00:00
parent 2303536ca1
commit 5aae0aa7d8
12 changed files with 296 additions and 46 deletions

Binary file not shown.

View File

@ -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 {
//

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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
);
}

View File

@ -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

View File

@ -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

View File

@ -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
);

View File

@ -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]

View File

@ -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.

View File

@ -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
);

View File

@ -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