3 Copyright (c) 2011-2014, ARM Limited. All rights reserved.
5 SPDX-License-Identifier: BSD-2-Clause-Patent
11 #include <Library/ArmGicLib.h>
13 #include <Ppi/ArmMpCoreInfo.h>
17 IN UINTN UefiMemoryBase
,
19 IN UINT64 StartTimeStamp
22 // Enable the GIC Distributor
23 ArmGicEnableDistributor (PcdGet64 (PcdGicDistributorBase
));
25 // In some cases, the secondary cores are waiting for an SGI from the next stage boot loader to resume their initialization
26 if (!FixedPcdGet32 (PcdSendSgiToBringUpSecondaryCores
)) {
27 // Sending SGI to all the Secondary CPU interfaces
28 ArmGicSendSgiTo (PcdGet64 (PcdGicDistributorBase
), ARM_GIC_ICDSGIR_FILTER_EVERYONEELSE
, 0x0E, PcdGet32 (PcdGicSgiIntId
));
31 PrePiMain (UefiMemoryBase
, StacksBase
, StartTimeStamp
);
33 // We must never return
43 ARM_MP_CORE_INFO_PPI
*ArmMpCoreInfoPpi
;
46 ARM_CORE_INFO
*ArmCoreInfoTable
;
50 VOID (*SecondaryStart
)(
53 UINTN SecondaryEntryAddr
;
54 UINTN AcknowledgeInterrupt
;
57 ClusterId
= GET_CLUSTER_ID (MpId
);
58 CoreId
= GET_CORE_ID (MpId
);
60 // On MP Core Platform we must implement the ARM MP Core Info PPI (gArmMpCoreInfoPpiGuid)
61 Status
= GetPlatformPpi (&gArmMpCoreInfoPpiGuid
, (VOID
**)&ArmMpCoreInfoPpi
);
62 ASSERT_EFI_ERROR (Status
);
65 Status
= ArmMpCoreInfoPpi
->GetMpCoreInfo (&ArmCoreCount
, &ArmCoreInfoTable
);
66 ASSERT_EFI_ERROR (Status
);
68 // Find the core in the ArmCoreTable
69 for (Index
= 0; Index
< ArmCoreCount
; Index
++) {
70 if ((ArmCoreInfoTable
[Index
].ClusterId
== ClusterId
) && (ArmCoreInfoTable
[Index
].CoreId
== CoreId
)) {
75 // The ARM Core Info Table must define every core
76 ASSERT (Index
!= ArmCoreCount
);
78 // Clear Secondary cores MailBox
79 MmioWrite32 (ArmCoreInfoTable
[Index
].MailboxClearAddress
, ArmCoreInfoTable
[Index
].MailboxClearValue
);
85 SecondaryEntryAddr
= MmioRead32 (ArmCoreInfoTable
[Index
].MailboxGetAddress
);
87 // Acknowledge the interrupt and send End of Interrupt signal.
88 AcknowledgeInterrupt
= ArmGicAcknowledgeInterrupt (PcdGet64 (PcdGicInterruptInterfaceBase
), &InterruptId
);
89 // Check if it is a valid interrupt ID
90 if (InterruptId
< ArmGicGetMaxNumInterrupts (PcdGet64 (PcdGicDistributorBase
))) {
91 // Got a valid SGI number hence signal End of Interrupt
92 ArmGicEndOfInterrupt (PcdGet64 (PcdGicInterruptInterfaceBase
), AcknowledgeInterrupt
);
94 } while (SecondaryEntryAddr
== 0);
96 // Jump to secondary core entry point.
97 SecondaryStart
= (VOID (*)()) SecondaryEntryAddr
;
100 // The secondaries shouldn't reach here