source: rtems/c/src/lib/libbsp/m68k/gen68360/start/start360.s @ 60b791ad

4.104.114.84.95
Last change on this file since 60b791ad was 60b791ad, checked in by Joel Sherrill <joel.sherrill@…>, on 02/17/98 at 23:46:28

updated copyright to 1998

  • 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 beginning of ROM.
312 */
313        .align 2
314        .long   ETHERNET_ADDRESS        | Low-order 3 octets of ethernet address
315
316/*
317 *  For some reason, the symbol start must not be global.
318 *
319 *       .global start
320 */
321
322/*
323 * Initial PC
324 */
325.globl start
326start:
327        /*
328         * Step 2: Stay in Supervisor Mode
329         */
330#if ( M68K_HAS_SEPARATE_STACKS == 1 )
331        oriw    #0x3000,sr              | Switch to Master Stack Pointer
332        lea     SYM(m360)+1024-64,a7    | Load stack pointer with space
333                                        |   for the Interrupt Stack
334#endif
335
336        /*
337         * Step 3: Write the VBR
338         */
339        lea     Entry,a0                | Get base of vector table
340        movec   a0,vbr                  | Set up the VBR
341
342        /*
343         * Step 4: Write the MBAR
344         */
345        movec   dfc,d1                  | Save destination register
346        moveq   #7,d0                   | CPU-space funcction code
347        movec   d0,dfc                  | Set destination function code register
348        movel   #SYM(m360)+0x101,d0     | MBAR value (mask CPU space accesses)
349        movesl  d0,0x3FF00              | Set MBAR
350        movec   d1,dfc                  | Restore destination register
351
352        /*
353         * Step 5: Verify a dual-port RAM location
354         */
355        lea     SYM(m360),a0            | Point a0 to first DPRAM location
356        moveb   #0x33,d0                | Set the test value
357        moveb   d0,a0@                  | Set the memory location
358        cmpb    a0@,d0                  | Does it read back?
359        bne     SYM(_uhoh)                      | If not, bad news!
360        notb    d0                      | Flip bits
361        moveb   d0,a0@                  | Set the memory location
362        cmpb    a0@,d0                  | Does it read back?
363        bne     SYM(_uhoh)                      | If not, bad news!
364
365        /*
366         * Remaining steps are handled by C code
367         */
368        jmp     SYM(_Init68360)         | Start C code (which never returns)
369
370/*
371 * Copy DATA segment, clear BSS segment, set up real stack,
372 * initialize heap, start C program.
373 * Assume that DATA and BSS sizes are multiples of 4.
374 */
375        PUBLIC (_CopyDataClearBSSAndStart)
376SYM(_CopyDataClearBSSAndStart):
377        lea     copy_start,a0           | Get start of DATA in RAM
378        lea     SYM(etext),a2           | Get start of DATA in ROM
379        cmpl    a0,a2                   | Are they the same?
380        beq.s   NOCOPY                  | Yes, no copy necessary
381        lea     copy_end,a1             | Get end of DATA in RAM
382        bra.s   COPYLOOPTEST            | Branch into copy loop
383COPYLOOP:
384        movel   a2@+,a0@+               | Copy word from ROM to RAM
385COPYLOOPTEST:
386        cmpl    a1,a0                   | Done?
387        bcs.s   COPYLOOP                | No, skip
388NOCOPY:
389
390        lea     clear_start,a0          | Get start of BSS
391        lea     clear_end,a1            | Get end of BSS
392        clrl    d0                      | Value to set
393        bra.s   ZEROLOOPTEST            | Branch into clear loop
394ZEROLOOP:
395        movel   d0,a0@+                 | Clear a word
396ZEROLOOPTEST:
397        cmpl    a1,a0                   | Done?
398        bcs.s   ZEROLOOP                | No, skip
399
400        movel   #stack_init,a7          | set master stack pointer
401        movel   d0,a7@-                 | environp
402        movel   d0,a7@-                 | argv
403        movel   d0,a7@-                 | argc
404        jsr     SYM(main)               | Call C main
405
406        PUBLIC (_mainDone)
407SYM(_mainDone):
408        nop                             | Leave spot for breakpoint
409        movew   #1,a7                   | Force a double bus error
410        movel   d0,a7@-                 | This should cause a RESET
411        stop    #0x2700                 | Stop with interrupts disabled
412        bra.s   SYM(_mainDone)          | Stuck forever
413
414        .align 2
415        PUBLIC (_HeapSize)
416SYM (_HeapSize):
417        .long  HeapSize
418        PUBLIC (_StackSize)
419SYM (_StackSize):
420        .long  StackSize
421END_CODE
422
423BEGIN_DATA_DCL
424        .align 2
425        PUBLIC (environ)
426SYM (environ):
427        .long   0
428        PUBLIC (_M68kSpuriousInterruptCount)
429SYM (_M68kSpuriousInterruptCount):
430        .long   0
431END_DATA_DCL
432
433END
434
Note: See TracBrowser for help on using the repository browser.