2011-07-01 13:09:00 +02:00
|
|
|
/** @file
|
|
|
|
*
|
2012-05-02 22:08:03 +02:00
|
|
|
* Copyright (c) 2011-2012, ARM Limited. All rights reserved.
|
2011-07-01 13:09:00 +02:00
|
|
|
*
|
|
|
|
* This program and the accompanying materials
|
|
|
|
* are licensed and made available under the terms and conditions of the BSD License
|
|
|
|
* which accompanies this distribution. The full text of the license may be found at
|
|
|
|
* http://opensource.org/licenses/bsd-license.php
|
|
|
|
*
|
|
|
|
* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|
|
|
*
|
|
|
|
**/
|
|
|
|
|
|
|
|
#include "PrePi.h"
|
|
|
|
|
2011-09-23 00:59:52 +02:00
|
|
|
#include <Library/ArmGicLib.h>
|
2011-07-01 13:09:00 +02:00
|
|
|
|
2011-11-02 00:41:52 +01:00
|
|
|
#include <Ppi/ArmMpCoreInfo.h>
|
|
|
|
|
2011-07-01 13:09:00 +02:00
|
|
|
VOID
|
|
|
|
PrimaryMain (
|
|
|
|
IN UINTN UefiMemoryBase,
|
2011-09-23 01:07:55 +02:00
|
|
|
IN UINTN StacksBase,
|
|
|
|
IN UINTN GlobalVariableBase,
|
2011-07-01 13:09:00 +02:00
|
|
|
IN UINT64 StartTimeStamp
|
|
|
|
)
|
|
|
|
{
|
2012-05-02 22:09:16 +02:00
|
|
|
// Check PcdGicPrimaryCoreId has been set in case the Primary Core is not the core 0 of Cluster 0
|
|
|
|
DEBUG_CODE_BEGIN();
|
|
|
|
if ((PcdGet32(PcdArmPrimaryCore) != 0) && (PcdGet32 (PcdGicPrimaryCoreId) == 0)) {
|
|
|
|
DEBUG((EFI_D_WARN,"Warning: the PCD PcdGicPrimaryCoreId does not seem to be set up for the configuration.\n"));
|
|
|
|
}
|
|
|
|
DEBUG_CODE_END();
|
|
|
|
|
2011-09-23 00:59:52 +02:00
|
|
|
// Enable the GIC Distributor
|
|
|
|
ArmGicEnableDistributor(PcdGet32(PcdGicDistributorBase));
|
2011-07-01 13:09:00 +02:00
|
|
|
|
2012-07-04 22:17:46 +02:00
|
|
|
// In some cases, the secondary cores are waiting for an SGI from the next stage boot loader to resume their initialization
|
2011-07-06 18:27:21 +02:00
|
|
|
if (!FixedPcdGet32(PcdSendSgiToBringUpSecondaryCores)) {
|
2011-07-01 13:09:00 +02:00
|
|
|
// Sending SGI to all the Secondary CPU interfaces
|
2012-05-02 22:08:03 +02:00
|
|
|
ArmGicSendSgiTo (PcdGet32(PcdGicDistributorBase), ARM_GIC_ICDSGIR_FILTER_EVERYONEELSE, 0x0E, PcdGet32 (PcdGicSgiIntId));
|
2011-07-01 13:09:00 +02:00
|
|
|
}
|
|
|
|
|
2011-09-23 01:07:55 +02:00
|
|
|
PrePiMain (UefiMemoryBase, StacksBase, GlobalVariableBase, StartTimeStamp);
|
2011-07-01 13:09:00 +02:00
|
|
|
|
|
|
|
// We must never return
|
|
|
|
ASSERT(FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
VOID
|
|
|
|
SecondaryMain (
|
2011-09-23 01:01:13 +02:00
|
|
|
IN UINTN MpId
|
2011-07-01 13:09:00 +02:00
|
|
|
)
|
|
|
|
{
|
2011-11-02 00:41:52 +01:00
|
|
|
EFI_STATUS Status;
|
|
|
|
ARM_MP_CORE_INFO_PPI *ArmMpCoreInfoPpi;
|
|
|
|
UINTN Index;
|
|
|
|
UINTN ArmCoreCount;
|
|
|
|
ARM_CORE_INFO *ArmCoreInfoTable;
|
|
|
|
UINT32 ClusterId;
|
|
|
|
UINT32 CoreId;
|
|
|
|
VOID (*SecondaryStart)(VOID);
|
|
|
|
UINTN SecondaryEntryAddr;
|
2012-05-02 22:09:16 +02:00
|
|
|
UINTN AcknowledgedCoreId;
|
2011-11-02 00:41:52 +01:00
|
|
|
|
|
|
|
ClusterId = GET_CLUSTER_ID(MpId);
|
|
|
|
CoreId = GET_CORE_ID(MpId);
|
|
|
|
|
|
|
|
// On MP Core Platform we must implement the ARM MP Core Info PPI (gArmMpCoreInfoPpiGuid)
|
|
|
|
Status = GetPlatformPpi (&gArmMpCoreInfoPpiGuid, (VOID**)&ArmMpCoreInfoPpi);
|
|
|
|
ASSERT_EFI_ERROR (Status);
|
|
|
|
|
|
|
|
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);
|
2011-07-01 13:09:00 +02:00
|
|
|
|
|
|
|
// Clear Secondary cores MailBox
|
2011-11-02 00:41:52 +01:00
|
|
|
MmioWrite32 (ArmCoreInfoTable[Index].MailboxClearAddress, ArmCoreInfoTable[Index].MailboxClearValue);
|
2011-07-01 13:09:00 +02:00
|
|
|
|
2012-05-02 22:09:16 +02:00
|
|
|
do {
|
2011-11-02 00:41:52 +01:00
|
|
|
ArmCallWFI ();
|
2012-05-02 22:09:16 +02:00
|
|
|
|
|
|
|
// Read the Mailbox
|
|
|
|
SecondaryEntryAddr = MmioRead32 (ArmCoreInfoTable[Index].MailboxGetAddress);
|
|
|
|
|
2011-07-01 13:09:00 +02:00
|
|
|
// Acknowledge the interrupt and send End of Interrupt signal.
|
2012-05-02 22:09:16 +02:00
|
|
|
ArmGicAcknowledgeInterrupt (PcdGet32(PcdGicDistributorBase), PcdGet32(PcdGicInterruptInterfaceBase), &AcknowledgedCoreId, NULL);
|
|
|
|
} while ((SecondaryEntryAddr == 0) && (AcknowledgedCoreId != PcdGet32 (PcdGicPrimaryCoreId)));
|
2011-07-01 13:09:00 +02:00
|
|
|
|
|
|
|
// Jump to secondary core entry point.
|
2011-11-02 00:41:52 +01:00
|
|
|
SecondaryStart = (VOID (*)())SecondaryEntryAddr;
|
|
|
|
SecondaryStart();
|
2011-07-01 13:09:00 +02:00
|
|
|
|
|
|
|
// The secondaries shouldn't reach here
|
|
|
|
ASSERT(FALSE);
|
|
|
|
}
|