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

4.104.114.84.95
Last change on this file since 622a429 was 0eef948f, checked in by Joel Sherrill <joel.sherrill@…>, on 06/08/01 at 13:29:13

2000-06-08 Eric Valette <valette@…>

  • console/console.c, include/commproc.h, startup/start.S: The printk/printf did not work when loaded by EPPCBUG. They did work when loaded with the BDM debugger. I suspected EPPBUG made some nasty things like patching Communication processor microcode... Anyway, the attached patch: 1) Enables to have printk nearly immediately after boot, 2) Make printf work automagically (I do not know why except I make a different initialization for printk that should be overwritten by console init later ?)

I let the default to be using EPPCBUG embedded firmware to boot and
using this printk early enabler code (LOADED_BY_EPPCBUG and
EARLY_CONSOLE) are on.

  • Property mode set to 100644
File size: 9.0 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 * #define LOADED_BY_EPPCBUG
244 */
245#define LOADED_BY_EPPCBUG
246#define EARLY_CONSOLE           
247/*
248 * Initialization code
249 */
250.startup:       
251        /* Get the start address. */
252        mflr    r1
253#ifdef LOADED_BY_EPPCBUG       
254        /* Save pointer to residual/board data */
255        lis     r9,eppcbugInfo@ha
256        stw     r3,eppcbugInfo@l(r9)
257#endif 
258        /* Initialize essential registers. */
259        bl      initregs
260        nop
261
262        /*
263         * C_setup.
264         */
265
266        /* set toc */
267        lwz r2, toc_pointer-base_addr(r1)
268
269        /* Set up stack pointer = beginning of text section - 56 */
270        addi    r1, r1, -56-4
271
272        /* Initialize the memory mapped MPC821 registers (done in C). */
273        EXTERN_PROC (_InitMBX8xx)
274        bl      PROC (_InitMBX8xx)
275        nop
276       
277        /* Clear the bss section. */
278        bl      bssclr
279        nop
280#if defined(EARLY_CONSOLE) && defined(LOADED_BY_EPPCBUG)
281        EXTERN_PROC (serial_init)
282        bl      PROC (serial_init)
283#endif 
284        lis     r5,environ@ha
285        la      r5,environ@l(r5)                /* environp */
286        /* clear argc and argv */
287        xor     r3, r3, r3
288        xor     r4, r4, r4
289       
290        EXTERN_PROC (boot_card)
291        bl       PROC (boot_card)       /* call the first C routine */
292        nop
293       
294        /* we should never return from boot_card, but in case we do ... */
295        /* The next instructions are dependent on your runtime environment */
296
297        /* Return to EPPCBug */
298        lis     r10, 0x0400             /* Data cache disable */
299        mtspr   568, r10
300        isync
301               
302        mtspr   560, r10                /* Instruction cache disable */
303        isync
304               
305stop_here:
306        li      r10, 0x0F00             /* .RETURN */
307        sc
308       
309        b       stop_here
310        nop
311
312/*
313 * bssclr - zero out bss
314 */
315bssclr:
316        lis     r3, base_addr@ha
317        addi    r3, r3, base_addr@l
318        lwz     r4, bss_addr-base_addr(r3)      /* Start of bss */
319        lwz     r5, bss_length-base_addr(r3)    /* Length of bss */
320
321        rlwinm. r5,r5,30,0x3FFFFFFF             /* form length/4 */
322        beqlr                                   /* no bss - return */
323        mtctr   r5                              /* set ctr reg */
324       
325        li      r5,0x0000                       /* r5 = 0 */
326clear_bss:
327        stw     r5,0(r4)                        /* store r6 */
328        addi    r4,r4,0x4                       /* update r4 */
329        bdnz    clear_bss                       /* dec counter and loop */
330       
331        blr                                     /* return */
332
333/*
334 * initregs
335 *      Initialize the MSR and basic core PowerPC registers
336 *
337 * Register usage:
338 *      r0 - scratch
339 */
340initregs:
341        /*       
342         * Disable address translation. We should already be running in real space,
343         * so this should be a no-op, i.e. no need to switch instruction stream
344         * addresses from virtual space to real space. Other bits set the processor
345         * for big-endian mode, exceptions vectored to 0x000n_nnnn (vectors are
346         * already in low memory!), no execution tracing, machine check exceptions
347         * enabled, floating-point not available (MPC8xx has none), supervisor
348         * priviledge level, external interrupts disabled, power management
349         * disabled (normal operation mode).
350         */
351        li      r0, 0x1000      /* MSR_ME */
352        mtmsr   r0              /* Context-synchronizing */
353        isync
354       
355        /*
356         * Clear the exception handling registers.
357         * Note SPRG3 is reserved for use by EPPCBug on the MBX8xx.
358         */     
359        li      r0, 0x0000
360        mtdar   r0
361        mtspr   sprg0, r0
362        mtspr   sprg1, r0
363        mtspr   sprg2, r0
364        mtspr   srr0, r0
365        mtspr   srr1, r0
366                       
367        mr      r6, r0
368        mr      r7, r0
369        mr      r8, r0
370        mr      r9, r0
371        mr      r10, r0
372        mr      r11, r0
373        mr      r12, r0
374        mr      r13, r0
375        mr      r14, r0
376        mr      r15, r0
377        mr      r16, r0
378        mr      r17, r0
379        mr      r18, r0
380        mr      r19, r0
381        mr      r20, r0
382        mr      r21, r0
383        mr      r22, r0
384        mr      r23, r0
385        mr      r24, r0
386        mr      r25, r0
387        mr      r26, r0
388        mr      r27, r0
389        mr      r28, r0
390        mr      r29, r0
391        mr      r30, r0
392        mr      r31, r0
393       
394        blr                     /* return */
395       
396.L_text_e:
397
398        .comm   environ,4,4
Note: See TracBrowser for help on using the repository browser.