]> git.proxmox.com Git - mirror_edk2.git/blob - ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA9x4/CTA9x4Helper.asm
ArmPkg/PL35xSmc: Split the SMC initialization in multiple Chip Select initialization...
[mirror_edk2.git] / ArmPlatformPkg / ArmVExpressPkg / Library / ArmVExpressLibCTA9x4 / CTA9x4Helper.asm
1 //
2 // Copyright (c) 2011, ARM Limited. All rights reserved.
3 //
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
8 //
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.
11 //
12 //
13
14 #include <AsmMacroIoLib.h>
15 #include <Base.h>
16 #include <Library/PcdLib.h>
17 #include <ArmPlatform.h>
18 #include <Drivers/PL354Smc.h>
19 #include <AutoGen.h>
20
21 INCLUDE AsmMacroIoLib.inc
22
23 EXPORT ArmPlatformIsMemoryInitialized
24 EXPORT ArmPlatformInitializeBootMemory
25 IMPORT SMCInitializeNOR
26 IMPORT SMCInitializeSRAM
27 IMPORT SMCInitializePeripherals
28 IMPORT SMCInitializeVRAM
29
30 PRESERVE8
31 AREA CTA9x4Helper, CODE, READONLY
32
33 /**
34 Called at the early stage of the Boot phase to know if the memory has already been initialized
35
36 Running the code from the reset vector does not mean we start from cold boot. In some case, we
37 can go through this code with the memory already initialized.
38 Because this function is called at the early stage, the implementation must not use the stack.
39 Its implementation must probably done in assembly to ensure this requirement.
40
41 @return Return the condition value into the 'Z' flag
42
43 **/
44 ArmPlatformIsMemoryInitialized
45 // Check if the memory has been already mapped, if so skipped the memory initialization
46 LoadConstantToReg (ARM_VE_SYS_CFGRW1_REG ,r0)
47 ldr r0, [r0, #0]
48
49 // 0x40000000 = Value of Physical Configuration Switch SW[0]
50 and r0, r0, #0x40000000
51 tst r0, #0x40000000
52 bx lr
53
54 /**
55 Initialize the memory where the initial stacks will reside
56
57 This memory can contain the initial stacks (Secure and Secure Monitor stacks).
58 In some platform, this region is already initialized and the implementation of this function can
59 do nothing. This memory can also represent the Secure RAM.
60 This function is called before the satck has been set up. Its implementation must ensure the stack
61 pointer is not used (probably required to use assembly language)
62
63 **/
64 ArmPlatformInitializeBootMemory
65 mov r5, lr
66
67 //
68 // Initialize PL354 SMC
69 //
70 LoadConstantToReg (ARM_VE_SMC_CTRL_BASE, r1)
71
72 // NOR Flash 0
73 mov r2, PL354_SMC_DIRECT_CMD_ADDR_CS(0,0)
74 blx SMCInitializeNOR
75
76 // NOR Flash 1
77 mov r2, PL354_SMC_DIRECT_CMD_ADDR_CS(1,0)
78 blx SMCInitializeNOR
79
80 // Setup SRAM
81 blx SMCInitializeSRAM
82
83 // Memory Mapped Peripherals
84 blx SMCInitializePeripherals
85
86 // Initialize VRAM
87 //TODO: Check if we really must inititialize Video SRAM in UEFI. Does Linux can do it ? Does the Video driver can do it ?
88 // It will be faster (only initialize if required) and easier (remove assembly code because of a stack available) to move this initialization.
89 LoadConstantToReg (VRAM_MOTHERBOARD_BASE, r2)
90 blx SMCInitializeVRAM
91
92 bx r5
93
94 END