]> git.proxmox.com Git - mirror_edk2.git/blob - ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA9x4/CTA9x4Helper.S
Add ArmPlatformPkg from ARM Ltd. patch.
[mirror_edk2.git] / ArmPlatformPkg / ArmVExpressPkg / Library / ArmVExpressLibCTA9x4 / CTA9x4Helper.S
1 #------------------------------------------------------------------------------
2 #
3 # ARM VE Entry point. Reset vector in FV header will brach to
4 # _ModuleEntryPoint.
5 #
6 # We use crazy macros, like LoadConstantToReg, since Xcode assembler
7 # does not support = assembly syntax for ldr.
8 #
9 # Copyright (c) 2011, ARM Limited. All rights reserved.
10 #
11 # This program and the accompanying materials
12 # are licensed and made available under the terms and conditions of the BSD License
13 # which accompanies this distribution. The full text of the license may be found at
14 # http://opensource.org/licenses/bsd-license.php
15 #
16 # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
17 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 #
19 #------------------------------------------------------------------------------
20
21 #include <AsmMacroIoLib.h>
22 #include <Base.h>
23 #include <Library/PcdLib.h>
24 #include <Library/ArmPlatformLib.h>
25 #include <AutoGen.h>
26
27 #Start of Code section
28 .text
29 .align 3
30
31 GCC_ASM_EXPORT(ArmPlatformIsMemoryInitialized)
32 GCC_ASM_EXPORT(ArmPlatformInitializeBootMemory)
33 .extern ASM_PFX(InitializeSMC)
34
35 /**
36 Called at the early stage of the Boot phase to know if the memory has already been initialized
37
38 Running the code from the reset vector does not mean we start from cold boot. In some case, we
39 can go through this code with the memory already initialized.
40 Because this function is called at the early stage, the implementation must not use the stack.
41 Its implementation must probably done in assembly to ensure this requirement.
42
43 @return Return the condition value into the 'Z' flag
44
45 **/
46 ASM_PFX(ArmPlatformIsMemoryInitialized):
47 // Check if the memory has been already mapped, if so skipped the memory initialization
48 LoadConstantToReg (ARM_VE_SYS_CFGRW1_REG ,r0)
49 ldr r0, [r0, #0]
50
51 // 0x40000000 = Value of Physical Configuration Switch SW[0]
52 and r0, r0, #0x40000000
53 tst r0, #0x40000000
54 bx lr
55
56 /**
57 Initialize the memory where the initial stacks will reside
58
59 This memory can contain the initial stacks (Secure and Secure Monitor stacks).
60 In some platform, this region is already initialized and the implementation of this function can
61 do nothing. This memory can also represent the Secure RAM.
62 This function is called before the satck has been set up. Its implementation must ensure the stack
63 pointer is not used (probably required to use assembly language)
64
65 **/
66 ASM_PFX(ArmPlatformInitializeBootMemory):
67 mov r5, lr
68 // Initialize PL354 SMC
69 LoadConstantToReg (ARM_VE_SMC_CTRL_BASE, r1)
70 LoadConstantToReg (ARM_VE_SMB_PERIPH_VRAM, r2)
71 blx ASM_PFX(InitializeSMC)
72 bx r5
73
74 .end