source: rtems/c/src/lib/libbsp/powerpc/mpc55xxevb/startup/start.S @ 6b150cc

4.104.115
Last change on this file since 6b150cc was 2f5435a4, checked in by Thomas Doerfler <Thomas.Doerfler@…>, on 03/25/10 at 20:26:00

add support for mpc551x based GW_LCFM system

  • Property mode set to 100644
File size: 4.1 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
11 * Embedded Brains GmbH
12 * Obere Lagerstr. 30
13 * D-82178 Puchheim
14 * Germany
15 * rtems@embedded-brains.de
16 *
17 * The license and distribution terms for this file may be found in the file
18 * LICENSE in this distribution or at http://www.rtems.com/license/LICENSE.
19 */
20
21/**
22 * @defgroup mpc55xx_asm Assembler files
23 *
24 * @ingroup mpc55xx
25 */
26
27#include <libcpu/powerpc-utility.h>
28#include <mpc55xx/reg-defs.h>
29
30.section ".entry", "ax"
31PUBLIC_VAR (start)
32.globl  fmpll_syncr_vals
33bam_rchw:
34/*
35 * BAM
36 */
37
38        /* BAM: RCHW */
39        .int 0x005a0000
40
41        /* BAM: Address of start instruction */
42        .int 0x8
43
44/*
45 * Enable time base
46 */
47start: 
48        li r0, 0
49        mtspr TBWU, r0
50        mtspr TBWL, r0
51        mfspr r2, HID0
52        ori r2, r2, 0x4000
53        mtspr HID0, r2
54
55/*
56 * System clock
57 */
58
59        LWI r3,fmpll_syncr_vals
60        bl SYM (mpc55xx_fmpll_reset_config)
61
62/*
63 * Enable branch prediction
64 */
65
66        LWI r2, BUCSR_BBFI | BUCSR_BPEN
67        mtspr BUCSR, r2
68
69/*
70 * Basics
71 */
72
73        /* Set stack start to end of ram */
74        LA r1, bsp_ram_end
75        addi r1, r1, -8
76
77        /* Enable SPE */
78        mfmsr r2
79        oris r2, r2, 0x200
80        mtmsr r2
81
82        /* Config internal flash */
83        bl SYM (mpc55xx_flash_config)
84
85        /* FIXME: Config cache */
86        bl config_cache
87
88/*
89 * TODO, FIXME: Enable cache in the MMU for the SRAM
90 */
91
92.equ MAS0, 624
93.equ MAS1, 625
94.equ MAS2, 626
95.equ MAS3, 627
96
97        LWI r3, 0x10030000
98        mtspr MAS0, r3
99        tlbre
100        LWI r4, ~0x00000008
101        mfspr r3, MAS2
102        and r3, r3, r4
103        mtspr MAS2, r3
104        tlbwe
105
106/*
107 * TODO, FIXME: Set MMU for the external SRAM
108 */
109
110        LWI r3, 0x10020000
111        mtspr MAS0, r3
112        tlbre
113        LWI r4, 0xfff
114        mfspr r3, MAS3
115        and r3, r3, r4
116        LWI r4, 0x20000000
117        or r3, r3, r4
118        mtspr MAS3, r3
119        tlbwe
120
121/*
122 * Zero RAM (needed to get proper ECC)
123 */
124
125        /* Addresses */
126        LA r3, bsp_ram_start
127        LA r4, bsp_ram_end
128
129        /* Assert: Proper alignment of destination start */
130        andi. r6, r3, 0x37
131        bne twiddle
132
133        /* Assert: Proper alignment of destination end */
134        andi. r6, r4, 0x37
135        bne twiddle
136
137        /* Data size = destination end - destination start */
138        subf r4, r3, r4
139
140        /* Save time */
141        mftb r24
142
143        /* Zero */
144        bl SYM (mpc55xx_zero_32)
145
146        /* Save time and get time delta */
147        mftb r25
148        subf r24, r24, r25
149
150/*
151 * Copy data
152 */
153
154        /* Addresses */
155        LA r3, bsp_section_text_end
156        LA r4, bsp_section_data_start
157        LA r5, bsp_section_data_end
158
159        /* Assert: Proper alignment of source start */
160        andi. r6, r3, 0x7
161        bne twiddle
162
163        /* Assert: Proper alignment of destination start */
164        andi. r6, r4, 0x7
165        bne twiddle
166
167        /* Assert: Proper alignment of destination end */
168        andi. r6, r5, 0x7
169        bne twiddle
170
171        /* Data size = destination end - destination start */
172        subf r5, r4, r5
173
174        /* Copy */
175        bl SYM (mpc55xx_copy_8)
176
177        /* Save time and get time delta */
178        mftb r26
179        subf r25, r25, r26
180
181/*
182 * Prepare high level initialization
183 */
184        LA r3, bsp_ram_start
185        LA r4, ppc_exc_vector_base
186        stw r3, 0(r4)
187
188        /* Set global BSP clock speed variable */
189        bl SYM (mpc55xx_get_system_clock)
190        LA r4, bsp_clock_speed
191        stw r3, 0(r4)
192
193        /* Create NULL */
194        li r0, 0
195
196        /* Return address */
197        stw r0, 4(r1)
198
199        /* Back chain */
200        stw r0, 0(r1)
201
202        /* Read-only small data */
203        LA r2, _SDA2_BASE_
204
205        /* Read-write small data */
206        LA r13, _SDA_BASE_
207
208/*
209 * Start RTEMS
210 */
211
212        /* Clear command line */
213        xor r3, r3, r3
214
215        /* Start RTEMS */
216        bl SYM (boot_card)
217
218        /* Spin around */
219        b twiddle
220
221.equ L1CSR0, 1010
222.equ L1CSR0_CINV, 0x2
223.equ L1CSR0_CABT, 0x4
224/* FIXME: CORG??? .equ L1CSR0_SETTINGS, 0x00180011 */
225.equ L1CSR0_SETTINGS, 0x00100001
226
227/*
228 * Configure cache
229 */
230config_cache:
231        /* Start cache invalidation */
232        LWI r5, L1CSR0_CINV
233        mtspr L1CSR0, r5
234
235        /* Bit masks to test and clear invalidation abortion (CABT) */
236        LWI r6, L1CSR0_CABT
237        not r7, r6
238
239        /* Wait for cache invalidation to complete */
240check_cache_invalidation:
241        mfspr r9, L1CSR0
242
243        /* Check if the invalidate was aborted */
244        and. r10, r9, r6
245        beq no_chache_invalidation_abort
246
247        /* Clear CABT bit */
248        and r10, r9, r7
249        mtspr L1CSR0, r10
250
251        /* Retry invalidation */
252        b config_cache
253
254no_chache_invalidation_abort:
255        /* Check CINV bit */
256        and. r10, r5, r9
257
258        /* Wait? */
259        bne check_cache_invalidation
260
261        /* Enable cache */
262        LWI r6, L1CSR0_SETTINGS
263        mfspr r5, L1CSR0
264        or r5, r5, r6
265        msync
266        isync
267        mtspr L1CSR0, r5
268
269        /* Return */
270        blr
271
272twiddle:
273        b       twiddle
Note: See TracBrowser for help on using the repository browser.