EFI_STATUS PreparePlatformHardware ( VOID ) { //Note: Interrupts will be disabled by the GIC driver when ExitBootServices() will be called. // Clean before Disable else the Stack gets corrupted with old data. ArmCleanDataCache (); LlcCleanInvalidate (); ArmDisableDataCache (); // Invalidate all the entries that might have snuck in. ArmInvalidateDataCache (); // Disable and invalidate the instruction cache ArmDisableInstructionCache (); ArmInvalidateInstructionCache (); // Turn off MMU ArmDisableMmu(); return EFI_SUCCESS; }
VOID CEntryPoint ( IN UINTN MpId, IN UINTN UefiMemoryBase, IN UINTN StacksBase ) { UINT64 StartTimeStamp; // Initialize the platform specific controllers ArmPlatformInitialize (MpId); if (PerformanceMeasurementEnabled ()) { // Initialize the Timer Library to setup the Timer HW controller TimerConstructor (); // We cannot call yet the PerformanceLib because the HOB List has not been initialized StartTimeStamp = GetPerformanceCounter (); } else { StartTimeStamp = 0; } // Data Cache enabled on Primary core when MMU is enabled. ArmDisableDataCache (); // Invalidate instruction cache ArmInvalidateInstructionCache (); // Enable Instruction Caches on all cores. ArmEnableInstructionCache (); PrePiMain (UefiMemoryBase, StacksBase, StartTimeStamp); // DXE Core should always load and never return ASSERT (FALSE); }
VOID ShutdownEfi ( VOID ) { EFI_STATUS Status; UINTN MemoryMapSize; EFI_MEMORY_DESCRIPTOR *MemoryMap; UINTN MapKey; UINTN DescriptorSize; UINTN DescriptorVersion; UINTN Pages; MemoryMap = NULL; MemoryMapSize = 0; do { Status = gBS->GetMemoryMap ( &MemoryMapSize, MemoryMap, &MapKey, &DescriptorSize, &DescriptorVersion ); if (Status == EFI_BUFFER_TOO_SMALL) { Pages = EFI_SIZE_TO_PAGES (MemoryMapSize) + 1; MemoryMap = AllocatePages (Pages); // // Get System MemoryMap // Status = gBS->GetMemoryMap ( &MemoryMapSize, MemoryMap, &MapKey, &DescriptorSize, &DescriptorVersion ); // Don't do anything between the GetMemoryMap() and ExitBootServices() if (!EFI_ERROR (Status)) { Status = gBS->ExitBootServices (gImageHandle, MapKey); if (EFI_ERROR (Status)) { FreePages (MemoryMap, Pages); MemoryMap = NULL; MemoryMapSize = 0; } } } } while (EFI_ERROR (Status)); //Clean and invalidate caches. WriteBackInvalidateDataCache(); InvalidateInstructionCache(); //Turning off Caches and MMU ArmDisableDataCache (); ArmDisableInstructionCache (); ArmDisableMmu (); }
VOID CEntryPoint ( IN UINTN MpId, IN UINTN UefiMemoryBase, IN UINTN StacksBase, IN UINTN GlobalVariableBase ) { UINT64 StartTimeStamp; ASSERT(!ArmIsMpCore() || (PcdGet32 (PcdCoreCount) > 1)); // Initialize the platform specific controllers ArmPlatformInitialize (MpId); if (ArmPlatformIsPrimaryCore (MpId) && PerformanceMeasurementEnabled ()) { // Initialize the Timer Library to setup the Timer HW controller TimerConstructor (); // We cannot call yet the PerformanceLib because the HOB List has not been initialized StartTimeStamp = GetPerformanceCounter (); } else { StartTimeStamp = 0; } // Data Cache enabled on Primary core when MMU is enabled. ArmDisableDataCache (); // Invalidate Data cache ArmInvalidateDataCache (); // Invalidate instruction cache ArmInvalidateInstructionCache (); // Enable Instruction Caches on all cores. ArmEnableInstructionCache (); // Define the Global Variable region when we are not running in XIP if (!IS_XIP()) { if (ArmPlatformIsPrimaryCore (MpId)) { mGlobalVariableBase = GlobalVariableBase; if (ArmIsMpCore()) { // Signal the Global Variable Region is defined (event: ARM_CPU_EVENT_DEFAULT) ArmCallSEV (); } } else { // Wait the Primay core has defined the address of the Global Variable region (event: ARM_CPU_EVENT_DEFAULT) ArmCallWFE (); } } // If not primary Jump to Secondary Main if (ArmPlatformIsPrimaryCore (MpId)) { // Goto primary Main. PrimaryMain (UefiMemoryBase, StacksBase, GlobalVariableBase, StartTimeStamp); } else { SecondaryMain (MpId); } // DXE Core should always load and never return ASSERT (FALSE); }
VOID CEntryPoint ( IN UINTN MpId, IN EFI_PEI_CORE_ENTRY_POINT PeiCoreEntryPoint ) { // Data Cache enabled on Primary core when MMU is enabled. ArmDisableDataCache (); // Invalidate Data cache ArmInvalidateDataCache (); // Invalidate instruction cache ArmInvalidateInstructionCache (); // Enable Instruction Caches on all cores. ArmEnableInstructionCache (); // // Note: Doesn't have to Enable CPU interface in non-secure world, // as Non-secure interface is already enabled in Secure world. // // Write VBAR - The Exception Vector table must be aligned to its requirement // Note: The AArch64 Vector table must be 2k-byte aligned - if this assertion fails ensure // 'Align=4K' is defined into your FDF for this module. ASSERT (((UINTN)PeiVectorTable & ARM_VECTOR_TABLE_ALIGNMENT) == 0); ArmWriteVBar ((UINTN)PeiVectorTable); //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 (ArmPlatformIsPrimaryCore (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 (MpId); } // PEI Core should always load and never return ASSERT (FALSE); }