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

4.104.115
Last change on this file since a4ed6b1 was 68e27077, checked in by Chris Johns <chrisj@…>, on 04/28/09 at 06:35:06

2009-04-28 Chris Johns <chrisj@…>

  • shared/start/start.S: Update for boot_card command line change.
  • Property mode set to 100644
File size: 11.9 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 *  COPYRIGHT (c) 1989-2006.
11 *  On-Line Applications Research Corporation (OAR).
12 *
13 *  The license and distribution terms for this file may be
14 *  found in the file LICENSE in this distribution or at
15 *  http://www.rtems.com/license/LICENSE.
16 *
17 *  $Id$
18 */
19
20#include <rtems/asm.h>
21#include <bspopts.h>
22
23#warning Call to boot_card has changed and needs checking.
24#warning The call is "void boot_card(const char* cmdline);"
25#warning You need to pass a NULL.
26#warning Please check and remove these warnings.
27       
28/*
29 *  Unexpected trap will halt the processor by forcing it to error state
30 */
31
32#define BAD_TRAP \
33  ta 0; \
34  nop; \
35  nop; \
36  nop;
37
38/*
39 *  Software trap. Treat as BAD_TRAP for the time being...
40 */
41
42#define SOFT_TRAP BAD_TRAP
43
44  .seg    "text"
45  PUBLIC(start)
46  .global start, __bsp_mem_init
47
48SYM(start):
49start:
50
51/*
52 *  The trap table has to be the first code in a boot PROM.  But because
53 *  the Memory Configuration comes up thinking we only have 4K of PROM, we
54 *  cannot have a full trap table and still have room left over to
55 *  reprogram the Memory Configuration register correctly.  This file
56 *  uses an abbreviated trap which has every entry which might be used
57 *  before RTEMS installs its own trap table.
58 */
59
60  PUBLIC(trap_table)
61SYM(trap_table):
62
63  RTRAP( 0, SYM(hard_reset) );                  ! 00 reset trap
64  BAD_TRAP;                                     ! 01 instruction access
65                                                !    exception
66  BAD_TRAP;                                     ! 02 illegal instruction
67  BAD_TRAP;                                     ! 03 privileged instruction
68  BAD_TRAP;                                     ! 04 fp disabled
69  TRAP( 5, SYM(window_overflow_trap_handler) ); ! 05 window overflow
70  TRAP( 6, SYM(window_underflow_trap_handler) );! 06 window underflow
71  BAD_TRAP;                                     ! 07 memory address not aligned
72  BAD_TRAP;                                     ! 08 fp exception
73  BAD_TRAP;                                     ! 09 data access exception
74  BAD_TRAP;                                     ! 0A tag overflow
75  BAD_TRAP;                                     ! 0B undefined
76  BAD_TRAP;                                     ! 0C undefined
77  BAD_TRAP;                                     ! 0D undefined
78  BAD_TRAP;                                     ! 0E undefined
79  BAD_TRAP;                                     ! 0F undefined
80  BAD_TRAP;                                     ! 10 undefined
81
82  /*
83   *  ERC32 defined traps
84   */
85
86  BAD_TRAP;                                     ! 11 masked errors
87  BAD_TRAP;                                     ! 12 external 1
88  BAD_TRAP;                                     ! 13 external 2
89  BAD_TRAP;                                     ! 14 UART A RX/TX
90  BAD_TRAP;                                     ! 15 UART B RX/TX
91  BAD_TRAP;                                     ! 16 correctable memory error
92  BAD_TRAP;                                     ! 17 UART error
93  BAD_TRAP;                                     ! 18 DMA access error
94  BAD_TRAP;                                     ! 19 DMA timeout
95  BAD_TRAP;                                     ! 1A external 3
96  BAD_TRAP;                                     ! 1B external 4
97  BAD_TRAP;                                     ! 1C general purpose timer
98  BAD_TRAP;                                     ! 1D real time clock
99  BAD_TRAP;                                     ! 1E external 5
100  BAD_TRAP;                                     ! 1F watchdog timeout
101
102  BAD_TRAP; BAD_TRAP; BAD_TRAP; BAD_TRAP;       ! 20 - 23 undefined
103  BAD_TRAP;                                     ! 24 cp_disabled
104            BAD_TRAP; BAD_TRAP; BAD_TRAP;       ! 25 - 27 undefined
105  BAD_TRAP;                                     ! 28 cp_exception
106            BAD_TRAP; BAD_TRAP; BAD_TRAP;       ! 29 - 2B undefined
107  BAD_TRAP; BAD_TRAP; BAD_TRAP; BAD_TRAP;       ! 2C - 2F undefined
108  BAD_TRAP; BAD_TRAP; BAD_TRAP; BAD_TRAP;       ! 30 - 33 undefined
109  BAD_TRAP; BAD_TRAP; BAD_TRAP; BAD_TRAP;       ! 34 - 37 undefined
110  BAD_TRAP; BAD_TRAP; BAD_TRAP; BAD_TRAP;       ! 38 - 3B undefined
111  BAD_TRAP; BAD_TRAP; BAD_TRAP; BAD_TRAP;       ! 3C - 3F undefined
112  BAD_TRAP; BAD_TRAP; BAD_TRAP; BAD_TRAP;       ! 40 - 43 undefined
113  BAD_TRAP; BAD_TRAP; BAD_TRAP; BAD_TRAP;       ! 44 - 47 undefined
114  BAD_TRAP; BAD_TRAP; BAD_TRAP; BAD_TRAP;       ! 48 - 4B undefined
115  BAD_TRAP; BAD_TRAP; BAD_TRAP; BAD_TRAP;       ! 4C - 4F undefined
116  BAD_TRAP; BAD_TRAP; BAD_TRAP; BAD_TRAP;       ! 50 - 53 undefined
117  BAD_TRAP; BAD_TRAP; BAD_TRAP; BAD_TRAP;       ! 54 - 57 undefined
118  BAD_TRAP; BAD_TRAP; BAD_TRAP; BAD_TRAP;       ! 58 - 5B undefined
119  BAD_TRAP; BAD_TRAP; BAD_TRAP; BAD_TRAP;       ! 5C - 5F undefined
120  BAD_TRAP; BAD_TRAP; BAD_TRAP; BAD_TRAP;       ! 60 - 63 undefined
121  BAD_TRAP; BAD_TRAP; BAD_TRAP; BAD_TRAP;       ! 64 - 67 undefined
122  BAD_TRAP; BAD_TRAP; BAD_TRAP; BAD_TRAP;       ! 68 - 6B undefined
123  BAD_TRAP; BAD_TRAP; BAD_TRAP; BAD_TRAP;       ! 6C - 6F undefined
124  BAD_TRAP; BAD_TRAP; BAD_TRAP; BAD_TRAP;       ! 70 - 73 undefined
125  BAD_TRAP; BAD_TRAP; BAD_TRAP; BAD_TRAP;       ! 74 - 77 undefined
126  BAD_TRAP; BAD_TRAP; BAD_TRAP; BAD_TRAP;       ! 78 - 7B undefined
127
128/*
129   This is a sad patch to make sure that we know where the
130   MEC timer control register mirror is so we can stop the timers
131   from an external debugger. It is needed because the control
132   register is write-only. Trap 0x7C cannot occure in ERC32...
133
134   We also use this location to store the last location of the
135   usable RAM in order not to overwrite the remote debugger with
136   the RTEMS work-space area.
137
138*/
139
140        .global SYM(_ERC32_MEC_Timer_Control_Mirror), SYM(rdb_start), SYM(CLOCK_SPEED)
141        .global SYM(Configuration)
142
143SYM(rdb_start):
144SYM(_ERC32_MEC_Timer_Control_Mirror):
145
146  BAD_TRAP; BAD_TRAP;                           ! 7C - 7D undefined
147
148SYM(CLOCK_SPEED):
149
150  .word 0x0a, 0, 0, 0                           ! 7E (10 MHz default)
151
152  BAD_TRAP;                                     ! 7F undefined
153
154  /*
155   *  Software traps
156   *
157   *  NOTE: At the risk of being redundant... this is not a full
158   *        table.  The setjmp on the SPARC requires a window flush trap
159   *        handler and RTEMS will preserve the entries that were
160   *        installed before.
161   */
162
163  TRAP( 0x80, SYM(syscall) );                   ! 80 syscall SW trap
164  SOFT_TRAP; SOFT_TRAP;                         ! 81 - 82
165  TRAP( 0x83, SYM(window_flush_trap_handler) ); ! 83 flush windows SW trap
166
167  SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP;   ! 84 - 87
168  SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP;   ! 88 - 8B
169  SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP;   ! 8C - 8F
170  SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP;   ! 90 - 93
171  SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP;   ! 94 - 97
172  SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP;   ! 98 - 9B
173  SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP;   ! 9C - 9F
174  SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP;   ! A0 - A3
175  SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP;   ! A4 - A7
176  SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP;   ! A8 - AB
177  SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP;   ! AC - AF
178  SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP;   ! B0 - B3
179  SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP;   ! B4 - B7
180  SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP;   ! B8 - BB
181  SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP;   ! BC - BF
182  SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP;   ! C0 - C3
183  SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP;   ! C4 - C7
184  SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP;   ! C8 - CB
185  SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP;   ! CC - CF
186  SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP;   ! D0 - D3
187  SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP;   ! D4 - D7
188  SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP;   ! D8 - DB
189  SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP;   ! DC - DF
190  SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP;   ! E0 - E3
191  SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP;   ! E4 - E7
192  SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP;   ! E8 - EB
193  SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP;   ! EC - EF
194  SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP;   ! F0 - F3
195  SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP;   ! F4 - F7
196  SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP;   ! F8 - FB
197  SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP;   ! FC - FF
198
199/*
200 *  This is the hard reset code.
201 */
202
203#define PSR_INIT   0x10c0       /* Disable traps, set s and ps */
204#define WIM_INIT   2
205#define STACK_SIZE 16 * 1024
206
207        PUBLIC(hard_reset)
208SYM(hard_reset):
209
210/* Common initialisation */
211
212        set     SYM(trap_table), %g1    ! Initialize TBR
213        mov     %g1, %tbr
214
215        mov     %psr, %g1               ! Initialize WIM
216        add     %g1, 1, %g2
217        and     %g2, 0x7, %g2
218        set     1, %g3
219        sll     %g3, %g2, %g3
220        mov     %g3, %wim
221
222        or      %g1, 0x20, %g1
223        wr      %g1, %psr               ! enable traps
224
225        nop
226        nop
227        nop
228
229        set     (SYM(rdb_start)), %g6   ! End of work-space area
230        st      %sp, [%g6]
231        sub     %sp, 4, %sp             ! stack starts at end of RAM - 4
232        andn    %sp, 0x0f, %sp          ! align stack on 16-byte boundary
233        mov     %sp, %fp                ! Set frame pointer
234        nop
235
236#if ENABLE_SIS_QUIRKS==1
237
238#include <erc32.h>
239       
240/* Check if MEC is initialised. If not, this means that we are
241   running on the simulator. Initiate some of the parameters
242   that are done by the boot-prom otherwise.
243*/
244
245        set     SYM(ERC32_MEC), %g3  ! g3 = base address of peripherals
246        ld      [%g3], %g2             
247        set     0xfe080000, %g1
248        andcc   %g1, %g2, %g0
249        bne     2f
250 
251 /* Set the correct memory size in MEC memory config register */
252 
253        set     SYM(PROM_SIZE), %l0     
254        set     0, %l1
255        srl     %l0, 18, %l0
2561:
257        tst     %l0
258        srl     %l0, 1, %l0
259        bne,a   1b
260        inc     %l1
261        sll     %l1, 8, %l1
262 
263        set     SYM(RAM_SIZE), %l0     
264        srl     %l0, 19, %l0
2651:
266        tst     %l0
267        srl     %l0, 1, %l0
268        bne,a   1b
269        inc     %l1
270        sll     %l1, 10, %l1
271 
272        ! set the Memory Configuration
273        st     %l1, [ %g3 + ERC32_MEC_MEMORY_CONFIGURATION_OFFSET ]
274        !DISABLE THE HARDWARE WATCHDOG
275        st     %g0, [ %g3 + ERC32_MEC_WATCHDOG_TRAP_DOOR_SET_OFFSET ]
276        !Reduce the number of wait states to 0 for all memory areas.
277        st     %g0, [ %g3 + ERC32_MEC_WAIT_STATE_CONFIGURATION_OFFSET ]
278         
279        set     SYM(RAM_START), %l1  ! Cannot use RAM_END due to bug in linker
280        set     SYM(RAM_SIZE), %l2
281        add     %l1, %l2, %sp
282        st      %sp, [%g6]     
283
284
285        set     SYM(CLOCK_SPEED), %g6   ! Use 14 MHz in simulator
286        set     14, %g1
287        st      %g1, [%g6]
288       
2892:     
290#endif 
291
292        /*
293         *  Copy the initialized data to RAM
294         *
295         *  FROM:   _endtext
296         *  TO:     _data_start
297         *  LENGTH: (__bss_start - _data_start) bytes
298         */
299
300        sethi %hi(_endtext),%g2
301        or    %g2,%lo(_endtext),%g2     ! g2 = start of initialized data in ROM
302
303        sethi %hi(_data_start),%g3
304        or    %g3,%lo(_data_start),%g3  ! g3 = start of initialized data in RAM
305
306        sethi %hi(__bss_start),%g4
307        or    %g4,%lo(__bss_start),%g4  ! g4 = end of initialized data in RAM
308
309        cmp   %g2, %g3
310        be    1f
311        nop
312
313copy_data:
314        ldd   [ %g2 ], %g6
315        std   %g6 , [ %g3 ]             ! copy this double word
316        add   %g3, 8, %g3               ! bump the destination pointer
317        add   %g2, 8, %g2               ! bump the source pointer
318        cmp   %g3, %g4                  ! Is the pointer past the end of dest?
319        bl    copy_data
320        nop
321
322        /* clear the bss */
3231:
324
325        sethi %hi(_edata),%g2
326        or    %g2,%lo(_edata),%g2       ! g2 = start of bss
327        sethi %hi(_end),%g3
328        or    %g3,%lo(_end),%g3         ! g3 = end of bss
329        mov   %g0,%g1                   ! so std has two zeros
330zerobss:
331        std    %g0,[%g2]
332        add    %g2,8,%g2
333        cmp    %g2,%g3
334        bleu,a zerobss
335        nop
336
337        mov     %0, %o0                 ! command line
338        call    SYM(boot_card)
339        sub     %sp, 0x60, %sp          ! room for boot_card to save args
340        nop
341
342        PUBLIC(BSP_fatal_return)
343SYM(BSP_fatal_return):
344        mov     1, %g1
345        ta      0                       ! Halt if _main returns ...
346        nop
347
348/* end of file */
Note: See TracBrowser for help on using the repository browser.