// When the firmware is built as not Standalone, the secondary cores need to wait the firmware // entirely written into DRAM. It is the firmware from DRAM which will wake up the secondary cores. VOID NonSecureWaitForFirmware ( VOID ) { VOID (*secondary_start)(VOID); // The secondary cores will execute the firmware once wake from WFI. secondary_start = (VOID (*)())PcdGet32(PcdFvBaseAddress); ArmCallWFI(); // Acknowledge the interrupt and send End of Interrupt signal. ArmGicAcknowledgeInterrupt (PcdGet32(PcdGicDistributorBase), PcdGet32(PcdGicInterruptInterfaceBase), NULL, NULL); // Jump to secondary core entry point. secondary_start (); // PEI Core should always load and never return ASSERT (FALSE); }
/* * This is the main function for secondary cores. They loop around until a non Null value is written to * SYS_FLAGS register.The SYS_FLAGS register is platform specific. * Note:The secondary cores, while executing secondary_main, assumes that: * : SGI 0 is configured as Non-secure interrupt * : Priority Mask is configured to allow SGI 0 * : Interrupt Distributor and CPU interfaces are enabled * */ VOID EFIAPI SecondaryMain ( IN UINTN MpId ) { EFI_STATUS Status; UINTN PpiListSize; UINTN PpiListCount; EFI_PEI_PPI_DESCRIPTOR *PpiList; ARM_MP_CORE_INFO_PPI *ArmMpCoreInfoPpi; UINTN Index; UINTN ArmCoreCount; ARM_CORE_INFO *ArmCoreInfoTable; UINT32 ClusterId; UINT32 CoreId; VOID (*SecondaryStart)(VOID); UINTN SecondaryEntryAddr; UINTN AcknowledgeInterrupt; UINTN InterruptId; ClusterId = GET_CLUSTER_ID(MpId); CoreId = GET_CORE_ID(MpId); // Get the gArmMpCoreInfoPpiGuid PpiListSize = 0; ArmPlatformGetPlatformPpiList (&PpiListSize, &PpiList); PpiListCount = PpiListSize / sizeof(EFI_PEI_PPI_DESCRIPTOR); for (Index = 0; Index < PpiListCount; Index++, PpiList++) { if (CompareGuid (PpiList->Guid, &gArmMpCoreInfoPpiGuid) == TRUE) { break; } } // On MP Core Platform we must implement the ARM MP Core Info PPI ASSERT (Index != PpiListCount); ArmMpCoreInfoPpi = PpiList->Ppi; ArmCoreCount = 0; Status = ArmMpCoreInfoPpi->GetMpCoreInfo (&ArmCoreCount, &ArmCoreInfoTable); ASSERT_EFI_ERROR (Status); // Find the core in the ArmCoreTable for (Index = 0; Index < ArmCoreCount; Index++) { if ((ArmCoreInfoTable[Index].ClusterId == ClusterId) && (ArmCoreInfoTable[Index].CoreId == CoreId)) { break; } } // The ARM Core Info Table must define every core ASSERT (Index != ArmCoreCount); // Clear Secondary cores MailBox MmioWrite32 (ArmCoreInfoTable[Index].MailboxClearAddress, ArmCoreInfoTable[Index].MailboxClearValue); do { ArmCallWFI (); // Read the Mailbox SecondaryEntryAddr = MmioRead32 (ArmCoreInfoTable[Index].MailboxGetAddress); // Acknowledge the interrupt and send End of Interrupt signal. AcknowledgeInterrupt = ArmGicAcknowledgeInterrupt (PcdGet32 (PcdGicInterruptInterfaceBase), &InterruptId); // Check if it is a valid interrupt ID if (InterruptId < ArmGicGetMaxNumInterrupts (PcdGet32 (PcdGicDistributorBase))) { // Got a valid SGI number hence signal End of Interrupt ArmGicEndOfInterrupt (PcdGet32 (PcdGicInterruptInterfaceBase), AcknowledgeInterrupt); } } while (SecondaryEntryAddr == 0); // Jump to secondary core entry point. SecondaryStart = (VOID (*)())SecondaryEntryAddr; SecondaryStart(); // The secondaries shouldn't reach here ASSERT(FALSE); }