]> git.proxmox.com Git - mirror_edk2.git/blame - ArmPlatformPkg/PrePeiCore/MainMPCore.c
Expand the PcdSrIovSystemPageSize type to PcdsPatchableInModule.
[mirror_edk2.git] / ArmPlatformPkg / PrePeiCore / MainMPCore.c
CommitLineData
1d5d0ae9 1/** @file\r
2*\r
3222e7b1 3* Copyright (c) 2011-2012, ARM Limited. All rights reserved.\r
1d5d0ae9 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
55a0d64b 15#include <Library/ArmGicLib.h>\r
44788bae 16\r
17#include <Ppi/ArmMpCoreInfo.h>\r
18\r
f598bf12 19#include "PrePeiCore.h"\r
20\r
1d5d0ae9 21/*\r
22 * This is the main function for secondary cores. They loop around until a non Null value is written to\r
23 * SYS_FLAGS register.The SYS_FLAGS register is platform specific.\r
24 * Note:The secondary cores, while executing secondary_main, assumes that:\r
25 * : SGI 0 is configured as Non-secure interrupt\r
26 * : Priority Mask is configured to allow SGI 0\r
27 * : Interrupt Distributor and CPU interfaces are enabled\r
28 *\r
29 */\r
30VOID\r
31EFIAPI\r
f598bf12 32SecondaryMain (\r
0787bc61 33 IN UINTN MpId\r
f598bf12 34 )\r
1d5d0ae9 35{\r
44788bae 36 EFI_STATUS Status;\r
37 UINTN PpiListSize;\r
38 UINTN PpiListCount;\r
39 EFI_PEI_PPI_DESCRIPTOR *PpiList;\r
40 ARM_MP_CORE_INFO_PPI *ArmMpCoreInfoPpi;\r
41 UINTN Index;\r
42 UINTN ArmCoreCount;\r
43 ARM_CORE_INFO *ArmCoreInfoTable;\r
44 UINT32 ClusterId;\r
45 UINT32 CoreId;\r
46 VOID (*SecondaryStart)(VOID);\r
47 UINTN SecondaryEntryAddr;\r
315649cd 48 UINTN AcknowledgedCoreId;\r
44788bae 49\r
50 ClusterId = GET_CLUSTER_ID(MpId);\r
51 CoreId = GET_CORE_ID(MpId);\r
52\r
53 // Get the gArmMpCoreInfoPpiGuid\r
54 PpiListSize = 0;\r
55 ArmPlatformGetPlatformPpiList (&PpiListSize, &PpiList);\r
56 PpiListCount = PpiListSize / sizeof(EFI_PEI_PPI_DESCRIPTOR);\r
57 for (Index = 0; Index < PpiListCount; Index++, PpiList++) {\r
58 if (CompareGuid (PpiList->Guid, &gArmMpCoreInfoPpiGuid) == TRUE) {\r
59 break;\r
60 }\r
61 }\r
62\r
63 // On MP Core Platform we must implement the ARM MP Core Info PPI\r
64 ASSERT (Index != PpiListCount);\r
65\r
66 ArmMpCoreInfoPpi = PpiList->Ppi;\r
67 ArmCoreCount = 0;\r
68 Status = ArmMpCoreInfoPpi->GetMpCoreInfo (&ArmCoreCount, &ArmCoreInfoTable);\r
69 ASSERT_EFI_ERROR (Status);\r
70\r
71 // Find the core in the ArmCoreTable\r
72 for (Index = 0; Index < ArmCoreCount; Index++) {\r
73 if ((ArmCoreInfoTable[Index].ClusterId == ClusterId) && (ArmCoreInfoTable[Index].CoreId == CoreId)) {\r
74 break;\r
75 }\r
76 }\r
77\r
78 // The ARM Core Info Table must define every core\r
79 ASSERT (Index != ArmCoreCount);\r
1d5d0ae9 80\r
f598bf12 81 // Clear Secondary cores MailBox\r
44788bae 82 MmioWrite32 (ArmCoreInfoTable[Index].MailboxClearAddress, ArmCoreInfoTable[Index].MailboxClearValue);\r
1d5d0ae9 83\r
315649cd 84 do {\r
44788bae 85 ArmCallWFI ();\r
315649cd 86\r
87 // Read the Mailbox\r
88 SecondaryEntryAddr = MmioRead32 (ArmCoreInfoTable[Index].MailboxGetAddress);\r
89\r
f598bf12 90 // Acknowledge the interrupt and send End of Interrupt signal.\r
315649cd 91 ArmGicAcknowledgeInterrupt (PcdGet32(PcdGicDistributorBase), PcdGet32(PcdGicInterruptInterfaceBase), &AcknowledgedCoreId, NULL);\r
92 } while ((SecondaryEntryAddr == 0) && (AcknowledgedCoreId != PcdGet32 (PcdGicPrimaryCoreId)));\r
1d5d0ae9 93\r
f598bf12 94 // Jump to secondary core entry point.\r
44788bae 95 SecondaryStart = (VOID (*)())SecondaryEntryAddr;\r
96 SecondaryStart();\r
1d5d0ae9 97\r
f598bf12 98 // The secondaries shouldn't reach here\r
99 ASSERT(FALSE);\r
1d5d0ae9 100}\r
101\r
f598bf12 102VOID\r
103EFIAPI\r
104PrimaryMain (\r
1d5d0ae9 105 IN EFI_PEI_CORE_ENTRY_POINT PeiCoreEntryPoint\r
106 )\r
107{\r
f598bf12 108 EFI_SEC_PEI_HAND_OFF SecCoreData;\r
77de7e53 109 UINTN PpiListSize;\r
110 EFI_PEI_PPI_DESCRIPTOR *PpiList;\r
111 UINTN TemporaryRamBase;\r
112 UINTN TemporaryRamSize;\r
113\r
315649cd 114 // Check PcdGicPrimaryCoreId has been set in case the Primary Core is not the core 0 of Cluster 0\r
115 DEBUG_CODE_BEGIN();\r
116 if ((PcdGet32(PcdArmPrimaryCore) != 0) && (PcdGet32 (PcdGicPrimaryCoreId) == 0)) {\r
117 DEBUG((EFI_D_WARN,"Warning: the PCD PcdGicPrimaryCoreId does not seem to be set up for the configuration.\n"));\r
118 }\r
119 DEBUG_CODE_END();\r
120\r
77de7e53 121 CreatePpiList (&PpiListSize, &PpiList);\r
1d5d0ae9 122\r
55a0d64b 123 // Enable the GIC Distributor\r
6f711615 124 ArmGicEnableDistributor (PcdGet32(PcdGicDistributorBase));\r
1d5d0ae9 125\r
f598bf12 126 // If ArmVe has not been built as Standalone then we need to wake up the secondary cores\r
55a0d64b 127 if (FeaturePcdGet (PcdSendSgiToBringUpSecondaryCores)) {\r
f598bf12 128 // Sending SGI to all the Secondary CPU interfaces\r
4c19ece3 129 ArmGicSendSgiTo (PcdGet32(PcdGicDistributorBase), ARM_GIC_ICDSGIR_FILTER_EVERYONEELSE, 0x0E, PcdGet32 (PcdGicSgiIntId));\r
f598bf12 130 }\r
1d5d0ae9 131\r
77de7e53 132 // Adjust the Temporary Ram as the new Ppi List (Common + Platform Ppi Lists) is created at\r
133 // the base of the primary core stack\r
134 PpiListSize = ALIGN_VALUE(PpiListSize, 0x4);\r
135 TemporaryRamBase = (UINTN)PcdGet32 (PcdCPUCoresStackBase) + PpiListSize;\r
136 TemporaryRamSize = (UINTN)PcdGet32 (PcdCPUCorePrimaryStackSize) - PpiListSize;\r
137\r
3222e7b1 138 // Make sure the size is 8-byte aligned. Once divided by 2, the size should be 4-byte aligned\r
139 // to ensure the stack pointer is 4-byte aligned.\r
140 TemporaryRamSize = TemporaryRamSize - (TemporaryRamSize & (0x8-1));\r
141\r
f598bf12 142 //\r
143 // Bind this information into the SEC hand-off state\r
144 // Note: this must be in sync with the stuff in the asm file\r
145 // Note also: HOBs (pei temp ram) MUST be above stack\r
146 //\r
147 SecCoreData.DataSize = sizeof(EFI_SEC_PEI_HAND_OFF);\r
f92b93c9 148 SecCoreData.BootFirmwareVolumeBase = (VOID *)(UINTN)PcdGet32 (PcdFvBaseAddress);\r
149 SecCoreData.BootFirmwareVolumeSize = PcdGet32 (PcdFvSize);\r
77de7e53 150 SecCoreData.TemporaryRamBase = (VOID *)TemporaryRamBase; // We run on the primary core (and so we use the first stack)\r
151 SecCoreData.TemporaryRamSize = TemporaryRamSize;\r
152 SecCoreData.PeiTemporaryRamBase = SecCoreData.TemporaryRamBase;\r
f598bf12 153 SecCoreData.PeiTemporaryRamSize = SecCoreData.TemporaryRamSize / 2;\r
3222e7b1 154 SecCoreData.StackBase = (VOID *)ALIGN_VALUE((UINTN)(SecCoreData.TemporaryRamBase) + SecCoreData.PeiTemporaryRamSize, 0x4);\r
155 SecCoreData.StackSize = (TemporaryRamBase + TemporaryRamSize) - (UINTN)SecCoreData.StackBase;\r
1d5d0ae9 156\r
f598bf12 157 // Jump to PEI core entry point\r
6f711615 158 PeiCoreEntryPoint (&SecCoreData, PpiList);\r
1d5d0ae9 159}\r