]> git.proxmox.com Git - mirror_edk2.git/blame - ArmPlatformPkg/PrePi/MainMPCore.c
ArmPlatformPkg: Introduce ArmPlatformGlobalVariableLib
[mirror_edk2.git] / ArmPlatformPkg / PrePi / MainMPCore.c
CommitLineData
cd872e40 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 "PrePi.h"\r
16\r
55a0d64b 17#include <Library/ArmGicLib.h>\r
cd872e40 18#include <Library/ArmMPCoreMailBoxLib.h>\r
19#include <Chipset/ArmV7.h>\r
cd872e40 20\r
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
d269095b 32 // In some cases, the secondary cores are waiting for an SGI from the next stage boot loader toresume their initialization\r
33 if (!FixedPcdGet32(PcdSendSgiToBringUpSecondaryCores)) {\r
cd872e40 34 // Sending SGI to all the Secondary CPU interfaces\r
55a0d64b 35 ArmGicSendSgiTo (PcdGet32(PcdGicDistributorBase), ARM_GIC_ICDSGIR_FILTER_EVERYONEELSE, 0x0E);\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
49 // Function pointer to Secondary Core entry point\r
50 VOID (*secondary_start)(VOID);\r
51 UINTN secondary_entry_addr=0;\r
52\r
53 // Clear Secondary cores MailBox\r
54 ArmClearMPCoreMailbox();\r
55\r
56 while (secondary_entry_addr = ArmGetMPCoreMailbox(), secondary_entry_addr == 0) {\r
57 ArmCallWFI();\r
58 // Acknowledge the interrupt and send End of Interrupt signal.\r
0787bc61 59 ArmGicAcknowledgeSgiFrom (PcdGet32(PcdGicInterruptInterfaceBase), PRIMARY_CORE_ID);\r
cd872e40 60 }\r
61\r
62 secondary_start = (VOID (*)())secondary_entry_addr;\r
63\r
64 // Jump to secondary core entry point.\r
65 secondary_start();\r
66\r
67 // The secondaries shouldn't reach here\r
68 ASSERT(FALSE);\r
69}\r