]> git.proxmox.com Git - mirror_edk2.git/blame - ArmPlatformPkg/PrePi/MainMPCore.c
ArmPkg/ArmCpuLib: Replaced complex functions ArmCpuSynchronizeWait & ArmCpuSynchroniz...
[mirror_edk2.git] / ArmPlatformPkg / PrePi / MainMPCore.c
CommitLineData
cd872e40 1/** @file\r
2*\r
3* Copyright (c) 2011, ARM Limited. All rights reserved.\r
4*\r
5* This program and the accompanying materials\r
6* are licensed and made available under the terms and conditions of the BSD License\r
7* which accompanies this distribution. The full text of the license may be found at\r
8* http://opensource.org/licenses/bsd-license.php\r
9*\r
10* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12*\r
13**/\r
14\r
15#include "PrePi.h"\r
16\r
55a0d64b 17#include <Library/ArmGicLib.h>\r
cd872e40 18\r
99565b88 19#include <Ppi/ArmMpCoreInfo.h>\r
20\r
21EFI_STATUS\r
22GetPlatformPpi (\r
23 IN EFI_GUID *PpiGuid,\r
24 OUT VOID **Ppi\r
25 )\r
26{\r
27 UINTN PpiListSize;\r
28 UINTN PpiListCount;\r
29 EFI_PEI_PPI_DESCRIPTOR *PpiList;\r
30 UINTN Index;\r
31\r
32 PpiListSize = 0;\r
33 ArmPlatformGetPlatformPpiList (&PpiListSize, &PpiList);\r
34 PpiListCount = PpiListSize / sizeof(EFI_PEI_PPI_DESCRIPTOR);\r
35 for (Index = 0; Index < PpiListCount; Index++, PpiList++) {\r
36 if (CompareGuid (PpiList->Guid, PpiGuid) == TRUE) {\r
37 *Ppi = PpiList->Ppi;\r
38 return EFI_SUCCESS;\r
39 }\r
40 }\r
41\r
42 return EFI_NOT_FOUND;\r
43}\r
44\r
cd872e40 45VOID\r
46PrimaryMain (\r
47 IN UINTN UefiMemoryBase,\r
c524ffbb 48 IN UINTN StacksBase,\r
49 IN UINTN GlobalVariableBase,\r
cd872e40 50 IN UINT64 StartTimeStamp\r
51 )\r
52{\r
99565b88 53 // On MP Core Platform we must implement the ARM MP Core Info PPI (gArmMpCoreInfoPpiGuid)\r
54 DEBUG_CODE_BEGIN();\r
55 EFI_STATUS Status;\r
56 ARM_MP_CORE_INFO_PPI *ArmMpCoreInfoPpi;\r
57\r
58 Status = GetPlatformPpi (&gArmMpCoreInfoPpiGuid, (VOID**)&ArmMpCoreInfoPpi);\r
59 ASSERT_EFI_ERROR (Status);\r
60 DEBUG_CODE_END();\r
61\r
55a0d64b 62 // Enable the GIC Distributor\r
63 ArmGicEnableDistributor(PcdGet32(PcdGicDistributorBase));\r
cd872e40 64\r
d269095b 65 // In some cases, the secondary cores are waiting for an SGI from the next stage boot loader toresume their initialization\r
66 if (!FixedPcdGet32(PcdSendSgiToBringUpSecondaryCores)) {\r
cd872e40 67 // Sending SGI to all the Secondary CPU interfaces\r
55a0d64b 68 ArmGicSendSgiTo (PcdGet32(PcdGicDistributorBase), ARM_GIC_ICDSGIR_FILTER_EVERYONEELSE, 0x0E);\r
cd872e40 69 }\r
70\r
c524ffbb 71 PrePiMain (UefiMemoryBase, StacksBase, GlobalVariableBase, StartTimeStamp);\r
cd872e40 72\r
73 // We must never return\r
74 ASSERT(FALSE);\r
75}\r
76\r
77VOID\r
78SecondaryMain (\r
0787bc61 79 IN UINTN MpId\r
cd872e40 80 )\r
81{\r
99565b88 82 EFI_STATUS Status;\r
83 ARM_MP_CORE_INFO_PPI *ArmMpCoreInfoPpi;\r
84 UINTN Index;\r
85 UINTN ArmCoreCount;\r
86 ARM_CORE_INFO *ArmCoreInfoTable;\r
87 UINT32 ClusterId;\r
88 UINT32 CoreId;\r
89 VOID (*SecondaryStart)(VOID);\r
90 UINTN SecondaryEntryAddr;\r
91\r
92 ClusterId = GET_CLUSTER_ID(MpId);\r
93 CoreId = GET_CORE_ID(MpId);\r
94\r
95 // On MP Core Platform we must implement the ARM MP Core Info PPI (gArmMpCoreInfoPpiGuid)\r
96 Status = GetPlatformPpi (&gArmMpCoreInfoPpiGuid, (VOID**)&ArmMpCoreInfoPpi);\r
97 ASSERT_EFI_ERROR (Status);\r
98\r
99 ArmCoreCount = 0;\r
100 Status = ArmMpCoreInfoPpi->GetMpCoreInfo (&ArmCoreCount, &ArmCoreInfoTable);\r
101 ASSERT_EFI_ERROR (Status);\r
102\r
103 // Find the core in the ArmCoreTable\r
104 for (Index = 0; Index < ArmCoreCount; Index++) {\r
105 if ((ArmCoreInfoTable[Index].ClusterId == ClusterId) && (ArmCoreInfoTable[Index].CoreId == CoreId)) {\r
106 break;\r
107 }\r
108 }\r
109\r
110 // The ARM Core Info Table must define every core\r
111 ASSERT (Index != ArmCoreCount);\r
cd872e40 112\r
113 // Clear Secondary cores MailBox\r
99565b88 114 MmioWrite32 (ArmCoreInfoTable[Index].MailboxClearAddress, ArmCoreInfoTable[Index].MailboxClearValue);\r
cd872e40 115\r
99565b88 116 SecondaryEntryAddr = 0;\r
117 while (SecondaryEntryAddr = MmioRead32 (ArmCoreInfoTable[Index].MailboxGetAddress), SecondaryEntryAddr == 0) {\r
118 ArmCallWFI ();\r
cd872e40 119 // Acknowledge the interrupt and send End of Interrupt signal.\r
0787bc61 120 ArmGicAcknowledgeSgiFrom (PcdGet32(PcdGicInterruptInterfaceBase), PRIMARY_CORE_ID);\r
cd872e40 121 }\r
122\r
cd872e40 123 // Jump to secondary core entry point.\r
99565b88 124 SecondaryStart = (VOID (*)())SecondaryEntryAddr;\r
125 SecondaryStart();\r
cd872e40 126\r
127 // The secondaries shouldn't reach here\r
128 ASSERT(FALSE);\r
129}\r