]> git.proxmox.com Git - mirror_edk2.git/blame - ArmPlatformPkg/PrePi/MainMPCore.c
ArmPlatformPkg: Apply uncrustify changes
[mirror_edk2.git] / ArmPlatformPkg / PrePi / MainMPCore.c
CommitLineData
cd872e40 1/** @file\r
5a5440d0
PG
2\r
3 Copyright (c) 2011-2014, ARM Limited. All rights reserved.\r
4\r
5 SPDX-License-Identifier: BSD-2-Clause-Patent\r
6\r
cd872e40 7**/\r
8\r
9#include "PrePi.h"\r
10\r
55a0d64b 11#include <Library/ArmGicLib.h>\r
cd872e40 12\r
99565b88 13#include <Ppi/ArmMpCoreInfo.h>\r
14\r
cd872e40 15VOID\r
16PrimaryMain (\r
40b0b23e
MK
17 IN UINTN UefiMemoryBase,\r
18 IN UINTN StacksBase,\r
19 IN UINT64 StartTimeStamp\r
cd872e40 20 )\r
21{\r
55a0d64b 22 // Enable the GIC Distributor\r
40b0b23e 23 ArmGicEnableDistributor (PcdGet64 (PcdGicDistributorBase));\r
cd872e40 24\r
0dbbacdf 25 // In some cases, the secondary cores are waiting for an SGI from the next stage boot loader to resume their initialization\r
40b0b23e 26 if (!FixedPcdGet32 (PcdSendSgiToBringUpSecondaryCores)) {\r
cd872e40 27 // Sending SGI to all the Secondary CPU interfaces\r
40b0b23e 28 ArmGicSendSgiTo (PcdGet64 (PcdGicDistributorBase), ARM_GIC_ICDSGIR_FILTER_EVERYONEELSE, 0x0E, PcdGet32 (PcdGicSgiIntId));\r
cd872e40 29 }\r
30\r
f2e17a07 31 PrePiMain (UefiMemoryBase, StacksBase, StartTimeStamp);\r
cd872e40 32\r
33 // We must never return\r
40b0b23e 34 ASSERT (FALSE);\r
cd872e40 35}\r
36\r
37VOID\r
38SecondaryMain (\r
40b0b23e 39 IN UINTN MpId\r
cd872e40 40 )\r
41{\r
40b0b23e
MK
42 EFI_STATUS Status;\r
43 ARM_MP_CORE_INFO_PPI *ArmMpCoreInfoPpi;\r
44 UINTN Index;\r
45 UINTN ArmCoreCount;\r
46 ARM_CORE_INFO *ArmCoreInfoTable;\r
47 UINT32 ClusterId;\r
48 UINT32 CoreId;\r
49\r
50 VOID (*SecondaryStart)(\r
51 VOID\r
52 );\r
53 UINTN SecondaryEntryAddr;\r
54 UINTN AcknowledgeInterrupt;\r
55 UINTN InterruptId;\r
56\r
57 ClusterId = GET_CLUSTER_ID (MpId);\r
58 CoreId = GET_CORE_ID (MpId);\r
99565b88 59\r
60 // On MP Core Platform we must implement the ARM MP Core Info PPI (gArmMpCoreInfoPpiGuid)\r
40b0b23e 61 Status = GetPlatformPpi (&gArmMpCoreInfoPpiGuid, (VOID **)&ArmMpCoreInfoPpi);\r
99565b88 62 ASSERT_EFI_ERROR (Status);\r
63\r
64 ArmCoreCount = 0;\r
40b0b23e 65 Status = ArmMpCoreInfoPpi->GetMpCoreInfo (&ArmCoreCount, &ArmCoreInfoTable);\r
99565b88 66 ASSERT_EFI_ERROR (Status);\r
67\r
68 // Find the core in the ArmCoreTable\r
69 for (Index = 0; Index < ArmCoreCount; Index++) {\r
70 if ((ArmCoreInfoTable[Index].ClusterId == ClusterId) && (ArmCoreInfoTable[Index].CoreId == CoreId)) {\r
71 break;\r
72 }\r
73 }\r
74\r
75 // The ARM Core Info Table must define every core\r
76 ASSERT (Index != ArmCoreCount);\r
cd872e40 77\r
78 // Clear Secondary cores MailBox\r
99565b88 79 MmioWrite32 (ArmCoreInfoTable[Index].MailboxClearAddress, ArmCoreInfoTable[Index].MailboxClearValue);\r
cd872e40 80\r
315649cd 81 do {\r
99565b88 82 ArmCallWFI ();\r
315649cd 83\r
84 // Read the Mailbox\r
85 SecondaryEntryAddr = MmioRead32 (ArmCoreInfoTable[Index].MailboxGetAddress);\r
86\r
cd872e40 87 // Acknowledge the interrupt and send End of Interrupt signal.\r
8a1f2378 88 AcknowledgeInterrupt = ArmGicAcknowledgeInterrupt (PcdGet64 (PcdGicInterruptInterfaceBase), &InterruptId);\r
2ca815a4 89 // Check if it is a valid interrupt ID\r
8a1f2378 90 if (InterruptId < ArmGicGetMaxNumInterrupts (PcdGet64 (PcdGicDistributorBase))) {\r
2ca815a4 91 // Got a valid SGI number hence signal End of Interrupt\r
8a1f2378 92 ArmGicEndOfInterrupt (PcdGet64 (PcdGicInterruptInterfaceBase), AcknowledgeInterrupt);\r
2ca815a4 93 }\r
f93f248a 94 } while (SecondaryEntryAddr == 0);\r
cd872e40 95\r
cd872e40 96 // Jump to secondary core entry point.\r
40b0b23e
MK
97 SecondaryStart = (VOID (*)()) SecondaryEntryAddr;\r
98 SecondaryStart ();\r
cd872e40 99\r
100 // The secondaries shouldn't reach here\r
40b0b23e 101 ASSERT (FALSE);\r
cd872e40 102}\r