mirror of https://github.com/acidanthera/audk.git
ArmPlatformPkg/PrePeiCore: Reverse Stack & PeiTemporary
To get the global variable at top of the Primary Stack such as in the Pei module. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12421 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
8fc38a3f50
commit
93d451c67b
|
@ -84,8 +84,8 @@ PrimaryMain (
|
|||
SecCoreData.TemporaryRamSize = (UINTN)(UINTN)PcdGet32 (PcdCPUCorePrimaryStackSize);
|
||||
SecCoreData.PeiTemporaryRamBase = (VOID *)((UINTN)(SecCoreData.TemporaryRamBase) + (SecCoreData.TemporaryRamSize / 2));
|
||||
SecCoreData.PeiTemporaryRamSize = SecCoreData.TemporaryRamSize / 2;
|
||||
SecCoreData.StackBase = SecCoreData.TemporaryRamBase;
|
||||
SecCoreData.StackSize = SecCoreData.TemporaryRamSize - SecCoreData.PeiTemporaryRamSize;
|
||||
SecCoreData.StackBase = (VOID *)((UINTN)(SecCoreData.TemporaryRamBase) + (SecCoreData.TemporaryRamSize/2));
|
||||
SecCoreData.StackSize = SecCoreData.TemporaryRamSize / 2;
|
||||
|
||||
// Jump to PEI core entry point
|
||||
(PeiCoreEntryPoint)(&SecCoreData, (VOID *)&gSecPpiTable);
|
||||
|
|
|
@ -46,8 +46,8 @@ PrimaryMain (
|
|||
SecCoreData.TemporaryRamSize = (UINTN)(UINTN)PcdGet32 (PcdCPUCorePrimaryStackSize);
|
||||
SecCoreData.PeiTemporaryRamBase = (VOID *)((UINTN)(SecCoreData.TemporaryRamBase) + (SecCoreData.TemporaryRamSize / 2));
|
||||
SecCoreData.PeiTemporaryRamSize = SecCoreData.TemporaryRamSize / 2;
|
||||
SecCoreData.StackBase = SecCoreData.TemporaryRamBase;
|
||||
SecCoreData.StackSize = SecCoreData.TemporaryRamSize - SecCoreData.PeiTemporaryRamSize;
|
||||
SecCoreData.StackBase = (VOID *)((UINTN)(SecCoreData.TemporaryRamBase) + (SecCoreData.TemporaryRamSize/2));
|
||||
SecCoreData.StackSize = SecCoreData.TemporaryRamSize / 2;
|
||||
|
||||
// jump to pei core entry point
|
||||
(PeiCoreEntryPoint)(&SecCoreData, (VOID *)&gSecPpiTable);
|
||||
|
|
|
@ -24,14 +24,14 @@
|
|||
|
||||
#include "PrePeiCore.h"
|
||||
|
||||
EFI_PEI_TEMPORARY_RAM_SUPPORT_PPI mSecTemporaryRamSupportPpi = {SecTemporaryRamSupport};
|
||||
EFI_PEI_TEMPORARY_RAM_SUPPORT_PPI mTemporaryRamSupportPpi = { PrePeiCoreTemporaryRamSupport };
|
||||
ARM_GLOBAL_VARIABLE_PPI mGlobalVariablePpi = { PrePeiCoreGetGlobalVariableMemory };
|
||||
|
||||
EFI_PEI_PPI_DESCRIPTOR gCommonPpiTable[] = {
|
||||
{
|
||||
EFI_PEI_PPI_DESCRIPTOR_PPI,
|
||||
&gEfiTemporaryRamSupportPpiGuid,
|
||||
&mSecTemporaryRamSupportPpi
|
||||
&mTemporaryRamSupportPpi
|
||||
},
|
||||
{
|
||||
EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,
|
||||
|
@ -85,23 +85,38 @@ CEntryPoint (
|
|||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
SecTemporaryRamSupport (
|
||||
PrePeiCoreTemporaryRamSupport (
|
||||
IN CONST EFI_PEI_SERVICES **PeiServices,
|
||||
IN EFI_PHYSICAL_ADDRESS TemporaryMemoryBase,
|
||||
IN EFI_PHYSICAL_ADDRESS PermanentMemoryBase,
|
||||
IN UINTN CopySize
|
||||
)
|
||||
{
|
||||
//
|
||||
// Migrate the whole temporary memory to permenent memory.
|
||||
//
|
||||
CopyMem (
|
||||
(VOID*)(UINTN)PermanentMemoryBase,
|
||||
(VOID*)(UINTN)TemporaryMemoryBase,
|
||||
CopySize
|
||||
);
|
||||
VOID *OldHeap;
|
||||
VOID *NewHeap;
|
||||
VOID *OldStack;
|
||||
VOID *NewStack;
|
||||
|
||||
SecSwitchStack((UINTN)(PermanentMemoryBase - TemporaryMemoryBase));
|
||||
OldHeap = (VOID*)(UINTN)TemporaryMemoryBase;
|
||||
NewHeap = (VOID*)((UINTN)PermanentMemoryBase + (CopySize >> 1));
|
||||
|
||||
OldStack = (VOID*)((UINTN)TemporaryMemoryBase + (CopySize >> 1));
|
||||
NewStack = (VOID*)(UINTN)PermanentMemoryBase;
|
||||
|
||||
//
|
||||
// Migrate the temporary memory stack to permanent memory stack.
|
||||
//
|
||||
CopyMem (NewStack, OldStack, CopySize >> 1);
|
||||
|
||||
//
|
||||
// Migrate the temporary memory heap to permanent memory heap.
|
||||
//
|
||||
CopyMem (NewHeap, OldHeap, CopySize >> 1);
|
||||
|
||||
SecSwitchStack ((UINTN)NewStack - (UINTN)OldStack);
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
PrePeiCoreGetGlobalVariableMemory (
|
||||
|
|
Loading…
Reference in New Issue