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
53 * 5.05 pkp 04/11/16 Enable the comparators for non-JTAG boot mode for
54 * lock-step to avoid putting debug logic to reset
61 ******************************************************************************/
63 #include "xparameters.h"
70 .global __supervisor_stack
77 /* Stack Pointer locations for boot code */
78 .set Undef_stack, __undef_stack
79 .set FIQ_stack, __fiq_stack
80 .set Abort_stack, __abort_stack
81 .set SPV_stack, __supervisor_stack
82 .set IRQ_stack, __irq_stack
83 .set SYS_stack, __stack
85 .set vector_base, _vector_table
87 .set RPU_GLBL_CNTL, 0xFF9A0000
88 .set RPU_ERR_INJ, 0xFF9A0020
89 .set RST_LPD_DBG, 0xFF5E0240
90 .set BOOT_MODE_USER, 0xFF5E0200
91 .set fault_log_enable, 0x101
96 /* this initializes the various processor modes */
103 /* Initialize processor registers to 0 */
118 /* Initialize stack pointer and banked registers for various mode */
119 mrs r0, cpsr /* get the current PSR */
120 mvn r1, #0x1f /* set up the irq stack pointer */
122 orr r2, r2, #0x12 /* IRQ mode */
124 ldr r13,=IRQ_stack /* IRQ stack pointer */
127 mrs r0, cpsr /* get the current PSR */
128 mvn r1, #0x1f /* set up the supervisor stack pointer */
130 orr r2, r2, #0x13 /* supervisor mode */
132 ldr r13,=SPV_stack /* Supervisor stack pointer */
135 mrs r0, cpsr /* get the current PSR */
136 mvn r1, #0x1f /* set up the Abort stack pointer */
138 orr r2, r2, #0x17 /* Abort mode */
140 ldr r13,=Abort_stack /* Abort stack pointer */
143 mrs r0, cpsr /* get the current PSR */
144 mvn r1, #0x1f /* set up the FIQ stack pointer */
146 orr r2, r2, #0x11 /* FIQ mode */
153 ldr r13,=FIQ_stack /* FIQ stack pointer */
156 mrs r0, cpsr /* get the current PSR */
157 mvn r1, #0x1f /* set up the Undefine stack pointer */
159 orr r2, r2, #0x1b /* Undefine mode */
161 ldr r13,=Undef_stack /* Undefine stack pointer */
164 mrs r0, cpsr /* get the current PSR */
165 mvn r1, #0x1f /* set up the system stack pointer */
167 orr r2, r2, #0x1F /* SYS mode */
169 ldr r13,=SYS_stack /* SYS stack pointer */
173 * Enable access to VFP by enabling access to Coprocessors 10 and 11.
174 * Enables Full Access i.e. in both privileged and non privileged modes
176 mrc p15, 0, r0, c1, c0, 2 /* Read Coprocessor Access Control Register (CPACR) */
177 orr r0, r0, #(0xF << 20) /* Enable access to CP 10 & 11 */
178 mcr p15, 0, r0, c1, c0, 2 /* Write Coprocessor Access Control Register (CPACR) */
181 /* enable fpu access */
186 /* clear the floating point register*/
205 /* restore previous value for fpu access */
208 /* Disable MPU and caches */
209 mrc p15, 0, r0, c1, c0, 0 /* Read CP15 Control Register*/
210 bic r0, r0, #0x05 /* Disable MPU (M bit) and data cache (C bit) */
211 bic r0, r0, #0x1000 /* Disable instruction cache (I bit) */
212 dsb /* Ensure all previous loads/stores have completed */
213 mcr p15, 0, r0, c1, c0, 0 /* Write CP15 Control Register */
214 isb /* Ensure subsequent insts execute wrt new MPU settings */
216 /* Disable Branch prediction, TCM ECC checks */
217 mrc p15, 0, r0, c1, c0, 1 /* Read ACTLR */
218 orr r0, r0, #(0x1 << 17) /* Enable RSDIS bit 17 to disable the return stack */
219 orr r0, r0, #(0x1 << 16) /* Clear BP bit 15 and set BP bit 16:*/
220 bic r0, r0, #(0x1 << 15) /* Branch always not taken and history table updates disabled*/
221 bic r0, r0, #(0x1 << 27) /* Disable B1TCM ECC check */
222 bic r0, r0, #(0x1 << 26) /* Disable B0TCM ECC check */
223 bic r0, r0, #(0x1 << 25) /* Disable ATCM ECC check */
224 orr r0, r0, #(0x1 << 5) /* Enable ECC with no forced write through with [5:3]=b'101*/
225 bic r0, r0, #(0x1 << 4)
226 orr r0, r0, #(0x1 << 3)
227 mcr p15, 0, r0, c1, c0, 1 /* Write ACTLR*/
228 dsb /* Complete all outstanding explicit memory operations*/
230 /* Invalidate caches */
231 mov r0,#0 /* r0 = 0 */
233 mcr p15, 0, r0, c7, c5, 0 /* invalidate icache */
234 mcr p15, 0, r0, c15, c5, 0 /* Invalidate entire data cache*/
237 /* enable fault log for lock step */
238 ldr r0,=RPU_GLBL_CNTL
241 /* branch to initialization if split mode*/
243 /* check for boot mode if in lock step, branch to init if JTAG boot mode*/
244 ldr r0,=BOOT_MODE_USER
248 /* reset the debug logic */
251 orr r1, r1, #(0x1 << 1)
252 orr r1, r1, #(0x1 << 4)
253 orr r1, r1, #(0x1 << 5)
255 /* enable fault log */
257 ldr r1,=fault_log_enable
265 bl Init_MPU /* Initialize MPU */
267 /* Enable Branch prediction */
268 mrc p15, 0, r0, c1, c0, 1 /* Read ACTLR*/
269 bic r0, r0, #(0x1 << 17) /* Clear RSDIS bit 17 to enable return stack*/
270 bic r0, r0, #(0x1 << 16) /* Clear BP bit 15 and BP bit 16:*/
271 bic r0, r0, #(0x1 << 15) /* Normal operation, BP is taken from the global history table.*/
272 orr r0, r0, #(0x1 << 14) /* Disable DBWR for errata 780125 */
273 mcr p15, 0, r0, c1, c0, 1 /* Write ACTLR*/
275 /* Enable icahce and dcache */
280 mcr p15,0,r1,c1,c0,0 /* Enable cache */
281 isb /* isb flush prefetch buffer */
283 /* Warning message to be removed after 2016.1 */
284 /* USEAMP was introduced in 2015.4 with ZynqMP and caused confusion with USE_AMP */
286 #warning "-DUSEAMP=1 is deprecated, use -DVEC_TABLE_IN_OCM instead to set vector table in OCM"
289 /* Set vector table in TCM/LOVEC */
290 #ifndef VEC_TABLE_IN_OCM
291 mrc p15, 0, r0, c1, c0, 0
294 mcr p15, 0, r0, c1, c0, 0
297 /* enable asynchronous abort exception */
302 b _startup /* jump to C startup code */
305 .Ldone: b .Ldone /* Paranoia: we should never get here */