source: rtems/c/src/lib/libbsp/m68k/uC5282/start/start.S @ 02682585

Last change on this file since 02682585 was 02682585, checked in by Joel Sherrill <joel.sherrill@…>, on 03/12/07 at 11:22:17

2007-03-12 Joel Sherrill <joel@…>

  • clock/clock.c, console/console.c, include/bsp.h, include/coverhd.h, include/tm27.h, network/network.c, start/start.S, startup/bspclean.c, startup/bspstart.c, startup/init5282.c, startup/linkcmds, timer/timer.c: Correct license URL and/or fix mistake in copyright notice. Both of these mistakes appear to be from code submitted after these changes were made previously.
  • Property mode set to 100644
File size: 14.0 KB
Line 
1/*
2 *  uC5282 startup code
3 *
4 *  This file contains the entry point for the application.
5 *  The name of this entry point is compiler dependent.
6 *  It jumps to the BSP which is responsible for performing
7 *  all initialization.
8 *
9 *  COPYRIGHT (c) 1989-1998.
10 *  On-Line Applications Research Corporation (OAR).
11 *
12 *  The license and distribution terms for this file may be
13 *  found in the file LICENSE in this distribution or at
14 *
15 *  http://www.rtems.com/license/LICENSE.
16 *
17 *  $Id$
18 */
19
20#include <rtems/asm.h>
21
22#define SRAM_SIZE (64*1024)
23#define DEFAULT_IPSBAR  0x40000000
24
25BEGIN_CODE
26
27/***************************************************************************
28   Function : Entry
29
30   Description : Entry point to the system. In a raw system we would have
31   put the initial stack pointer as the first 4 bytes.  Instead we have to
32   provide a real instruction at the first location since we might be getting
33   started by dBUG after downloading from TFTP or FLASH.   Hack in an
34   'initial stack pointer' that actually is a jump to the start address!
35 ***************************************************************************/
36Entry:
37
38
39    nop ; jmp SYM(start)    |   0: Initial 'SSP'    1: Initial PC
40    .long   SYM(_uhoh)      |   2: Bus error
41    .long   SYM(_uhoh)      |   3: Address error
42    .long   SYM(_uhoh)      |   4: Illegal instruction
43    .long   SYM(_uhoh)      |   5: Zero division
44    .long   SYM(_uhoh)      |   6: CHK, CHK2 instruction
45    .long   SYM(_uhoh)      |   7: TRAPcc, TRAPV instructions
46    .long   SYM(_uhoh)      |   8: Privilege violation
47    .long   SYM(_uhoh)      |   9: Trace
48    .long   SYM(_uhoh)      |  10: Line 1010 emulator
49    .long   SYM(_uhoh)      |  11: Line 1111 emulator
50    .long   SYM(_uhoh)      |  12: Hardware breakpoint
51    .long   SYM(_uhoh)      |  13: Reserved for coprocessor violation
52    .long   SYM(_uhoh)      |  14: Format error
53    .long   SYM(_uhoh)      |  15: Uninitialized interrupt
54    .long   SYM(_uhoh)      |  16: Unassigned, reserved
55    .long   SYM(_uhoh)      |  17:
56    .long   SYM(_uhoh)      |  18:
57    .long   SYM(_uhoh)      |  19:
58    .long   SYM(_uhoh)      |  20:
59    .long   SYM(_uhoh)      |  21:
60    .long   SYM(_uhoh)      |  22:
61    .long   SYM(_uhoh)      |  23:
62    .long   SYM(_spuriousInterrupt) |  24: Spurious interrupt
63    .long   SYM(_uhoh)      |  25: Level 1 interrupt autovector
64    .long   SYM(_uhoh)      |  26: Level 2 interrupt autovector
65    .long   SYM(_uhoh)      |  27: Level 3 interrupt autovector
66    .long   SYM(_uhoh)      |  28: Level 4 interrupt autovector
67    .long   SYM(_uhoh)      |  29: Level 5 interrupt autovector
68    .long   SYM(_uhoh)      |  30: Level 6 interrupt autovector
69    .long   SYM(_uhoh)      |  31: Level 7 interrupt autovector
70    .long   SYM(_uhoh)      |  32: Trap instruction (0-15)
71    .long   SYM(_uhoh)      |  33:
72    .long   SYM(_uhoh)      |  34:
73    .long   SYM(_uhoh)      |  35:
74    .long   SYM(_uhoh)      |  36:
75    .long   SYM(_uhoh)      |  37:
76    .long   SYM(_uhoh)      |  38:
77    .long   SYM(_uhoh)      |  39:
78    .long   SYM(_uhoh)      |  40:
79    .long   SYM(_uhoh)      |  41:
80    .long   SYM(_uhoh)      |  42:
81    .long   SYM(_uhoh)      |  43:
82    .long   SYM(_uhoh)      |  44:
83    .long   SYM(_uhoh)      |  45:
84    .long   SYM(_uhoh)      |  46:
85    .long   SYM(_uhoh)      |  47:
86    .long   SYM(_uhoh)      |  48: Reserved for coprocessor
87    .long   SYM(_uhoh)      |  49:
88    .long   SYM(_uhoh)      |  50:
89    .long   SYM(_uhoh)      |  51:
90    .long   SYM(_uhoh)      |  52:
91    .long   SYM(_uhoh)      |  53:
92    .long   SYM(_uhoh)      |  54:
93    .long   SYM(_uhoh)      |  55:
94    .long   SYM(_uhoh)      |  56:
95    .long   SYM(_uhoh)      |  57:
96    .long   SYM(_uhoh)      |  58:
97    .long   SYM(_uhoh)      |  59: Unassigned, reserved
98    .long   SYM(_uhoh)      |  60:
99    .long   SYM(_uhoh)      |  61:
100    .long   SYM(_uhoh)      |  62:
101    .long   SYM(_uhoh)      |  63:
102    .long   SYM(_spuriousInterrupt) |  64: User spurious handler
103    .long   SYM(_uhoh)      |  65:
104    .long   SYM(_uhoh)      |  66:
105    .long   SYM(_uhoh)      |  67:
106    .long   SYM(_uhoh)      |  68:
107    .long   SYM(_uhoh)      |  69:
108    .long   SYM(_uhoh)      |  70:
109    .long   SYM(_uhoh)      |  71:
110    .long   SYM(_uhoh)      |  72:
111    .long   SYM(_uhoh)      |  73:
112    .long   SYM(_uhoh)      |  74:
113    .long   SYM(_uhoh)      |  75:
114    .long   SYM(_uhoh)      |  76:
115    .long   SYM(_uhoh)      |  77:
116    .long   SYM(_uhoh)      |  78:
117    .long   SYM(_uhoh)      |  79:
118    .long   SYM(_uhoh)      |  80:
119    .long   SYM(_uhoh)      |  81:
120    .long   SYM(_uhoh)      |  82:
121    .long   SYM(_uhoh)      |  83:
122    .long   SYM(_uhoh)      |  84:
123    .long   SYM(_uhoh)      |  85:
124    .long   SYM(_uhoh)      |  86:
125    .long   SYM(_uhoh)      |  87:
126    .long   SYM(_uhoh)      |  88:
127    .long   SYM(_uhoh)      |  89:
128    .long   SYM(_uhoh)      |  90:
129    .long   SYM(_uhoh)      |  91:
130    .long   SYM(_uhoh)      |  92:
131    .long   SYM(_uhoh)      |  93:
132    .long   SYM(_uhoh)      |  94:
133    .long   SYM(_uhoh)      |  95:
134    .long   SYM(_uhoh)      |  96:
135    .long   SYM(_uhoh)      |  97:
136    .long   SYM(_uhoh)      |  98:
137    .long   SYM(_uhoh)      |  99:
138    .long   SYM(_uhoh)      | 100:
139    .long   SYM(_uhoh)      | 101:
140    .long   SYM(_uhoh)      | 102:
141    .long   SYM(_uhoh)      | 103:
142    .long   SYM(_uhoh)      | 104:
143    .long   SYM(_uhoh)      | 105:
144    .long   SYM(_uhoh)      | 106:
145    .long   SYM(_uhoh)      | 107:
146    .long   SYM(_uhoh)      | 108:
147    .long   SYM(_uhoh)      | 109:
148    .long   SYM(_uhoh)      | 110:
149    .long   SYM(_uhoh)      | 111:
150    .long   SYM(_uhoh)      | 112:
151    .long   SYM(_uhoh)      | 113:
152    .long   SYM(_uhoh)      | 114:
153    .long   SYM(_uhoh)      | 115:
154    .long   SYM(_uhoh)      | 116:
155    .long   SYM(_uhoh)      | 117:
156    .long   SYM(_uhoh)      | 118:
157    .long   SYM(_uhoh)      | 119:
158    .long   SYM(_uhoh)      | 120:
159    .long   SYM(_uhoh)      | 121:
160    .long   SYM(_uhoh)      | 122:
161    .long   SYM(_uhoh)      | 123:
162    .long   SYM(_uhoh)      | 124:
163    .long   SYM(_uhoh)      | 125:
164    .long   SYM(_uhoh)      | 126:
165    .long   SYM(_uhoh)      | 127:
166    .long   SYM(_uhoh)      | 128:
167    .long   SYM(_uhoh)      | 129:
168    .long   SYM(_uhoh)      | 130:
169    .long   SYM(_uhoh)      | 131:
170    .long   SYM(_uhoh)      | 132:
171    .long   SYM(_uhoh)      | 133:
172    .long   SYM(_uhoh)      | 134:
173    .long   SYM(_uhoh)      | 135:
174    .long   SYM(_uhoh)      | 136:
175    .long   SYM(_uhoh)      | 137:
176    .long   SYM(_uhoh)      | 138:
177    .long   SYM(_uhoh)      | 139:
178    .long   SYM(_uhoh)      | 140:
179    .long   SYM(_uhoh)      | 141:
180    .long   SYM(_uhoh)      | 142:
181    .long   SYM(_uhoh)      | 143:
182    .long   SYM(_uhoh)      | 144:
183    .long   SYM(_uhoh)      | 145:
184    .long   SYM(_uhoh)      | 146:
185    .long   SYM(_uhoh)      | 147:
186    .long   SYM(_uhoh)      | 148:
187    .long   SYM(_uhoh)      | 149:
188    .long   SYM(_uhoh)      | 150:
189    .long   SYM(_uhoh)      | 151:
190    .long   SYM(_uhoh)      | 152:
191    .long   SYM(_uhoh)      | 153:
192    .long   SYM(_uhoh)      | 154:
193    .long   SYM(_uhoh)      | 155:
194    .long   SYM(_uhoh)      | 156:
195    .long   SYM(_uhoh)      | 157:
196    .long   SYM(_uhoh)      | 158:
197    .long   SYM(_uhoh)      | 159:
198    .long   SYM(_uhoh)      | 160:
199    .long   SYM(_uhoh)      | 161:
200    .long   SYM(_uhoh)      | 162:
201    .long   SYM(_uhoh)      | 163:
202    .long   SYM(_uhoh)      | 164:
203    .long   SYM(_uhoh)      | 165:
204    .long   SYM(_uhoh)      | 166:
205    .long   SYM(_uhoh)      | 167:
206    .long   SYM(_uhoh)      | 168:
207    .long   SYM(_uhoh)      | 169:
208    .long   SYM(_uhoh)      | 170:
209    .long   SYM(_uhoh)      | 171:
210    .long   SYM(_uhoh)      | 172:
211    .long   SYM(_uhoh)      | 173:
212    .long   SYM(_uhoh)      | 174:
213    .long   SYM(_uhoh)      | 175:
214    .long   SYM(_uhoh)      | 176:
215    .long   SYM(_uhoh)      | 177:
216    .long   SYM(_uhoh)      | 178:
217    .long   SYM(_uhoh)      | 179:
218    .long   SYM(_uhoh)      | 180:
219    .long   SYM(_uhoh)      | 181:
220    .long   SYM(_uhoh)      | 182:
221    .long   SYM(_uhoh)      | 183:
222    .long   SYM(_uhoh)      | 184:
223    .long   SYM(_uhoh)      | 185:
224    .long   SYM(_uhoh)      | 186:
225    .long   SYM(_uhoh)      | 187:
226    .long   SYM(_uhoh)      | 188:
227    .long   SYM(_uhoh)      | 189:
228    .long   SYM(_uhoh)      | 190:
229    .long   SYM(_uhoh)      | 191:
230    .long   SYM(_uhoh)      | 192:
231    .long   SYM(_uhoh)      | 193:
232    .long   SYM(_uhoh)      | 194:
233    .long   SYM(_uhoh)      | 195:
234    .long   SYM(_uhoh)      | 196:
235    .long   SYM(_uhoh)      | 197:
236    .long   SYM(_uhoh)      | 198:
237    .long   SYM(_uhoh)      | 199:
238    .long   SYM(_uhoh)      | 200:
239    .long   SYM(_uhoh)      | 201:
240    .long   SYM(_uhoh)      | 202:
241    .long   SYM(_uhoh)      | 203:
242    .long   SYM(_uhoh)      | 204:
243    .long   SYM(_uhoh)      | 205:
244    .long   SYM(_uhoh)      | 206:
245    .long   SYM(_uhoh)      | 207:
246    .long   SYM(_uhoh)      | 208:
247    .long   SYM(_uhoh)      | 209:
248    .long   SYM(_uhoh)      | 210:
249    .long   SYM(_uhoh)      | 211:
250    .long   SYM(_uhoh)      | 212:
251    .long   SYM(_uhoh)      | 213:
252    .long   SYM(_uhoh)      | 214:
253    .long   SYM(_uhoh)      | 215:
254    .long   SYM(_uhoh)      | 216:
255    .long   SYM(_uhoh)      | 217:
256    .long   SYM(_uhoh)      | 218:
257    .long   SYM(_uhoh)      | 219:
258    .long   SYM(_uhoh)      | 220:
259    .long   SYM(_uhoh)      | 221:
260    .long   SYM(_uhoh)      | 222:
261    .long   SYM(_uhoh)      | 223:
262    .long   SYM(_uhoh)      | 224:
263    .long   SYM(_uhoh)      | 225:
264    .long   SYM(_uhoh)      | 226:
265    .long   SYM(_uhoh)      | 227:
266    .long   SYM(_uhoh)      | 228:
267    .long   SYM(_uhoh)      | 229:
268    .long   SYM(_uhoh)      | 230:
269    .long   SYM(_uhoh)      | 231:
270    .long   SYM(_uhoh)      | 232:
271    .long   SYM(_uhoh)      | 233:
272    .long   SYM(_uhoh)      | 234:
273    .long   SYM(_uhoh)      | 235:
274    .long   SYM(_uhoh)      | 236:
275    .long   SYM(_uhoh)      | 237:
276    .long   SYM(_uhoh)      | 238:
277    .long   SYM(_uhoh)      | 239:
278    .long   SYM(_uhoh)      | 240:
279    .long   SYM(_uhoh)      | 241:
280    .long   SYM(_uhoh)      | 242:
281    .long   SYM(_uhoh)      | 243:
282    .long   SYM(_uhoh)      | 244:
283    .long   SYM(_uhoh)      | 245:
284    .long   SYM(_uhoh)      | 246:
285    .long   SYM(_uhoh)      | 247:
286    .long   SYM(_uhoh)      | 248:
287    .long   SYM(_uhoh)      | 249:
288    .long   SYM(_uhoh)      | 250:
289    .long   SYM(_uhoh)      | 251:
290    .long   SYM(_uhoh)      | 252:
291    .long   SYM(_uhoh)      | 253:
292    .long   SYM(_uhoh)      | 254:
293    .long   SYM(_uhoh)      | 255:
294
295/*
296 * Default trap handler
297 * With an oscilloscope you can see AS* stop
298 */
299.align 4
300    PUBLIC (_uhoh)
301SYM(_uhoh):
302    nop                 | Leave spot for breakpoint
303    stop    #0x2700             | Stop with interrupts disabled
304    bra.w   SYM(_uhoh)          | Stuck forever
305
306.align 4
307    PUBLIC (_spuriousInterrupt)
308SYM(_spuriousInterrupt):
309    addql   #1,SYM(_M68kSpuriousInterruptCount)
310    rte
311
312.align 4
313    PUBLIC (start)
314SYM(start):
315    move.w  #0x2700,sr                 | Disable interrupts
316
317    /*
318     * If we're being started by the debugger, and the debugger has
319     * moved the IPSBAR, we're doomed........
320     */
321    move.l  #__IPSBAR+1,d0             | Enable the MCF5282 internal peripherals
322    move.l  d0,DEFAULT_IPSBAR
323    move.l  #__SRAMBASE+0x201,d0       | Enable the MCF5282 internal SRAM
324    movec   d0,%rambar                 | CPU-space copy of RAMBAR
325    move.l  d0,DEFAULT_IPSBAR+8        | Memory-space copy of RAMBAR
326    move.l  #__SRAMBASE+SRAM_SIZE-4,sp | Overwrite the fake stack pointer
327
328    /*
329     * Copy the vector table to address 0 (VBR must be 0 mod 2^20)
330     * Leave the dBUG vectors (0-63) alone
331     */
332    lea.l  (64*4)+Entry,a0
333    lea.l  (64*4),a1
334    move.l #(256-64)-1,d0
335vectcpy:
336    move.l a0@+,a1@+       | Copy the vector table
337    sub.l  #1,d0
338    bne.s  vectcpy
339     
340    /*
341     * Remainder of the startup code is handled by C code
342     */
343    jmp SYM(Init5282)       | Start C code (which never returns)
344   
345/***************************************************************************
346   Function : CopyDataClearBSSAndStart
347
348   Description : Copy DATA segment, Copy SRAM segment, clear BSS segment,
349   start C program. Assume that DATA and BSS sizes are multiples of 4.
350 ***************************************************************************/
351.align 4
352
353    PUBLIC (CopyDataClearBSSAndStart)
354SYM(CopyDataClearBSSAndStart):
355    lea SYM(_data_dest_start),a0        | Get start of DATA in RAM
356    lea SYM(_data_src_start),a2     | Get start of DATA in ROM
357        sub.l   #SYM(_header_offset),a2          | Change source by the amount of the header offset
358    cmpl    a0,a2                   | Are they the same?
359    beq.s   NODATACOPY              | Yes, no copy necessary
360    lea SYM(_data_dest_end),a1      | Get end of DATA in RAM
361    bra.s   DATACOPYLOOPTEST            | Branch into copy loop
362DATACOPYLOOP:
363    movel   a2@+,a0@+               | Copy word from ROM to RAM
364DATACOPYLOOPTEST:
365    cmpl    a1,a0                   | Done?
366    bcs.s   DATACOPYLOOP                | No, skip
367NODATACOPY:
368       
369/* Now, clear BSS */
370        lea _clear_start,a0     | Get start of BSS
371    lea _clear_end,a1       | Get end of BSS
372    clrl    d0          | Value to set
373    bra.s   ZEROLOOPTEST        | Branch into clear loop
374ZEROLOOP:
375    movel   d0,a0@+         | Clear a word
376ZEROLOOPTEST:
377    cmpl    a1,a0           | Done?
378    bcs.s   ZEROLOOP        | No, skip
379
380
381    /*
382     * Right : Now we're ready to boot RTEMS
383     */
384    clrl    d0          | Pass in null to all boot_card() params
385    movel   d0,a7@-         | environp
386    movel   d0,a7@-         | argv
387    movel   d0,a7@-         | argc
388    jsr SYM(boot_card)      | Call C boot_card function to startup RTEMS
389        movel   a7@+,d0
390        movel   a7@+,d0
391        movel   a7@+,d0
392MULTI_TASK_EXIT:
393        nop
394        nop
395        trap    #14
396        bra     MULTI_TASK_EXIT     
397
398
399END_CODE
400
401        .align 2
402BEGIN_DATA_DCL
403        .align 2
404    PUBLIC (_M68kSpuriousInterruptCount)
405SYM (_M68kSpuriousInterruptCount):
406    .long   0
407END_DATA_DCL
408
409END
410
Note: See TracBrowser for help on using the repository browser.