2011-07-01 13:09:00 +02:00
|
|
|
/** @file
|
|
|
|
*
|
2014-07-04 16:41:30 +02:00
|
|
|
* Copyright (c) 2011-2014, 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,
|
2011-07-01 13:09:00 +02:00
|
|
|
IN UINT64 StartTimeStamp
|
|
|
|
)
|
|
|
|
{
|
2011-09-23 00:59:52 +02:00
|
|
|
// Enable the GIC Distributor
|
2016-09-05 13:38:20 +02:00
|
|
|
ArmGicEnableDistributor(PcdGet64(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
|
2016-09-05 13:38:20 +02:00
|
|
|
ArmGicSendSgiTo (PcdGet64(PcdGicDistributorBase), ARM_GIC_ICDSGIR_FILTER_EVERYONEELSE, 0x0E, PcdGet32 (PcdGicSgiIntId));
|
2011-07-01 13:09:00 +02:00
|
|
|
}
|
|
|
|
|
2015-11-27 18:07:06 +01:00
|
|
|
PrePiMain (UefiMemoryBase, StacksBase, 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;
|
2014-07-04 16:41:30 +02:00
|
|
|
UINTN AcknowledgeInterrupt;
|
|
|
|
UINTN InterruptId;
|
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.
|
2016-09-05 13:38:20 +02:00
|
|
|
AcknowledgeInterrupt = ArmGicAcknowledgeInterrupt (PcdGet64 (PcdGicInterruptInterfaceBase), &InterruptId);
|
2014-07-04 13:13:27 +02:00
|
|
|
// Check if it is a valid interrupt ID
|
2016-09-05 13:38:20 +02:00
|
|
|
if (InterruptId < ArmGicGetMaxNumInterrupts (PcdGet64 (PcdGicDistributorBase))) {
|
2014-07-04 13:13:27 +02:00
|
|
|
// Got a valid SGI number hence signal End of Interrupt
|
2016-09-05 13:38:20 +02:00
|
|
|
ArmGicEndOfInterrupt (PcdGet64 (PcdGicInterruptInterfaceBase), AcknowledgeInterrupt);
|
2014-07-04 13:13:27 +02:00
|
|
|
}
|
2013-07-17 08:23:07 +02:00
|
|
|
} while (SecondaryEntryAddr == 0);
|
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);
|
|
|
|
}
|