]> git.proxmox.com Git - mirror_edk2.git/blame - ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA9x4/CTA9x4Boot.S
ArmPlatformPkg/ArmPlatformLib: Introduce ArmPlatformSecBootAction function
[mirror_edk2.git] / ArmPlatformPkg / ArmVExpressPkg / Library / ArmVExpressLibCTA9x4 / CTA9x4Boot.S
CommitLineData
c52e2dca 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/ArmPlatformLib.h>\r
17#include <Drivers/PL35xSmc.h>\r
18#include <ArmPlatform.h>\r
19#include <AutoGen.h>\r
20\r
21.text\r
22.align 3\r
23\r
44e272fd 24GCC_ASM_EXPORT(ArmPlatformSecBootAction)\r
c52e2dca 25GCC_ASM_EXPORT(ArmPlatformInitializeBootMemory)\r
26GCC_ASM_IMPORT(PL35xSmcInitialize)\r
27\r
28//\r
29// For each Chip Select: ChipSelect / SetCycle / SetOpMode\r
30//\r
31VersatileExpressSmcConfiguration:\r
32 // NOR Flash 0\r
33 .word PL350_SMC_DIRECT_CMD_ADDR_CS(0)\r
3723a71a 34 .word PL350_SMC_SET_CYCLE_NAND_T_RC(0xA) | PL350_SMC_SET_CYCLE_NAND_T_WC(0x3) | PL350_SMC_SET_CYCLE_NAND_T_REA(0x1) | PL350_SMC_SET_CYCLE_NAND_T_WP(0x7) | PL350_SMC_SET_CYCLE_NAND_T_AR(0x1)\r
35 .word PL350_SMC_SET_OPMODE_MEM_WIDTH_32 | PL350_SMC_SET_OPMODE_SET_RD_BURST_LENGTH_CONT | PL350_SMC_SET_OPMODE_SET_WR_BURST_LENGTH_CONT | PL350_SMC_SET_OPMODE_SET_ADV\r
c52e2dca 36\r
37 // NOR Flash 1\r
38 .word PL350_SMC_DIRECT_CMD_ADDR_CS(4)\r
3723a71a 39 .word PL350_SMC_SET_CYCLE_NAND_T_RC(0xA) | PL350_SMC_SET_CYCLE_NAND_T_WC(0x3) | PL350_SMC_SET_CYCLE_NAND_T_REA(0x1) | PL350_SMC_SET_CYCLE_NAND_T_WP(0x7) | PL350_SMC_SET_CYCLE_NAND_T_AR(0x1)\r
40 .word PL350_SMC_SET_OPMODE_MEM_WIDTH_32 | PL350_SMC_SET_OPMODE_SET_RD_BURST_LENGTH_CONT | PL350_SMC_SET_OPMODE_SET_WR_BURST_LENGTH_CONT | PL350_SMC_SET_OPMODE_SET_ADV\r
c52e2dca 41\r
42 // SRAM\r
43 .word PL350_SMC_DIRECT_CMD_ADDR_CS(2)\r
3723a71a 44 .word PL350_SMC_SET_CYCLE_SRAM_T_RC(0x8) | PL350_SMC_SET_CYCLE_SRAM_T_WC(0x5) | PL350_SMC_SET_CYCLE_SRAM_T_CEOE(0x1) | PL350_SMC_SET_CYCLE_SRAM_T_WP(0x6) | PL350_SMC_SET_CYCLE_SRAM_T_PC(0x1) | PL350_SMC_SET_CYCLE_SRAM_T_TR(0x1)\r
45 .word PL350_SMC_SET_OPMODE_MEM_WIDTH_32 | PL350_SMC_SET_OPMODE_SET_ADV\r
c52e2dca 46\r
47 // Usb/Eth/VRAM\r
48 .word PL350_SMC_DIRECT_CMD_ADDR_CS(3)\r
3723a71a 49 .word PL350_SMC_SET_CYCLE_SRAM_T_RC(0xA) | PL350_SMC_SET_CYCLE_SRAM_T_WC(0xA) | PL350_SMC_SET_CYCLE_SRAM_T_CEOE(0x2) | PL350_SMC_SET_CYCLE_SRAM_T_WP(0x2) | PL350_SMC_SET_CYCLE_SRAM_T_PC(0x3) | PL350_SMC_SET_CYCLE_SRAM_T_TR(0x6)\r
50 .word PL350_SMC_SET_OPMODE_MEM_WIDTH_32 | PL350_SMC_SET_OPMODE_SET_RD_SYNC | PL350_SMC_SET_OPMODE_SET_WR_SYNC\r
c52e2dca 51\r
52 // Memory Mapped Peripherals\r
53 .word PL350_SMC_DIRECT_CMD_ADDR_CS(7)\r
3723a71a 54 .word PL350_SMC_SET_CYCLE_SRAM_T_RC(0x6) | PL350_SMC_SET_CYCLE_SRAM_T_WC(0x5) | PL350_SMC_SET_CYCLE_SRAM_T_CEOE(0x1) | PL350_SMC_SET_CYCLE_SRAM_T_WP(0x2) | PL350_SMC_SET_CYCLE_SRAM_T_PC(0x1) | PL350_SMC_SET_CYCLE_SRAM_T_TR(0x1)\r
55 .word PL350_SMC_SET_OPMODE_MEM_WIDTH_32 | PL350_SMC_SET_OPMODE_SET_RD_SYNC | PL350_SMC_SET_OPMODE_SET_WR_SYNC\r
c52e2dca 56\r
57 // VRAM\r
58 .word PL350_SMC_DIRECT_CMD_ADDR_CS(1)\r
59 .word 0x00049249\r
3723a71a 60 .word PL350_SMC_SET_OPMODE_MEM_WIDTH_32 | PL350_SMC_SET_OPMODE_SET_RD_SYNC | PL350_SMC_SET_OPMODE_SET_WR_SYNC\r
c52e2dca 61VersatileExpressSmcConfigurationEnd:\r
62\r
44e272fd 63/**\r
64 Call at the beginning of the platform boot up\r
65\r
66 This function allows the firmware platform to do extra actions at the early\r
67 stage of the platform power up.\r
68\r
69 Note: This function must be implemented in assembler as there is no stack set up yet\r
70\r
71**/\r
72ASM_PFX(ArmPlatformSecBootAction):\r
73 bx lr\r
74\r
c52e2dca 75/**\r
76 Initialize the memory where the initial stacks will reside\r
77\r
78 This memory can contain the initial stacks (Secure and Secure Monitor stacks).\r
79 In some platform, this region is already initialized and the implementation of this function can\r
80 do nothing. This memory can also represent the Secure RAM.\r
81 This function is called before the satck has been set up. Its implementation must ensure the stack\r
82 pointer is not used (probably required to use assembly language)\r
83\r
84**/\r
85ASM_PFX(ArmPlatformInitializeBootMemory):\r
86 mov r5, lr\r
87\r
88 //\r
89 // Initialize PL354 SMC\r
90 //\r
91 LoadConstantToReg (ARM_VE_SMC_CTRL_BASE, r1)\r
1d36ec02 92 LoadConstantToReg (VersatileExpressSmcConfiguration, r2)\r
93 LoadConstantToReg (VersatileExpressSmcConfigurationEnd, r3)\r
c52e2dca 94 blx ASM_PFX(PL35xSmcInitialize)\r
95\r
96 //\r
97 // Page mode setup for VRAM\r
98 //\r
99 LoadConstantToReg (VRAM_MOTHERBOARD_BASE, r2)\r
100\r
101 // Read current state\r
102 ldr r0, [r2, #0]\r
103 ldr r0, [r2, #0]\r
104 ldr r0, = 0x00000000\r
105 str r0, [r2, #0]\r
106 ldr r0, [r2, #0]\r
107\r
108 // Enable page mode\r
109 ldr r0, [r2, #0]\r
110 ldr r0, [r2, #0]\r
111 ldr r0, = 0x00000000\r
112 str r0, [r2, #0]\r
1d36ec02 113 LoadConstantToReg (0x00900090, r0)\r
c52e2dca 114 str r0, [r2, #0]\r
115\r
116 // Confirm page mode enabled\r
117 ldr r0, [r2, #0]\r
118 ldr r0, [r2, #0]\r
119 ldr r0, = 0x00000000\r
120 str r0, [r2, #0]\r
121 ldr r0, [r2, #0]\r
122\r
123 bx r5\r