source: rtems/c/src/lib/libbsp/powerpc/ss555/startup/start.S @ ac7af4a

4.104.115
Last change on this file since ac7af4a was ac7af4a, checked in by Ralf Corsepius <ralf.corsepius@…>, on 11/30/09 at 04:37:44

Whitespace removal.

  • Property mode set to 100644
File size: 9.6 KB
Line 
1/*  start.S
2 *
3 *  This file contains the entry veneer for RTEMS programs on the Intec
4 *  SS555 board.  It jumps to the BSP which is responsible for performing
5 *  all remaining initialization.
6 *
7 * This file is based on several others:
8 *
9 * (1) start360.s from the gen68360 BSP by
10 *     W. Eric Norum (eric@skatter.usask.ca)
11 *     with the following copyright and license:
12 *
13 *     COPYRIGHT (c) 1989-1998.
14 *     On-Line Applications Research Corporation (OAR).
15 *
16 *     The license and distribution terms for this file may in
17 *     the file LICENSE in this distribution or at
18 *     http://www.rtems.com/license/LICENSE.
19 *
20 * (2) start.s for the eth_comm port by
21 *     Jay Monkman (jmonkman@fracsa.com),
22 *     which itself is based on the
23 *
24 * (3) dlentry.s for the Papyrus BSP, written by:
25 *     Andrew Bray <andy@i-cubed.co.uk>
26 *     with the following copyright and license:
27 *
28 *     COPYRIGHT (c) 1995 by i-cubed ltd.
29 *
30 * (4) start860.S for the MBX821/MBX860, written by:
31 *     Darlene A. Stewart <darlene.stewart@iit.nrc.ca>
32 *     Copyright (c) 1999, National Research Council of Canada
33 *
34 *     To anyone who acknowledges that this file is provided "AS IS"
35 *     without any express or implied warranty:
36 *         permission to use, copy, modify, and distribute this file
37 *         for any purpose is hereby granted without fee, provided that
38 *         the above copyright notice and this notice appears in all
39 *         copies, and that the name of i-cubed limited not be used in
40 *         advertising or publicity pertaining to distribution of the
41 *         software without specific, written prior permission.
42 *         i-cubed limited makes no representations about the suitability
43 *         of this software for any purpose.
44 *
45 * (5) Modifications (for MBX8xx) of respective RTEMS files:
46 *     Copyright (c) 1999, National Research Council of Canada
47 *
48 * SS555 port sponsored by Defence Research and Development Canada - Suffield
49 * Copyright (C) 2004, Real-Time Systems Inc. (querbach@realtime.bc.ca)
50 */
51
52#include <rtems/asm.h>
53#include <rtems/powerpc/registers.h>
54
55#warning Call to boot_card has changed and needs checking.
56#warning The call is "void boot_card(const char* cmdline);"
57#warning You need to pass a NULL.
58#warning Please check and remove these warnings.
59
60/*
61 *  The initial stack is set to the top of the internal RAM.
62 *
63 *  All the entry veneer has to do is to clear the .bss section and copy the
64 *  initializers into the .data section.
65 */
66
67/*
68 *  GDB likes to have debugging information for the entry veneer.
69 *  Play compiler and provide some DWARF information.
70 *
71 *  CHANGE TO SUIT YOUR SETUP!
72 */
73
74        .section .entry,"ax",@progbits
75.L_text_b:
76.L_LC1:
77        .previous
78
79.section        .debug_sfnames
80.L_sfnames_b:
81        .byte "rtems/c/src/lib/libbsp/powerpc/ss555/startup/"
82        .byte 0
83.L_F0:
84        .byte "start.S"
85        .byte 0
86        .previous
87
88.section        .line
89.L_line_b:
90        .4byte  .L_line_e-.L_line_b
91        .4byte  .L_text_b
92.L_LE1:
93.L_line_last:
94        .4byte  0x0
95        .2byte  0xffff
96        .4byte  .L_text_e-.L_text_b
97.L_line_e:
98        .previous
99
100.section        .debug_srcinfo
101.L_srcinfo_b:
102        .4byte  .L_line_b
103        .4byte  .L_sfnames_b
104        .4byte  .L_text_b
105        .4byte  .L_text_e
106        .4byte  0xffffffff
107        .4byte  .L_LE1-.L_line_b
108        .4byte  .L_F0-.L_sfnames_b
109        .4byte  .L_line_last-.L_line_b
110        .4byte  0xffffffff
111        .previous
112
113.section        .debug_pubnames
114        .4byte  .L_debug_b
115        .4byte  .L_P0
116        .byte "start"
117        .byte 0
118        .4byte  0x0
119        .byte 0
120        .previous
121
122.section        .debug_aranges
123        .4byte  .L_debug_b
124        .4byte  .L_text_b
125        .4byte  .L_text_e-.L_text_b
126        .4byte  0
127        .4byte  0
128        .4byte  0
129        .4byte  0
130        .4byte  0
131        .4byte  0
132        .4byte  0x0
133        .4byte  0x0
134        .previous
135
136.section        .debug
137.L_debug_b:
138.L_D1:
139        .4byte  .L_D1_e-.L_D1
140        .2byte  0x11    /* TAG_compile_unit */
141        .2byte  0x12    /* AT_sibling */
142        .4byte  .L_D2
143        .2byte  0x38    /* AT_name */
144        .byte "start.S"
145        .byte 0
146        .2byte  0x258   /* AT_producer */
147        .byte "GAS 2.5.2"
148        .byte 0
149        .2byte  0x111   /* AT_low_pc */
150        .4byte  .L_text_b
151        .2byte  0x121   /* AT_high_pc */
152        .4byte  .L_text_e
153        .2byte  0x106   /* AT_stmt_list */
154        .4byte  .L_line_b
155        .2byte  0x1b8   /* AT_comp_dir */
156        .byte "rtems/c/src/lib/libbsp/powerpc/ss555/startup/"
157        .byte 0
158        .2byte  0x8006  /* AT_sf_names */
159        .4byte  .L_sfnames_b
160        .2byte  0x8016  /* AT_src_info */
161        .4byte  .L_srcinfo_b
162.L_D1_e:
163.L_P0:
164.L_D3:
165        .4byte  .L_D3_e-.L_D3
166        .2byte  0x6     /* TAG_global_subroutine */
167        .2byte  0x12    /* AT_sibling */
168        .4byte  .L_D4
169        .2byte  0x38    /* AT_name */
170        .byte "start"
171        .byte 0
172        .2byte  0x278   /* AT_prototyped */
173        .byte 0
174        .2byte  0x111   /* AT_low_pc */
175        .4byte  .L_text_b
176        .2byte  0x121   /* AT_high_pc */
177        .4byte  .L_text_e
178        .2byte  0x8041  /* AT_body_begin */
179        .4byte  .L_text_b
180        .2byte  0x8051  /* AT_body_end */
181        .4byte  .L_text_e
182.L_D3_e:
183
184.L_D4:
185        .4byte  .L_D4_e-.L_D4
186        .align 2
187.L_D4_e:
188.L_D2:
189        .previous
190
191/*
192 * Tell C's eabi-ctor's that we have an atexit function,
193 * and that it is to register __do_global_dtors.
194 */
195        EXTERN_PROC(atexit)
196        PUBLIC_VAR(__atexit)
197        .section ".sdata","aw"
198        .align  2
199SYM(__atexit):
200        EXT_PROC_REF(atexit)@fixup
201        .previous
202
203        .section ".fixup","aw"
204        .align  2
205        EXT_SYM_REF(__atexit)
206        .previous
207
208/* That should do it */
209
210/*
211 *  Put the entry point in its own section. That way, we can guarantee
212 *  to put it first in the .text section in the linker script.
213 */
214        .section .entry
215
216        PUBLIC_VAR (start)
217SYM(start):
218        bl      .startup        /* or bl .spin */
219base_addr:
220
221/*
222 * Parameters from linker
223 */
224stack_top:
225        .long   initStackPtr
226
227toc_pointer:
228        .long   __GOT_START__
229
230bss_length:
231        .long   bss.size
232bss_addr:
233        .long   bss.start
234
235data_length:
236        .long   data.size
237data_addr:
238        .long   data.start
239contents_addr:
240        .long   data.contents.start
241
242PUBLIC_VAR (text_addr)
243text_addr:
244        .long   text.start
245
246PUBLIC_VAR (text_length)
247text_length:
248        .long   text.size
249
250/*
251 * Spin, if necessary, to acquire control from debugger (CodeWarrior).
252 */
253spin:
254        .long   0x0001
255.spin:
256        lis     r3, spin@ha
257        lwz     r3, spin@l(r3)
258        cmpwi   r3, 0x1
259        beq     .spin
260
261/*
262 * Initialization code
263 */
264.startup:
265        /* Capture address of linker parameters. */
266        mflr    r3
267
268        /* Set initial stack pointer to end of internal RAM - 56. */
269        lwz     r1, stack_top-base_addr(r3)
270        addi    r1, r1, -56
271
272        /* Initialize essential registers. */
273        bl      initregs
274
275        /* Set TOC pointer */
276        lwz r2, toc_pointer-base_addr(r3)
277
278        /* Initialize the memory mapped MPC555 registers (done in C). */
279        EXTERN_PROC (_InitSS555)
280        bl      PROC (_InitSS555)
281
282        /* Clear the .bss section. */
283        bl      bssclr
284
285        /* Copy initializers into the .data section */
286        bl      datacopy
287
288        /* Enable floating point, since gcc sometimes uses the floating
289         * point registers for data moves, even if the C source code doesn't
290         * include floating point operations.
291         */
292        mfmsr   r0
293        ori     r0, r0, MSR_FP
294        mtmsr   r0
295
296        /* Start system. */
297        li      r3, 0                   /* command line */
298        EXTERN_PROC (boot_card)
299        bl       PROC (boot_card)       /* call the first C routine */
300
301        /* We should never return from boot_card, but in case we do ... */
302        /* The next instructions are dependent on your runtime environment. */
303
304stop_here:
305        b       stop_here
306
307/*
308 * datacopy - copy initializers into .data section
309 */
310datacopy:
311        lis     r3, base_addr@ha                /* point to linker data */
312        addi    r3, r3, base_addr@l
313
314        lwz     r4, contents_addr-base_addr(r3) /* .data contents in ROM */
315        lwz     r5, data_addr-base_addr(r3)     /* .data section in RAM */
316        lwz     r6, data_length-base_addr(r3)   /* length of .data */
317
318        rlwinm. r6, r6, 30, 0x3FFFFFFF          /* form length / 4 */
319        beqlr                                   /* no .data - return */
320
321        mtctr   r6                              /* set ctr reg */
322dc1:
323        lwz     r6, 0(r4)                       /* get word */
324        stw     r6, 0(r5)                       /* store word */
325        addi    r4, r4, 0x4                     /* next source */
326        addi    r5, r5, 0x4                     /* next target */
327        bdnz    dc1                             /* dec counter and loop */
328
329        blr                                     /* return */
330
331/*
332 * bssclr - zero out bss
333 */
334bssclr:
335        lis     r3, base_addr@ha                /* point to linker data */
336        addi    r3, r3, base_addr@l
337
338        lwz     r4, bss_addr-base_addr(r3)      /* Start of bss */
339        lwz     r5, bss_length-base_addr(r3)    /* Length of bss */
340
341        rlwinm. r5, r5, 30, 0x3FFFFFFF          /* form length/4 */
342        beqlr                                   /* no bss - return */
343
344        mtctr   r5                              /* set ctr reg */
345        li      r5, 0x0000                      /* r5 = 0 */
346clear_bss:
347        stw     r5, 0(r4)                       /* store r6 */
348        addi    r4, r4, 0x4                     /* update r4 */
349        bdnz    clear_bss                       /* dec counter and loop */
350
351        blr                                     /* return */
352
353/*
354 * initregs
355 *      Initialize the MSR and basic core PowerPC registers
356 *
357 * Register usage:
358 *      r0 - scratch
359 */
360initregs:
361        /*
362         * Set the processor for big-endian mode, exceptions vectored to
363         * 0x000n_nnnn, no execution tracing, machine check exceptions
364         * enabled, floating-point not available, supervisor priviledge
365         * level, external interrupts disabled, power management disabled
366         * (normal operation mode).
367         */
368        li      r0, 0x1000      /* MSR_ME */
369        mtmsr   r0              /* Context-synchronizing */
370        isync
371
372        /*
373         * Clear the exception handling registers.
374         */
375        li      r0, 0x0000
376        mtdar   r0
377        mtspr   sprg0, r0
378        mtspr   sprg1, r0
379        mtspr   sprg2, r0
380        mtspr   sprg3, r0
381        mtspr   srr0, r0
382        mtspr   srr1, r0
383
384        mr      r6, r0
385        mr      r7, r0
386        mr      r8, r0
387        mr      r9, r0
388        mr      r10, r0
389        mr      r11, r0
390        mr      r12, r0
391        mr      r13, r0
392        mr      r14, r0
393        mr      r15, r0
394        mr      r16, r0
395        mr      r17, r0
396        mr      r18, r0
397        mr      r19, r0
398        mr      r20, r0
399        mr      r21, r0
400        mr      r22, r0
401        mr      r23, r0
402        mr      r24, r0
403        mr      r25, r0
404        mr      r26, r0
405        mr      r27, r0
406        mr      r28, r0
407        mr      r29, r0
408        mr      r30, r0
409        mr      r31, r0
410
411        blr                     /* return */
412
413.L_text_e:
Note: See TracBrowser for help on using the repository browser.