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