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