source: rtems/c/src/lib/libbsp/m68k/gen68360/start/start.S @ 0c291bc

4.104.114.84.95
Last change on this file since 0c291bc was 0162910, checked in by Joel Sherrill <joel.sherrill@…>, on 12/14/98 at 23:15:38

Patch from Ralf Corsepius <corsepiu@…> to rename all
.s files to .S in conformance with GNU conventions. This is a
minor step along the way to supporting automake.

  • Property mode set to 100644
File size: 11.4 KB
Line 
1/*
2 *
3 *  This file contains the entry point for the application.
4 *  The name of this entry point is compiler dependent.
5 *  It jumps to the BSP which is responsible for performing
6 *  all initialization.
7 *
8 *  COPYRIGHT (c) 1989-1998.
9 *  On-Line Applications Research Corporation (OAR).
10 *  Copyright assigned to U.S. Government, 1994.
11 *
12 *  The license and distribution terms for this file may in
13 *  the file LICENSE in this distribution or at
14 *  http://www.OARcorp.com/rtems/license.html.
15 *
16 * Based on the `gen68302' board support package, and covered by the
17 * original distribution terms.
18 *
19 * W. Eric Norum
20 * Saskatchewan Accelerator Laboratory
21 * University of Saskatchewan
22 * Saskatoon, Saskatchewan, CANADA
23 * eric@skatter.usask.ca
24 *
25 *  $Id$
26 */
27
28#include "asm.h"
29
30BEGIN_CODE
31        /*
32         * Step 1: Decide on Reset Stack Pointer and Initial Program Counter
33         */
34Entry:
35        .long   SYM(m360)+1024          |   0: Initial SSP
36        .long   start                   |   1: Initial PC
37        .long   SYM(_uhoh)              |   2: Bus error
38        .long   SYM(_uhoh)              |   3: Address error
39        .long   SYM(_uhoh)              |   4: Illegal instruction
40        .long   SYM(_uhoh)              |   5: Zero division
41        .long   SYM(_uhoh)              |   6: CHK, CHK2 instruction
42        .long   SYM(_uhoh)              |   7: TRAPcc, TRAPV instructions
43        .long   SYM(_uhoh)              |   8: Privilege violation
44        .long   SYM(_uhoh)              |   9: Trace
45        .long   SYM(_uhoh)              |  10: Line 1010 emulator
46        .long   SYM(_uhoh)              |  11: Line 1111 emulator
47        .long   SYM(_uhoh)              |  12: Hardware breakpoint
48        .long   SYM(_uhoh)              |  13: Reserved for coprocessor violation
49        .long   SYM(_uhoh)              |  14: Format error
50        .long   SYM(_uhoh)              |  15: Uninitialized interrupt
51        .long   SYM(_uhoh)              |  16: Unassigned, reserved
52        .long   SYM(_uhoh)              |  17:
53        .long   SYM(_uhoh)              |  18:
54        .long   SYM(_uhoh)              |  19:
55        .long   SYM(_uhoh)              |  20:
56        .long   SYM(_uhoh)              |  21:
57        .long   SYM(_uhoh)              |  22:
58        .long   SYM(_uhoh)              |  23:
59        .long   SYM(_spuriousInterrupt) |  24: Spurious interrupt
60        .long   SYM(_uhoh)              |  25: Level 1 interrupt autovector
61        .long   SYM(_uhoh)              |  26: Level 2 interrupt autovector
62        .long   SYM(_uhoh)              |  27: Level 3 interrupt autovector
63        .long   SYM(_uhoh)              |  28: Level 4 interrupt autovector
64        .long   SYM(_uhoh)              |  29: Level 5 interrupt autovector
65        .long   SYM(_uhoh)              |  30: Level 6 interrupt autovector
66        .long   SYM(_uhoh)              |  31: Level 7 interrupt autovector
67        .long   SYM(_uhoh)              |  32: Trap instruction (0-15)
68        .long   SYM(_uhoh)              |  33:
69        .long   SYM(_uhoh)              |  34:
70        .long   SYM(_uhoh)              |  35:
71        .long   SYM(_uhoh)              |  36:
72        .long   SYM(_uhoh)              |  37:
73        .long   SYM(_uhoh)              |  38:
74        .long   SYM(_uhoh)              |  39:
75        .long   SYM(_uhoh)              |  40:
76        .long   SYM(_uhoh)              |  41:
77        .long   SYM(_uhoh)              |  42:
78        .long   SYM(_uhoh)              |  43:
79        .long   SYM(_uhoh)              |  44:
80        .long   SYM(_uhoh)              |  45:
81        .long   SYM(_uhoh)              |  46:
82        .long   SYM(_uhoh)              |  47:
83        .long   SYM(_uhoh)              |  48: Reserved for coprocessor
84        .long   SYM(_uhoh)              |  49:
85        .long   SYM(_uhoh)              |  50:
86        .long   SYM(_uhoh)              |  51:
87        .long   SYM(_uhoh)              |  52:
88        .long   SYM(_uhoh)              |  53:
89        .long   SYM(_uhoh)              |  54:
90        .long   SYM(_uhoh)              |  55:
91        .long   SYM(_uhoh)              |  56:
92        .long   SYM(_uhoh)              |  57:
93        .long   SYM(_uhoh)              |  58:
94        .long   SYM(_uhoh)              |  59: Unassigned, reserved
95        .long   SYM(_uhoh)              |  60:
96        .long   SYM(_uhoh)              |  61:
97        .long   SYM(_uhoh)              |  62:
98        .long   SYM(_uhoh)              |  63:
99        .long   SYM(_uhoh)              |  64: User defined vectors (192)
100        .long   SYM(_uhoh)              |  65:
101        .long   SYM(_uhoh)              |  66:
102        .long   SYM(_uhoh)              |  67:
103        .long   SYM(_uhoh)              |  68:
104        .long   SYM(_uhoh)              |  69:
105        .long   SYM(_uhoh)              |  70:
106        .long   SYM(_uhoh)              |  71:
107        .long   SYM(_uhoh)              |  72:
108        .long   SYM(_uhoh)              |  73:
109        .long   SYM(_uhoh)              |  74:
110        .long   SYM(_uhoh)              |  75:
111        .long   SYM(_uhoh)              |  76:
112        .long   SYM(_uhoh)              |  77:
113        .long   SYM(_uhoh)              |  78:
114        .long   SYM(_uhoh)              |  79:
115        .long   SYM(_uhoh)              |  80:
116        .long   SYM(_uhoh)              |  81:
117        .long   SYM(_uhoh)              |  82:
118        .long   SYM(_uhoh)              |  83:
119        .long   SYM(_uhoh)              |  84:
120        .long   SYM(_uhoh)              |  85:
121        .long   SYM(_uhoh)              |  86:
122        .long   SYM(_uhoh)              |  87:
123        .long   SYM(_uhoh)              |  88:
124        .long   SYM(_uhoh)              |  89:
125        .long   SYM(_uhoh)              |  90:
126        .long   SYM(_uhoh)              |  91:
127        .long   SYM(_uhoh)              |  92:
128        .long   SYM(_uhoh)              |  93:
129        .long   SYM(_uhoh)              |  94:
130        .long   SYM(_uhoh)              |  95:
131        .long   SYM(_uhoh)              |  96:
132        .long   SYM(_uhoh)              |  97:
133        .long   SYM(_uhoh)              |  98:
134        .long   SYM(_uhoh)              |  99:
135        .long   SYM(_uhoh)              | 100:
136        .long   SYM(_uhoh)              | 101:
137        .long   SYM(_uhoh)              | 102:
138        .long   SYM(_uhoh)              | 103:
139        .long   SYM(_uhoh)              | 104:
140        .long   SYM(_uhoh)              | 105:
141        .long   SYM(_uhoh)              | 106:
142        .long   SYM(_uhoh)              | 107:
143        .long   SYM(_uhoh)              | 108:
144        .long   SYM(_uhoh)              | 109:
145        .long   SYM(_uhoh)              | 110:
146        .long   SYM(_uhoh)              | 111:
147        .long   SYM(_uhoh)              | 112:
148        .long   SYM(_uhoh)              | 113:
149        .long   SYM(_uhoh)              | 114:
150        .long   SYM(_uhoh)              | 115:
151        .long   SYM(_uhoh)              | 116:
152        .long   SYM(_uhoh)              | 117:
153        .long   SYM(_uhoh)              | 118:
154        .long   SYM(_uhoh)              | 119:
155        .long   SYM(_uhoh)              | 120:
156        .long   SYM(_uhoh)              | 121:
157        .long   SYM(_uhoh)              | 122:
158        .long   SYM(_uhoh)              | 123:
159        .long   SYM(_uhoh)              | 124:
160        .long   SYM(_uhoh)              | 125:
161        .long   SYM(_uhoh)              | 126:
162        .long   SYM(_uhoh)              | 127:
163        .long   SYM(_uhoh)              | 128:
164        .long   SYM(_uhoh)              | 129:
165        .long   SYM(_uhoh)              | 130:
166        .long   SYM(_uhoh)              | 131:
167        .long   SYM(_uhoh)              | 132:
168        .long   SYM(_uhoh)              | 133:
169        .long   SYM(_uhoh)              | 134:
170        .long   SYM(_uhoh)              | 135:
171        .long   SYM(_uhoh)              | 136:
172        .long   SYM(_uhoh)              | 137:
173        .long   SYM(_uhoh)              | 138:
174        .long   SYM(_uhoh)              | 139:
175        .long   SYM(_uhoh)              | 140:
176        .long   SYM(_uhoh)              | 141:
177        .long   SYM(_uhoh)              | 142:
178        .long   SYM(_uhoh)              | 143:
179        .long   SYM(_uhoh)              | 144:
180        .long   SYM(_uhoh)              | 145:
181        .long   SYM(_uhoh)              | 146:
182        .long   SYM(_uhoh)              | 147:
183        .long   SYM(_uhoh)              | 148:
184        .long   SYM(_uhoh)              | 149:
185        .long   SYM(_uhoh)              | 150:
186        .long   SYM(_uhoh)              | 151:
187        .long   SYM(_uhoh)              | 152:
188        .long   SYM(_uhoh)              | 153:
189        .long   SYM(_uhoh)              | 154:
190        .long   SYM(_uhoh)              | 155:
191        .long   SYM(_uhoh)              | 156:
192        .long   SYM(_uhoh)              | 157:
193        .long   SYM(_uhoh)              | 158:
194        .long   SYM(_uhoh)              | 159:
195        .long   SYM(_uhoh)              | 160:
196        .long   SYM(_uhoh)              | 161:
197        .long   SYM(_uhoh)              | 162:
198        .long   SYM(_uhoh)              | 163:
199        .long   SYM(_uhoh)              | 164:
200        .long   SYM(_uhoh)              | 165:
201        .long   SYM(_uhoh)              | 166:
202        .long   SYM(_uhoh)              | 167:
203        .long   SYM(_uhoh)              | 168:
204        .long   SYM(_uhoh)              | 169:
205        .long   SYM(_uhoh)              | 170:
206        .long   SYM(_uhoh)              | 171:
207        .long   SYM(_uhoh)              | 172:
208        .long   SYM(_uhoh)              | 173:
209        .long   SYM(_uhoh)              | 174:
210        .long   SYM(_uhoh)              | 175:
211        .long   SYM(_uhoh)              | 176:
212        .long   SYM(_uhoh)              | 177:
213        .long   SYM(_uhoh)              | 178:
214        .long   SYM(_uhoh)              | 179:
215        .long   SYM(_uhoh)              | 180:
216        .long   SYM(_uhoh)              | 181:
217        .long   SYM(_uhoh)              | 182:
218        .long   SYM(_uhoh)              | 183:
219        .long   SYM(_uhoh)              | 184:
220        .long   SYM(_uhoh)              | 185:
221        .long   SYM(_uhoh)              | 186:
222        .long   SYM(_uhoh)              | 187:
223        .long   SYM(_uhoh)              | 188:
224        .long   SYM(_uhoh)              | 189:
225        .long   SYM(_uhoh)              | 190:
226        .long   SYM(_uhoh)              | 191:
227        .long   SYM(_uhoh)              | 192:
228        .long   SYM(_uhoh)              | 193:
229        .long   SYM(_uhoh)              | 194:
230        .long   SYM(_uhoh)              | 195:
231        .long   SYM(_uhoh)              | 196:
232        .long   SYM(_uhoh)              | 197:
233        .long   SYM(_uhoh)              | 198:
234        .long   SYM(_uhoh)              | 199:
235        .long   SYM(_uhoh)              | 200:
236        .long   SYM(_uhoh)              | 201:
237        .long   SYM(_uhoh)              | 202:
238        .long   SYM(_uhoh)              | 203:
239        .long   SYM(_uhoh)              | 204:
240        .long   SYM(_uhoh)              | 205:
241        .long   SYM(_uhoh)              | 206:
242        .long   SYM(_uhoh)              | 207:
243        .long   SYM(_uhoh)              | 208:
244        .long   SYM(_uhoh)              | 209:
245        .long   SYM(_uhoh)              | 210:
246        .long   SYM(_uhoh)              | 211:
247        .long   SYM(_uhoh)              | 212:
248        .long   SYM(_uhoh)              | 213:
249        .long   SYM(_uhoh)              | 214:
250        .long   SYM(_uhoh)              | 215:
251        .long   SYM(_uhoh)              | 216:
252        .long   SYM(_uhoh)              | 217:
253        .long   SYM(_uhoh)              | 218:
254        .long   SYM(_uhoh)              | 219:
255        .long   SYM(_uhoh)              | 220:
256        .long   SYM(_uhoh)              | 221:
257        .long   SYM(_uhoh)              | 222:
258        .long   SYM(_uhoh)              | 223:
259        .long   SYM(_uhoh)              | 224:
260        .long   SYM(_uhoh)              | 225:
261        .long   SYM(_uhoh)              | 226:
262        .long   SYM(_uhoh)              | 227:
263        .long   SYM(_uhoh)              | 228:
264        .long   SYM(_uhoh)              | 229:
265        .long   SYM(_uhoh)              | 230:
266        .long   SYM(_uhoh)              | 231:
267        .long   SYM(_uhoh)              | 232:
268        .long   SYM(_uhoh)              | 233:
269        .long   SYM(_uhoh)              | 234:
270        .long   SYM(_uhoh)              | 235:
271        .long   SYM(_uhoh)              | 236:
272        .long   SYM(_uhoh)              | 237:
273        .long   SYM(_uhoh)              | 238:
274        .long   SYM(_uhoh)              | 239:
275        .long   SYM(_uhoh)              | 240:
276        .long   SYM(_uhoh)              | 241:
277        .long   SYM(_uhoh)              | 242:
278        .long   SYM(_uhoh)              | 243:
279        .long   SYM(_uhoh)              | 244:
280        .long   SYM(_uhoh)              | 245:
281        .long   SYM(_uhoh)              | 246:
282        .long   SYM(_uhoh)              | 247:
283        .long   SYM(_uhoh)              | 248:
284        .long   SYM(_uhoh)              | 249:
285        .long   SYM(_uhoh)              | 250:
286        .long   SYM(_uhoh)              | 251:
287        .long   SYM(_uhoh)              | 252:
288        .long   SYM(_uhoh)              | 253:
289        .long   SYM(_uhoh)              | 254:
290        .long   SYM(_uhoh)              | 255:
291
292/*
293 * Default trap handler
294 * With an oscilloscope you can see AS* stop
295 */
296        PUBLIC (_uhoh)
297SYM(_uhoh):     nop                             | Leave spot for breakpoint
298        stop    #0x2700                 | Stop with interrupts disabled
299        bra.s   SYM(_uhoh)                      | Stuck forever
300
301/*
302 * Log, but otherwise ignore, spurious interrupts
303 */
304        PUBLIC (_spuriousInterrupt)
305SYM(_spuriousInterrupt):
306        addql   #1,SYM(_M68kSpuriousInterruptCount)
307        rte
308
309/*
310 * Place the low-order 3 octets of the board's ethernet address at
311 * a `well-known' fixed location relative to the startup location.
312 */
313        .align 2
314        .word   0                       | Padding
315ethernet_address_buffer:
316        .word   0x08F3                  | Default address
317        .word   0xDEAD
318        .word   0xCAFE
319
320/*
321 * Initial PC
322 */
323.globl start
324start:
325        /*
326         * Step 2: Stay in Supervisor Mode
327         */
328#if ( M68K_HAS_SEPARATE_STACKS == 1 )
329        oriw    #0x3000,sr              | Switch to Master Stack Pointer
330        lea     SYM(m360)+1024-64,a7    | Put stack in dual-port ram
331                                        | a little below the interrupt stack
332#endif
333
334        /*
335         * Step 3: Write the VBR
336         */
337        lea     Entry,a0                | Get base of vector table
338        movec   a0,vbr                  | Set up the VBR
339
340        /*
341         * Step 4: Write the MBAR
342         */
343        movec   dfc,d1                  | Save destination register
344        moveq   #7,d0                   | CPU-space funcction code
345        movec   d0,dfc                  | Set destination function code register
346        movel   #SYM(m360)+0x101,d0     | MBAR value (mask CPU space accesses)
347        movesl  d0,0x3FF00              | Set MBAR
348        movec   d1,dfc                  | Restore destination register
349
350        /*
351         * Step 5: Verify a dual-port RAM location
352         */
353        lea     SYM(m360),a0            | Point a0 to first DPRAM location
354        moveb   #0x33,d0                | Set the test value
355        moveb   d0,a0@                  | Set the memory location
356        cmpb    a0@,d0                  | Does it read back?
357        bne     SYM(_uhoh)                      | If not, bad news!
358        notb    d0                      | Flip bits
359        moveb   d0,a0@                  | Set the memory location
360        cmpb    a0@,d0                  | Does it read back?
361        bne     SYM(_uhoh)                      | If not, bad news!
362
363        /*
364         * Remaining steps are handled by C code
365         */
366        jmp     SYM(_Init68360)         | Start C code (which never returns)
367
368/*
369 * Copy DATA segment, clear BSS segment, set up real stack,
370 * initialize heap, start C program.
371 * Assume that DATA and BSS sizes are multiples of 4.
372 */
373        PUBLIC (_CopyDataClearBSSAndStart)
374SYM(_CopyDataClearBSSAndStart):
375        lea     copy_start,a0           | Get start of DATA in RAM
376        lea     SYM(etext),a2           | Get start of DATA in ROM
377        cmpl    a0,a2                   | Are they the same?
378        beq.s   NOCOPY                  | Yes, no copy necessary
379        lea     copy_end,a1             | Get end of DATA in RAM
380        bra.s   COPYLOOPTEST            | Branch into copy loop
381COPYLOOP:
382        movel   a2@+,a0@+               | Copy word from ROM to RAM
383COPYLOOPTEST:
384        cmpl    a1,a0                   | Done?
385        bcs.s   COPYLOOP                | No, skip
386NOCOPY:
387
388        lea     clear_start,a0          | Get start of BSS
389        lea     clear_end,a1            | Get end of BSS
390        clrl    d0                      | Value to set
391        bra.s   ZEROLOOPTEST            | Branch into clear loop
392ZEROLOOP:
393        movel   d0,a0@+                 | Clear a word
394ZEROLOOPTEST:
395        cmpl    a1,a0                   | Done?
396        bcs.s   ZEROLOOP                | No, skip
397
398        movel   #stack_init,a7          | set master stack pointer
399        movel   d0,a7@-                 | environp
400        movel   d0,a7@-                 | argv
401        movel   d0,a7@-                 | argc
402        jsr     SYM(boot_card)          | Call C main
403
404        PUBLIC (_mainDone)
405SYM(_mainDone):
406        nop                             | Leave spot for breakpoint
407        movew   #1,a7                   | Force a double bus error
408        movel   d0,a7@-                 | This should cause a RESET
409        stop    #0x2700                 | Stop with interrupts disabled
410        bra.s   SYM(_mainDone)          | Stuck forever
411
412        .align 2
413        PUBLIC (_HeapSize)
414SYM (_HeapSize):
415        .long  HeapSize
416        PUBLIC (_StackSize)
417SYM (_StackSize):
418        .long  StackSize
419END_CODE
420
421BEGIN_DATA_DCL
422        .align 2
423        PUBLIC (environ)
424SYM (environ):
425        .long   0
426        PUBLIC (_M68kSpuriousInterruptCount)
427SYM (_M68kSpuriousInterruptCount):
428        .long   0
429END_DATA_DCL
430
431END
432
Note: See TracBrowser for help on using the repository browser.