2 // Copyright (c) 2011, ARM Limited. All rights reserved.
4 // This program and the accompanying materials
5 // are licensed and made available under the terms and conditions of the BSD License
6 // which accompanies this distribution. The full text of the license may be found at
7 // http://opensource.org/licenses/bsd-license.php
9 // THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 // WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
14 #include <AsmMacroIoLib.h>
16 #include <Library/PcdLib.h>
22 GCC_ASM_IMPORT(CEntryPoint)
23 GCC_ASM_IMPORT(ArmReadMpidr)
24 GCC_ASM_EXPORT(_ModuleEntryPoint)
26 StartupAddr: .word CEntryPoint
28 ASM_PFX(_ModuleEntryPoint):
30 bl ASM_PFX(ArmReadMpidr)
31 // Get ID of this CPU in Multicore system
32 LoadConstantToReg (FixedPcdGet32(PcdArmPrimaryCoreMask), r1)
35 // Get the top of the primary stacks (and the base of the secondary stacks)
36 LoadConstantToReg (FixedPcdGet32(PcdCPUCoresStackBase), r1)
37 LoadConstantToReg (FixedPcdGet32(PcdCPUCorePrimaryStackSize), r2)
40 // Is it the Primary Core ?
41 LoadConstantToReg (FixedPcdGet32(PcdArmPrimaryCore), r3)
43 beq _SetupPrimaryCoreStack
45 _SetupSecondaryCoreStack:
46 // r1 contains the base of the secondary stacks
48 // Get the Core Position (ClusterId * 4) + CoreId
49 GetCorePositionFromMpId(r0, r5, r2)
50 // The stack starts at the top of the stack region. Add '1' to the Core Position to get the top of the stack
53 // StackOffset = CorePos * StackSize
54 LoadConstantToReg (FixedPcdGet32(PcdCPUCoreSecondaryStackSize), r2)
56 // SP = StackBase + StackOffset
60 // The PEI Core Entry Point has been computed by GenFV and stored in the second entry of the Reset Vector
61 LoadConstantToReg (FixedPcdGet32(PcdFvBaseAddress), r2)
65 // Move sec startup address into a data register
66 // Ensure we're jumping to FV version of the code (not boot remapped alias)
69 // Jump to PrePeiCore C code
71 // r1 = pei_core_address
75 _SetupPrimaryCoreStack:
76 // r1 contains the top of the primary stack
77 LoadConstantToReg (FixedPcdGet32(PcdPeiGlobalVariableSize), r2)
79 // The reserved space for global variable must be 8-bytes aligned for pushing
80 // 64-bit variable on the stack
81 SetPrimaryStack (r1, r2, r3)