summaryrefslogtreecommitdiffstats
path: root/ArmPlatformPkg/PrePi
diff options
context:
space:
mode:
authormergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2024-08-27 16:26:54 +0000
committerGitHub <noreply@github.com>2024-08-27 16:26:54 +0000
commit1bf1b9cc9b55fde85d44a22f829cf09f41a974ab (patch)
treefeb30fce2c8f5cdba62210d726a7f3ad2ab7035b /ArmPlatformPkg/PrePi
parent911a62f1327a7a689e3d061efc4e62508521d48d (diff)
parentb2a431868c4ae0ad99def0a504d2fe097e16cd4f (diff)
downloadedk2-1bf1b9cc9b55fde85d44a22f829cf09f41a974ab.tar.gz
Merge branch 'master' into dependabot/github_actions/github/issue-labeler-3.4dependabot/github_actions/github/issue-labeler-3.4
Diffstat (limited to 'ArmPlatformPkg/PrePi')
-rw-r--r--ArmPlatformPkg/PrePi/AArch64/ArchPrePi.c2
-rw-r--r--ArmPlatformPkg/PrePi/AArch64/ModuleEntryPoint.S30
-rw-r--r--ArmPlatformPkg/PrePi/Arm/ModuleEntryPoint.S33
-rw-r--r--ArmPlatformPkg/PrePi/MainMPCore.c104
-rw-r--r--ArmPlatformPkg/PrePi/MainUniCore.c31
-rw-r--r--ArmPlatformPkg/PrePi/PeiMPCore.inf106
-rw-r--r--ArmPlatformPkg/PrePi/PeiUniCore.inf4
-rw-r--r--ArmPlatformPkg/PrePi/PrePi.c60
-rw-r--r--ArmPlatformPkg/PrePi/PrePi.h31
9 files changed, 37 insertions, 364 deletions
diff --git a/ArmPlatformPkg/PrePi/AArch64/ArchPrePi.c b/ArmPlatformPkg/PrePi/AArch64/ArchPrePi.c
index 296b029e08..27a85049fa 100644
--- a/ArmPlatformPkg/PrePi/AArch64/ArchPrePi.c
+++ b/ArmPlatformPkg/PrePi/AArch64/ArchPrePi.c
@@ -8,7 +8,7 @@
#include "PrePi.h"
-#include <Chipset/AArch64.h>
+#include <AArch64/AArch64.h>
VOID
ArchInitialize (
diff --git a/ArmPlatformPkg/PrePi/AArch64/ModuleEntryPoint.S b/ArmPlatformPkg/PrePi/AArch64/ModuleEntryPoint.S
index e3aa546897..c45fc5f400 100644
--- a/ArmPlatformPkg/PrePi/AArch64/ModuleEntryPoint.S
+++ b/ArmPlatformPkg/PrePi/AArch64/ModuleEntryPoint.S
@@ -11,11 +11,6 @@ ASM_FUNC(_ModuleEntryPoint)
// Do early platform specific actions
bl ASM_PFX(ArmPlatformPeiBootAction)
- // Get ID of this CPU in multi-core system
- bl ASM_PFX(ArmReadMpidr)
- // Keep a copy of the MpId register value
- mov x10, x0
-
_SetSVCMode:
// Check if we can install the stack at the top of the System Memory or if we need
// to install the stacks at the bottom of the Firmware Device (case the FD is located
@@ -71,31 +66,16 @@ _GetBaseUefiMemory:
sub x11, x1, x4
_GetStackBase:
- // r1 = The top of the Mpcore Stacks
+ // r1 = The top of the stack
+ mov sp, x1
+
// Stack for the primary core = PrimaryCoreStack
MOV32 (x2, FixedPcdGet32(PcdCPUCorePrimaryStackSize))
sub x12, x1, x2
- // Stack for the secondary core = Number of Cores - 1
- MOV32 (x1, (FixedPcdGet32(PcdCoreCount) - 1) * FixedPcdGet32(PcdCPUCoreSecondaryStackSize))
- sub x12, x12, x1
-
- // x12 = The base of the MpCore Stacks (primary stack & secondary stacks)
- mov x0, x12
- mov x1, x10
- //ArmPlatformStackSet(StackBase, MpId, PrimaryStackSize, SecondaryStackSize)
- MOV32 (x2, FixedPcdGet32(PcdCPUCorePrimaryStackSize))
- MOV32 (x3, FixedPcdGet32(PcdCPUCoreSecondaryStackSize))
- bl ASM_PFX(ArmPlatformStackSet)
-
- // Is it the Primary Core ?
- mov x0, x10
- bl ASM_PFX(ArmPlatformIsPrimaryCore)
- cmp x0, #1
- bne _PrepareArguments
+ // Get ID of this CPU in multi-core system
+ bl ASM_PFX(ArmReadMpidr)
-_PrepareArguments:
- mov x0, x10
mov x1, x11
mov x2, x12
diff --git a/ArmPlatformPkg/PrePi/Arm/ModuleEntryPoint.S b/ArmPlatformPkg/PrePi/Arm/ModuleEntryPoint.S
index 6709dad0b9..c87f94689c 100644
--- a/ArmPlatformPkg/PrePi/Arm/ModuleEntryPoint.S
+++ b/ArmPlatformPkg/PrePi/Arm/ModuleEntryPoint.S
@@ -7,17 +7,12 @@
#include <AsmMacroIoLib.h>
-#include <Chipset/ArmV7.h>
+#include <Arm/AArch32.h>
ASM_FUNC(_ModuleEntryPoint)
// Do early platform specific actions
bl ASM_PFX(ArmPlatformPeiBootAction)
- // Get ID of this CPU in multi-core system
- bl ASM_PFX(ArmReadMpidr)
- // Keep a copy of the MpId register value
- mov r8, r0
-
_SetSVCMode:
// Enter SVC mode, Disable FIQ and IRQ
mov r1, #(CPSR_MODE_SVC | CPSR_IRQ | CPSR_FIQ)
@@ -81,34 +76,18 @@ _GetBaseUefiMemory:
sub r9, r1, r4
_GetStackBase:
- // r1 = The top of the Mpcore Stacks
+ // r1 = The top of the stack
+ mov sp, r1
+
// Stack for the primary core = PrimaryCoreStack
MOV32 (r2, FixedPcdGet32(PcdCPUCorePrimaryStackSize))
sub r10, r1, r2
- // Stack for the secondary core = Number of Cores - 1
- MOV32 (r1, (FixedPcdGet32(PcdCoreCount) - 1) * FixedPcdGet32(PcdCPUCoreSecondaryStackSize))
- sub r10, r10, r1
-
- // r10 = The base of the MpCore Stacks (primary stack & secondary stacks)
- mov r0, r10
- mov r1, r8
- //ArmPlatformStackSet(StackBase, MpId, PrimaryStackSize, SecondaryStackSize)
- MOV32 (r2, FixedPcdGet32(PcdCPUCorePrimaryStackSize))
- MOV32 (r3, FixedPcdGet32(PcdCPUCoreSecondaryStackSize))
- bl ASM_PFX(ArmPlatformStackSet)
-
- // Is it the Primary Core ?
- mov r0, r8
- bl ASM_PFX(ArmPlatformIsPrimaryCore)
- cmp r0, #1
- bne _PrepareArguments
+ // Get ID of this CPU in multi-core system
+ bl ASM_PFX(ArmReadMpidr)
-_PrepareArguments:
- mov r0, r8
mov r1, r9
mov r2, r10
- mov r3, sp
// Move sec startup address into a data register
// Ensure we're jumping to FV version of the code (not boot remapped alias)
diff --git a/ArmPlatformPkg/PrePi/MainMPCore.c b/ArmPlatformPkg/PrePi/MainMPCore.c
deleted file mode 100644
index 68a7c13298..0000000000
--- a/ArmPlatformPkg/PrePi/MainMPCore.c
+++ /dev/null
@@ -1,104 +0,0 @@
-/** @file
-
- Copyright (c) 2011-2014, ARM Limited. All rights reserved.
-
- SPDX-License-Identifier: BSD-2-Clause-Patent
-
-**/
-
-#include "PrePi.h"
-
-#include <Library/ArmGicLib.h>
-
-#include <Ppi/ArmMpCoreInfo.h>
-
-VOID
-PrimaryMain (
- IN UINTN UefiMemoryBase,
- IN UINTN StacksBase,
- IN UINT64 StartTimeStamp
- )
-{
- // Enable the GIC Distributor
- ArmGicEnableDistributor (PcdGet64 (PcdGicDistributorBase));
-
- // In some cases, the secondary cores are waiting for an SGI from the next stage boot loader to resume their initialization
- if (!FixedPcdGet32 (PcdSendSgiToBringUpSecondaryCores)) {
- // Sending SGI to all the Secondary CPU interfaces
- ArmGicSendSgiTo (PcdGet64 (PcdGicDistributorBase), ARM_GIC_ICDSGIR_FILTER_EVERYONEELSE, 0x0E, PcdGet32 (PcdGicSgiIntId));
- }
-
- PrePiMain (UefiMemoryBase, StacksBase, StartTimeStamp);
-
- // We must never return
- ASSERT (FALSE);
-}
-
-VOID
-SecondaryMain (
- IN UINTN MpId
- )
-{
- 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;
- UINTN AcknowledgeInterrupt;
- UINTN InterruptId;
-
- 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 ((GET_MPIDR_AFF1 (ArmCoreInfoTable[Index].Mpidr) == ClusterId) &&
- (GET_MPIDR_AFF0 (ArmCoreInfoTable[Index].Mpidr) == 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 (PcdGet64 (PcdGicInterruptInterfaceBase), &InterruptId);
- // Check if it is a valid interrupt ID
- if (InterruptId < ArmGicGetMaxNumInterrupts (PcdGet64 (PcdGicDistributorBase))) {
- // Got a valid SGI number hence signal End of Interrupt
- ArmGicEndOfInterrupt (PcdGet64 (PcdGicInterruptInterfaceBase), AcknowledgeInterrupt);
- }
- } while (SecondaryEntryAddr == 0);
-
- // Jump to secondary core entry point.
- SecondaryStart = (VOID (*)()) SecondaryEntryAddr;
- SecondaryStart ();
-
- // The secondaries shouldn't reach here
- ASSERT (FALSE);
-}
diff --git a/ArmPlatformPkg/PrePi/MainUniCore.c b/ArmPlatformPkg/PrePi/MainUniCore.c
deleted file mode 100644
index 6162d1241f..0000000000
--- a/ArmPlatformPkg/PrePi/MainUniCore.c
+++ /dev/null
@@ -1,31 +0,0 @@
-/** @file
-
- Copyright (c) 2011, ARM Limited. All rights reserved.
-
- SPDX-License-Identifier: BSD-2-Clause-Patent
-
-**/
-
-#include "PrePi.h"
-
-VOID
-PrimaryMain (
- IN UINTN UefiMemoryBase,
- IN UINTN StacksBase,
- IN UINT64 StartTimeStamp
- )
-{
- PrePiMain (UefiMemoryBase, StacksBase, StartTimeStamp);
-
- // We must never return
- ASSERT (FALSE);
-}
-
-VOID
-SecondaryMain (
- IN UINTN MpId
- )
-{
- // We must never get into this function on UniCore system
- ASSERT (FALSE);
-}
diff --git a/ArmPlatformPkg/PrePi/PeiMPCore.inf b/ArmPlatformPkg/PrePi/PeiMPCore.inf
deleted file mode 100644
index 0b13b72353..0000000000
--- a/ArmPlatformPkg/PrePi/PeiMPCore.inf
+++ /dev/null
@@ -1,106 +0,0 @@
-#/** @file
-#
-# (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
-# Copyright (c) 2011-2017, ARM Ltd. All rights reserved.<BR>
-#
-# SPDX-License-Identifier: BSD-2-Clause-Patent
-#
-#**/
-
-[Defines]
- INF_VERSION = 1.30
- BASE_NAME = ArmPlatformPrePiMPCore
- FILE_GUID = d959e387-7b91-452c-90e0-a1dbac90ddb8
- MODULE_TYPE = SEC
- VERSION_STRING = 1.0
-
-[Sources]
- PrePi.h
- PrePi.c
- MainMPCore.c
-
-[Sources.ARM]
- Arm/ArchPrePi.c
- Arm/ModuleEntryPoint.S | GCC
-
-[Sources.AArch64]
- AArch64/ArchPrePi.c
- AArch64/ModuleEntryPoint.S
-
-[Packages]
- MdePkg/MdePkg.dec
- MdeModulePkg/MdeModulePkg.dec
- EmbeddedPkg/EmbeddedPkg.dec
- ArmPkg/ArmPkg.dec
- ArmPlatformPkg/ArmPlatformPkg.dec
-
-[LibraryClasses]
- BaseLib
- CacheMaintenanceLib
- DebugLib
- DebugAgentLib
- ArmLib
- ArmGicLib
- IoLib
- TimerLib
- SerialPortLib
- ExtractGuidedSectionLib
- LzmaDecompressLib
- DebugAgentLib
- PrePiLib
- ArmPlatformLib
- ArmPlatformStackLib
- MemoryAllocationLib
- HobLib
- PrePiHobListPointerLib
- PlatformPeiLib
- MemoryInitPeiLib
-
-[Ppis]
- gArmMpCoreInfoPpiGuid
-
-[Guids]
- gArmMpCoreInfoGuid
- gEfiFirmwarePerformanceGuid
-
-[FeaturePcd]
- gEmbeddedTokenSpaceGuid.PcdPrePiProduceMemoryTypeInformationHob
- gArmPlatformTokenSpaceGuid.PcdSendSgiToBringUpSecondaryCores
-
-[Pcd]
- gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVersionString
-
-[FixedPcd]
- gArmTokenSpaceGuid.PcdVFPEnabled
-
- gArmTokenSpaceGuid.PcdFdBaseAddress
- gArmTokenSpaceGuid.PcdFdSize
-
- gArmTokenSpaceGuid.PcdFvBaseAddress
- gArmTokenSpaceGuid.PcdFvSize
-
- gArmPlatformTokenSpaceGuid.PcdCPUCorePrimaryStackSize
- gArmPlatformTokenSpaceGuid.PcdCPUCoreSecondaryStackSize
-
- gArmTokenSpaceGuid.PcdGicDistributorBase
- gArmTokenSpaceGuid.PcdGicInterruptInterfaceBase
- gArmTokenSpaceGuid.PcdGicSgiIntId
-
- gArmTokenSpaceGuid.PcdSystemMemoryBase
- gArmTokenSpaceGuid.PcdSystemMemorySize
- gArmPlatformTokenSpaceGuid.PcdSystemMemoryUefiRegionSize
-
- gArmPlatformTokenSpaceGuid.PcdCoreCount
-
- gEmbeddedTokenSpaceGuid.PcdPrePiCpuIoSize
-
- gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiACPIReclaimMemory
- gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiACPIMemoryNVS
- gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiReservedMemoryType
- gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiRuntimeServicesData
- gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiRuntimeServicesCode
- gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiBootServicesCode
- gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiBootServicesData
- gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiLoaderCode
- gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiLoaderData
-
diff --git a/ArmPlatformPkg/PrePi/PeiUniCore.inf b/ArmPlatformPkg/PrePi/PeiUniCore.inf
index 2e237172d5..9aa97d0a30 100644
--- a/ArmPlatformPkg/PrePi/PeiUniCore.inf
+++ b/ArmPlatformPkg/PrePi/PeiUniCore.inf
@@ -18,7 +18,6 @@
[Sources]
PrePi.h
PrePi.c
- MainUniCore.c
[Sources.ARM]
Arm/ArchPrePi.c
@@ -49,7 +48,6 @@
DebugAgentLib
PrePiLib
ArmPlatformLib
- ArmPlatformStackLib
MemoryAllocationLib
HobLib
PrePiHobListPointerLib
@@ -65,7 +63,6 @@
[FeaturePcd]
gEmbeddedTokenSpaceGuid.PcdPrePiProduceMemoryTypeInformationHob
- gArmPlatformTokenSpaceGuid.PcdSendSgiToBringUpSecondaryCores
[Pcd]
gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVersionString
@@ -80,7 +77,6 @@
gArmTokenSpaceGuid.PcdFvSize
gArmPlatformTokenSpaceGuid.PcdCPUCorePrimaryStackSize
- gArmPlatformTokenSpaceGuid.PcdCPUCoreSecondaryStackSize
gArmPlatformTokenSpaceGuid.PcdSystemMemoryUefiRegionSize
diff --git a/ArmPlatformPkg/PrePi/PrePi.c b/ArmPlatformPkg/PrePi/PrePi.c
index 9b127b94a6..f98a0e56c1 100644
--- a/ArmPlatformPkg/PrePi/PrePi.c
+++ b/ArmPlatformPkg/PrePi/PrePi.c
@@ -28,6 +28,15 @@
UINT64 mSystemMemoryEnd = FixedPcdGet64 (PcdSystemMemoryBase) +
FixedPcdGet64 (PcdSystemMemorySize) - 1;
+/**
+ Obtain a PPI from the list of PPIs provided by the platform code.
+
+ @param[in] PpiGuid GUID of the PPI to obtain
+ @param[out] Ppi Address of GUID pointer to return the PPI
+
+ @return Whether the PPI was obtained successfully
+**/
+STATIC
EFI_STATUS
GetPlatformPpi (
IN EFI_GUID *PpiGuid,
@@ -52,6 +61,14 @@ GetPlatformPpi (
return EFI_NOT_FOUND;
}
+/**
+ SEC main routine.
+
+ @param[in] UefiMemoryBase Start of the PI/UEFI memory region
+ @param[in] StacksBase Start of the stack
+ @param[in] StartTimeStamp Timer value at start of execution
+**/
+STATIC
VOID
PrePiMain (
IN UINTN UefiMemoryBase,
@@ -108,14 +125,8 @@ PrePiMain (
Status = MemoryPeim (UefiMemoryBase, FixedPcdGet32 (PcdSystemMemoryUefiRegionSize));
ASSERT_EFI_ERROR (Status);
- // Create the Stacks HOB (reserve the memory for all stacks)
- if (ArmIsMpCore ()) {
- StacksSize = PcdGet32 (PcdCPUCorePrimaryStackSize) +
- ((FixedPcdGet32 (PcdCoreCount) - 1) * FixedPcdGet32 (PcdCPUCoreSecondaryStackSize));
- } else {
- StacksSize = PcdGet32 (PcdCPUCorePrimaryStackSize);
- }
-
+ // Create the Stacks HOB
+ StacksSize = PcdGet32 (PcdCPUCorePrimaryStackSize);
BuildStackHob (StacksBase, StacksSize);
// TODO: Call CpuPei as a library
@@ -177,9 +188,7 @@ CEntryPoint (
// Initialize the platform specific controllers
ArmPlatformInitialize (MpId);
- if (ArmPlatformIsPrimaryCore (MpId) && PerformanceMeasurementEnabled ()) {
- // Initialize the Timer Library to setup the Timer HW controller
- TimerConstructor ();
+ if (PerformanceMeasurementEnabled ()) {
// We cannot call yet the PerformanceLib because the HOB List has not been initialized
StartTimeStamp = GetPerformanceCounter ();
} else {
@@ -193,31 +202,12 @@ CEntryPoint (
// 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)) {
- if (ArmIsMpCore ()) {
- // Signal the Global Variable Region is defined (event: ARM_CPU_EVENT_DEFAULT)
- ArmCallSEV ();
- }
- } else {
- // Wait the Primary 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)) {
- InvalidateDataCacheRange (
- (VOID *)UefiMemoryBase,
- FixedPcdGet32 (PcdSystemMemoryUefiRegionSize)
- );
+ InvalidateDataCacheRange (
+ (VOID *)UefiMemoryBase,
+ FixedPcdGet32 (PcdSystemMemoryUefiRegionSize)
+ );
- // Goto primary Main.
- PrimaryMain (UefiMemoryBase, StacksBase, StartTimeStamp);
- } else {
- SecondaryMain (MpId);
- }
+ PrePiMain (UefiMemoryBase, StacksBase, StartTimeStamp);
// DXE Core should always load and never return
ASSERT (FALSE);
diff --git a/ArmPlatformPkg/PrePi/PrePi.h b/ArmPlatformPkg/PrePi/PrePi.h
index 1d47ba26be..9d3e7feaa0 100644
--- a/ArmPlatformPkg/PrePi/PrePi.h
+++ b/ArmPlatformPkg/PrePi/PrePi.h
@@ -23,19 +23,6 @@
extern UINT64 mSystemMemoryEnd;
-RETURN_STATUS
-EFIAPI
-TimerConstructor (
- VOID
- );
-
-VOID
-PrePiMain (
- IN UINTN UefiMemoryBase,
- IN UINTN StacksBase,
- IN UINT64 StartTimeStamp
- );
-
EFI_STATUS
EFIAPI
MemoryPeim (
@@ -49,30 +36,12 @@ PlatformPeim (
VOID
);
-VOID
-PrimaryMain (
- IN UINTN UefiMemoryBase,
- IN UINTN StacksBase,
- IN UINT64 StartTimeStamp
- );
-
-VOID
-SecondaryMain (
- IN UINTN MpId
- );
-
// Either implemented by PrePiLib or by MemoryInitPei
VOID
BuildMemoryTypeInformationHob (
VOID
);
-EFI_STATUS
-GetPlatformPpi (
- IN EFI_GUID *PpiGuid,
- OUT VOID **Ppi
- );
-
// Initialize the Architecture specific controllers
VOID
ArchInitialize (