source: rtems/bsps/powerpc/mpc55xxevb/start/start.S @ ff081aee

5
Last change on this file since ff081aee was ff081aee, checked in by Sebastian Huber <sebastian.huber@…>, on 11/06/18 at 15:58:02

score: Rename interrupt stack symbols

Rename

  • _Configuration_Interrupt_stack_area_begin in _ISR_Stack_area_begin,
  • _Configuration_Interrupt_stack_area_end in _ISR_Stack_area_end, and
  • _Configuration_Interrupt_stack_size in _ISR_Stack_size.

Move definitions to <rtems/score/isr.h>. The new names are considerable
shorter and in the right namespace.

Update #3459.

  • Property mode set to 100644
File size: 5.6 KB
Line 
1/**
2 * @file
3 *
4 * @ingroup mpc55xx_asm
5 *
6 * @brief Boot and system start code.
7 */
8
9/*
10 * Copyright (c) 2008-2012 embedded brains GmbH.  All rights reserved.
11 *
12 *  embedded brains GmbH
13 *  Obere Lagerstr. 30
14 *  82178 Puchheim
15 *  Germany
16 *  <rtems@embedded-brains.de>
17 *
18 * The license and distribution terms for this file may be
19 * found in the file LICENSE in this distribution or at
20 * http://www.rtems.org/license/LICENSE.
21 */
22
23#include <bspopts.h>
24#include <bsp/linker-symbols.h>
25#include <libcpu/powerpc-utility.h>
26
27#if MPC55XX_CHIP_FAMILY != 551
28  #define HAS_SPE
29#endif
30
31#if MPC55XX_CHIP_FAMILY == 564
32  #define INIT_REGISTERS_FOR_LSM
33#endif
34
35#ifdef HAS_SPE
36  #define ZERO_GPR(reg) evxor   reg, reg, reg
37#else
38  #define ZERO_GPR(reg) xor     reg, reg, reg
39#endif
40
41        .extern __eabi
42        .extern boot_card
43        .extern bsp_ram_start
44        .extern mpc55xx_start_config_mmu_early
45        .extern mpc55xx_start_config_mmu_early_count
46        .extern mpc55xx_start_early
47
48        .globl  _start
49        .globl  mpc55xx_start_load_section
50        .globl  mpc55xx_start_mmu_apply_config
51
52#ifdef MPC55XX_BOOTFLAGS
53        .globl  mpc55xx_bootflag_0
54        .globl  mpc55xx_bootflag_1
55#endif
56
57        .section        ".bsp_start_text", "ax"
58
59        /* BAM: RCHW */
60        .int    0x005a0000
61
62        /* BAM: Address of start instruction */
63        .int    _start
64
65#ifdef MPC55XX_BOOTFLAGS
66        /*
67         * We skip over the next two boot flag words to the next 64-bit
68         * aligned start address. It is 64-bit aligned to play well with
69         * FLASH programming.  These boot flags can be set by debuggers
70         * and emulators to customize boot.  Currently bit0 of
71         * bootflag_0 means to "skip setting up the MMU", allowing
72         * external MMU setup in a debugger before branching to 0x10.
73         * This can be used e.g., to map FLASH into RAM.
74         */
75mpc55xx_bootflag_0:
76        .int    0xffffffff
77mpc55xx_bootflag_1:
78        .int    0xffffffff
79#endif
80
81_start:
82
83#ifdef MPC55XX_ENABLE_START_PROLOGUE
84        bl      mpc55xx_start_prologue
85#endif
86
87#ifdef MPC55XX_NEEDS_LOW_LEVEL_INIT
88
89        /* Enable SPE */
90#ifdef HAS_SPE
91        mfmsr   r3
92        oris    r3, r3, MSR_SPE >> 16
93        mtmsr   r3
94        isync
95#endif
96
97        /*
98         * Initialization of core registers according to "e200z4 Power
99         * Architecture Core Reference Manual" section 2.6 "Reset Settings"
100         * table 2-16 "Reset Settings of e200 Resources".  This is necessary
101         * for lock step mode (LSM).
102         */
103        ZERO_GPR(r0)
104#ifdef INIT_REGISTERS_FOR_LSM
105        ZERO_GPR(r1)
106        ZERO_GPR(r2)
107        ZERO_GPR(r4)
108        ZERO_GPR(r5)
109        ZERO_GPR(r6)
110        ZERO_GPR(r7)
111        ZERO_GPR(r8)
112        ZERO_GPR(r9)
113        ZERO_GPR(r10)
114        ZERO_GPR(r11)
115        ZERO_GPR(r12)
116        ZERO_GPR(r13)
117        ZERO_GPR(r14)
118        ZERO_GPR(r15)
119        ZERO_GPR(r16)
120        ZERO_GPR(r17)
121        ZERO_GPR(r18)
122        ZERO_GPR(r19)
123        ZERO_GPR(r20)
124        ZERO_GPR(r21)
125        ZERO_GPR(r22)
126        ZERO_GPR(r23)
127        ZERO_GPR(r24)
128        ZERO_GPR(r25)
129        ZERO_GPR(r26)
130        ZERO_GPR(r27)
131        ZERO_GPR(r28)
132        ZERO_GPR(r29)
133        ZERO_GPR(r30)
134        ZERO_GPR(r31)
135        mtcrf   0xff, r0
136        mtcsrr0 r0
137        mtcsrr1 r0
138        mtctr   r0
139        mtspr   FSL_EIS_DBCNT, r0
140        mtspr   DEAR_BOOKE, r0
141        mtdec   r0
142        mtspr   BOOKE_DECAR, r0
143        mtspr   FSL_EIS_DSRR0, r0
144        mtspr   FSL_EIS_DSRR1, r0
145        mtspr   BOOKE_DVC1, r0
146        mtspr   BOOKE_DVC2, r0
147        mtspr   BOOKE_IVPR, r0
148        mtlr    r0
149        mtspr   FSL_EIS_MCAR, r0
150        mtmcsrr0        r0
151        mtmcsrr1        r0
152        mtspr   SPRG0, r0
153        mtspr   SPRG1, r0
154        mtspr   SPRG2, r0
155        mtspr   SPRG3, r0
156        mtspr   SPRG4, r0
157        mtspr   SPRG5, r0
158        mtspr   SPRG6, r0
159        mtspr   SPRG7, r0
160        mtspr   FSL_EIS_SPRG8, r0
161        mtspr   FSL_EIS_SPRG9, r0
162        mtsrr0  r0
163        mtsrr1  r0
164        mtspr   USPRG0, r0
165#ifdef HAS_SPE
166        evmra   r0, r0
167#endif
168#endif /* INIT_REGISTERS_FOR_LSM */
169        mtspr   TBWL, r0
170        mtspr   TBWU, r0
171
172        /* Enable time base */
173        mfspr   r3, HID0
174        ori     r3, r3, 0x4000
175        mtspr   HID0, r3
176
177        /*
178         * Enable branch prediction.
179         *
180         * Errata e4396: e200z7: Erroneous Address Fetch
181         *
182         * The propose workaround does not work.
183         */
184#if MPC55XX_CHIP_FAMILY != 567
185        LWI     r3, FSL_EIS_BUCSR_BBFI | FSL_EIS_BUCSR_BALLOC_ALL | FSL_EIS_BUCSR_BPRED_NOT_TAKEN | FSL_EIS_BUCSR_BPEN
186        mtspr   FSL_EIS_BUCSR, r3
187#endif
188
189#endif /* MPC55XX_NEEDS_LOW_LEVEL_INIT */
190
191        /* MMU early initialization */
192        LA      r3, mpc55xx_start_config_mmu_early
193        LW      r4, mpc55xx_start_config_mmu_early_count
194        bl      mpc55xx_start_mmu_apply_config
195
196#ifdef MPC55XX_NEEDS_LOW_LEVEL_INIT
197
198        /* Initialize intermediate stack (ECC) */
199
200        LA      r3, bsp_ram_start
201        addi    r4, r3, MPC55XX_EARLY_STACK_SIZE
202
203zero_intermediate_stack_loop:
204
205#ifdef HAS_SPE
206        evstdd  r0, 0(r3)
207        evstdd  r0, 8(r3)
208        evstdd  r0, 16(r3)
209        evstdd  r0, 24(r3)
210#else
211        stw     r0, 0(r3)
212        stw     r0, 4(r3)
213        stw     r0, 8(r3)
214        stw     r0, 12(r3)
215        stw     r0, 16(r3)
216        stw     r0, 20(r3)
217        stw     r0, 24(r3)
218        stw     r0, 28(r3)
219#endif
220        addi    r3, r3, 32
221        cmpw    cr7, r3, r4
222        bne     cr7, zero_intermediate_stack_loop
223        subi    r1, r3, 16
224
225#endif /* MPC55XX_NEEDS_LOW_LEVEL_INIT */
226
227        /* Next steps in C */
228        bl      mpc55xx_start_early
229
230        /* Initialize start stack */
231        LA      r1, _ISR_Stack_area_end
232        subi    r1, r1, 16
233        li      r0, 0
234        stw     r0, 0(r1)
235
236        /*
237         * Load sections.  This must be performed after the stack switch
238         * because it may overwrite the initial stack.
239         */
240        LA      r3, bsp_section_fast_text_begin
241        LA      r4, bsp_section_fast_text_load_begin
242        LA      r5, bsp_section_fast_text_size
243        bl      mpc55xx_start_load_section
244        LA      r3, bsp_section_fast_data_begin
245        LA      r4, bsp_section_fast_data_load_begin
246        LA      r5, bsp_section_fast_data_size
247        bl      mpc55xx_start_load_section
248        LA      r3, bsp_section_data_begin
249        LA      r4, bsp_section_data_load_begin
250        LA      r5, bsp_section_data_size
251        bl      mpc55xx_start_load_section
252
253        /* Set up EABI and SYSV environment */
254        bl      __eabi
255
256        /* Clear command line */
257        li      r3, 0
258
259        /* Start RTEMS */
260        bl      boot_card
261
262        /* Spin around */
263twiddle:
264
265        b       twiddle
266
267mpc55xx_start_mmu_apply_config:
268
269        cmpwi   cr7, r4, r0
270        beqlr   cr7
271        mtctr   r4
272
273mmu_init_loop:
274
275        lwz     r4, 0(r3)
276        lwz     r5, 4(r3)
277        lwz     r6, 8(r3)
278        lwz     r7, 12(r3)
279        mtspr   FSL_EIS_MAS0, r4
280        mtspr   FSL_EIS_MAS1, r5
281        mtspr   FSL_EIS_MAS2, r6
282        mtspr   FSL_EIS_MAS3, r7
283        tlbwe
284        addi    r3, r3, 16
285        bdnz    mmu_init_loop
286        blr
287
288mpc55xx_start_load_section:
289        cmpw    cr7, r3, r4
290        beqlr   cr7
291        b       memcpy
Note: See TracBrowser for help on using the repository browser.