2 // Copyright (c) 2011-2013, 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>
19 INCLUDE AsmMacroIoLib.inc
22 IMPORT ArmPlatformGetCorePosition
23 IMPORT ArmPlatformIsPrimaryCore
25 IMPORT ArmPlatformPeiBootAction
26 EXPORT _ModuleEntryPoint
29 AREA PrePeiCoreEntryPoint, CODE, READONLY
31 StartupAddr DCD CEntryPoint
34 // Do early platform specific actions
35 bl ArmPlatformPeiBootAction
39 // Keep a copy of the MpId register value
42 // Is it the Primary Core ?
43 bl ArmPlatformIsPrimaryCore
45 // Get the top of the primary stacks (and the base of the secondary stacks)
46 LoadConstantToReg (FixedPcdGet64(PcdCPUCoresStackBase), r1)
47 LoadConstantToReg (FixedPcdGet32(PcdCPUCorePrimaryStackSize), r2)
50 // r0 is equal to 1 if I am the primary core
52 beq _SetupPrimaryCoreStack
54 _SetupSecondaryCoreStack
55 // r1 contains the base of the secondary stacks
57 // Get the Core Position
58 mov r6, r1 // Save base of the secondary stacks
60 bl ArmPlatformGetCorePosition
61 // The stack starts at the top of the stack region. Add '1' to the Core Position to get the top of the stack
64 // StackOffset = CorePos * StackSize
65 LoadConstantToReg (FixedPcdGet32(PcdCPUCoreSecondaryStackSize), r2)
67 // SP = StackBase + StackOffset
71 // The PEI Core Entry Point has been computed by GenFV and stored in the second entry of the Reset Vector
72 LoadConstantToReg (FixedPcdGet32(PcdFvBaseAddress), r2)
76 // Move sec startup address into a data register
77 // Ensure we're jumping to FV version of the code (not boot remapped alias)
80 // Jump to PrePeiCore C code
82 // r1 = pei_core_address
86 _SetupPrimaryCoreStack