1 /******************************************************************************
3 * Copyright (C) 2014 - 2015 Xilinx, Inc. All rights reserved.
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the "Software"), to deal
7 * in the Software without restriction, including without limitation the rights
8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 * copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
15 * Use of the Software is limited solely to applications:
16 * (a) running on a Xilinx device, or
17 * (b) that interact with a Xilinx device through a bus or interconnect.
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 * XILINX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
24 * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27 * Except as contained in this notice, the name of the Xilinx shall not be used
28 * in advertising or otherwise to promote the sale, use or other dealings in
29 * this Software without prior written authorization from Xilinx.
31 ******************************************************************************/
32 /*****************************************************************************/
36 * This file contains the initial startup code for the Cortex R5 processor
39 * MODIFICATION HISTORY:
41 * Ver Who Date Changes
42 * ----- ---- -------- ---------------------------------------------------
43 * 5.00 pkp 02/10/14 Initial version
44 * 5.04 pkp 09/11/15 Disabled ACTLR.DBWR bit to avoid potential R5 deadlock
46 * 5.04 pkp 02/04/16 Enabled the fault log for lock-step mode
47 * 5.04 pkp 02/25/16 Initialized the banked registers for various modes,
48 * initialized floating point registers and enabled the
49 * cache ECC check before enabling the fault log for
51 * 5.04 pkp 03/24/16 Reset the dbg_lpd_reset before enabling the fault log
52 * to avoid intervention for lock-step mode
59 ******************************************************************************/
61 #include "xparameters.h"
68 .global __supervisor_stack
75 /* Stack Pointer locations for boot code */
76 .set Undef_stack, __undef_stack
77 .set FIQ_stack, __fiq_stack
78 .set Abort_stack, __abort_stack
79 .set SPV_stack, __supervisor_stack
80 .set IRQ_stack, __irq_stack
81 .set SYS_stack, __stack
83 .set vector_base, _vector_table
85 .set RPU_GLBL_CNTL, 0xFF9A0000
86 .set RPU_ERR_INJ, 0xFF9A0020
87 .set RST_LPD_DBG, 0xFF5E0240
88 .set fault_log_enable, 0x101
93 /* this initializes the various processor modes */
100 /* Initialize processor registers to 0 */
115 /* Initialize stack pointer and banked registers for various mode */
116 mrs r0, cpsr /* get the current PSR */
117 mvn r1, #0x1f /* set up the irq stack pointer */
119 orr r2, r2, #0x12 /* IRQ mode */
121 ldr r13,=IRQ_stack /* IRQ stack pointer */
124 mrs r0, cpsr /* get the current PSR */
125 mvn r1, #0x1f /* set up the supervisor stack pointer */
127 orr r2, r2, #0x13 /* supervisor mode */
129 ldr r13,=SPV_stack /* Supervisor stack pointer */
132 mrs r0, cpsr /* get the current PSR */
133 mvn r1, #0x1f /* set up the Abort stack pointer */
135 orr r2, r2, #0x17 /* Abort mode */
137 ldr r13,=Abort_stack /* Abort stack pointer */
140 mrs r0, cpsr /* get the current PSR */
141 mvn r1, #0x1f /* set up the FIQ stack pointer */
143 orr r2, r2, #0x11 /* FIQ mode */
150 ldr r13,=FIQ_stack /* FIQ stack pointer */
153 mrs r0, cpsr /* get the current PSR */
154 mvn r1, #0x1f /* set up the Undefine stack pointer */
156 orr r2, r2, #0x1b /* Undefine mode */
158 ldr r13,=Undef_stack /* Undefine stack pointer */
161 mrs r0, cpsr /* get the current PSR */
162 mvn r1, #0x1f /* set up the system stack pointer */
164 orr r2, r2, #0x1F /* SYS mode */
166 ldr r13,=SYS_stack /* SYS stack pointer */
170 * Enable access to VFP by enabling access to Coprocessors 10 and 11.
171 * Enables Full Access i.e. in both privileged and non privileged modes
173 mrc p15, 0, r0, c1, c0, 2 /* Read Coprocessor Access Control Register (CPACR) */
174 orr r0, r0, #(0xF << 20) /* Enable access to CP 10 & 11 */
175 mcr p15, 0, r0, c1, c0, 2 /* Write Coprocessor Access Control Register (CPACR) */
178 /* enable fpu access */
183 /* clear the floating point register*/
202 /* restore previous value for fpu access */
205 /* Disable MPU and caches */
206 mrc p15, 0, r0, c1, c0, 0 /* Read CP15 Control Register*/
207 bic r0, r0, #0x05 /* Disable MPU (M bit) and data cache (C bit) */
208 bic r0, r0, #0x1000 /* Disable instruction cache (I bit) */
209 dsb /* Ensure all previous loads/stores have completed */
210 mcr p15, 0, r0, c1, c0, 0 /* Write CP15 Control Register */
211 isb /* Ensure subsequent insts execute wrt new MPU settings */
213 /* Disable Branch prediction, TCM ECC checks */
214 mrc p15, 0, r0, c1, c0, 1 /* Read ACTLR */
215 orr r0, r0, #(0x1 << 17) /* Enable RSDIS bit 17 to disable the return stack */
216 orr r0, r0, #(0x1 << 16) /* Clear BP bit 15 and set BP bit 16:*/
217 bic r0, r0, #(0x1 << 15) /* Branch always not taken and history table updates disabled*/
218 bic r0, r0, #(0x1 << 27) /* Disable B1TCM ECC check */
219 bic r0, r0, #(0x1 << 26) /* Disable B0TCM ECC check */
220 bic r0, r0, #(0x1 << 25) /* Disable ATCM ECC check */
221 orr r0, r0, #(0x1 << 5) /* Enable ECC with no forced write through with [5:3]=b'101*/
222 bic r0, r0, #(0x1 << 4)
223 orr r0, r0, #(0x1 << 3)
224 mcr p15, 0, r0, c1, c0, 1 /* Write ACTLR*/
225 dsb /* Complete all outstanding explicit memory operations*/
227 /* Invalidate caches */
228 mov r0,#0 /* r0 = 0 */
230 mcr p15, 0, r0, c7, c5, 0 /* invalidate icache */
231 mcr p15, 0, r0, c15, c5, 0 /* Invalidate entire data cache*/
234 /* enable fault log for lock step */
235 ldr r0,=RPU_GLBL_CNTL
238 /* branch to initialization if split mode*/
240 /* reset the debug logic */
243 orr r1, r1, #(0x1 << 1)
244 orr r1, r1, #(0x1 << 4)
245 orr r1, r1, #(0x1 << 5)
247 /* enable fault log */
249 ldr r1,=fault_log_enable
257 bl Init_MPU /* Initialize MPU */
259 /* Enable Branch prediction */
260 mrc p15, 0, r0, c1, c0, 1 /* Read ACTLR*/
261 bic r0, r0, #(0x1 << 17) /* Clear RSDIS bit 17 to enable return stack*/
262 bic r0, r0, #(0x1 << 16) /* Clear BP bit 15 and BP bit 16:*/
263 bic r0, r0, #(0x1 << 15) /* Normal operation, BP is taken from the global history table.*/
264 orr r0, r0, #(0x1 << 14) /* Disable DBWR for errata 780125 */
265 mcr p15, 0, r0, c1, c0, 1 /* Write ACTLR*/
267 /* Enable icahce and dcache */
272 mcr p15,0,r1,c1,c0,0 /* Enable cache */
273 isb /* isb flush prefetch buffer */
275 /* Warning message to be removed after 2016.1 */
276 /* USEAMP was introduced in 2015.4 with ZynqMP and caused confusion with USE_AMP */
278 #warning "-DUSEAMP=1 is deprecated, use -DVEC_TABLE_IN_OCM instead to set vector table in OCM"
281 /* Set vector table in TCM/LOVEC */
282 #ifndef VEC_TABLE_IN_OCM
283 mrc p15, 0, r0, c1, c0, 0
286 mcr p15, 0, r0, c1, c0, 0
289 /* enable asynchronous abort exception */
294 b _startup /* jump to C startup code */
297 .Ldone: b .Ldone /* Paranoia: we should never get here */