source: rtems/c/src/lib/libbsp/m68k/gen68340/start340/start340.S @ 08b5f55

4.104.114.84.95
Last change on this file since 08b5f55 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: 24.5 KB
Line 
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 <m68349.inc>
31
32#define _OLD_ASTECC 1 /* old addresses for AST68340 only, undefine for AST68349 */
33
34BEGIN_CODE
35        /*
36         * Step 1: Decide on Reset Stack Pointer and Initial Program Counter
37         */
38Entry:
39        .long   SYM(m340)+1024          |   0: Initial SSP
40        .long   start                   |   1: Initial PC
41        .long   SYM(_uhoh)              |   2: Bus error
42        .long   SYM(_uhoh)              |   3: Address error
43        .long   SYM(_uhoh)              |   4: Illegal instruction
44        .long   SYM(_uhoh)              |   5: Zero division
45        .long   SYM(_uhoh)              |   6: CHK, CHK2 instruction
46        .long   SYM(_uhoh)              |   7: TRAPcc, TRAPV instructions
47        .long   SYM(_uhoh)              |   8: Privilege violation
48        .long   SYM(_uhoh)              |   9: Trace
49        .long   SYM(_uhoh)              |  10: Line 1010 emulator
50        .long   SYM(_uhoh)              |  11: Line 1111 emulator
51        .long   SYM(_uhoh)              |  12: Hardware breakpoint
52        .long   SYM(_uhoh)              |  13: Reserved for coprocessor violation
53        .long   SYM(_uhoh)              |  14: Format error
54        .long   SYM(_uhoh)              |  15: Uninitialized interrupt
55        .long   SYM(_uhoh)              |  16: Unassigned, reserved
56        .long   SYM(_uhoh)              |  17:
57        .long   SYM(_uhoh)              |  18:
58        .long   SYM(_uhoh)              |  19:
59        .long   SYM(_uhoh)              |  20:
60        .long   SYM(_uhoh)              |  21:
61        .long   SYM(_uhoh)              |  22:
62        .long   SYM(_uhoh)              |  23:
63        .long   SYM(_spuriousInterrupt) |  24: Spurious interrupt
64        .long   SYM(_uhoh)              |  25: Level 1 interrupt autovector
65        .long   SYM(_uhoh)              |  26: Level 2 interrupt autovector
66        .long   SYM(_uhoh)              |  27: Level 3 interrupt autovector
67        .long   SYM(_uhoh)              |  28: Level 4 interrupt autovector
68        .long   SYM(_uhoh)              |  29: Level 5 interrupt autovector
69        .long   SYM(_uhoh)              |  30: Level 6 interrupt autovector
70        .long   SYM(_uhoh)              |  31: Level 7 interrupt autovector
71        .long   SYM(_uhoh)              |  32: Trap instruction (0-15)
72        .long   SYM(_uhoh)              |  33:
73        .long   SYM(_uhoh)              |  34:
74        .long   SYM(_uhoh)              |  35:
75        .long   SYM(_uhoh)              |  36:
76        .long   SYM(_uhoh)              |  37:
77        .long   SYM(_uhoh)              |  38:
78        .long   SYM(_uhoh)              |  39:
79        .long   SYM(_uhoh)              |  40:
80        .long   SYM(_uhoh)              |  41:
81        .long   SYM(_uhoh)              |  42:
82        .long   SYM(_uhoh)              |  43:
83        .long   SYM(_uhoh)              |  44:
84        .long   SYM(_uhoh)              |  45:
85        .long   SYM(_uhoh)              |  46:
86        .long   SYM(_uhoh)              |  47:
87        .long   SYM(_uhoh)              |  48: Reserved for coprocessor
88        .long   SYM(_uhoh)              |  49:
89        .long   SYM(_uhoh)              |  50:
90        .long   SYM(_uhoh)              |  51:
91        .long   SYM(_uhoh)              |  52:
92        .long   SYM(_uhoh)              |  53:
93        .long   SYM(_uhoh)              |  54:
94        .long   SYM(_uhoh)              |  55:
95        .long   SYM(_uhoh)              |  56:
96        .long   SYM(_uhoh)              |  57:
97        .long   SYM(_uhoh)              |  58:
98        .long   SYM(_uhoh)              |  59: Unassigned, reserved
99        .long   SYM(_uhoh)              |  60:
100        .long   SYM(_uhoh)              |  61:
101        .long   SYM(_uhoh)              |  62:
102        .long   SYM(_uhoh)              |  63:
103        .long   SYM(_uhoh)              |  64: User defined vectors (192)
104        .long   SYM(_uhoh)              |  65:
105        .long   SYM(_uhoh)              |  66:
106        .long   SYM(_uhoh)              |  67:
107        .long   SYM(_uhoh)              |  68:
108        .long   SYM(_uhoh)              |  69:
109        .long   SYM(_uhoh)              |  70:
110        .long   SYM(_uhoh)              |  71:
111        .long   SYM(_uhoh)              |  72:
112        .long   SYM(_uhoh)              |  73:
113        .long   SYM(_uhoh)              |  74:
114        .long   SYM(_uhoh)              |  75:
115        .long   SYM(_uhoh)              |  76:
116        .long   SYM(_uhoh)              |  77:
117        .long   SYM(_uhoh)              |  78:
118        .long   SYM(_uhoh)              |  79:
119        .long   SYM(_uhoh)              |  80:
120        .long   SYM(_uhoh)              |  81:
121        .long   SYM(_uhoh)              |  82:
122        .long   SYM(_uhoh)              |  83:
123        .long   SYM(_uhoh)              |  84:
124        .long   SYM(_uhoh)              |  85:
125        .long   SYM(_uhoh)              |  86:
126        .long   SYM(_uhoh)              |  87:
127        .long   SYM(_uhoh)              |  88:
128        .long   SYM(_uhoh)              |  89:
129        .long   SYM(_uhoh)              |  90:
130        .long   SYM(_uhoh)              |  91:
131        .long   SYM(_uhoh)              |  92:
132        .long   SYM(_uhoh)              |  93:
133        .long   SYM(_uhoh)              |  94:
134        .long   SYM(_uhoh)              |  95:
135        .long   SYM(_uhoh)              |  96:
136        .long   SYM(_uhoh)              |  97:
137        .long   SYM(_uhoh)              |  98:
138        .long   SYM(_uhoh)              |  99:
139        .long   SYM(_uhoh)              | 100:
140        .long   SYM(_uhoh)              | 101:
141        .long   SYM(_uhoh)              | 102:
142        .long   SYM(_uhoh)              | 103:
143        .long   SYM(_uhoh)              | 104:
144        .long   SYM(_uhoh)              | 105:
145        .long   SYM(_uhoh)              | 106:
146        .long   SYM(_uhoh)              | 107:
147        .long   SYM(_uhoh)              | 108:
148        .long   SYM(_uhoh)              | 109:
149        .long   SYM(_uhoh)              | 110:
150        .long   SYM(_uhoh)              | 111:
151        .long   SYM(_uhoh)              | 112:
152        .long   SYM(_uhoh)              | 113:
153        .long   SYM(_uhoh)              | 114:
154        .long   SYM(_uhoh)              | 115:
155        .long   SYM(_uhoh)              | 116:
156        .long   SYM(_uhoh)              | 117:
157        .long   SYM(_uhoh)              | 118:
158        .long   SYM(_uhoh)              | 119:
159        .long   SYM(_uhoh)              | 120:
160        .long   SYM(_uhoh)              | 121:
161        .long   SYM(_uhoh)              | 122:
162        .long   SYM(_uhoh)              | 123:
163        .long   SYM(_uhoh)              | 124:
164        .long   SYM(_uhoh)              | 125:
165        .long   SYM(_uhoh)              | 126:
166        .long   SYM(_uhoh)              | 127:
167        .long   SYM(_uhoh)              | 128:
168        .long   SYM(_uhoh)              | 129:
169        .long   SYM(_uhoh)              | 130:
170        .long   SYM(_uhoh)              | 131:
171        .long   SYM(_uhoh)              | 132:
172        .long   SYM(_uhoh)              | 133:
173        .long   SYM(_uhoh)              | 134:
174        .long   SYM(_uhoh)              | 135:
175        .long   SYM(_uhoh)              | 136:
176        .long   SYM(_uhoh)              | 137:
177        .long   SYM(_uhoh)              | 138:
178        .long   SYM(_uhoh)              | 139:
179        .long   SYM(_uhoh)              | 140:
180        .long   SYM(_uhoh)              | 141:
181        .long   SYM(_uhoh)              | 142:
182        .long   SYM(_uhoh)              | 143:
183        .long   SYM(_uhoh)              | 144:
184        .long   SYM(_uhoh)              | 145:
185        .long   SYM(_uhoh)              | 146:
186        .long   SYM(_uhoh)              | 147:
187        .long   SYM(_uhoh)              | 148:
188        .long   SYM(_uhoh)              | 149:
189        .long   SYM(_uhoh)              | 150:
190        .long   SYM(_uhoh)              | 151:
191        .long   SYM(_uhoh)              | 152:
192        .long   SYM(_uhoh)              | 153:
193        .long   SYM(_uhoh)              | 154:
194        .long   SYM(_uhoh)              | 155:
195        .long   SYM(_uhoh)              | 156:
196        .long   SYM(_uhoh)              | 157:
197        .long   SYM(_uhoh)              | 158:
198        .long   SYM(_uhoh)              | 159:
199        .long   SYM(_uhoh)              | 160:
200        .long   SYM(_uhoh)              | 161:
201        .long   SYM(_uhoh)              | 162:
202        .long   SYM(_uhoh)              | 163:
203        .long   SYM(_uhoh)              | 164:
204        .long   SYM(_uhoh)              | 165:
205        .long   SYM(_uhoh)              | 166:
206        .long   SYM(_uhoh)              | 167:
207        .long   SYM(_uhoh)              | 168:
208        .long   SYM(_uhoh)              | 169:
209        .long   SYM(_uhoh)              | 170:
210        .long   SYM(_uhoh)              | 171:
211        .long   SYM(_uhoh)              | 172:
212        .long   SYM(_uhoh)              | 173:
213        .long   SYM(_uhoh)              | 174:
214        .long   SYM(_uhoh)              | 175:
215        .long   SYM(_uhoh)              | 176:
216        .long   SYM(_uhoh)              | 177:
217        .long   SYM(_uhoh)              | 178:
218        .long   SYM(_uhoh)              | 179:
219        .long   SYM(_uhoh)              | 180:
220        .long   SYM(_uhoh)              | 181:
221        .long   SYM(_uhoh)              | 182:
222        .long   SYM(_uhoh)              | 183:
223        .long   SYM(_uhoh)              | 184:
224        .long   SYM(_uhoh)              | 185:
225        .long   SYM(_uhoh)              | 186:
226        .long   SYM(_uhoh)              | 187:
227        .long   SYM(_uhoh)              | 188:
228        .long   SYM(_uhoh)              | 189:
229        .long   SYM(_uhoh)              | 190:
230        .long   SYM(_uhoh)              | 191:
231        .long   SYM(_uhoh)              | 192:
232        .long   SYM(_uhoh)              | 193:
233        .long   SYM(_uhoh)              | 194:
234        .long   SYM(_uhoh)              | 195:
235        .long   SYM(_uhoh)              | 196:
236        .long   SYM(_uhoh)              | 197:
237        .long   SYM(_uhoh)              | 198:
238        .long   SYM(_uhoh)              | 199:
239        .long   SYM(_uhoh)              | 200:
240        .long   SYM(_uhoh)              | 201:
241        .long   SYM(_uhoh)              | 202:
242        .long   SYM(_uhoh)              | 203:
243        .long   SYM(_uhoh)              | 204:
244        .long   SYM(_uhoh)              | 205:
245        .long   SYM(_uhoh)              | 206:
246        .long   SYM(_uhoh)              | 207:
247        .long   SYM(_uhoh)              | 208:
248        .long   SYM(_uhoh)              | 209:
249        .long   SYM(_uhoh)              | 210:
250        .long   SYM(_uhoh)              | 211:
251        .long   SYM(_uhoh)              | 212:
252        .long   SYM(_uhoh)              | 213:
253        .long   SYM(_uhoh)              | 214:
254        .long   SYM(_uhoh)              | 215:
255        .long   SYM(_uhoh)              | 216:
256        .long   SYM(_uhoh)              | 217:
257        .long   SYM(_uhoh)              | 218:
258        .long   SYM(_uhoh)              | 219:
259        .long   SYM(_uhoh)              | 220:
260        .long   SYM(_uhoh)              | 221:
261        .long   SYM(_uhoh)              | 222:
262        .long   SYM(_uhoh)              | 223:
263        .long   SYM(_uhoh)              | 224:
264        .long   SYM(_uhoh)              | 225:
265        .long   SYM(_uhoh)              | 226:
266        .long   SYM(_uhoh)              | 227:
267        .long   SYM(_uhoh)              | 228:
268        .long   SYM(_uhoh)              | 229:
269        .long   SYM(_uhoh)              | 230:
270        .long   SYM(_uhoh)              | 231:
271        .long   SYM(_uhoh)              | 232:
272        .long   SYM(_uhoh)              | 233:
273        .long   SYM(_uhoh)              | 234:
274        .long   SYM(_uhoh)              | 235:
275        .long   SYM(_uhoh)              | 236:
276        .long   SYM(_uhoh)              | 237:
277        .long   SYM(_uhoh)              | 238:
278        .long   SYM(_uhoh)              | 239:
279        .long   SYM(_uhoh)              | 240:
280        .long   SYM(_uhoh)              | 241:
281        .long   SYM(_uhoh)              | 242:
282        .long   SYM(_uhoh)              | 243:
283        .long   SYM(_uhoh)              | 244:
284        .long   SYM(_uhoh)              | 245:
285        .long   SYM(_uhoh)              | 246:
286        .long   SYM(_uhoh)              | 247:
287        .long   SYM(_uhoh)              | 248:
288        .long   SYM(_uhoh)              | 249:
289        .long   SYM(_uhoh)              | 250:
290        .long   SYM(_uhoh)              | 251:
291        .long   SYM(_uhoh)              | 252:
292        .long   SYM(_uhoh)              | 253:
293        .long   SYM(_uhoh)              | 254:
294        .long   SYM(_uhoh)              | 255:
295
296/*
297 * Default trap handler
298 * With an oscilloscope you can see AS* stop
299 */
300        PUBLIC (_uhoh)
301SYM(_uhoh):     nop                             | Leave spot for breakpoint
302/*      stop    #0x2700                         | Stop with interrupts disabled */
303        move.w  #0x2700,sr
304        move.w  (a7),_boot_panic_registers+4    | SR
305        move.l  2(a7),_boot_panic_registers     | PC
306        move.w  6(a7),_boot_panic_registers+6   | format & vector
307        movem.l d0-d7/a0-a7, _boot_panic_registers+8
308        movec   sfc, d0
309        movem.l d0, _boot_panic_registers+72
310        movec   dfc, d0
311        movem.l d0, _boot_panic_registers+76
312        movec   vbr, d0
313        movem.l d0, _boot_panic_registers+80
314        jmp     SYM(_dbug_dumpanic)
315        bra.s   _crt0_cold_start
316
317/*
318 * Log, but otherwise ignore, spurious interrupts
319 */
320        PUBLIC (_spuriousInterrupt)
321SYM(_spuriousInterrupt):
322        addql   #1,SYM(_M68kSpuriousInterruptCount)
323        rte
324
325/*
326 * Place the low-order 3 octets of the board's ethernet address at
327 * a `well-known' fixed location relative to the startup location.
328 */
329        .align 2
330        .word   0                       | Padding
331ethernet_address_buffer:
332        .word   0x08F3                  | Default address
333        .word   0xDEAD
334        .word   0xCAFE
335
336BEGIN_DATA
337
338/* equates */
339
340.equ    _CPU340, 0x0
341.equ    _CPU349, 0x31
342
343#ifdef _OLD_ASTECC                              /* old addresses for AST68340 only */
344.equ    _EPLD_CS_BASE, 0x1
345.equ    _PROM_Start, 0x01000000                 /* CS0 */
346.equ    _FLEX_Start, 0x08000000                 /* CS2 */
347.equ    _I2C_Start, 0x0c000000                  /* CS3 */
348
349.equ    _BCCram_Start, 0x00000000               /* CS1  64 Kbytes */
350.equ    _BCCram_Size, 0x00010000                /* CS1  64 Kbytes */
351
352.equ    _ExtRam_Start, 0x10000000               /* SRAM */
353.equ    _ExtRam_Size, 0x00400000                /* 4 Mbytes */
354
355.equ    _FastRam_Start, 0x00000000              /* overlap /CS1 for the first 4 Kbytes */
356.equ    _FastRam_Size, 0x00001000               /* 4 Kbytes */
357
358#else   /* new addresses for AST68349 and 68340 */
359
360.equ    _EPLD_CS_BASE, 0x5
361.equ    _PROM_Start, 0x50000000                 /* CS0 */
362.equ    _FLEX_Start, 0x08000000                 /* CS2 */
363.equ    _I2C_Start, 0x0c000000                  /* CS3 */
364
365.equ    _BCCram_Start, 0x00000000               /* CS1  64 Kbytes */
366.equ    _BCCram_Size, 0x00010000                /* CS1  64 Kbytes */
367
368.equ    _ExtRam_Start, 0x80000000               /* DRAM */
369.equ    _ExtRam_Size, 0x00400000                /* 4 Mbytes */
370
371.equ    _FastRam_Start, 0x00000000              /* overlap /CS1 for the first 4 Kbytes */
372.equ    _FastRam_Size, 0x00001000               /* 4 Kbytes */
373#endif
374
375.equ    _SPEED349, 0xD680                       /* 24 Mhz */
376.equ    _SPEED340, 0xD700                       /* 25 Mhz */
377/* .equ _SPEED340, 0xCE00                        16 Mhz */
378
379#define crt0_boot_type  d0                      /* cold/warm start (must be D0) */
380#define crt0_temp       d1
381#define crt0_cpu_type   d2
382#define crt0_csswitch   d3
383#define crt0_buswidth   d4
384#define crt0_pdcs       d5
385#define crt0_spare6     d6
386#define crt0_spare7     d7
387#define crt0_sim_base   a0
388#define crt0_glue       a1
389#define crt0_dram       a2
390#define crt0_ptr3       a3
391#define crt0_ptr4       a4
392#define crt0_ptr5       a5
393#define crt0_ptr6       a6
394
395/* -- PDCS buffer equates -- */
396.equ    pdcs_mask, 0x1F                         /* DRAM configuration */
397.equ    pdcs_sw12, 7                            /* switch 12 */
398.equ    pdcs_sw11, 6                            /* switch 11 */
399.equ    pdcs_sw14, 5                            /* switch 14 */
400
401.equ    bit_cache, pdcs_sw12                    /* enable cache if on */
402.equ    bit_meminit, pdcs_sw11                  /* init memory if on */
403
404/* -- Initialization stack and vars -- */
405
406_AsteccBusWidth:        ds.b 1
407_AsteccCsSwitch:        ds.b 1
408_AsteccCpuName:         ds.l 1
409
410.align 4
411
412_crt0_init_stack:
413                ds.l    500
414_crt0_init_stktop:
415
416/* -- Initialization code -- */
417BEGIN_CODE
418
419.align 4
420                dc.l    _crt0_init_stktop        /* reset SP */
421                dc.l    _crt0_cold_start         /* reset PC */
422                dc.l    _crt0_warm_start
423
424                .ascii  "BOOT XHM68K/Spectra for ASTECC 68349 and 68340 boards"
425                dc.w    0
426.align 4
427
428.globl start
429start:
430
431_crt0_cold_start:
432        moveq.l #0,crt0_boot_type                       | signal cold reset
433        bra.s   _crt0_common_start
434
435_crt0_warm_start:
436        moveq.l #1,crt0_boot_type                       | signal warm reset
437
438_crt0_common_start:
439        move.w  #0x2700,sr                              | disable interrupts and switch to interrupt mode
440        movea.l #_crt0_init_stktop,sp                   | set up initialization stack
441
442        move.l  #Entry,crt0_temp                        | VBR initialization
443        movec.l crt0_temp,vbr                           |
444        moveq.l #0x07,crt0_temp
445        movec.l crt0_temp,dfc                           | prepare access in CPU space
446        move.l  #(BASE_SIM+0x111),crt0_temp             | mask CPU, RESERVED USER SPACES
447        moves.l crt0_temp,BASE_REG                      | base initialization (must be MOVES, PCC-130795)
448
449        movea.l #BASE_SIM,crt0_sim_base
450
451        /* -- disable Bus Monitor -- */
452        move.b  #0,SIM_SYPCR(crt0_sim_base)             | system protection control register
453
454        /* -- enable A31-A24 -- */
455        clr.b   SIM_PPRA1(crt0_sim_base)
456
457        /* -- show cycles, user acces to SIM, 4 /CS & 4 /IT -- */
458        move.w  #0x427F,SIM_MCR(crt0_sim_base)
459
460        /* -- enable /IRQ3, 5, 6, 7 -- */
461        move.b   #0xE8,SIM_PPRB(crt0_sim_base)
462
463        /* -- enable autovector on /IRQ7 -- */
464        move.b   #0x80,SIM_AVR(crt0_sim_base)
465
466        /* -- test CPU type -- */
467        cmp.b     #_CPU349,SIM_IDR(crt0_sim_base)
468        bne       cpu_is_68340
469
470/*-------------------------------------------------------------------------------------------*/
471cpu_is_68349:
472
473        /* -- set cpu clock -- */
474        move.w  #_SPEED349,SIM_SYNCR(crt0_sim_base)             | clock
475
476sync_wait349:
477        btst.b  #3,(SIM_SYNCR+1)(crt0_sim_base)
478        beq     sync_wait349
479
480        /* to allow access to the EPLD internal registers, it is necessary
481        to disable the global chip-select /CS0 (which decodes every external
482        cycles). To do that, we initialize the 68349 internal RAM,
483        copy a part of the initialization code in it, and jump there.
484        from that moment, /CS0 is not used, therefore it can be initialized
485        with its default value. Its width may be incorrect, but it will be
486        adjusted later. The goal is to avoid any conflict with
487        the accesses to the EPLD registers.
488        When this is done, we read the RESET parameters (boot prom width
489        and chip-select switch) and proceed with the initialization
490        when all is done, we jump back to the boot prom now
491        decoded with a properly configured /CS0 */
492
493        /*-------------------------------------*/
494        /* -- configure internal SRAM banks -- */
495
496        move.l  #0x00000000,QDMM_MCR(crt0_sim_base)
497        move.l  #_FastRam_Start+0x0005,QDMM_QBAR0(crt0_sim_base)
498        move.l  #_FastRam_Start+0x0405,QDMM_QBAR1(crt0_sim_base)
499        move.l  #_FastRam_Start+0x0805,QDMM_QBAR2(crt0_sim_base)
500        move.l  #_FastRam_Start+0x0c05,QDMM_QBAR3(crt0_sim_base)
501
502        /*--------------------------------------------------------*/
503        /* -- copy to address of the 68349 initialization code -- */
504
505        lea.l           _copy_start(%pc),crt0_ptr3
506        lea.l           _copy_end(%pc),crt0_ptr4
507        move.l          crt0_ptr4,crt0_temp
508        sub.l           crt0_ptr3,crt0_temp
509        add.l           #3,crt0_temp                            | adjust to next long word
510        lsr.l           #2,crt0_temp
511
512        move.l          #_FastRam_Start,crt0_ptr4
513_copy_loop:
514        move.l          (crt0_ptr3)+,(crt0_ptr4)+
515        subq.l          #1,crt0_temp
516        bne.s           _copy_loop
517        bra.l           _FastRam_Start                          | jump to code in internal RAM
518
519        /*------------------------------------*/
520        /* -- start of initialization code -- */
521
522_copy_start:
523        bra.l           _begin_68349_init
524
525        /*----------------------------------------------------------*/
526        /*  Astecc  68349 board : chip-select initialization values */
527
528_table_csepld:
529        dc.b    (_EPLD_CS_BASE&0x0F)+0x80                       | 16 bits, 0ws
530        dc.b    0x80                                            | 16 bits, 0 ws
531        dc.b    0x90                                            | 16 bits, ext /dsack
532        dc.b    0x90                                            | 16 bits, ext /dsack
533
534_table_cs349:
535        dc.l    0x003FFFF4                                      | Mask CS0 (4Mbytes PROM, 32bits, 1WS)
536        dc.l    (_PROM_Start&0xFFFFFF00)+0x00000003             | Base CS0
537        dc.l    0x003FFFF1                                      | MASK CS1 (4Mbytes RAM, 16bits, 0WS)
538        dc.l    (_BCCram_Start&0xFFFFFF00)+0x00000003           | Base CS1
539        dc.l    0x000000FF                                      | MASK CS2 (FLEX, ext DTACK, 256 bytes)
540        dc.l    (_FLEX_Start&0xFFFFFF00)+0x00000003             | Base CS2
541        dc.l    0x000000FF                                      | Mask CS3 (I2C, ext DTACK, 256 bytes)
542        dc.l    (_I2C_Start&0xFFFFFF00)+0x00000003              | Base CS3
543
544        /*-------------------------------------------------*/
545_begin_68349_init:
546
547        /*-------------------------------------------------*/
548        /* 68349 chip select initialization
549       
550        at this stage, the width of /CS0 may be incorrect
551        it will be corrected later
552        */
553
554_cs68349_init:
555        lea.l           SIM_MASKH0(crt0_sim_base),crt0_ptr4
556        lea.l           _table_cs349(%pc),crt0_ptr3
557
558        moveq.l         #0x07,crt0_temp
559_cs349_init2:
560        move.l          (crt0_ptr3)+,(crt0_ptr4)+
561        dbra            crt0_temp,_cs349_init2
562
563        /*-----------------------------------------------*/
564        /* -- prepare access to the internal registers --*/
565        moveq.l         #EPLD_SPACE,crt0_temp
566        movec.l         crt0_temp,dfc
567        movec.l         crt0_temp,sfc
568        move.l          #GLUE_EPLD,crt0_glue
569        move.l          #DRAM_EPLD,crt0_dram
570
571        /*-------------------------------------------*/
572        /* EPLD generated /CS[3..0] must be disabled */
573
574_csepld_clear:
575        move.l          crt0_glue,crt0_ptr4
576        move.w          #3,crt0_spare6
577        clr.b           crt0_temp
578
579_csepld_clear1:
580        moves.b         crt0_temp,(crt0_ptr4)+
581        dbra            crt0_spare6,_csepld_clear1
582
583        /*---------------------------------------------------------*/
584        /* -- get width of boot PROM, and active chip-select set --*/
585        moves.b         REG_BUSWIDTH(crt0_dram),crt0_csswitch
586        move.b          crt0_csswitch,crt0_buswidth
587
588        /* state of CS_SWITCH  : sel == 0 => CPU chip_selects  (/CS[3..0])
589                               : sel == 1 => EPLD chip_selects (/CS[3..0]) */
590        and.b           #1,crt0_csswitch
591
592        /* bus width of /CS0 during reset               bw[1..0]  : 0   1   2       3
593                                                        bus width : 32  16  8   ext./dsackx */
594        rol.b           #2,crt0_buswidth
595        and.b           #3,crt0_buswidth
596
597        /*----------------------------------------------------*/
598        /* -- configure chip select 0 with boot prom width -- */
599        lea.l           SIM_MASKH0(crt0_sim_base),crt0_ptr4
600        lea.l           _table_cs349(%pc),crt0_ptr3
601        move.l          (crt0_ptr3)+,crt0_temp
602        and.b           #0xFC,crt0_temp                         | clear PS0 & PS1
603        or.b            crt0_buswidth,crt0_temp                 | set boot PROM bus width
604        move.l          crt0_temp,(crt0_ptr4)+
605
606        /*------------------------*/
607        /* -- read PDCS buffer -- */
608        moves.b         REG_PDCS(crt0_glue),crt0_pdcs
609/*      move.b          #0x3F,crt0_pdcs                                         pour test */
610
611
612        /*---------------------------------------*/
613        /* -- EPLD chip-select initialization -- */
614        /*---------------------------------------*/
615        btst.b          #0,crt0_csswitch
616        beq             _cs_init_end
617
618        /*--------------------------------------------*/
619        /* 68349 generated /CS[3..0] must be disabled */
620        lea.l           SIM_MASKH0(crt0_sim_base),crt0_ptr4
621        lea.l           _table_cs349(%pc),crt0_ptr3
622        moveq.l         #0x03,crt0_temp
623_cs349_clear:
624        move.l          (crt0_ptr3)+,(crt0_ptr4)+
625        move.l          (crt0_ptr3)+,crt0_spare6
626        and.b           #0xFE,crt0_spare6                       | disable chip-select
627        move.l          crt0_spare6,(crt0_ptr4)+
628        dbra            crt0_temp,_cs349_clear
629
630        /*---------------------------------------------*/
631        /* EPLD generated /CS[3..0] must be configured */
632_csepld_init:
633        move.l          crt0_glue,crt0_ptr4
634        lea.l           _table_csepld(%pc),crt0_ptr3
635
636        move.b          (crt0_ptr3)+,crt0_temp
637        or.b            #0x20,crt0_temp                         | default width is 32 bits
638        tst.b           crt0_buswidth                           | is boot PROM bus width 32 bits ?
639        beq             _csepld1                                | if not
640        and.b           #0xDF,crt0_temp                         | set width to 16 bits
641_csepld1:
642        moves.b         crt0_temp,(crt0_ptr4)+
643
644        moveq.l         #0x02,crt0_spare6
645_csepld2:
646        move.b          (crt0_ptr3)+,crt0_temp
647        moves.b         crt0_temp,(crt0_ptr4)+
648        dbra            crt0_spare6,_csepld2
649
650_cs_init_end:
651
652        /*--------------------------------------*/
653        /* -- DRAM controller initialization -- */
654_dram_init:
655        move.w          #15,crt0_temp
656        move.l          #_ExtRam_Start,crt0_ptr3
657
658_dram_init1:
659        clr.l           (crt0_ptr3)+                            | must access DRAM
660        dbra            crt0_temp,_dram_init1                   | prior to init refresh
661
662_dram_init2:
663        move.b          #3,crt0_temp
664        moves.b         crt0_temp,REG_WS(crt0_dram)             | set 3 wait-states
665
666        move.b          #0x81,crt0_temp
667        moves.b         crt0_temp,REG_REFRESH(crt0_dram)        | refresh every 10µs
668
669        move.b          #0,crt0_temp
670        moves.b         crt0_temp,REG_CONFIG(crt0_dram)         | default size = 4Mbytes
671
672        /*-----------------------*/
673        /* -- configure cache -- */
674_init_cache:
675        move.l          #0x000001E0,CACHE_MCR(crt0_sim_base)
676        btst.b          #bit_cache,crt0_pdcs
677        bne             _init_cache_end
678        or.l            #0x00000001,CACHE_MCR(crt0_sim_base)
679
680_init_cache_end:
681
682        /*-----------------------------*/
683        /* -- timers initialization -- */
684
685        clr.b           crt0_temp
686        moves.b         crt0_temp,REG_TIMER1(crt0_glue)         | disable timer 1
687        moves.b         crt0_temp,REG_TIMER2(crt0_glue)         | disable timer 2
688
689        /*--------------------------*/
690        /* -- I2C initialization -- */
691        move.b          #3,crt0_temp
692        moves.b         crt0_temp,REG_I2C(crt0_glue)            | tri-states I2C ports
693
694        /*-----------------------------------------*/
695        /* -- baudrate generator initialization -- */
696        move.b          #2,crt0_temp
697        moves.b         crt0_temp,REG_BAUDRATE(crt0_glue)       | baudrate = 38400
698
699        /*-------------------------------*/
700        /* --  IO port initialization -- */
701        clr.b           crt0_temp
702        moves.b         crt0_temp,REG_IO(crt0_glue)             | set port as input
703
704        /* -- */
705
706        move.l          #68349,crt0_cpu_type
707
708
709        /* -- jump back to PROM -- */
710
711        jmp.l           (_fill_test)                            | must be absolute long
712
713_copy_end:
714
715/*-------------------------------------------------
716  initialization code for the 68340 board
717  -------------------------------------------------*/
718
719        /* Astecc  68340 board : chip-select initialization values */
720_table_cs340:
721        dc.l    0x003FFFF0                              /* Mask CS0 (4Mbytes PROM, 32bits, 0WS) */
722        dc.l    ((_PROM_Start&0xFFFFFF00)+0x00000003)   /* Base CS0 */
723        dc.l    0x0000FFFD                              /* MASK CS1 (RAMBCC340, 0WS, FTE) */
724        dc.l    ((_BCCram_Start&0xFFFFFF00)+0x00000003) /* Base CS1 */
725        dc.l    0x000000FF                              /* MASK CS2 (FLEX, ext DTACK, 256 bytes) */
726        dc.l    ((_FLEX_Start&0xFFFFFF00)+0x00000003)   /* Base CS2 */
727        dc.l    0x000000FF                              /* Mask CS3 (I2C, ext DTACK, 256 bytes) */
728        dc.l    ((_I2C_Start&0xFFFFFF00)+0x00000003)    /* Base CS3 */
729
730cpu_is_68340:
731
732        /* -- set cpu clock -- */
733        move.w  #_SPEED340,SIM_SYNCR(crt0_sim_base)             | clock
734sync_wait340:
735        btst.b  #3,(SIM_SYNCR+1)(crt0_sim_base)
736        beq     sync_wait340
737
738        /* -- chip select initialization -- */
739        lea.l   SIM_MASKH0(crt0_sim_base),crt0_ptr4
740        lea.l   _table_cs340(%pc),crt0_ptr3
741        moveq.l #0x07,crt0_temp
742_b_cs340:
743        move.l  (crt0_ptr3)+,crt0_ptr5
744        move.l  crt0_ptr5,(crt0_ptr4)+                          | pour test
745        dbra    crt0_temp,_b_cs340
746
747        move.l  #68340,crt0_cpu_type
748        move.b  #0,crt0_csswitch                                | CPU
749        move.b  #1,crt0_buswidth                                | 16 bits
750
751
752        /*-------------------------------------------------
753          fill RAM if COLDSTART
754          -------------------------------------------------*/
755_fill_test:
756
757        tst.l   crt0_boot_type
758        bne     _dont_fill
759
760        cmp.b   #_CPU349,SIM_IDR(crt0_sim_base)
761        bne     _fill
762        btst.b  #bit_meminit,crt0_pdcs
763        bne     _dont_fill
764
765        /* fill main memory */
766_fill:
767        move.l  #_crt0_init_stack,crt0_ptr3                     | skip Astecc vars
768        move.l  #_ExtRam_Start,crt0_temp
769        sub.l   #_crt0_init_stack,crt0_temp
770        add.l   #_ExtRam_Size,crt0_temp                         | get size
771        lsr.l   #2,crt0_temp                                    | ajust for long word
772_fill_loop:
773        clr.l   (crt0_ptr3)+
774        subq.l  #1,crt0_temp
775        bne     _fill_loop
776
777        cmp.b   #_CPU349,SIM_IDR(crt0_sim_base)
778        bne     _fill_bccram
779
780        /* fill QDMM memory */
781        movea.l #_FastRam_Start,crt0_ptr3                       | get start
782        move.l  #_FastRam_Size,crt0_temp                        | get size
783        lsr.l   #2,crt0_temp                                    | ajust for long word
784
785_QDMMfill_loop:
786        clr.l   (crt0_ptr3)+
787        subq.l  #1,crt0_temp
788        bne     _QDMMfill_loop
789        bra     _dont_fill
790
791        /* fill BCC memory */
792_fill_bccram:
793        movea.l #_BCCram_Start,crt0_ptr3                        | get start
794        move.l  #_BCCram_Size,crt0_temp                         | get size
795        lsr.l   #2,crt0_temp                                    | ajust for long word
796_BCCfill_loop:
797        clr.l   (crt0_ptr3)+
798        subq.l  #1,crt0_temp
799        bne     _BCCfill_loop
800
801        *-------------------------------------------------*/
802_dont_fill:
803        move.b  crt0_csswitch,_AsteccCsSwitch
804        move.b  crt0_buswidth,_AsteccBusWidth
805        move.l  crt0_cpu_type,_AsteccCpuName
806
807        jmp     SYM(_Init68340)                                 | Start C code (which never returns)
808
809/*
810 * Copy DATA segment, clear BSS segment, set up real stack,
811 * initialize heap, start C program.
812 * Assume that DATA and BSS sizes are multiples of 4.
813 */
814        PUBLIC (_CopyDataClearBSSAndStart)
815SYM(_CopyDataClearBSSAndStart):
816        lea     copy_start,a0                                   | Get start of DATA in RAM
817        lea     SYM(etext),a2                                   | Get start of DATA in ROM
818        cmpl    a0,a2                                           | Are they the same?
819        beq.s   NOCOPY                                          | Yes, no copy necessary
820        lea     copy_end,a1                                     | Get end of DATA in RAM
821        bra.s   COPYLOOPTEST                                    | Branch into copy loop
822COPYLOOP:
823        movel   a2@+,a0@+                                       | Copy word from ROM to RAM
824COPYLOOPTEST:
825        cmpl    a1,a0                                           | Done?
826        bcs.s   COPYLOOP                                        | No, skip
827NOCOPY:
828
829        lea     clear_start,a0                                  | Get start of BSS
830        lea     clear_end,a1                                    | Get end of BSS
831        clrl    d0                                              | Value to set
832        bra.s   ZEROLOOPTEST                                    | Branch into clear loop
833ZEROLOOP:
834        movel   d0,a0@+                                         | Clear a word
835ZEROLOOPTEST:
836        cmpl    a1,a0                                           | Done?
837        bcs.s   ZEROLOOP                                        | No, skip
838
839        movel   #stack_init,a7                                  | set master stack pointer
840        movel   d0,a7@-                                         | environp
841        movel   d0,a7@-                                         | argv
842        movel   d0,a7@-                                         | argc
843        jsr     SYM(boot_card)                                  | Call C main
844
845        PUBLIC (_mainDone)
846SYM(_mainDone):
847        nop                                                     | Leave spot for breakpoint
848        movew   #1,a7                                           | Force a double bus error
849        movel   d0,a7@-                                         | This should cause a RESET
850/*      stop    #0x2700                                         | Stop with interrupts disabled */
851        move.w  #0x2700,sr
852        bra.s   SYM(_mainDone)                                  | Stuck forever
853
854        .align 2
855        PUBLIC (_HeapSize)
856SYM (_HeapSize):
857        .long  HeapSize
858        PUBLIC (_StackSize)
859SYM (_StackSize):
860        .long  StackSize
861END_CODE
862
863BEGIN_DATA_DCL
864        .align 2
865        PUBLIC (environ)
866SYM (environ):
867        .long   0
868        PUBLIC (_M68kSpuriousInterruptCount)
869SYM (_M68kSpuriousInterruptCount):
870        .long   0
871END_DATA_DCL
872
873END
874
Note: See TracBrowser for help on using the repository browser.