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