2011-09-23 00:53:54 +02:00
|
|
|
//
|
2013-05-10 14:41:27 +02:00
|
|
|
// Copyright (c) 2011-2013, ARM Limited. All rights reserved.
|
2011-09-23 00:53:54 +02:00
|
|
|
//
|
2019-04-04 01:03:21 +02:00
|
|
|
// SPDX-License-Identifier: BSD-2-Clause-Patent
|
2011-09-23 00:53:54 +02:00
|
|
|
//
|
|
|
|
//
|
|
|
|
|
|
|
|
#include <AsmMacroIoLib.h>
|
|
|
|
|
2016-08-10 16:24:24 +02:00
|
|
|
ASM_FUNC(_ModuleEntryPoint)
|
2013-05-10 14:49:10 +02:00
|
|
|
// Do early platform specific actions
|
|
|
|
bl ASM_PFX(ArmPlatformPeiBootAction)
|
|
|
|
|
2011-09-23 01:05:20 +02:00
|
|
|
// Identify CPU ID
|
2011-09-23 01:01:13 +02:00
|
|
|
bl ASM_PFX(ArmReadMpidr)
|
2013-05-10 14:41:27 +02:00
|
|
|
// Keep a copy of the MpId register value
|
|
|
|
mov r5, r0
|
|
|
|
|
|
|
|
// Is it the Primary Core ?
|
|
|
|
bl ASM_PFX(ArmPlatformIsPrimaryCore)
|
|
|
|
|
2012-02-28 18:23:53 +01:00
|
|
|
// Get the top of the primary stacks (and the base of the secondary stacks)
|
2016-08-10 16:24:24 +02:00
|
|
|
MOV32 (r1, FixedPcdGet64(PcdCPUCoresStackBase) + FixedPcdGet32(PcdCPUCorePrimaryStackSize))
|
2011-09-23 01:05:20 +02:00
|
|
|
|
2013-05-10 14:41:27 +02:00
|
|
|
// r0 is equal to 1 if I am the primary core
|
|
|
|
cmp r0, #1
|
2011-09-23 01:05:20 +02:00
|
|
|
beq _SetupPrimaryCoreStack
|
|
|
|
|
|
|
|
_SetupSecondaryCoreStack:
|
2012-02-28 18:23:53 +01:00
|
|
|
// r1 contains the base of the secondary stacks
|
2011-09-23 01:05:20 +02:00
|
|
|
|
2013-05-10 14:46:11 +02:00
|
|
|
// Get the Core Position
|
|
|
|
mov r6, r1 // Save base of the secondary stacks
|
|
|
|
mov r0, r5
|
|
|
|
bl ASM_PFX(ArmPlatformGetCorePosition)
|
2011-09-23 01:05:20 +02:00
|
|
|
// The stack starts at the top of the stack region. Add '1' to the Core Position to get the top of the stack
|
2012-02-28 18:23:53 +01:00
|
|
|
add r0, r0, #1
|
2011-09-23 01:05:20 +02:00
|
|
|
|
|
|
|
// StackOffset = CorePos * StackSize
|
2016-08-10 16:24:24 +02:00
|
|
|
MOV32 (r2, FixedPcdGet32(PcdCPUCoreSecondaryStackSize))
|
2012-02-28 18:23:53 +01:00
|
|
|
mul r0, r0, r2
|
2011-09-23 01:05:20 +02:00
|
|
|
// SP = StackBase + StackOffset
|
2013-05-10 14:46:11 +02:00
|
|
|
add sp, r6, r0
|
2011-09-23 00:53:54 +02:00
|
|
|
|
|
|
|
_PrepareArguments:
|
2011-09-23 01:05:20 +02:00
|
|
|
// The PEI Core Entry Point has been computed by GenFV and stored in the second entry of the Reset Vector
|
2016-08-10 16:24:24 +02:00
|
|
|
MOV32 (r2, FixedPcdGet32(PcdFvBaseAddress))
|
|
|
|
ldr r1, [r2, #4]
|
2011-09-23 00:53:54 +02:00
|
|
|
|
2012-02-28 18:23:53 +01:00
|
|
|
// Move sec startup address into a data register
|
|
|
|
// Ensure we're jumping to FV version of the code (not boot remapped alias)
|
2016-08-10 16:24:24 +02:00
|
|
|
ldr r3, =ASM_PFX(CEntryPoint)
|
2014-08-19 15:29:52 +02:00
|
|
|
|
2012-02-28 18:23:53 +01:00
|
|
|
// Jump to PrePeiCore C code
|
2011-09-23 01:05:20 +02:00
|
|
|
// r0 = mp_id
|
|
|
|
// r1 = pei_core_address
|
2012-02-28 18:23:53 +01:00
|
|
|
mov r0, r5
|
|
|
|
blx r3
|
|
|
|
|
|
|
|
_SetupPrimaryCoreStack:
|
2015-11-27 18:07:31 +01:00
|
|
|
mov sp, r1
|
2017-10-20 12:44:04 +02:00
|
|
|
MOV32 (r8, FixedPcdGet64 (PcdCPUCoresStackBase))
|
|
|
|
MOV32 (r9, FixedPcdGet32 (PcdInitValueInTempStack))
|
|
|
|
mov r10, r9
|
|
|
|
mov r11, r9
|
|
|
|
mov r12, r9
|
|
|
|
0:stm r8!, {r9-r12}
|
|
|
|
cmp r8, r1
|
|
|
|
blt 0b
|
2012-02-28 18:23:53 +01:00
|
|
|
b _PrepareArguments
|
2011-09-23 01:05:20 +02:00
|
|
|
|
|
|
|
_NeverReturn:
|
|
|
|
b _NeverReturn
|