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>
|
|
|
|
|
2013-01-25 13:05:17 +01:00
|
|
|
#include <Chipset/ArmV7.h>
|
|
|
|
|
2015-07-06 18:56:31 +02:00
|
|
|
GCC_ASM_EXPORT(mSystemMemoryEnd)
|
2011-07-01 13:09:00 +02:00
|
|
|
|
2016-08-10 16:04:27 +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: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
|
|
|
|
|
2016-08-10 16:04:27 +02:00
|
|
|
MOV32 (r1, FixedPcdGet32(PcdSystemMemoryBase) + FixedPcdGet32(PcdSystemMemorySize) - 1)
|
|
|
|
|
2015-07-06 18:56:31 +02:00
|
|
|
// 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
|
2016-08-10 16:04:27 +02:00
|
|
|
MOV32 (r2, FixedPcdGet32(PcdFdBaseAddress))
|
|
|
|
MOV32 (r3, FixedPcdGet32(PcdFdSize) - 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)
|
2016-08-10 16:04:27 +02:00
|
|
|
MOV32 (r4, FixedPcdGet32(PcdSystemMemoryUefiRegionSize))
|
2011-07-06 18:27:21 +02:00
|
|
|
|
|
|
|
//
|
|
|
|
// 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)
|
2016-08-10 16:04:27 +02:00
|
|
|
MOV32 (r9, ~EFI_PAGE_MASK & 0xFFFFFFFF)
|
|
|
|
and 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
|
2016-08-10 16:04:27 +02:00
|
|
|
MOV32 (r2, FixedPcdGet32(PcdCPUCorePrimaryStackSize))
|
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
|
2016-09-07 14:16:18 +02:00
|
|
|
MOV32 (r1, (FixedPcdGet32(PcdCoreCount) - 1) * FixedPcdGet32(PcdCPUCoreSecondaryStackSize))
|
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)
|
2016-08-10 16:04:27 +02:00
|
|
|
MOV32 (r2, FixedPcdGet32(PcdCPUCorePrimaryStackSize))
|
|
|
|
MOV32 (r3, FixedPcdGet32(PcdCPUCoreSecondaryStackSize))
|
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)
|
2016-08-10 16:04:27 +02:00
|
|
|
ldr r4, =ASM_PFX(CEntryPoint)
|
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
|
|
|
|
|
2016-08-10 16:04:27 +02:00
|
|
|
ASM_PFX(mSystemMemoryEnd): .8byte 0
|