source: rtems/c/src/lib/libbsp/powerpc/mbx8xx/startup/start.S @ 976b159

4.104.115
Last change on this file since 976b159 was 976b159, checked in by Chris Johns <chrisj@…>, on 04/28/09 at 06:33:16

2009-04-28 Chris Johns <chrisj@…>

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