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

4.104.114.84.95
Last change on this file since 3eec211 was 3eec211, checked in by Joel Sherrill <joel.sherrill@…>, on 11/13/00 at 22:31:22

2000-11-13 Jiri Gaisler <jgais@…>

  • ChangeLog?, .cvsignore, Makefile.am, bspclean.c, bspstart.c, gnatcommon.c, start.S: New files. Largely moved from ERC32 BSP to be able to be shared with LEON and other SPARC BSPs.
  • 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 <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
32  .seg    "text"
33  PUBLIC(start)
34  .global start, __bsp_mem_init
35
36SYM(start):
37start:
38
39/*
40 *  The trap table has to be the first code in a boot PROM.  But because
41 *  the Memory Configuration comes up thinking we only have 4K of PROM, we
42 *  cannot have a full trap table and still have room left over to
43 *  reprogram the Memory Configuration register correctly.  This file
44 *  uses an abbreviated trap which has every entry which might be used
45 *  before RTEMS installs its own trap table.
46 */
47
48
49  PUBLIC(trap_table)
50SYM(trap_table):
51
52  RTRAP( 0, SYM(hard_reset) );                   ! 00 reset trap
53  BAD_TRAP;                                     ! 01 instruction access
54                                                !    exception
55  BAD_TRAP;                                     ! 02 illegal instruction
56  BAD_TRAP;                                     ! 03 privileged instruction
57  BAD_TRAP;                                     ! 04 fp disabled
58  TRAP( 5, SYM(window_overflow_trap_handler) ); ! 05 window overflow
59  TRAP( 6, SYM(window_underflow_trap_handler) );! 06 window underflow
60  BAD_TRAP;                                     ! 07 memory address not aligned
61  BAD_TRAP;                                     ! 08 fp exception
62  BAD_TRAP;                                     ! 09 data access exception
63  BAD_TRAP;                                     ! 0A tag overflow
64  BAD_TRAP;                                     ! 0B undefined
65  BAD_TRAP;                                     ! 0C undefined
66  BAD_TRAP;                                     ! 0D undefined
67  BAD_TRAP;                                     ! 0E undefined
68  BAD_TRAP;                                     ! 0F undefined
69  BAD_TRAP;                                     ! 10 undefined
70
71  /*
72   *  ERC32 defined traps
73   */
74
75  BAD_TRAP;                                     ! 11 masked errors
76  BAD_TRAP;                                     ! 12 external 1
77  BAD_TRAP;                                     ! 13 external 2
78  BAD_TRAP;                                     ! 14 UART A RX/TX
79  BAD_TRAP;                                     ! 15 UART B RX/TX
80  BAD_TRAP;                                     ! 16 correctable memory error
81  BAD_TRAP;                                     ! 17 UART error
82  BAD_TRAP;                                     ! 18 DMA access error
83  BAD_TRAP;                                     ! 19 DMA timeout
84  BAD_TRAP;                                     ! 1A external 3
85  BAD_TRAP;                                     ! 1B external 4
86  BAD_TRAP;                                     ! 1C general purpose timer
87  BAD_TRAP;                                     ! 1D real time clock
88  BAD_TRAP;                                     ! 1E external 5
89  BAD_TRAP;                                     ! 1F watchdog timeout
90
91
92  BAD_TRAP; BAD_TRAP; BAD_TRAP; BAD_TRAP;       ! 20 - 23 undefined
93  BAD_TRAP;                                     ! 24 cp_disabled
94            BAD_TRAP; BAD_TRAP; BAD_TRAP;       ! 25 - 27 undefined
95  BAD_TRAP;                                     ! 28 cp_exception
96            BAD_TRAP; BAD_TRAP; BAD_TRAP;       ! 29 - 2B undefined
97  BAD_TRAP; BAD_TRAP; BAD_TRAP; BAD_TRAP;       ! 2C - 2F undefined
98  BAD_TRAP; BAD_TRAP; BAD_TRAP; BAD_TRAP;       ! 30 - 33 undefined
99  BAD_TRAP; BAD_TRAP; BAD_TRAP; BAD_TRAP;       ! 34 - 37 undefined
100  BAD_TRAP; BAD_TRAP; BAD_TRAP; BAD_TRAP;       ! 38 - 3B undefined
101  BAD_TRAP; BAD_TRAP; BAD_TRAP; BAD_TRAP;       ! 3C - 3F undefined
102  BAD_TRAP; BAD_TRAP; BAD_TRAP; BAD_TRAP;       ! 40 - 43 undefined
103  BAD_TRAP; BAD_TRAP; BAD_TRAP; BAD_TRAP;       ! 44 - 47 undefined
104  BAD_TRAP; BAD_TRAP; BAD_TRAP; BAD_TRAP;       ! 48 - 4B undefined
105  BAD_TRAP; BAD_TRAP; BAD_TRAP; BAD_TRAP;       ! 4C - 4F undefined
106  BAD_TRAP; BAD_TRAP; BAD_TRAP; BAD_TRAP;       ! 50 - 53 undefined
107  BAD_TRAP; BAD_TRAP; BAD_TRAP; BAD_TRAP;       ! 54 - 57 undefined
108  BAD_TRAP; BAD_TRAP; BAD_TRAP; BAD_TRAP;       ! 58 - 5B undefined
109  BAD_TRAP; BAD_TRAP; BAD_TRAP; BAD_TRAP;       ! 5C - 5F undefined
110  BAD_TRAP; BAD_TRAP; BAD_TRAP; BAD_TRAP;       ! 60 - 63 undefined
111  BAD_TRAP; BAD_TRAP; BAD_TRAP; BAD_TRAP;       ! 64 - 67 undefined
112  BAD_TRAP; BAD_TRAP; BAD_TRAP; BAD_TRAP;       ! 68 - 6B undefined
113  BAD_TRAP; BAD_TRAP; BAD_TRAP; BAD_TRAP;       ! 6C - 6F undefined
114  BAD_TRAP; BAD_TRAP; BAD_TRAP; BAD_TRAP;       ! 70 - 73 undefined
115  BAD_TRAP; BAD_TRAP; BAD_TRAP; BAD_TRAP;       ! 74 - 77 undefined
116  BAD_TRAP; BAD_TRAP; BAD_TRAP; BAD_TRAP;       ! 78 - 7B undefined
117
118/*
119   This is a sad patch to make sure that we know where the
120   MEC timer control register mirror is so we can stop the timers
121   from an external debugger. It is needed because the control
122   register is write-only. Trap 0x7C cannot occure in ERC32...
123
124   We also use this location to store the last location of the
125   usable RAM in order not to overwrite the remote debugger with
126   the RTEMS work-space area.
127
128*/
129
130        .global SYM(_ERC32_MEC_Timer_Control_Mirror), SYM(rdb_start), SYM(CLOCK_SPEED)
131        .global SYM(Configuration)
132
133SYM(rdb_start):
134SYM(_ERC32_MEC_Timer_Control_Mirror):
135
136  BAD_TRAP; BAD_TRAP;                           ! 7C - 7D undefined
137
138SYM(CLOCK_SPEED):
139
140  .word 0x0a, 0, 0, 0                           ! 7E (10 MHz default)
141 
142  BAD_TRAP;                                     ! 7F undefined
143
144  /*
145   *  Software traps
146   *
147   *  NOTE: At the risk of being redundant... this is not a full
148   *        table.  The setjmp on the SPARC requires a window flush trap
149   *        handler and RTEMS will preserve the entries that were
150   *        installed before.
151   */
152
153  TRAP( 0x80, SYM(syscall) );                   ! 80 syscall SW trap
154  SOFT_TRAP; SOFT_TRAP;                         ! 81 - 82
155  TRAP( 0x83, SYM(window_flush_trap_handler) ); ! 83 flush windows SW trap
156
157  SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP;   ! 84 - 87
158  SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP;   ! 88 - 8B
159  SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP;   ! 8C - 8F
160  SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP;   ! 90 - 93
161  SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP;   ! 94 - 97
162  SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP;   ! 98 - 9B
163  SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP;   ! 9C - 9F
164  SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP;   ! A0 - A3
165  SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP;   ! A4 - A7
166  SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP;   ! A8 - AB
167  SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP;   ! AC - AF
168  SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP;   ! B0 - B3
169  SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP;   ! B4 - B7
170  SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP;   ! B8 - BB
171  SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP;   ! BC - BF
172  SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP;   ! C0 - C3
173  SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP;   ! C4 - C7
174  SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP;   ! C8 - CB
175  SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP;   ! CC - CF
176  SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP;   ! D0 - D3
177  SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP;   ! D4 - D7
178  SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP;   ! D8 - DB
179  SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP;   ! DC - DF
180  SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP;   ! E0 - E3
181  SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP;   ! E4 - E7
182  SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP;   ! E8 - EB
183  SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP;   ! EC - EF
184  SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP;   ! F0 - F3
185  SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP;   ! F4 - F7
186  SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP;   ! F8 - FB
187  SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP;   ! FC - FF
188
189/*
190 *  This is the hard reset code.
191 */
192
193#define PSR_INIT   0x10c0       /* Disable traps, set s and ps */
194#define WIM_INIT   2
195#define STACK_SIZE 16 * 1024
196
197        PUBLIC(hard_reset)
198SYM(hard_reset):
199
200/* Common initialisation */
201
202        set     SYM(trap_table), %g1           ! Initialize TBR
203        mov     %g1, %tbr
204
205        set     WIM_INIT, %g1           ! Initialize WIM
206        mov     %g1, %wim               
207
208        set     PSR_INIT, %g1
209        wr      %g1, 0x20, %psr         ! enable traps
210
211        nop
212        nop
213        nop
214
215        call    __bsp_board_init
216        nop
217
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        /*
230         *  Copy the initialized data to RAM
231         *
232         *  FROM:   _endtext
233         *  TO:     _data_start
234         *  LENGTH: (__bss_start - _data_start) bytes
235         */
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
260        /* clear the bss */
2611:
262
263        sethi %hi(_edata),%g2
264        or    %g2,%lo(_edata),%g2       ! g2 = start of bss
265        sethi %hi(_end),%g3
266        or    %g3,%lo(_end),%g3         ! g3 = end of bss
267        mov   %g0,%g1                   ! so std has two zeros
268zerobss:
269        std    %g0,[%g2]
270        add    %g2,8,%g2
271        cmp    %g2,%g3
272        bleu,a zerobss
273        nop
274
275        mov     %0, %o2                 ! environ
276        mov     %0, %o1                 ! argv
277        mov     %0, %o0                 ! argc
278        call    SYM(boot_card)
279        sub     %sp, 0x60, %sp          ! room for boot_card to save args
280        nop
281
282        PUBLIC(BSP_fatal_return)
283SYM(BSP_fatal_return):
284        mov     1, %g1
285        ta      0                       ! Halt if _main returns ...
286        nop
287
288/* end of file */
Note: See TracBrowser for help on using the repository browser.