]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_A53_64-bit_UltraScale_MPSoC/RTOSDemo_A53_bsp/psu_cortexa53_0/libsrc/standalone_v6_1/src/xil-crt0.S
Update Zynq MPSoC hardware definition and BSP files to be those shipped with the...
[freertos] / FreeRTOS / Demo / CORTEX_A53_64-bit_UltraScale_MPSoC / RTOSDemo_A53_bsp / psu_cortexa53_0 / libsrc / standalone_v6_1 / src / xil-crt0.S
1 /******************************************************************************
2 *
3 * Copyright (C) 2014 - 2015 Xilinx, Inc. All rights reserved.
4 *
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:
11 *
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
14 *
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.
18 *
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
25 * SOFTWARE.
26 *
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.
30 *
31 ******************************************************************************/
32 /*****************************************************************************/
33 /**
34 * @file xil-crt0.S
35 *
36 * <pre>
37 * MODIFICATION HISTORY:
38 *
39 * Ver   Who  Date     Changes
40 * ----- ---- -------- ---------------------------------------------------
41 * 5.00  pkp  05/21/14 Initial version
42 * 5.04  pkp  12/18/15 Initialized global constructor for C++ applications
43 * 5.04  pkp  01/05/16 Set the reset vector register RVBAR equivalent to
44 *                     vector table base address
45 * </pre>
46 *
47 * @note
48 *
49 * None.
50 *
51 ******************************************************************************/
52
53         .file   "xil-crt0.S"
54         .section ".got2","aw"
55         .align  2
56
57         .text
58 .Lsbss_start:
59         .quad   __sbss_start
60
61 .Lsbss_end:
62         .quad   __sbss_end
63
64 .Lbss_start:
65         .quad   __bss_start__
66
67 .Lbss_end:
68         .quad   __bss_end__
69
70
71 .set APU_PWRCTL,        0xFD5C0090
72
73         .globl  _startup
74 _startup:
75
76         mov     x0, #0
77
78         /* Check whether the clearing of bss sections shall be skipped */
79         ldr     x10, =APU_PWRCTL        /* Load PWRCTRL address */
80         ldr     w11, [x10]              /* Read PWRCTRL register */
81         mrs     x2, MPIDR_EL1           /* Read MPIDR_EL1 */
82         ubfx    x2, x2, #0, #8          /* Extract CPU ID (affinity level 0) */
83         mov     w1, #1
84         lsl     w2, w1, w2              /* Shift CPU ID to get one-hot ID */
85         ands    w11, w11, w2            /* Get PWRCTRL bit for this core */
86         bne     .Lenclbss               /* Skip BSS and SBSS clearing */
87
88         /* clear sbss */
89         ldr     x1,.Lsbss_start         /* calculate beginning of the SBSS */
90         ldr     x2,.Lsbss_end           /* calculate end of the SBSS */
91
92 .Lloop_sbss:
93         cmp     x1,x2
94         bge     .Lenclsbss              /* If no SBSS, no clearing required */
95         str     x0, [x1], #8
96         b       .Lloop_sbss
97
98 .Lenclsbss:
99         /* clear bss */
100         ldr     x1,.Lbss_start          /* calculate beginning of the BSS */
101         ldr     x2,.Lbss_end            /* calculate end of the BSS */
102
103 .Lloop_bss:
104         cmp     x1,x2
105         bge     .Lenclbss               /* If no BSS, no clearing required */
106         str     x0, [x1], #8
107         b       .Lloop_bss
108
109 .Lenclbss:
110         /* run global constructors */
111         bl __libc_init_array
112
113         /* make sure argc and argv are valid */
114         mov     x0, #0
115         mov     x1, #0
116
117         bl      main                    /* Jump to main C code */
118
119         /* Cleanup global constructors */
120         bl __libc_fini_array
121
122         bl      exit
123
124 .Lexit: /* should never get here */
125         b .Lexit
126
127 .Lstart:
128         .size   _startup,.Lstart-_startup