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

4.104.114.84.95
Last change on this file since bfbc4d3 was 15c48f4c, checked in by Joel Sherrill <joel.sherrill@…>, on 08/02/00 at 16:30:57

Properly pass argc, argc, and environp to boot_card.

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