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

4.104.114.84.95
Last change on this file since 310a2ec was 8ef3818, checked in by Joel Sherrill <joel.sherrill@…>, on 06/12/00 at 19:57:02

Patch from John Cotton <john.cotton@…>, Charles-Antoine Gauthier
<charles.gauthier@…>, and Darlene A. Stewart
<Darlene.Stewart@…> to add support for a number of very
significant things:

+ BSPs for many variations on the Motorola MBX8xx board series
+ Cache Manager including initial support for m68040

and PowerPC

+ Rework of mpc8xx libcpu code so all mpc8xx CPUs now use

same code base.

+ Rework of eth_comm BSP to utiltize above.

John reports this works on the 821 and 860

  • 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        /* clear argc and argv */
274        xor     r3, r3, r3
275        xor     r4, r4, r4
276       
277        EXTERN_PROC (boot_card)
278        bl       PROC (boot_card)       /* call the first C routine */
279        nop
280       
281        /* we should never return from boot_card, but in case we do ... */
282        /* The next instructions are dependent on your runtime environment */
283
284        /* Return to EPPCBug */
285        lis     r10, 0x0400             /* Data cache disable */
286        mtspr   568, r10
287        isync
288               
289        mtspr   560, r10                /* Instruction cache disable */
290        isync
291               
292stop_here:
293        li      r10, 0x0F00             /* .RETURN */
294        sc
295       
296        b       stop_here
297        nop
298
299/*
300 * bssclr - zero out bss
301 */
302bssclr:
303        lis     r3, base_addr@ha
304        addi    r3, r3, base_addr@l
305        lwz     r4, bss_addr-base_addr(r3)      /* Start of bss */
306        lwz     r5, bss_length-base_addr(r3)    /* Length of bss */
307
308        rlwinm. r5,r5,30,0x3FFFFFFF             /* form length/4 */
309        beqlr                                   /* no bss - return */
310        mtctr   r5                              /* set ctr reg */
311       
312        li      r5,0x0000                       /* r5 = 0 */
313clear_bss:
314        stw     r5,0(r4)                        /* store r6 */
315        addi    r4,r4,0x4                       /* update r4 */
316        bdnz    clear_bss                       /* dec counter and loop */
317       
318        blr                                     /* return */
319
320/*
321 * initregs
322 *      Initialize the MSR and basic core PowerPC registers
323 *
324 * Register usage:
325 *      r0 - scratch
326 */
327initregs:
328        /*       
329         * Disable address translation. We should already be running in real space,
330         * so this should be a no-op, i.e. no need to switch instruction stream
331         * addresses from virtual space to real space. Other bits set the processor
332         * for big-endian mode, exceptions vectored to 0x000n_nnnn (vectors are
333         * already in low memory!), no execution tracing, machine check exceptions
334         * enabled, floating-point not available (MPC8xx has none), supervisor
335         * priviledge level, external interrupts disabled, power management
336         * disabled (normal operation mode).
337         */
338        li      r0, 0x1000      /* MSR_ME */
339        mtmsr   r0              /* Context-synchronizing */
340        isync
341       
342        /*
343         * Clear the exception handling registers.
344         * Note SPRG3 is reserved for use by EPPCBug on the MBX8xx.
345         */     
346        li      r0, 0x0000
347        mtdar   r0
348        mtspr   sprg0, r0
349        mtspr   sprg1, r0
350        mtspr   sprg2, r0
351        mtspr   srr0, r0
352        mtspr   srr1, r0
353                       
354        mr      r6, r0
355        mr      r7, r0
356        mr      r8, r0
357        mr      r9, r0
358        mr      r10, r0
359        mr      r11, r0
360        mr      r12, r0
361        mr      r13, r0
362        mr      r14, r0
363        mr      r15, r0
364        mr      r16, r0
365        mr      r17, r0
366        mr      r18, r0
367        mr      r19, r0
368        mr      r20, r0
369        mr      r21, r0
370        mr      r22, r0
371        mr      r23, r0
372        mr      r24, r0
373        mr      r25, r0
374        mr      r26, r0
375        mr      r27, r0
376        mr      r28, r0
377        mr      r29, r0
378        mr      r30, r0
379        mr      r31, r0
380       
381        blr                     /* return */
382       
383.L_text_e:
Note: See TracBrowser for help on using the repository browser.