1 | /* |
---|
2 | * This file contains the entry point for the application. |
---|
3 | * The name of this entry point is compiler dependent. |
---|
4 | * It jumps to the BSP which is responsible for performing |
---|
5 | * all initialization. |
---|
6 | * |
---|
7 | * COPYRIGHT (c) 1989-1998. |
---|
8 | * On-Line Applications Research Corporation (OAR). |
---|
9 | * Copyright assigned to U.S. Government, 1994. |
---|
10 | * |
---|
11 | * The license and distribution terms for this file may in |
---|
12 | * the file LICENSE in this distribution or at |
---|
13 | * http://www.OARcorp.com/rtems/license.html. |
---|
14 | * |
---|
15 | * Based on the `gen68360' board support package, and covered by the |
---|
16 | * original distribution terms. |
---|
17 | * |
---|
18 | * Geoffroy Montel |
---|
19 | * France Telecom - CNET/DSM/TAM/CAT |
---|
20 | * 4, rue du Clos Courtel |
---|
21 | * 35512 CESSON-SEVIGNE |
---|
22 | * FRANCE |
---|
23 | * |
---|
24 | * e-mail: g_montel@yahoo.com |
---|
25 | * |
---|
26 | * $Id$ |
---|
27 | */ |
---|
28 | |
---|
29 | #include "asm.h" |
---|
30 | #include <m68340.inc> |
---|
31 | |
---|
32 | BEGIN_CODE |
---|
33 | /* |
---|
34 | * Step 1: Decide on Reset Stack Pointer and Initial Program Counter |
---|
35 | */ |
---|
36 | Entry: |
---|
37 | .long SYM(m340)+1024 | 0: Initial SSP |
---|
38 | .long start | 1: Initial PC |
---|
39 | .long SYM(_uhoh) | 2: Bus error |
---|
40 | .long SYM(_uhoh) | 3: Address error |
---|
41 | .long SYM(_uhoh) | 4: Illegal instruction |
---|
42 | .long SYM(_uhoh) | 5: Zero division |
---|
43 | .long SYM(_uhoh) | 6: CHK, CHK2 instruction |
---|
44 | .long SYM(_uhoh) | 7: TRAPcc, TRAPV instructions |
---|
45 | .long SYM(_uhoh) | 8: Privilege violation |
---|
46 | .long SYM(_uhoh) | 9: Trace |
---|
47 | .long SYM(_uhoh) | 10: Line 1010 emulator |
---|
48 | .long SYM(_uhoh) | 11: Line 1111 emulator |
---|
49 | .long SYM(_uhoh) | 12: Hardware breakpoint |
---|
50 | .long SYM(_uhoh) | 13: Reserved for coprocessor violation |
---|
51 | .long SYM(_uhoh) | 14: Format error |
---|
52 | .long SYM(_uhoh) | 15: Uninitialized interrupt |
---|
53 | .long SYM(_uhoh) | 16: Unassigned, reserved |
---|
54 | .long SYM(_uhoh) | 17: |
---|
55 | .long SYM(_uhoh) | 18: |
---|
56 | .long SYM(_uhoh) | 19: |
---|
57 | .long SYM(_uhoh) | 20: |
---|
58 | .long SYM(_uhoh) | 21: |
---|
59 | .long SYM(_uhoh) | 22: |
---|
60 | .long SYM(_uhoh) | 23: |
---|
61 | .long SYM(_spuriousInterrupt) | 24: Spurious interrupt |
---|
62 | .long SYM(_uhoh) | 25: Level 1 interrupt autovector |
---|
63 | .long SYM(_uhoh) | 26: Level 2 interrupt autovector |
---|
64 | .long SYM(_uhoh) | 27: Level 3 interrupt autovector |
---|
65 | .long SYM(_uhoh) | 28: Level 4 interrupt autovector |
---|
66 | .long SYM(_uhoh) | 29: Level 5 interrupt autovector |
---|
67 | .long SYM(_uhoh) | 30: Level 6 interrupt autovector |
---|
68 | .long SYM(_uhoh) | 31: Level 7 interrupt autovector |
---|
69 | .long SYM(_uhoh) | 32: Trap instruction (0-15) |
---|
70 | .long SYM(_uhoh) | 33: |
---|
71 | .long SYM(_uhoh) | 34: |
---|
72 | .long SYM(_uhoh) | 35: |
---|
73 | .long SYM(_uhoh) | 36: |
---|
74 | .long SYM(_uhoh) | 37: |
---|
75 | .long SYM(_uhoh) | 38: |
---|
76 | .long SYM(_uhoh) | 39: |
---|
77 | .long SYM(_uhoh) | 40: |
---|
78 | .long SYM(_uhoh) | 41: |
---|
79 | .long SYM(_uhoh) | 42: |
---|
80 | .long SYM(_uhoh) | 43: |
---|
81 | .long SYM(_uhoh) | 44: |
---|
82 | .long SYM(_uhoh) | 45: |
---|
83 | .long SYM(_uhoh) | 46: |
---|
84 | .long SYM(_uhoh) | 47: |
---|
85 | .long SYM(_uhoh) | 48: Reserved for coprocessor |
---|
86 | .long SYM(_uhoh) | 49: |
---|
87 | .long SYM(_uhoh) | 50: |
---|
88 | .long SYM(_uhoh) | 51: |
---|
89 | .long SYM(_uhoh) | 52: |
---|
90 | .long SYM(_uhoh) | 53: |
---|
91 | .long SYM(_uhoh) | 54: |
---|
92 | .long SYM(_uhoh) | 55: |
---|
93 | .long SYM(_uhoh) | 56: |
---|
94 | .long SYM(_uhoh) | 57: |
---|
95 | .long SYM(_uhoh) | 58: |
---|
96 | .long SYM(_uhoh) | 59: Unassigned, reserved |
---|
97 | .long SYM(_uhoh) | 60: |
---|
98 | .long SYM(_uhoh) | 61: |
---|
99 | .long SYM(_uhoh) | 62: |
---|
100 | .long SYM(_uhoh) | 63: |
---|
101 | .long SYM(_uhoh) | 64: User defined vectors (192) |
---|
102 | .long SYM(_uhoh) | 65: |
---|
103 | .long SYM(_uhoh) | 66: |
---|
104 | .long SYM(_uhoh) | 67: |
---|
105 | .long SYM(_uhoh) | 68: |
---|
106 | .long SYM(_uhoh) | 69: |
---|
107 | .long SYM(_uhoh) | 70: |
---|
108 | .long SYM(_uhoh) | 71: |
---|
109 | .long SYM(_uhoh) | 72: |
---|
110 | .long SYM(_uhoh) | 73: |
---|
111 | .long SYM(_uhoh) | 74: |
---|
112 | .long SYM(_uhoh) | 75: |
---|
113 | .long SYM(_uhoh) | 76: |
---|
114 | .long SYM(_uhoh) | 77: |
---|
115 | .long SYM(_uhoh) | 78: |
---|
116 | .long SYM(_uhoh) | 79: |
---|
117 | .long SYM(_uhoh) | 80: |
---|
118 | .long SYM(_uhoh) | 81: |
---|
119 | .long SYM(_uhoh) | 82: |
---|
120 | .long SYM(_uhoh) | 83: |
---|
121 | .long SYM(_uhoh) | 84: |
---|
122 | .long SYM(_uhoh) | 85: |
---|
123 | .long SYM(_uhoh) | 86: |
---|
124 | .long SYM(_uhoh) | 87: |
---|
125 | .long SYM(_uhoh) | 88: |
---|
126 | .long SYM(_uhoh) | 89: |
---|
127 | .long SYM(_uhoh) | 90: |
---|
128 | .long SYM(_uhoh) | 91: |
---|
129 | .long SYM(_uhoh) | 92: |
---|
130 | .long SYM(_uhoh) | 93: |
---|
131 | .long SYM(_uhoh) | 94: |
---|
132 | .long SYM(_uhoh) | 95: |
---|
133 | .long SYM(_uhoh) | 96: |
---|
134 | .long SYM(_uhoh) | 97: |
---|
135 | .long SYM(_uhoh) | 98: |
---|
136 | .long SYM(_uhoh) | 99: |
---|
137 | .long SYM(_uhoh) | 100: |
---|
138 | .long SYM(_uhoh) | 101: |
---|
139 | .long SYM(_uhoh) | 102: |
---|
140 | .long SYM(_uhoh) | 103: |
---|
141 | .long SYM(_uhoh) | 104: |
---|
142 | .long SYM(_uhoh) | 105: |
---|
143 | .long SYM(_uhoh) | 106: |
---|
144 | .long SYM(_uhoh) | 107: |
---|
145 | .long SYM(_uhoh) | 108: |
---|
146 | .long SYM(_uhoh) | 109: |
---|
147 | .long SYM(_uhoh) | 110: |
---|
148 | .long SYM(_uhoh) | 111: |
---|
149 | .long SYM(_uhoh) | 112: |
---|
150 | .long SYM(_uhoh) | 113: |
---|
151 | .long SYM(_uhoh) | 114: |
---|
152 | .long SYM(_uhoh) | 115: |
---|
153 | .long SYM(_uhoh) | 116: |
---|
154 | .long SYM(_uhoh) | 117: |
---|
155 | .long SYM(_uhoh) | 118: |
---|
156 | .long SYM(_uhoh) | 119: |
---|
157 | .long SYM(_uhoh) | 120: |
---|
158 | .long SYM(_uhoh) | 121: |
---|
159 | .long SYM(_uhoh) | 122: |
---|
160 | .long SYM(_uhoh) | 123: |
---|
161 | .long SYM(_uhoh) | 124: |
---|
162 | .long SYM(_uhoh) | 125: |
---|
163 | .long SYM(_uhoh) | 126: |
---|
164 | .long SYM(_uhoh) | 127: |
---|
165 | .long SYM(_uhoh) | 128: |
---|
166 | .long SYM(_uhoh) | 129: |
---|
167 | .long SYM(_uhoh) | 130: |
---|
168 | .long SYM(_uhoh) | 131: |
---|
169 | .long SYM(_uhoh) | 132: |
---|
170 | .long SYM(_uhoh) | 133: |
---|
171 | .long SYM(_uhoh) | 134: |
---|
172 | .long SYM(_uhoh) | 135: |
---|
173 | .long SYM(_uhoh) | 136: |
---|
174 | .long SYM(_uhoh) | 137: |
---|
175 | .long SYM(_uhoh) | 138: |
---|
176 | .long SYM(_uhoh) | 139: |
---|
177 | .long SYM(_uhoh) | 140: |
---|
178 | .long SYM(_uhoh) | 141: |
---|
179 | .long SYM(_uhoh) | 142: |
---|
180 | .long SYM(_uhoh) | 143: |
---|
181 | .long SYM(_uhoh) | 144: |
---|
182 | .long SYM(_uhoh) | 145: |
---|
183 | .long SYM(_uhoh) | 146: |
---|
184 | .long SYM(_uhoh) | 147: |
---|
185 | .long SYM(_uhoh) | 148: |
---|
186 | .long SYM(_uhoh) | 149: |
---|
187 | .long SYM(_uhoh) | 150: |
---|
188 | .long SYM(_uhoh) | 151: |
---|
189 | .long SYM(_uhoh) | 152: |
---|
190 | .long SYM(_uhoh) | 153: |
---|
191 | .long SYM(_uhoh) | 154: |
---|
192 | .long SYM(_uhoh) | 155: |
---|
193 | .long SYM(_uhoh) | 156: |
---|
194 | .long SYM(_uhoh) | 157: |
---|
195 | .long SYM(_uhoh) | 158: |
---|
196 | .long SYM(_uhoh) | 159: |
---|
197 | .long SYM(_uhoh) | 160: |
---|
198 | .long SYM(_uhoh) | 161: |
---|
199 | .long SYM(_uhoh) | 162: |
---|
200 | .long SYM(_uhoh) | 163: |
---|
201 | .long SYM(_uhoh) | 164: |
---|
202 | .long SYM(_uhoh) | 165: |
---|
203 | .long SYM(_uhoh) | 166: |
---|
204 | .long SYM(_uhoh) | 167: |
---|
205 | .long SYM(_uhoh) | 168: |
---|
206 | .long SYM(_uhoh) | 169: |
---|
207 | .long SYM(_uhoh) | 170: |
---|
208 | .long SYM(_uhoh) | 171: |
---|
209 | .long SYM(_uhoh) | 172: |
---|
210 | .long SYM(_uhoh) | 173: |
---|
211 | .long SYM(_uhoh) | 174: |
---|
212 | .long SYM(_uhoh) | 175: |
---|
213 | .long SYM(_uhoh) | 176: |
---|
214 | .long SYM(_uhoh) | 177: |
---|
215 | .long SYM(_uhoh) | 178: |
---|
216 | .long SYM(_uhoh) | 179: |
---|
217 | .long SYM(_uhoh) | 180: |
---|
218 | .long SYM(_uhoh) | 181: |
---|
219 | .long SYM(_uhoh) | 182: |
---|
220 | .long SYM(_uhoh) | 183: |
---|
221 | .long SYM(_uhoh) | 184: |
---|
222 | .long SYM(_uhoh) | 185: |
---|
223 | .long SYM(_uhoh) | 186: |
---|
224 | .long SYM(_uhoh) | 187: |
---|
225 | .long SYM(_uhoh) | 188: |
---|
226 | .long SYM(_uhoh) | 189: |
---|
227 | .long SYM(_uhoh) | 190: |
---|
228 | .long SYM(_uhoh) | 191: |
---|
229 | .long SYM(_uhoh) | 192: |
---|
230 | .long SYM(_uhoh) | 193: |
---|
231 | .long SYM(_uhoh) | 194: |
---|
232 | .long SYM(_uhoh) | 195: |
---|
233 | .long SYM(_uhoh) | 196: |
---|
234 | .long SYM(_uhoh) | 197: |
---|
235 | .long SYM(_uhoh) | 198: |
---|
236 | .long SYM(_uhoh) | 199: |
---|
237 | .long SYM(_uhoh) | 200: |
---|
238 | .long SYM(_uhoh) | 201: |
---|
239 | .long SYM(_uhoh) | 202: |
---|
240 | .long SYM(_uhoh) | 203: |
---|
241 | .long SYM(_uhoh) | 204: |
---|
242 | .long SYM(_uhoh) | 205: |
---|
243 | .long SYM(_uhoh) | 206: |
---|
244 | .long SYM(_uhoh) | 207: |
---|
245 | .long SYM(_uhoh) | 208: |
---|
246 | .long SYM(_uhoh) | 209: |
---|
247 | .long SYM(_uhoh) | 210: |
---|
248 | .long SYM(_uhoh) | 211: |
---|
249 | .long SYM(_uhoh) | 212: |
---|
250 | .long SYM(_uhoh) | 213: |
---|
251 | .long SYM(_uhoh) | 214: |
---|
252 | .long SYM(_uhoh) | 215: |
---|
253 | .long SYM(_uhoh) | 216: |
---|
254 | .long SYM(_uhoh) | 217: |
---|
255 | .long SYM(_uhoh) | 218: |
---|
256 | .long SYM(_uhoh) | 219: |
---|
257 | .long SYM(_uhoh) | 220: |
---|
258 | .long SYM(_uhoh) | 221: |
---|
259 | .long SYM(_uhoh) | 222: |
---|
260 | .long SYM(_uhoh) | 223: |
---|
261 | .long SYM(_uhoh) | 224: |
---|
262 | .long SYM(_uhoh) | 225: |
---|
263 | .long SYM(_uhoh) | 226: |
---|
264 | .long SYM(_uhoh) | 227: |
---|
265 | .long SYM(_uhoh) | 228: |
---|
266 | .long SYM(_uhoh) | 229: |
---|
267 | .long SYM(_uhoh) | 230: |
---|
268 | .long SYM(_uhoh) | 231: |
---|
269 | .long SYM(_uhoh) | 232: |
---|
270 | .long SYM(_uhoh) | 233: |
---|
271 | .long SYM(_uhoh) | 234: |
---|
272 | .long SYM(_uhoh) | 235: |
---|
273 | .long SYM(_uhoh) | 236: |
---|
274 | .long SYM(_uhoh) | 237: |
---|
275 | .long SYM(_uhoh) | 238: |
---|
276 | .long SYM(_uhoh) | 239: |
---|
277 | .long SYM(_uhoh) | 240: |
---|
278 | .long SYM(_uhoh) | 241: |
---|
279 | .long SYM(_uhoh) | 242: |
---|
280 | .long SYM(_uhoh) | 243: |
---|
281 | .long SYM(_uhoh) | 244: |
---|
282 | .long SYM(_uhoh) | 245: |
---|
283 | .long SYM(_uhoh) | 246: |
---|
284 | .long SYM(_uhoh) | 247: |
---|
285 | .long SYM(_uhoh) | 248: |
---|
286 | .long SYM(_uhoh) | 249: |
---|
287 | .long SYM(_uhoh) | 250: |
---|
288 | .long SYM(_uhoh) | 251: |
---|
289 | .long SYM(_uhoh) | 252: |
---|
290 | .long SYM(_uhoh) | 253: |
---|
291 | .long SYM(_uhoh) | 254: |
---|
292 | .long SYM(_uhoh) | 255: |
---|
293 | |
---|
294 | /* |
---|
295 | * Default trap handler |
---|
296 | * With an oscilloscope you can see AS* stop |
---|
297 | */ |
---|
298 | PUBLIC (_uhoh) |
---|
299 | SYM(_uhoh): nop | Leave spot for breakpoint |
---|
300 | stop #0x2700 | Stop with interrupts disabled |
---|
301 | bra.s SYM(_uhoh) | Stuck forever |
---|
302 | |
---|
303 | /* |
---|
304 | * Log, but otherwise ignore, spurious interrupts |
---|
305 | */ |
---|
306 | PUBLIC (_spuriousInterrupt) |
---|
307 | SYM(_spuriousInterrupt): |
---|
308 | addql #1,SYM(_M68kSpuriousInterruptCount) |
---|
309 | rte |
---|
310 | |
---|
311 | /* |
---|
312 | * Place the low-order 3 octets of the board's ethernet address at |
---|
313 | * a `well-known' fixed location relative to the startup location. |
---|
314 | */ |
---|
315 | .align 2 |
---|
316 | .word 0 | Padding |
---|
317 | ethernet_address_buffer: |
---|
318 | .word 0x08F3 | Default address |
---|
319 | .word 0xDEAD |
---|
320 | .word 0xCAFE |
---|
321 | |
---|
322 | /* -- equates -- */ |
---|
323 | .equ _PROM_Start, 0x01000000 /* CS0 */ |
---|
324 | .equ _BCCram_Start, 0x00000000 /* CS1 */ |
---|
325 | .equ _FLEX_Start, 0x08000000 /* CS2 */ |
---|
326 | .equ _I2C_Start, 0x02000000 /* CS3 */ |
---|
327 | .equ _EXTram_Start, 0x10000000 /* CS4 */ |
---|
328 | .equ _EXTram_Size, 0x000400000 /* 4 Mbytes */ |
---|
329 | .equ _SPEED, 0xD780 /* 25 Mhz CPU349 */ |
---|
330 | /* .equ _SPEED, 0xD700 25 Mhz */ |
---|
331 | /* .equ _SPEED, 0xCE00 16 Mhz */ |
---|
332 | |
---|
333 | BEGIN_DATA |
---|
334 | |
---|
335 | _crt0_init_stack: |
---|
336 | ds.l 0x1000 |
---|
337 | _crt0_init_stktop: |
---|
338 | |
---|
339 | |
---|
340 | BEGIN_CODE |
---|
341 | dc.l _crt0_init_stktop /* reset SP */ |
---|
342 | dc.l _crt0_cold_start /* reset PC */ |
---|
343 | dc.l _crt0_warm_start |
---|
344 | |
---|
345 | .ascii "BOOT XHM68K/Spectra for ASTECC PLATFORM" |
---|
346 | dc.w 0 |
---|
347 | |
---|
348 | .align 2 |
---|
349 | |
---|
350 | _table_cs: |
---|
351 | /* carte Astecc - 68340 */ |
---|
352 | dc.l 0x003FFFF0 /* Mask CS0 (4Mbytes PROM, 32bits, 0WS) */ |
---|
353 | /* dc.l 0x003FFFFD Mask CS0 (4Mbytes PROM, 16bits, 3WS) */ |
---|
354 | dc.l ((_PROM_Start&0xFFFFFF00)+0x00000003) /* Base CS0 */ |
---|
355 | /* dc.l 0x0000FFF1 MASK CS1 (RAMBCC340, 0WS, FTE) */ |
---|
356 | dc.l 0x0000FFFD /* MASK CS1 (RAMBCC340, 0WS, FTE) */ |
---|
357 | /* dc.l ((_BCCram_Start&0xFFFFFF00)+0x00000007) Base CS1 */ |
---|
358 | dc.l ((_BCCram_Start&0xFFFFFF00)+0x00000003) /* Base CS1 */ |
---|
359 | dc.l 0x000000FF /* MASK CS2 (FLEX, ext DTACK, 256 bytes) */ |
---|
360 | dc.l ((_FLEX_Start&0xFFFFFF00)+0x00000003) /* Base CS2 */ |
---|
361 | dc.l 0x000000FF /* Mask CS3 (I2C, ext DTACK, 256 bytes) */ |
---|
362 | dc.l ((_I2C_Start&0xFFFFFF00)+0x00000003) /* Base CS3 */ |
---|
363 | |
---|
364 | /* |
---|
365 | * Initial PC |
---|
366 | */ |
---|
367 | .globl start |
---|
368 | start: |
---|
369 | |
---|
370 | _crt0_cold_start: |
---|
371 | moveq.l #0,d0 /* signal cold reset */ |
---|
372 | bra.s _crt0_common_start |
---|
373 | |
---|
374 | _crt0_warm_start: |
---|
375 | moveq.l #1,d0 /* signal warm reset */ |
---|
376 | |
---|
377 | _crt0_common_start: |
---|
378 | move.w #0x2700,sr /* disable interrupts and switch to interrupt mode */ |
---|
379 | movea.l #_crt0_init_stktop,sp /* set up initialization stack */ |
---|
380 | |
---|
381 | lea Entry,a0 /* Get base of vector table */ |
---|
382 | movec a0,vbr /* Set up the VBR */ |
---|
383 | |
---|
384 | moveq.l #0x07,d1 |
---|
385 | movec.l d1,dfc /* prepare access in CPU space */ |
---|
386 | move.l #(BASE_SIM+1),d1 |
---|
387 | moves.l d1,BASE_REG /* base initialization (must be MOVES, PCC-130795) */ |
---|
388 | moveq.l #0x05,d1 |
---|
389 | movec.l d1,dfc |
---|
390 | |
---|
391 | movea.l #BASE_SIM,a0 |
---|
392 | |
---|
393 | /* -- disable Bus Monitor -- */ |
---|
394 | move.b #0,SIM_SYPCR(a0) /* system protection control register */ |
---|
395 | |
---|
396 | /* -- set frequency to 25.16 Mhz -- */ |
---|
397 | move.w #_SPEED,SIM_SYNCR(a0) /* clock */ |
---|
398 | |
---|
399 | sync_wait: |
---|
400 | btst.b #3,(SIM_SYNCR+1)(a0) |
---|
401 | beq sync_wait |
---|
402 | |
---|
403 | /* -- enable A31-A24 -- */ |
---|
404 | clr.b SIM_PPRA1(a0) |
---|
405 | |
---|
406 | /* -- show cycles, user acces to SIM, 4 /CS & 4 /IT -- */ |
---|
407 | move.w #0x427F,SIM_MCR(a0) |
---|
408 | |
---|
409 | /* -- chip select initialization -- */ |
---|
410 | lea.l SIM_MASKH0(a0),a2 |
---|
411 | lea.l _table_cs(%pc),a1 |
---|
412 | |
---|
413 | moveq.l #0x07,d1 |
---|
414 | |
---|
415 | _b_cs: |
---|
416 | /* move.l (a1)+, (a2)+ */ |
---|
417 | move.l (a1)+, d2 |
---|
418 | move.l d2, (a2)+ |
---|
419 | dbra d1,_b_cs |
---|
420 | |
---|
421 | /* fill RAM if COLDSTART */ |
---|
422 | tst.l d0 |
---|
423 | bne _dont_fill |
---|
424 | |
---|
425 | movea.l #_EXTram_Start,a0 /* get start */ |
---|
426 | move.l #_EXTram_Size,d1 /* get size */ |
---|
427 | lsr.l #2,d1 /* ajust for long word */ |
---|
428 | |
---|
429 | _fill_loop: |
---|
430 | clr.l (a0)+ |
---|
431 | subq.l #1,d1 |
---|
432 | bne _fill_loop |
---|
433 | |
---|
434 | /* jsr __initcopy */ |
---|
435 | |
---|
436 | _dont_fill: |
---|
437 | jmp SYM(_Init68340) | Start C code (which never returns) |
---|
438 | |
---|
439 | /* |
---|
440 | * Copy DATA segment, clear BSS segment, set up real stack, |
---|
441 | * initialize heap, start C program. |
---|
442 | * Assume that DATA and BSS sizes are multiples of 4. |
---|
443 | */ |
---|
444 | PUBLIC (_CopyDataClearBSSAndStart) |
---|
445 | SYM(_CopyDataClearBSSAndStart): |
---|
446 | lea copy_start,a0 | Get start of DATA in RAM |
---|
447 | lea SYM(etext),a2 | Get start of DATA in ROM |
---|
448 | cmpl a0,a2 | Are they the same? |
---|
449 | beq.s NOCOPY | Yes, no copy necessary |
---|
450 | lea copy_end,a1 | Get end of DATA in RAM |
---|
451 | bra.s COPYLOOPTEST | Branch into copy loop |
---|
452 | COPYLOOP: |
---|
453 | movel a2@+,a0@+ | Copy word from ROM to RAM |
---|
454 | COPYLOOPTEST: |
---|
455 | cmpl a1,a0 | Done? |
---|
456 | bcs.s COPYLOOP | No, skip |
---|
457 | NOCOPY: |
---|
458 | |
---|
459 | lea clear_start,a0 | Get start of BSS |
---|
460 | lea clear_end,a1 | Get end of BSS |
---|
461 | clrl d0 | Value to set |
---|
462 | bra.s ZEROLOOPTEST | Branch into clear loop |
---|
463 | ZEROLOOP: |
---|
464 | movel d0,a0@+ | Clear a word |
---|
465 | ZEROLOOPTEST: |
---|
466 | cmpl a1,a0 | Done? |
---|
467 | bcs.s ZEROLOOP | No, skip |
---|
468 | |
---|
469 | movel #stack_init,a7 | set master stack pointer |
---|
470 | movel d0,a7@- | environp |
---|
471 | movel d0,a7@- | argv |
---|
472 | movel d0,a7@- | argc |
---|
473 | jsr SYM(boot_card) | Call C main |
---|
474 | |
---|
475 | PUBLIC (_mainDone) |
---|
476 | SYM(_mainDone): |
---|
477 | nop | Leave spot for breakpoint |
---|
478 | movew #1,a7 | Force a double bus error |
---|
479 | movel d0,a7@- | This should cause a RESET |
---|
480 | stop #0x2700 | Stop with interrupts disabled |
---|
481 | bra.s SYM(_mainDone) | Stuck forever |
---|
482 | |
---|
483 | .align 2 |
---|
484 | PUBLIC (_HeapSize) |
---|
485 | SYM (_HeapSize): |
---|
486 | .long HeapSize |
---|
487 | PUBLIC (_StackSize) |
---|
488 | SYM (_StackSize): |
---|
489 | .long StackSize |
---|
490 | END_CODE |
---|
491 | |
---|
492 | BEGIN_DATA_DCL |
---|
493 | .align 2 |
---|
494 | PUBLIC (environ) |
---|
495 | SYM (environ): |
---|
496 | .long 0 |
---|
497 | PUBLIC (_M68kSpuriousInterruptCount) |
---|
498 | SYM (_M68kSpuriousInterruptCount): |
---|
499 | .long 0 |
---|
500 | END_DATA_DCL |
---|
501 | |
---|
502 | END |
---|
503 | |
---|