source: rtems/c/src/lib/libbsp/sparc/shared/start.S @ cba119c9

4.104.114.84.95
Last change on this file since cba119c9 was 8a6570d0, checked in by Joel Sherrill <joel.sherrill@…>, on 09/02/05 at 14:49:13

2005-09-02 Joel Sherrill <joel@…>

PR 821/bsps

  • start.S: Workaround -- just avoid copying non-existent initialized data in ROM to RAM.
  • Property mode set to 100644
File size: 10.4 KB
Line 
1/*
2 *  start.s
3 *
4 *  Common start code for SPARC.
5 *
6 *  This is based on the file srt0.s provided with the binary
7 *  distribution of the SPARC Instruction Simulator (SIS) found
8 *  at ftp://ftp.estec.esa.nl/pub/ws/wsd/erc32.
9 *
10 *  $Id$
11 */
12
13#include <rtems/asm.h>
14
15/*
16 *  Unexpected trap will halt the processor by forcing it to error state
17 */
18
19#define BAD_TRAP \
20  ta 0; \
21  nop; \
22  nop; \
23  nop;
24
25/*
26 *  Software trap. Treat as BAD_TRAP for the time being...
27 */
28
29#define SOFT_TRAP BAD_TRAP
30
31  .seg    "text"
32  PUBLIC(start)
33  .global start, __bsp_mem_init
34
35SYM(start):
36start:
37
38/*
39 *  The trap table has to be the first code in a boot PROM.  But because
40 *  the Memory Configuration comes up thinking we only have 4K of PROM, we
41 *  cannot have a full trap table and still have room left over to
42 *  reprogram the Memory Configuration register correctly.  This file
43 *  uses an abbreviated trap which has every entry which might be used
44 *  before RTEMS installs its own trap table.
45 */
46
47  PUBLIC(trap_table)
48SYM(trap_table):
49
50  RTRAP( 0, SYM(hard_reset) );                   ! 00 reset trap
51  BAD_TRAP;                                     ! 01 instruction access
52                                                !    exception
53  BAD_TRAP;                                     ! 02 illegal instruction
54  BAD_TRAP;                                     ! 03 privileged instruction
55  BAD_TRAP;                                     ! 04 fp disabled
56  TRAP( 5, SYM(window_overflow_trap_handler) ); ! 05 window overflow
57  TRAP( 6, SYM(window_underflow_trap_handler) );! 06 window underflow
58  BAD_TRAP;                                     ! 07 memory address not aligned
59  BAD_TRAP;                                     ! 08 fp exception
60  BAD_TRAP;                                     ! 09 data access exception
61  BAD_TRAP;                                     ! 0A tag overflow
62  BAD_TRAP;                                     ! 0B undefined
63  BAD_TRAP;                                     ! 0C undefined
64  BAD_TRAP;                                     ! 0D undefined
65  BAD_TRAP;                                     ! 0E undefined
66  BAD_TRAP;                                     ! 0F undefined
67  BAD_TRAP;                                     ! 10 undefined
68
69  /*
70   *  ERC32 defined traps
71   */
72
73  BAD_TRAP;                                     ! 11 masked errors
74  BAD_TRAP;                                     ! 12 external 1
75  BAD_TRAP;                                     ! 13 external 2
76  BAD_TRAP;                                     ! 14 UART A RX/TX
77  BAD_TRAP;                                     ! 15 UART B RX/TX
78  BAD_TRAP;                                     ! 16 correctable memory error
79  BAD_TRAP;                                     ! 17 UART error
80  BAD_TRAP;                                     ! 18 DMA access error
81  BAD_TRAP;                                     ! 19 DMA timeout
82  BAD_TRAP;                                     ! 1A external 3
83  BAD_TRAP;                                     ! 1B external 4
84  BAD_TRAP;                                     ! 1C general purpose timer
85  BAD_TRAP;                                     ! 1D real time clock
86  BAD_TRAP;                                     ! 1E external 5
87  BAD_TRAP;                                     ! 1F watchdog timeout
88
89  BAD_TRAP; BAD_TRAP; BAD_TRAP; BAD_TRAP;       ! 20 - 23 undefined
90  BAD_TRAP;                                     ! 24 cp_disabled
91            BAD_TRAP; BAD_TRAP; BAD_TRAP;       ! 25 - 27 undefined
92  BAD_TRAP;                                     ! 28 cp_exception
93            BAD_TRAP; BAD_TRAP; BAD_TRAP;       ! 29 - 2B undefined
94  BAD_TRAP; BAD_TRAP; BAD_TRAP; BAD_TRAP;       ! 2C - 2F undefined
95  BAD_TRAP; BAD_TRAP; BAD_TRAP; BAD_TRAP;       ! 30 - 33 undefined
96  BAD_TRAP; BAD_TRAP; BAD_TRAP; BAD_TRAP;       ! 34 - 37 undefined
97  BAD_TRAP; BAD_TRAP; BAD_TRAP; BAD_TRAP;       ! 38 - 3B undefined
98  BAD_TRAP; BAD_TRAP; BAD_TRAP; BAD_TRAP;       ! 3C - 3F undefined
99  BAD_TRAP; BAD_TRAP; BAD_TRAP; BAD_TRAP;       ! 40 - 43 undefined
100  BAD_TRAP; BAD_TRAP; BAD_TRAP; BAD_TRAP;       ! 44 - 47 undefined
101  BAD_TRAP; BAD_TRAP; BAD_TRAP; BAD_TRAP;       ! 48 - 4B undefined
102  BAD_TRAP; BAD_TRAP; BAD_TRAP; BAD_TRAP;       ! 4C - 4F undefined
103  BAD_TRAP; BAD_TRAP; BAD_TRAP; BAD_TRAP;       ! 50 - 53 undefined
104  BAD_TRAP; BAD_TRAP; BAD_TRAP; BAD_TRAP;       ! 54 - 57 undefined
105  BAD_TRAP; BAD_TRAP; BAD_TRAP; BAD_TRAP;       ! 58 - 5B undefined
106  BAD_TRAP; BAD_TRAP; BAD_TRAP; BAD_TRAP;       ! 5C - 5F undefined
107  BAD_TRAP; BAD_TRAP; BAD_TRAP; BAD_TRAP;       ! 60 - 63 undefined
108  BAD_TRAP; BAD_TRAP; BAD_TRAP; BAD_TRAP;       ! 64 - 67 undefined
109  BAD_TRAP; BAD_TRAP; BAD_TRAP; BAD_TRAP;       ! 68 - 6B undefined
110  BAD_TRAP; BAD_TRAP; BAD_TRAP; BAD_TRAP;       ! 6C - 6F undefined
111  BAD_TRAP; BAD_TRAP; BAD_TRAP; BAD_TRAP;       ! 70 - 73 undefined
112  BAD_TRAP; BAD_TRAP; BAD_TRAP; BAD_TRAP;       ! 74 - 77 undefined
113  BAD_TRAP; BAD_TRAP; BAD_TRAP; BAD_TRAP;       ! 78 - 7B undefined
114
115/*
116   This is a sad patch to make sure that we know where the
117   MEC timer control register mirror is so we can stop the timers
118   from an external debugger. It is needed because the control
119   register is write-only. Trap 0x7C cannot occure in ERC32...
120
121   We also use this location to store the last location of the
122   usable RAM in order not to overwrite the remote debugger with
123   the RTEMS work-space area.
124
125*/
126
127        .global SYM(_ERC32_MEC_Timer_Control_Mirror), SYM(rdb_start), SYM(CLOCK_SPEED)
128        .global SYM(Configuration)
129
130SYM(rdb_start):
131SYM(_ERC32_MEC_Timer_Control_Mirror):
132
133  BAD_TRAP; BAD_TRAP;                           ! 7C - 7D undefined
134
135SYM(CLOCK_SPEED):
136
137  .word 0x0a, 0, 0, 0                           ! 7E (10 MHz default)
138
139  BAD_TRAP;                                     ! 7F undefined
140
141  /*
142   *  Software traps
143   *
144   *  NOTE: At the risk of being redundant... this is not a full
145   *        table.  The setjmp on the SPARC requires a window flush trap
146   *        handler and RTEMS will preserve the entries that were
147   *        installed before.
148   */
149
150  TRAP( 0x80, SYM(syscall) );                   ! 80 syscall SW trap
151  SOFT_TRAP; SOFT_TRAP;                         ! 81 - 82
152  TRAP( 0x83, SYM(window_flush_trap_handler) ); ! 83 flush windows SW trap
153
154  SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP;   ! 84 - 87
155  SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP;   ! 88 - 8B
156  SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP;   ! 8C - 8F
157  SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP;   ! 90 - 93
158  SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP;   ! 94 - 97
159  SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP;   ! 98 - 9B
160  SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP;   ! 9C - 9F
161  SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP;   ! A0 - A3
162  SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP;   ! A4 - A7
163  SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP;   ! A8 - AB
164  SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP;   ! AC - AF
165  SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP;   ! B0 - B3
166  SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP;   ! B4 - B7
167  SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP;   ! B8 - BB
168  SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP;   ! BC - BF
169  SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP;   ! C0 - C3
170  SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP;   ! C4 - C7
171  SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP;   ! C8 - CB
172  SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP;   ! CC - CF
173  SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP;   ! D0 - D3
174  SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP;   ! D4 - D7
175  SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP;   ! D8 - DB
176  SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP;   ! DC - DF
177  SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP;   ! E0 - E3
178  SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP;   ! E4 - E7
179  SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP;   ! E8 - EB
180  SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP;   ! EC - EF
181  SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP;   ! F0 - F3
182  SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP;   ! F4 - F7
183  SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP;   ! F8 - FB
184  SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP;   ! FC - FF
185
186/*
187 *  This is the hard reset code.
188 */
189
190#define PSR_INIT   0x10c0       /* Disable traps, set s and ps */
191#define WIM_INIT   2
192#define STACK_SIZE 16 * 1024
193
194        PUBLIC(hard_reset)
195SYM(hard_reset):
196
197/* Common initialisation */
198
199        set     SYM(trap_table), %g1    ! Initialize TBR
200        mov     %g1, %tbr
201
202        mov     %psr, %g1               ! Initialize WIM
203        add     %g1, 1, %g2
204        and     %g2, 0x7, %g2
205        set     1, %g3
206        sll     %g3, %g2, %g3
207        mov     %g3, %wim
208
209        or      %g1, 0x20, %g1
210        wr      %g1, %psr         ! enable traps
211
212        nop
213        nop
214        nop
215
216        call    __bsp_board_init
217        nop
218
219        set     (SYM(rdb_start)), %g6   ! End of work-space area
220        st      %sp, [%g6]
221        set     (SYM(Configuration)), %l1
222        ld      [%l1+4], %l3            ! work_space_size
223        sub     %sp, %l3, %sp           ! set %sp to area below work_space
224        andn    %sp, 0x0f, %sp          ! align stack on 16-byte boundary
225
226        mov     %sp, %fp                ! Set frame pointer
227        nop
228
229#if 0
230        /*
231         *  Copy the initialized data to RAM
232         *
233         *  FROM:   _endtext
234         *  TO:     _data_start
235         *  LENGTH: (__bss_start - _data_start) bytes
236         */
237
238        sethi %hi(_endtext),%g2
239        or    %g2,%lo(_endtext),%g2     ! g2 = start of initialized data in ROM
240
241        sethi %hi(_data_start),%g3
242        or    %g3,%lo(_data_start),%g3  ! g3 = start of initialized data in RAM
243
244        sethi %hi(__bss_start),%g4
245        or    %g4,%lo(__bss_start),%g4  ! g4 = end of initialized data in RAM
246
247        cmp   %g2, %g3
248        be    1f
249        nop
250
251copy_data:
252        ldd   [ %g2 ], %g6
253        std   %g6 , [ %g3 ]             ! copy this double word
254        add   %g3, 8, %g3               ! bump the destination pointer
255        add   %g2, 8, %g2               ! bump the source pointer
256        cmp   %g3, %g4                  ! Is the pointer past the end of dest?
257        bl    copy_data
258        nop
259#endif
260
261        /* clear the bss */
2621:
263
264        sethi %hi(_edata),%g2
265        or    %g2,%lo(_edata),%g2       ! g2 = start of bss
266        sethi %hi(_end),%g3
267        or    %g3,%lo(_end),%g3         ! g3 = end of bss
268        mov   %g0,%g1                   ! so std has two zeros
269zerobss:
270        std    %g0,[%g2]
271        add    %g2,8,%g2
272        cmp    %g2,%g3
273        bleu,a zerobss
274        nop
275
276        mov     %0, %o2                 ! environ
277        mov     %0, %o1                 ! argv
278        mov     %0, %o0                 ! argc
279        call    SYM(boot_card)
280        sub     %sp, 0x60, %sp          ! room for boot_card to save args
281        nop
282
283        PUBLIC(BSP_fatal_return)
284SYM(BSP_fatal_return):
285        mov     1, %g1
286        ta      0                       ! Halt if _main returns ...
287        nop
288
289/* end of file */
Note: See TracBrowser for help on using the repository browser.