]> git.proxmox.com Git - mirror_edk2.git/blame - ArmPlatformPkg/PrePeiCore/MainMPCore.c
ArmPlatformPkg: Rename gEmbeddedTokenSpaceGuid.PcdEmbeddedFd* into gArmTokenSpaceGuid...
[mirror_edk2.git] / ArmPlatformPkg / PrePeiCore / MainMPCore.c
CommitLineData
1d5d0ae9 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 <PiPei.h>\r
16#include <Library/DebugLib.h>\r
17#include <Library/PcdLib.h>\r
18#include <Library/ArmMPCoreMailBoxLib.h>\r
19#include <Chipset/ArmV7.h>\r
20#include <Drivers/PL390Gic.h>\r
21\r
22extern EFI_PEI_PPI_DESCRIPTOR *gSecPpiTable;\r
23\r
24/*\r
25 * This is the main function for secondary cores. They loop around until a non Null value is written to\r
26 * SYS_FLAGS register.The SYS_FLAGS register is platform specific.\r
27 * Note:The secondary cores, while executing secondary_main, assumes that:\r
28 * : SGI 0 is configured as Non-secure interrupt\r
29 * : Priority Mask is configured to allow SGI 0\r
30 * : Interrupt Distributor and CPU interfaces are enabled\r
31 *\r
32 */\r
33VOID\r
34EFIAPI\r
35secondary_main(IN UINTN CoreId)\r
36{\r
37 //Function pointer to Secondary Core entry point\r
38 VOID (*secondary_start)(VOID);\r
39 UINTN secondary_entry_addr=0;\r
40\r
41 //Clear Secondary cores MailBox\r
42 ArmClearMPCoreMailbox();\r
43\r
44 while (secondary_entry_addr = ArmGetMPCoreMailbox(), secondary_entry_addr == 0) {\r
45 ArmCallWFI();\r
46 //Acknowledge the interrupt and send End of Interrupt signal.\r
47 PL390GicAcknowledgeSgiFrom(PcdGet32(PcdGicInterruptInterfaceBase),0/*CoreId*/);\r
48 }\r
49\r
50 secondary_start = (VOID (*)())secondary_entry_addr;\r
51\r
52 //Jump to secondary core entry point.\r
53 secondary_start();\r
54\r
55 //the secondaries shouldn't reach here\r
56 ASSERT(FALSE);\r
57}\r
58\r
59VOID primary_main (\r
60 IN EFI_PEI_CORE_ENTRY_POINT PeiCoreEntryPoint\r
61 )\r
62{\r
63 EFI_SEC_PEI_HAND_OFF SecCoreData;\r
64\r
65 //Enable the GIC Distributor\r
66 PL390GicEnableDistributor(PcdGet32(PcdGicDistributorBase));\r
67\r
68 // If ArmVe has not been built as Standalone then we need to wake up the secondary cores\r
69 if (FeaturePcdGet(PcdStandalone) == FALSE) {\r
70 // Sending SGI to all the Secondary CPU interfaces\r
71 PL390GicSendSgiTo (PcdGet32(PcdGicDistributorBase), GIC_ICDSGIR_FILTER_EVERYONEELSE, 0x0E);\r
72 }\r
73\r
74 //\r
75 // Bind this information into the SEC hand-off state\r
76 // Note: this must be in sync with the stuff in the asm file\r
77 // Note also: HOBs (pei temp ram) MUST be above stack\r
78 //\r
79 SecCoreData.DataSize = sizeof(EFI_SEC_PEI_HAND_OFF);\r
262a9b04 80 SecCoreData.BootFirmwareVolumeBase = (VOID *)(UINTN)PcdGet32 (PcdNormalFdBaseAddress);\r
81 SecCoreData.BootFirmwareVolumeSize = PcdGet32 (PcdNormalFdSize);\r
1d5d0ae9 82 SecCoreData.TemporaryRamBase = (VOID *)(UINTN)PcdGet32 (PcdCPUCoresNonSecStackBase); // We consider we run on the primary core (and so we use the first stack)\r
83 SecCoreData.TemporaryRamSize = (UINTN)(UINTN)PcdGet32 (PcdCPUCoresNonSecStackSize);\r
84 SecCoreData.PeiTemporaryRamBase = (VOID *)((UINTN)(SecCoreData.TemporaryRamBase) + (SecCoreData.TemporaryRamSize / 2));\r
85 SecCoreData.PeiTemporaryRamSize = SecCoreData.TemporaryRamSize / 2;\r
86 SecCoreData.StackBase = SecCoreData.TemporaryRamBase;\r
87 SecCoreData.StackSize = SecCoreData.TemporaryRamSize - SecCoreData.PeiTemporaryRamSize;\r
88\r
89 // jump to pei core entry point\r
90 (PeiCoreEntryPoint)(&SecCoreData, (VOID *)&gSecPpiTable);\r
91}\r