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

4.104.115
Last change on this file since dccbb21 was dccbb21, checked in by Thomas Doerfler <Thomas.Doerfler@…>, on 03/27/10 at 20:44:18

code changes to remove warnings

  • Property mode set to 100644
File size: 9.4 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/*
56 *  The initial stack is set to the top of the internal RAM.
57 *
58 *  All the entry veneer has to do is to clear the .bss section and copy the
59 *  initializers into the .data section.
60 */
61
62/*
63 *  GDB likes to have debugging information for the entry veneer.
64 *  Play compiler and provide some DWARF information.
65 *
66 *  CHANGE TO SUIT YOUR SETUP!
67 */
68
69        .section .entry,"ax",@progbits
70.L_text_b:
71.L_LC1:
72        .previous
73
74.section        .debug_sfnames
75.L_sfnames_b:
76        .byte "rtems/c/src/lib/libbsp/powerpc/ss555/startup/"
77        .byte 0
78.L_F0:
79        .byte "start.S"
80        .byte 0
81        .previous
82
83.section        .line
84.L_line_b:
85        .4byte  .L_line_e-.L_line_b
86        .4byte  .L_text_b
87.L_LE1:
88.L_line_last:
89        .4byte  0x0
90        .2byte  0xffff
91        .4byte  .L_text_e-.L_text_b
92.L_line_e:
93        .previous
94
95.section        .debug_srcinfo
96.L_srcinfo_b:
97        .4byte  .L_line_b
98        .4byte  .L_sfnames_b
99        .4byte  .L_text_b
100        .4byte  .L_text_e
101        .4byte  0xffffffff
102        .4byte  .L_LE1-.L_line_b
103        .4byte  .L_F0-.L_sfnames_b
104        .4byte  .L_line_last-.L_line_b
105        .4byte  0xffffffff
106        .previous
107
108.section        .debug_pubnames
109        .4byte  .L_debug_b
110        .4byte  .L_P0
111        .byte "start"
112        .byte 0
113        .4byte  0x0
114        .byte 0
115        .previous
116
117.section        .debug_aranges
118        .4byte  .L_debug_b
119        .4byte  .L_text_b
120        .4byte  .L_text_e-.L_text_b
121        .4byte  0
122        .4byte  0
123        .4byte  0
124        .4byte  0
125        .4byte  0
126        .4byte  0
127        .4byte  0x0
128        .4byte  0x0
129        .previous
130
131.section        .debug
132.L_debug_b:
133.L_D1:
134        .4byte  .L_D1_e-.L_D1
135        .2byte  0x11    /* TAG_compile_unit */
136        .2byte  0x12    /* AT_sibling */
137        .4byte  .L_D2
138        .2byte  0x38    /* AT_name */
139        .byte "start.S"
140        .byte 0
141        .2byte  0x258   /* AT_producer */
142        .byte "GAS 2.5.2"
143        .byte 0
144        .2byte  0x111   /* AT_low_pc */
145        .4byte  .L_text_b
146        .2byte  0x121   /* AT_high_pc */
147        .4byte  .L_text_e
148        .2byte  0x106   /* AT_stmt_list */
149        .4byte  .L_line_b
150        .2byte  0x1b8   /* AT_comp_dir */
151        .byte "rtems/c/src/lib/libbsp/powerpc/ss555/startup/"
152        .byte 0
153        .2byte  0x8006  /* AT_sf_names */
154        .4byte  .L_sfnames_b
155        .2byte  0x8016  /* AT_src_info */
156        .4byte  .L_srcinfo_b
157.L_D1_e:
158.L_P0:
159.L_D3:
160        .4byte  .L_D3_e-.L_D3
161        .2byte  0x6     /* TAG_global_subroutine */
162        .2byte  0x12    /* AT_sibling */
163        .4byte  .L_D4
164        .2byte  0x38    /* AT_name */
165        .byte "start"
166        .byte 0
167        .2byte  0x278   /* AT_prototyped */
168        .byte 0
169        .2byte  0x111   /* AT_low_pc */
170        .4byte  .L_text_b
171        .2byte  0x121   /* AT_high_pc */
172        .4byte  .L_text_e
173        .2byte  0x8041  /* AT_body_begin */
174        .4byte  .L_text_b
175        .2byte  0x8051  /* AT_body_end */
176        .4byte  .L_text_e
177.L_D3_e:
178
179.L_D4:
180        .4byte  .L_D4_e-.L_D4
181        .align 2
182.L_D4_e:
183.L_D2:
184        .previous
185
186/*
187 * Tell C's eabi-ctor's that we have an atexit function,
188 * and that it is to register __do_global_dtors.
189 */
190        EXTERN_PROC(atexit)
191        PUBLIC_VAR(__atexit)
192        .section ".sdata","aw"
193        .align  2
194SYM(__atexit):
195        EXT_PROC_REF(atexit)@fixup
196        .previous
197
198        .section ".fixup","aw"
199        .align  2
200        EXT_SYM_REF(__atexit)
201        .previous
202
203/* That should do it */
204
205/*
206 *  Put the entry point in its own section. That way, we can guarantee
207 *  to put it first in the .text section in the linker script.
208 */
209        .section .entry
210
211        PUBLIC_VAR (start)
212SYM(start):
213        bl      .startup        /* or bl .spin */
214base_addr:
215
216/*
217 * Parameters from linker
218 */
219stack_top:
220        .long   initStackPtr
221
222toc_pointer:
223        .long   __GOT_START__
224
225bss_length:
226        .long   bss.size
227bss_addr:
228        .long   bss.start
229
230data_length:
231        .long   data.size
232data_addr:
233        .long   data.start
234contents_addr:
235        .long   data.contents.start
236
237PUBLIC_VAR (text_addr)
238text_addr:
239        .long   text.start
240
241PUBLIC_VAR (text_length)
242text_length:
243        .long   text.size
244
245/*
246 * Spin, if necessary, to acquire control from debugger (CodeWarrior).
247 */
248spin:
249        .long   0x0001
250.spin:
251        lis     r3, spin@ha
252        lwz     r3, spin@l(r3)
253        cmpwi   r3, 0x1
254        beq     .spin
255
256/*
257 * Initialization code
258 */
259.startup:
260        /* Capture address of linker parameters. */
261        mflr    r3
262
263        /* Set initial stack pointer to end of internal RAM - 56. */
264        lwz     r1, stack_top-base_addr(r3)
265        addi    r1, r1, -56
266
267        /* Initialize essential registers. */
268        bl      initregs
269
270        /* Set TOC pointer */
271        lwz r2, toc_pointer-base_addr(r3)
272
273        /* Initialize the memory mapped MPC555 registers (done in C). */
274        EXTERN_PROC (_InitSS555)
275        bl      PROC (_InitSS555)
276
277        /* Clear the .bss section. */
278        bl      bssclr
279
280        /* Copy initializers into the .data section */
281        bl      datacopy
282
283        /* Enable floating point, since gcc sometimes uses the floating
284         * point registers for data moves, even if the C source code doesn't
285         * include floating point operations.
286         */
287        mfmsr   r0
288        ori     r0, r0, MSR_FP
289        mtmsr   r0
290
291        /* Start system. */
292        li      r3, 0                   /* command line */
293        EXTERN_PROC (boot_card)
294        bl       PROC (boot_card)       /* call the first C routine */
295
296        /* We should never return from boot_card, but in case we do ... */
297        /* The next instructions are dependent on your runtime environment. */
298
299stop_here:
300        b       stop_here
301
302/*
303 * datacopy - copy initializers into .data section
304 */
305datacopy:
306        lis     r3, base_addr@ha                /* point to linker data */
307        addi    r3, r3, base_addr@l
308
309        lwz     r4, contents_addr-base_addr(r3) /* .data contents in ROM */
310        lwz     r5, data_addr-base_addr(r3)     /* .data section in RAM */
311        lwz     r6, data_length-base_addr(r3)   /* length of .data */
312
313        rlwinm. r6, r6, 30, 0x3FFFFFFF          /* form length / 4 */
314        beqlr                                   /* no .data - return */
315
316        mtctr   r6                              /* set ctr reg */
317dc1:
318        lwz     r6, 0(r4)                       /* get word */
319        stw     r6, 0(r5)                       /* store word */
320        addi    r4, r4, 0x4                     /* next source */
321        addi    r5, r5, 0x4                     /* next target */
322        bdnz    dc1                             /* dec counter and loop */
323
324        blr                                     /* return */
325
326/*
327 * bssclr - zero out bss
328 */
329bssclr:
330        lis     r3, base_addr@ha                /* point to linker data */
331        addi    r3, r3, base_addr@l
332
333        lwz     r4, bss_addr-base_addr(r3)      /* Start of bss */
334        lwz     r5, bss_length-base_addr(r3)    /* Length of bss */
335
336        rlwinm. r5, r5, 30, 0x3FFFFFFF          /* form length/4 */
337        beqlr                                   /* no bss - return */
338
339        mtctr   r5                              /* set ctr reg */
340        li      r5, 0x0000                      /* r5 = 0 */
341clear_bss:
342        stw     r5, 0(r4)                       /* store r6 */
343        addi    r4, r4, 0x4                     /* update r4 */
344        bdnz    clear_bss                       /* dec counter and loop */
345
346        blr                                     /* return */
347
348/*
349 * initregs
350 *      Initialize the MSR and basic core PowerPC registers
351 *
352 * Register usage:
353 *      r0 - scratch
354 */
355initregs:
356        /*
357         * Set the processor for big-endian mode, exceptions vectored to
358         * 0x000n_nnnn, no execution tracing, machine check exceptions
359         * enabled, floating-point not available, supervisor priviledge
360         * level, external interrupts disabled, power management disabled
361         * (normal operation mode).
362         */
363        li      r0, 0x1000      /* MSR_ME */
364        mtmsr   r0              /* Context-synchronizing */
365        isync
366
367        /*
368         * Clear the exception handling registers.
369         */
370        li      r0, 0x0000
371        mtdar   r0
372        mtspr   sprg0, r0
373        mtspr   sprg1, r0
374        mtspr   sprg2, r0
375        mtspr   sprg3, r0
376        mtspr   srr0, r0
377        mtspr   srr1, r0
378
379        mr      r6, r0
380        mr      r7, r0
381        mr      r8, r0
382        mr      r9, r0
383        mr      r10, r0
384        mr      r11, r0
385        mr      r12, r0
386        mr      r13, r0
387        mr      r14, r0
388        mr      r15, r0
389        mr      r16, r0
390        mr      r17, r0
391        mr      r18, r0
392        mr      r19, r0
393        mr      r20, r0
394        mr      r21, r0
395        mr      r22, r0
396        mr      r23, r0
397        mr      r24, r0
398        mr      r25, r0
399        mr      r26, r0
400        mr      r27, r0
401        mr      r28, r0
402        mr      r29, r0
403        mr      r30, r0
404        mr      r31, r0
405
406        blr                     /* return */
407
408.L_text_e:
Note: See TracBrowser for help on using the repository browser.