X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=ArmPlatformPkg%2FPrePeiCore%2FPrePeiCore.c;h=f1300e0e8c96dd33ae482a615b451ee84eb089bd;hp=ccf0e7d3d453be27bf4c479773d811152a716921;hb=f437141a9cf4ce1052566a3b2bf656383f488d4a;hpb=5cc45b70c310f853f28b2351f3d93109ff858dcf diff --git a/ArmPlatformPkg/PrePeiCore/PrePeiCore.c b/ArmPlatformPkg/PrePeiCore/PrePeiCore.c index ccf0e7d3d4..f1300e0e8c 100644 --- a/ArmPlatformPkg/PrePeiCore/PrePeiCore.c +++ b/ArmPlatformPkg/PrePeiCore/PrePeiCore.c @@ -13,29 +13,63 @@ * **/ -#include #include -#include +#include #include #include #include -#include + +#include #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 gSecPpiTable[] = { +EFI_PEI_PPI_DESCRIPTOR gCommonPpiTable[] = { { - EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST, + EFI_PEI_PPI_DESCRIPTOR_PPI, &gEfiTemporaryRamSupportPpiGuid, - &mSecTemporaryRamSupportPpi + &mTemporaryRamSupportPpi + }, + { + EFI_PEI_PPI_DESCRIPTOR_PPI, + &gArmGlobalVariablePpiGuid, + &mGlobalVariablePpi } }; +VOID +CreatePpiList ( + OUT UINTN *PpiListSize, + OUT EFI_PEI_PPI_DESCRIPTOR **PpiList + ) +{ + EFI_PEI_PPI_DESCRIPTOR *PlatformPpiList; + UINTN PlatformPpiListSize; + UINTN ListBase; + EFI_PEI_PPI_DESCRIPTOR *LastPpi; + + // Get the Platform PPIs + PlatformPpiListSize = 0; + ArmPlatformGetPlatformPpiList (&PlatformPpiListSize, &PlatformPpiList); + + // Copy the Common and Platform PPis in Temporrary Memory + ListBase = PcdGet32 (PcdCPUCoresStackBase); + CopyMem ((VOID*)ListBase, gCommonPpiTable, sizeof(gCommonPpiTable)); + CopyMem ((VOID*)(ListBase + sizeof(gCommonPpiTable)), PlatformPpiList, PlatformPpiListSize); + + // Set the Terminate flag on the last PPI entry + LastPpi = (EFI_PEI_PPI_DESCRIPTOR*)ListBase + ((sizeof(gCommonPpiTable) + PlatformPpiListSize) / sizeof(EFI_PEI_PPI_DESCRIPTOR)) - 1; + LastPpi->Flags |= EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST; + + *PpiList = (EFI_PEI_PPI_DESCRIPTOR*)ListBase; + *PpiListSize = sizeof(gCommonPpiTable) + PlatformPpiListSize; +} + VOID CEntryPoint ( - IN UINTN CoreId, + IN UINTN MpId, IN EFI_PEI_CORE_ENTRY_POINT PeiCoreEntryPoint ) { @@ -60,12 +94,19 @@ CEntryPoint ( //Note: The MMU will be enabled by MemoryPeim. Only the primary core will have the MMU on. - //If not primary Jump to Secondary Main - if(0 == CoreId) { - //Goto primary Main. + // If not primary Jump to Secondary Main + if (IS_PRIMARY_CORE(MpId)) { + // Initialize the Debug Agent for Source Level Debugging + InitializeDebugAgent (DEBUG_AGENT_INIT_POSTMEM_SEC, NULL, NULL); + SaveAndSetDebugTimerInterrupt (TRUE); + + // Initialize the platform specific controllers + ArmPlatformInitialize (MpId); + + // Goto primary Main. PrimaryMain (PeiCoreEntryPoint); } else { - SecondaryMain (CoreId); + SecondaryMain (MpId); } // PEI Core should always load and never return @@ -74,23 +115,49 @@ 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 ) { + VOID *OldHeap; + VOID *NewHeap; + VOID *OldStack; + VOID *NewStack; + + 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 whole temporary memory to permenent memory. + // Migrate the temporary memory heap to permanent memory heap. // - CopyMem ( - (VOID*)(UINTN)PermanentMemoryBase, - (VOID*)(UINTN)TemporaryMemoryBase, - CopySize - ); + CopyMem (NewHeap, OldHeap, CopySize >> 1); + + SecSwitchStack ((UINTN)NewStack - (UINTN)OldStack); + + return EFI_SUCCESS; +} + +EFI_STATUS +PrePeiCoreGetGlobalVariableMemory ( + OUT EFI_PHYSICAL_ADDRESS *GlobalVariableBase + ) +{ + ASSERT (GlobalVariableBase != NULL); - SecSwitchStack((UINTN)(PermanentMemoryBase - TemporaryMemoryBase)); + *GlobalVariableBase = (UINTN)PcdGet32 (PcdCPUCoresStackBase) + + (UINTN)PcdGet32 (PcdCPUCorePrimaryStackSize) - + (UINTN)PcdGet32 (PcdPeiGlobalVariableSize); return EFI_SUCCESS; }