2011-07-01 13:09:00 +02:00
|
|
|
//
|
2015-07-06 18:56:31 +02:00
|
|
|
// Copyright (c) 2011-2015, ARM Limited. All rights reserved.
|
2011-07-01 13:09:00 +02:00
|
|
|
//
|
|
|
|
// This program and the accompanying materials
|
|
|
|
// are licensed and made available under the terms and conditions of the BSD License
|
|
|
|
// which accompanies this distribution. The full text of the license may be found at
|
|
|
|
// http://opensource.org/licenses/bsd-license.php
|
|
|
|
//
|
|
|
|
// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|
|
|
//
|
|
|
|
//
|
|
|
|
|
|
|
|
#include <AsmMacroIoLib.h>
|
|
|
|
#include <Base.h>
|
|
|
|
#include <Library/PcdLib.h>
|
|
|
|
#include <AutoGen.h>
|
|
|
|
|
2013-01-25 13:05:17 +01:00
|
|
|
#include <Chipset/ArmV7.h>
|
|
|
|
|
2011-07-01 13:09:00 +02:00
|
|
|
.text
|
|
|
|
.align 3
|
|
|
|
|
|
|
|
GCC_ASM_IMPORT(CEntryPoint)
|
2013-05-10 14:41:27 +02:00
|
|
|
GCC_ASM_IMPORT(ArmPlatformIsPrimaryCore)
|
2011-09-23 01:01:13 +02:00
|
|
|
GCC_ASM_IMPORT(ArmReadMpidr)
|
2013-05-10 14:49:10 +02:00
|
|
|
GCC_ASM_IMPORT(ArmPlatformPeiBootAction)
|
2012-09-28 13:01:36 +02:00
|
|
|
GCC_ASM_IMPORT(ArmPlatformStackSet)
|
2011-07-06 18:27:21 +02:00
|
|
|
GCC_ASM_EXPORT(_ModuleEntryPoint)
|
2015-07-06 18:56:31 +02:00
|
|
|
GCC_ASM_EXPORT(mSystemMemoryEnd)
|
2011-07-01 13:09:00 +02:00
|
|
|
|
2015-07-06 18:56:31 +02:00
|
|
|
StartupAddr: .word CEntryPoint
|
|
|
|
mSystemMemoryEnd: .8byte 0
|
2011-07-01 13:09:00 +02:00
|
|
|
|
|
|
|
|
|
|
|
ASM_PFX(_ModuleEntryPoint):
|
2013-05-10 14:49:10 +02:00
|
|
|
// Do early platform specific actions
|
|
|
|
bl ASM_PFX(ArmPlatformPeiBootAction)
|
|
|
|
|
2011-09-23 01:01:13 +02:00
|
|
|
// Get ID of this CPU in Multicore system
|
|
|
|
bl ASM_PFX(ArmReadMpidr)
|
2013-05-10 14:41:27 +02:00
|
|
|
// Keep a copy of the MpId register value
|
2014-01-23 01:59:08 +01:00
|
|
|
mov r8, r0
|
2011-07-01 13:09:00 +02:00
|
|
|
|
2011-07-06 18:27:21 +02:00
|
|
|
_SetSVCMode:
|
2011-11-02 00:41:52 +01:00
|
|
|
// Enter SVC mode, Disable FIQ and IRQ
|
2013-01-25 13:05:17 +01:00
|
|
|
mov r1, #(CPSR_MODE_SVC | CPSR_IRQ | CPSR_FIQ)
|
2011-07-06 18:27:21 +02:00
|
|
|
msr CPSR_c, r1
|
|
|
|
|
2011-09-23 01:05:20 +02:00
|
|
|
// Check if we can install the stack at the top of the System Memory or if we need
|
2011-07-06 18:27:21 +02:00
|
|
|
// to install the stacks at the bottom of the Firmware Device (case the FD is located
|
|
|
|
// at the top of the DRAM)
|
2015-07-06 18:56:31 +02:00
|
|
|
_SystemMemoryEndInit:
|
|
|
|
ldr r1, mSystemMemoryEnd
|
|
|
|
|
|
|
|
// Is mSystemMemoryEnd initialized?
|
|
|
|
cmp r1, #0
|
|
|
|
bne _SetupStackPosition
|
|
|
|
|
|
|
|
LoadConstantToReg (FixedPcdGet32(PcdSystemMemoryBase), r1)
|
|
|
|
LoadConstantToReg (FixedPcdGet32(PcdSystemMemorySize), r2)
|
2012-02-28 18:22:13 +01:00
|
|
|
sub r2, r2, #1
|
2015-07-06 18:56:31 +02:00
|
|
|
add r1, r1, r2
|
|
|
|
// Update the global variable
|
|
|
|
adr r2, mSystemMemoryEnd
|
|
|
|
str r1, [r2]
|
|
|
|
|
|
|
|
_SetupStackPosition:
|
|
|
|
// r1 = SystemMemoryTop
|
2011-07-01 13:09:00 +02:00
|
|
|
|
2011-07-06 18:27:21 +02:00
|
|
|
// Calculate Top of the Firmware Device
|
2011-09-23 01:06:31 +02:00
|
|
|
LoadConstantToReg (FixedPcdGet32(PcdFdBaseAddress), r2)
|
|
|
|
LoadConstantToReg (FixedPcdGet32(PcdFdSize), r3)
|
2012-02-28 18:22:13 +01:00
|
|
|
sub r3, r3, #1
|
2012-03-26 12:48:45 +02:00
|
|
|
add r3, r3, r2 // r3 = FdTop = PcdFdBaseAddress + PcdFdSize
|
2011-07-06 18:27:21 +02:00
|
|
|
|
|
|
|
// UEFI Memory Size (stacks are allocated in this region)
|
|
|
|
LoadConstantToReg (FixedPcdGet32(PcdSystemMemoryUefiRegionSize), r4)
|
|
|
|
|
|
|
|
//
|
|
|
|
// Reserve the memory for the UEFI region (contain stacks on its top)
|
|
|
|
//
|
|
|
|
|
|
|
|
// Calculate how much space there is between the top of the Firmware and the Top of the System Memory
|
ARM Packages: Replace tabs by spaces for indentation
Replace tabs by spaces for indentation to comply to EDK2 coding standards.
Done in files with extension ".S", ".c", ".h", ".asm", ".dsc", ".inc", "*.inf",
"*.dec" or ".fdf" and located in ArmPkg, ArmPlatformPkg, EmbeddedPkg,
BeagleBoardPkg or Omap35xxPkg.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
Reviewed-By: Olivier Martin <olivier.martin@arm.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15901 6f19259b-4bc3-4df7-8a09-765794883524
2014-08-26 12:14:17 +02:00
|
|
|
subs r0, r1, r3 // r0 = SystemMemoryTop - FdTop
|
|
|
|
bmi _SetupStack // Jump if negative (FdTop > SystemMemoryTop). Case when the PrePi is in XIP memory outside of the DRAM
|
|
|
|
cmp r0, r4
|
|
|
|
bge _SetupStack
|
2011-07-06 18:27:21 +02:00
|
|
|
|
|
|
|
// Case the top of stacks is the FdBaseAddress
|
ARM Packages: Replace tabs by spaces for indentation
Replace tabs by spaces for indentation to comply to EDK2 coding standards.
Done in files with extension ".S", ".c", ".h", ".asm", ".dsc", ".inc", "*.inf",
"*.dec" or ".fdf" and located in ArmPkg, ArmPlatformPkg, EmbeddedPkg,
BeagleBoardPkg or Omap35xxPkg.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
Reviewed-By: Olivier Martin <olivier.martin@arm.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15901 6f19259b-4bc3-4df7-8a09-765794883524
2014-08-26 12:14:17 +02:00
|
|
|
mov r1, r2
|
2011-07-01 13:09:00 +02:00
|
|
|
|
|
|
|
_SetupStack:
|
2011-09-23 01:05:20 +02:00
|
|
|
// r1 contains the top of the stack (and the UEFI Memory)
|
2011-07-06 18:27:21 +02:00
|
|
|
|
2012-02-28 18:22:13 +01:00
|
|
|
// Because the 'push' instruction is equivalent to 'stmdb' (decrement before), we need to increment
|
|
|
|
// one to the top of the stack. We check if incrementing one does not overflow (case of DRAM at the
|
|
|
|
// top of the memory space)
|
2014-01-23 01:59:08 +01:00
|
|
|
adds r9, r1, #1
|
2012-02-28 18:22:13 +01:00
|
|
|
bcs _SetupOverflowStack
|
|
|
|
|
|
|
|
_SetupAlignedStack:
|
2014-01-23 01:59:08 +01:00
|
|
|
mov r1, r9
|
2012-02-28 18:22:13 +01:00
|
|
|
b _GetBaseUefiMemory
|
|
|
|
|
|
|
|
_SetupOverflowStack:
|
|
|
|
// Case memory at the top of the address space. Ensure the top of the stack is EFI_PAGE_SIZE
|
|
|
|
// aligned (4KB)
|
2014-01-23 01:59:08 +01:00
|
|
|
LoadConstantToReg (EFI_PAGE_MASK, r9)
|
|
|
|
and r9, r9, r1
|
|
|
|
sub r1, r1, r9
|
2012-02-28 18:22:13 +01:00
|
|
|
|
|
|
|
_GetBaseUefiMemory:
|
2011-07-06 18:27:21 +02:00
|
|
|
// Calculate the Base of the UEFI Memory
|
2014-01-23 01:59:08 +01:00
|
|
|
sub r9, r1, r4
|
2011-07-01 13:09:00 +02:00
|
|
|
|
2011-09-23 01:05:20 +02:00
|
|
|
_GetStackBase:
|
2012-02-28 18:23:53 +01:00
|
|
|
// r1 = The top of the Mpcore Stacks
|
2011-09-23 01:05:20 +02:00
|
|
|
// Stack for the primary core = PrimaryCoreStack
|
|
|
|
LoadConstantToReg (FixedPcdGet32(PcdCPUCorePrimaryStackSize), r2)
|
2014-01-23 01:59:08 +01:00
|
|
|
sub r10, r1, r2
|
2012-09-28 13:01:36 +02:00
|
|
|
|
|
|
|
// Stack for the secondary core = Number of Cores - 1
|
|
|
|
LoadConstantToReg (FixedPcdGet32(PcdCoreCount), r0)
|
ARM Packages: Replace tabs by spaces for indentation
Replace tabs by spaces for indentation to comply to EDK2 coding standards.
Done in files with extension ".S", ".c", ".h", ".asm", ".dsc", ".inc", "*.inf",
"*.dec" or ".fdf" and located in ArmPkg, ArmPlatformPkg, EmbeddedPkg,
BeagleBoardPkg or Omap35xxPkg.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
Reviewed-By: Olivier Martin <olivier.martin@arm.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15901 6f19259b-4bc3-4df7-8a09-765794883524
2014-08-26 12:14:17 +02:00
|
|
|
sub r0, r0, #1
|
2012-09-28 13:01:36 +02:00
|
|
|
LoadConstantToReg (FixedPcdGet32(PcdCPUCoreSecondaryStackSize), r1)
|
|
|
|
mul r1, r1, r0
|
2014-01-23 01:59:08 +01:00
|
|
|
sub r10, r10, r1
|
2012-09-28 13:01:36 +02:00
|
|
|
|
2014-01-23 01:59:08 +01:00
|
|
|
// r10 = The base of the MpCore Stacks (primary stack & secondary stacks)
|
ARM Packages: Replace tabs by spaces for indentation
Replace tabs by spaces for indentation to comply to EDK2 coding standards.
Done in files with extension ".S", ".c", ".h", ".asm", ".dsc", ".inc", "*.inf",
"*.dec" or ".fdf" and located in ArmPkg, ArmPlatformPkg, EmbeddedPkg,
BeagleBoardPkg or Omap35xxPkg.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
Reviewed-By: Olivier Martin <olivier.martin@arm.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15901 6f19259b-4bc3-4df7-8a09-765794883524
2014-08-26 12:14:17 +02:00
|
|
|
mov r0, r10
|
|
|
|
mov r1, r8
|
2012-09-28 13:01:36 +02:00
|
|
|
//ArmPlatformStackSet(StackBase, MpId, PrimaryStackSize, SecondaryStackSize)
|
2012-02-28 18:23:53 +01:00
|
|
|
LoadConstantToReg (FixedPcdGet32(PcdCPUCorePrimaryStackSize), r2)
|
2012-09-28 13:01:36 +02:00
|
|
|
LoadConstantToReg (FixedPcdGet32(PcdCPUCoreSecondaryStackSize), r3)
|
ARM Packages: Replace tabs by spaces for indentation
Replace tabs by spaces for indentation to comply to EDK2 coding standards.
Done in files with extension ".S", ".c", ".h", ".asm", ".dsc", ".inc", "*.inf",
"*.dec" or ".fdf" and located in ArmPkg, ArmPlatformPkg, EmbeddedPkg,
BeagleBoardPkg or Omap35xxPkg.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
Reviewed-By: Olivier Martin <olivier.martin@arm.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15901 6f19259b-4bc3-4df7-8a09-765794883524
2014-08-26 12:14:17 +02:00
|
|
|
bl ASM_PFX(ArmPlatformStackSet)
|
2011-09-23 01:05:20 +02:00
|
|
|
|
|
|
|
// Is it the Primary Core ?
|
2014-01-23 01:59:08 +01:00
|
|
|
mov r0, r8
|
2013-05-10 14:41:27 +02:00
|
|
|
bl ASM_PFX(ArmPlatformIsPrimaryCore)
|
|
|
|
cmp r0, #1
|
2011-07-01 13:09:00 +02:00
|
|
|
bne _PrepareArguments
|
|
|
|
|
|
|
|
_PrepareArguments:
|
2014-01-23 01:59:08 +01:00
|
|
|
mov r0, r8
|
|
|
|
mov r1, r9
|
|
|
|
mov r2, r10
|
2011-09-23 01:07:55 +02:00
|
|
|
mov r3, sp
|
|
|
|
|
2011-07-01 13:09:00 +02:00
|
|
|
// Move sec startup address into a data register
|
|
|
|
// Ensure we're jumping to FV version of the code (not boot remapped alias)
|
2011-09-23 01:07:55 +02:00
|
|
|
ldr r4, StartupAddr
|
2011-07-01 13:09:00 +02:00
|
|
|
|
2011-07-06 18:27:21 +02:00
|
|
|
// Jump to PrePiCore C code
|
2011-09-23 01:01:13 +02:00
|
|
|
// r0 = MpId
|
2011-07-01 13:09:00 +02:00
|
|
|
// r1 = UefiMemoryBase
|
2011-09-23 01:07:55 +02:00
|
|
|
// r2 = StacksBase
|
|
|
|
blx r4
|
2011-07-01 13:09:00 +02:00
|
|
|
|
2011-09-23 01:05:20 +02:00
|
|
|
_NeverReturn:
|
|
|
|
b _NeverReturn
|
|
|
|
|