OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rtems-20020807/] [c/] [src/] [lib/] [libbsp/] [sparc/] [shared/] [start.S] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1026 ivang
/*
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
 *  start.S,v 1.2 2001/04/24 20:49:11 joel Exp
11
 */
12
 
13
#include 
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
 
36
SYM(start):
37
start:
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)
50
SYM(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
 
133
SYM(rdb_start):
134
SYM(_ERC32_MEC_Timer_Control_Mirror):
135
 
136
  BAD_TRAP; BAD_TRAP;                           ! 7C - 7D undefined
137
 
138
SYM(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)
198
SYM(hard_reset):
199
 
200
/* Common initialisation */
201
 
202
        set     SYM(trap_table), %g1    ! Initialize TBR
203
        mov     %g1, %tbr
204
 
205
        mov     %psr, %g1               ! Initialize WIM
206
        add     %g1, 1, %g2
207
        and     %g2, 0x7, %g2
208
        set     1, %g3
209
        sll     %g3, %g2, %g3
210
        mov     %g3, %wim
211
 
212
        or      %g1, 0x20, %g1
213
        wr      %g1, %psr         ! enable traps
214
 
215
        nop
216
        nop
217
        nop
218
 
219
        call    __bsp_board_init
220
        nop
221
 
222
 
223
        set     (SYM(rdb_start)), %g6   ! End of work-space area
224
        st      %sp, [%g6]
225
        set     (SYM(Configuration)), %l1
226
        ld      [%l1+4], %l3            ! work_space_size
227
        sub     %sp, %l3, %sp           ! set %sp to area below work_space
228
        andn    %sp, 0x0f, %sp          ! align stack on 16-byte boundary
229
 
230
        mov     %sp, %fp                ! Set frame pointer
231
        nop
232
 
233
        /*
234
         *  Copy the initialized data to RAM
235
         *
236
         *  FROM:   _endtext
237
         *  TO:     _data_start
238
         *  LENGTH: (__bss_start - _data_start) bytes
239
         */
240
 
241
 
242
        sethi %hi(_endtext),%g2
243
        or    %g2,%lo(_endtext),%g2     ! g2 = start of initialized data in ROM
244
 
245
        sethi %hi(_data_start),%g3
246
        or    %g3,%lo(_data_start),%g3  ! g3 = start of initialized data in RAM
247
 
248
        sethi %hi(__bss_start),%g4
249
        or    %g4,%lo(__bss_start),%g4  ! g4 = end of initialized data in RAM
250
 
251
        cmp   %g2, %g3
252
        be    1f
253
        nop
254
 
255
copy_data:
256
        ldd   [ %g2 ], %g6
257
        std   %g6 , [ %g3 ]             ! copy this double word
258
        add   %g3, 8, %g3               ! bump the destination pointer
259
        add   %g2, 8, %g2               ! bump the source pointer
260
        cmp   %g3, %g4                  ! Is the pointer past the end of dest?
261
        bl    copy_data
262
        nop
263
 
264
        /* clear the bss */
265
1:
266
 
267
        sethi %hi(_edata),%g2
268
        or    %g2,%lo(_edata),%g2       ! g2 = start of bss
269
        sethi %hi(_end),%g3
270
        or    %g3,%lo(_end),%g3         ! g3 = end of bss
271
        mov   %g0,%g1                   ! so std has two zeros
272
zerobss:
273
        std    %g0,[%g2]
274
        add    %g2,8,%g2
275
        cmp    %g2,%g3
276
        bleu,a zerobss
277
        nop
278
 
279
        mov     %0, %o2                 ! environ
280
        mov     %0, %o1                 ! argv
281
        mov     %0, %o0                 ! argc
282
        call    SYM(boot_card)
283
        sub     %sp, 0x60, %sp          ! room for boot_card to save args
284
        nop
285
 
286
        PUBLIC(BSP_fatal_return)
287
SYM(BSP_fatal_return):
288
        mov     1, %g1
289
        ta      0                       ! Halt if _main returns ...
290
        nop
291
 
292
/* end of file */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.