]> git.proxmox.com Git - mirror_edk2.git/blame - ArmPlatformPkg/PrePi/MainMPCore.c
ARM Packages: Use .8byte instead of .dword for pointers
[mirror_edk2.git] / ArmPlatformPkg / PrePi / MainMPCore.c
CommitLineData
cd872e40 1/** @file\r
2*\r
4c19ece3 3* Copyright (c) 2011-2012, ARM Limited. All rights reserved.\r
cd872e40 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
cd872e40 21VOID\r
22PrimaryMain (\r
23 IN UINTN UefiMemoryBase,\r
c524ffbb 24 IN UINTN StacksBase,\r
25 IN UINTN GlobalVariableBase,\r
cd872e40 26 IN UINT64 StartTimeStamp\r
27 )\r
28{\r
55a0d64b 29 // Enable the GIC Distributor\r
30 ArmGicEnableDistributor(PcdGet32(PcdGicDistributorBase));\r
cd872e40 31\r
0dbbacdf 32 // In some cases, the secondary cores are waiting for an SGI from the next stage boot loader to resume their initialization\r
d269095b 33 if (!FixedPcdGet32(PcdSendSgiToBringUpSecondaryCores)) {\r
cd872e40 34 // Sending SGI to all the Secondary CPU interfaces\r
4c19ece3 35 ArmGicSendSgiTo (PcdGet32(PcdGicDistributorBase), ARM_GIC_ICDSGIR_FILTER_EVERYONEELSE, 0x0E, PcdGet32 (PcdGicSgiIntId));\r
cd872e40 36 }\r
37\r
c524ffbb 38 PrePiMain (UefiMemoryBase, StacksBase, GlobalVariableBase, StartTimeStamp);\r
cd872e40 39\r
40 // We must never return\r
41 ASSERT(FALSE);\r
42}\r
43\r
44VOID\r
45SecondaryMain (\r
0787bc61 46 IN UINTN MpId\r
cd872e40 47 )\r
48{\r
99565b88 49 EFI_STATUS Status;\r
50 ARM_MP_CORE_INFO_PPI *ArmMpCoreInfoPpi;\r
51 UINTN Index;\r
52 UINTN ArmCoreCount;\r
53 ARM_CORE_INFO *ArmCoreInfoTable;\r
54 UINT32 ClusterId;\r
55 UINT32 CoreId;\r
56 VOID (*SecondaryStart)(VOID);\r
57 UINTN SecondaryEntryAddr;\r
58\r
59 ClusterId = GET_CLUSTER_ID(MpId);\r
60 CoreId = GET_CORE_ID(MpId);\r
61\r
62 // On MP Core Platform we must implement the ARM MP Core Info PPI (gArmMpCoreInfoPpiGuid)\r
63 Status = GetPlatformPpi (&gArmMpCoreInfoPpiGuid, (VOID**)&ArmMpCoreInfoPpi);\r
64 ASSERT_EFI_ERROR (Status);\r
65\r
66 ArmCoreCount = 0;\r
67 Status = ArmMpCoreInfoPpi->GetMpCoreInfo (&ArmCoreCount, &ArmCoreInfoTable);\r
68 ASSERT_EFI_ERROR (Status);\r
69\r
70 // Find the core in the ArmCoreTable\r
71 for (Index = 0; Index < ArmCoreCount; Index++) {\r
72 if ((ArmCoreInfoTable[Index].ClusterId == ClusterId) && (ArmCoreInfoTable[Index].CoreId == CoreId)) {\r
73 break;\r
74 }\r
75 }\r
76\r
77 // The ARM Core Info Table must define every core\r
78 ASSERT (Index != ArmCoreCount);\r
cd872e40 79\r
80 // Clear Secondary cores MailBox\r
99565b88 81 MmioWrite32 (ArmCoreInfoTable[Index].MailboxClearAddress, ArmCoreInfoTable[Index].MailboxClearValue);\r
cd872e40 82\r
315649cd 83 do {\r
99565b88 84 ArmCallWFI ();\r
315649cd 85\r
86 // Read the Mailbox\r
87 SecondaryEntryAddr = MmioRead32 (ArmCoreInfoTable[Index].MailboxGetAddress);\r
88\r
cd872e40 89 // Acknowledge the interrupt and send End of Interrupt signal.\r
f93f248a
OM
90 ArmGicAcknowledgeInterrupt (PcdGet32(PcdGicDistributorBase), PcdGet32(PcdGicInterruptInterfaceBase), NULL, NULL);\r
91 } while (SecondaryEntryAddr == 0);\r
cd872e40 92\r
cd872e40 93 // Jump to secondary core entry point.\r
99565b88 94 SecondaryStart = (VOID (*)())SecondaryEntryAddr;\r
95 SecondaryStart();\r
cd872e40 96\r
97 // The secondaries shouldn't reach here\r
98 ASSERT(FALSE);\r
99}\r