File indexing completed on 2025-05-11 08:23:45
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047 #include <rtems/asm.h>
0048 #include <m68349.inc>
0049
0050 #include <bsp.h> /* to indicate dependencies */
0051
0052
0053 #define _OLD_ASTECC 1
0054
0055 BEGIN_CODE
0056
0057
0058
0059 Entry:
0060 .long SYM(m340)+1024 | 0: Initial SSP
0061 .long start | 1: Initial PC
0062 .long SYM(_uhoh) | 2: Bus error
0063 .long SYM(_uhoh) | 3: Address error
0064 .long SYM(_uhoh) | 4: Illegal instruction
0065 .long SYM(_uhoh) | 5: Zero division
0066 .long SYM(_uhoh) | 6: CHK, CHK2 instruction
0067 .long SYM(_uhoh) | 7: TRAPcc, TRAPV instructions
0068 .long SYM(_uhoh) | 8: Privilege violation
0069 .long SYM(_uhoh) | 9: Trace
0070 .long SYM(_uhoh) | 10: Line 1010 emulator
0071 .long SYM(_uhoh) | 11: Line 1111 emulator
0072 .long SYM(_uhoh) | 12: Hardware breakpoint
0073 .long SYM(_uhoh) | 13: Reserved for coprocessor violation
0074 .long SYM(_uhoh) | 14: Format error
0075 .long SYM(_uhoh) | 15: Uninitialized interrupt
0076 .long SYM(_uhoh) | 16: Unassigned, reserved
0077 .long SYM(_uhoh) | 17:
0078 .long SYM(_uhoh) | 18:
0079 .long SYM(_uhoh) | 19:
0080 .long SYM(_uhoh) | 20:
0081 .long SYM(_uhoh) | 21:
0082 .long SYM(_uhoh) | 22:
0083 .long SYM(_uhoh) | 23:
0084 .long SYM(_spuriousInterrupt) | 24: Spurious interrupt
0085 .long SYM(_uhoh) | 25: Level 1 interrupt autovector
0086 .long SYM(_uhoh) | 26: Level 2 interrupt autovector
0087 .long SYM(_uhoh) | 27: Level 3 interrupt autovector
0088 .long SYM(_uhoh) | 28: Level 4 interrupt autovector
0089 .long SYM(_uhoh) | 29: Level 5 interrupt autovector
0090 .long SYM(_uhoh) | 30: Level 6 interrupt autovector
0091 .long SYM(_uhoh) | 31: Level 7 interrupt autovector
0092 .long SYM(_uhoh) | 32: Trap instruction (0-15)
0093 .long SYM(_uhoh) | 33:
0094 .long SYM(_uhoh) | 34:
0095 .long SYM(_uhoh) | 35:
0096 .long SYM(_uhoh) | 36:
0097 .long SYM(_uhoh) | 37:
0098 .long SYM(_uhoh) | 38:
0099 .long SYM(_uhoh) | 39:
0100 .long SYM(_uhoh) | 40:
0101 .long SYM(_uhoh) | 41:
0102 .long SYM(_uhoh) | 42:
0103 .long SYM(_uhoh) | 43:
0104 .long SYM(_uhoh) | 44:
0105 .long SYM(_uhoh) | 45:
0106 .long SYM(_uhoh) | 46:
0107 .long SYM(_uhoh) | 47:
0108 .long SYM(_uhoh) | 48: Reserved for coprocessor
0109 .long SYM(_uhoh) | 49:
0110 .long SYM(_uhoh) | 50:
0111 .long SYM(_uhoh) | 51:
0112 .long SYM(_uhoh) | 52:
0113 .long SYM(_uhoh) | 53:
0114 .long SYM(_uhoh) | 54:
0115 .long SYM(_uhoh) | 55:
0116 .long SYM(_uhoh) | 56:
0117 .long SYM(_uhoh) | 57:
0118 .long SYM(_uhoh) | 58:
0119 .long SYM(_uhoh) | 59: Unassigned, reserved
0120 .long SYM(_uhoh) | 60:
0121 .long SYM(_uhoh) | 61:
0122 .long SYM(_uhoh) | 62:
0123 .long SYM(_uhoh) | 63:
0124 .long SYM(_uhoh) | 64: User defined vectors (192)
0125 .long SYM(_uhoh) | 65:
0126 .long SYM(_uhoh) | 66:
0127 .long SYM(_uhoh) | 67:
0128 .long SYM(_uhoh) | 68:
0129 .long SYM(_uhoh) | 69:
0130 .long SYM(_uhoh) | 70:
0131 .long SYM(_uhoh) | 71:
0132 .long SYM(_uhoh) | 72:
0133 .long SYM(_uhoh) | 73:
0134 .long SYM(_uhoh) | 74:
0135 .long SYM(_uhoh) | 75:
0136 .long SYM(_uhoh) | 76:
0137 .long SYM(_uhoh) | 77:
0138 .long SYM(_uhoh) | 78:
0139 .long SYM(_uhoh) | 79:
0140 .long SYM(_uhoh) | 80:
0141 .long SYM(_uhoh) | 81:
0142 .long SYM(_uhoh) | 82:
0143 .long SYM(_uhoh) | 83:
0144 .long SYM(_uhoh) | 84:
0145 .long SYM(_uhoh) | 85:
0146 .long SYM(_uhoh) | 86:
0147 .long SYM(_uhoh) | 87:
0148 .long SYM(_uhoh) | 88:
0149 .long SYM(_uhoh) | 89:
0150 .long SYM(_uhoh) | 90:
0151 .long SYM(_uhoh) | 91:
0152 .long SYM(_uhoh) | 92:
0153 .long SYM(_uhoh) | 93:
0154 .long SYM(_uhoh) | 94:
0155 .long SYM(_uhoh) | 95:
0156 .long SYM(_uhoh) | 96:
0157 .long SYM(_uhoh) | 97:
0158 .long SYM(_uhoh) | 98:
0159 .long SYM(_uhoh) | 99:
0160 .long SYM(_uhoh) | 100:
0161 .long SYM(_uhoh) | 101:
0162 .long SYM(_uhoh) | 102:
0163 .long SYM(_uhoh) | 103:
0164 .long SYM(_uhoh) | 104:
0165 .long SYM(_uhoh) | 105:
0166 .long SYM(_uhoh) | 106:
0167 .long SYM(_uhoh) | 107:
0168 .long SYM(_uhoh) | 108:
0169 .long SYM(_uhoh) | 109:
0170 .long SYM(_uhoh) | 110:
0171 .long SYM(_uhoh) | 111:
0172 .long SYM(_uhoh) | 112:
0173 .long SYM(_uhoh) | 113:
0174 .long SYM(_uhoh) | 114:
0175 .long SYM(_uhoh) | 115:
0176 .long SYM(_uhoh) | 116:
0177 .long SYM(_uhoh) | 117:
0178 .long SYM(_uhoh) | 118:
0179 .long SYM(_uhoh) | 119:
0180 .long SYM(_uhoh) | 120:
0181 .long SYM(_uhoh) | 121:
0182 .long SYM(_uhoh) | 122:
0183 .long SYM(_uhoh) | 123:
0184 .long SYM(_uhoh) | 124:
0185 .long SYM(_uhoh) | 125:
0186 .long SYM(_uhoh) | 126:
0187 .long SYM(_uhoh) | 127:
0188 .long SYM(_uhoh) | 128:
0189 .long SYM(_uhoh) | 129:
0190 .long SYM(_uhoh) | 130:
0191 .long SYM(_uhoh) | 131:
0192 .long SYM(_uhoh) | 132:
0193 .long SYM(_uhoh) | 133:
0194 .long SYM(_uhoh) | 134:
0195 .long SYM(_uhoh) | 135:
0196 .long SYM(_uhoh) | 136:
0197 .long SYM(_uhoh) | 137:
0198 .long SYM(_uhoh) | 138:
0199 .long SYM(_uhoh) | 139:
0200 .long SYM(_uhoh) | 140:
0201 .long SYM(_uhoh) | 141:
0202 .long SYM(_uhoh) | 142:
0203 .long SYM(_uhoh) | 143:
0204 .long SYM(_uhoh) | 144:
0205 .long SYM(_uhoh) | 145:
0206 .long SYM(_uhoh) | 146:
0207 .long SYM(_uhoh) | 147:
0208 .long SYM(_uhoh) | 148:
0209 .long SYM(_uhoh) | 149:
0210 .long SYM(_uhoh) | 150:
0211 .long SYM(_uhoh) | 151:
0212 .long SYM(_uhoh) | 152:
0213 .long SYM(_uhoh) | 153:
0214 .long SYM(_uhoh) | 154:
0215 .long SYM(_uhoh) | 155:
0216 .long SYM(_uhoh) | 156:
0217 .long SYM(_uhoh) | 157:
0218 .long SYM(_uhoh) | 158:
0219 .long SYM(_uhoh) | 159:
0220 .long SYM(_uhoh) | 160:
0221 .long SYM(_uhoh) | 161:
0222 .long SYM(_uhoh) | 162:
0223 .long SYM(_uhoh) | 163:
0224 .long SYM(_uhoh) | 164:
0225 .long SYM(_uhoh) | 165:
0226 .long SYM(_uhoh) | 166:
0227 .long SYM(_uhoh) | 167:
0228 .long SYM(_uhoh) | 168:
0229 .long SYM(_uhoh) | 169:
0230 .long SYM(_uhoh) | 170:
0231 .long SYM(_uhoh) | 171:
0232 .long SYM(_uhoh) | 172:
0233 .long SYM(_uhoh) | 173:
0234 .long SYM(_uhoh) | 174:
0235 .long SYM(_uhoh) | 175:
0236 .long SYM(_uhoh) | 176:
0237 .long SYM(_uhoh) | 177:
0238 .long SYM(_uhoh) | 178:
0239 .long SYM(_uhoh) | 179:
0240 .long SYM(_uhoh) | 180:
0241 .long SYM(_uhoh) | 181:
0242 .long SYM(_uhoh) | 182:
0243 .long SYM(_uhoh) | 183:
0244 .long SYM(_uhoh) | 184:
0245 .long SYM(_uhoh) | 185:
0246 .long SYM(_uhoh) | 186:
0247 .long SYM(_uhoh) | 187:
0248 .long SYM(_uhoh) | 188:
0249 .long SYM(_uhoh) | 189:
0250 .long SYM(_uhoh) | 190:
0251 .long SYM(_uhoh) | 191:
0252 .long SYM(_uhoh) | 192:
0253 .long SYM(_uhoh) | 193:
0254 .long SYM(_uhoh) | 194:
0255 .long SYM(_uhoh) | 195:
0256 .long SYM(_uhoh) | 196:
0257 .long SYM(_uhoh) | 197:
0258 .long SYM(_uhoh) | 198:
0259 .long SYM(_uhoh) | 199:
0260 .long SYM(_uhoh) | 200:
0261 .long SYM(_uhoh) | 201:
0262 .long SYM(_uhoh) | 202:
0263 .long SYM(_uhoh) | 203:
0264 .long SYM(_uhoh) | 204:
0265 .long SYM(_uhoh) | 205:
0266 .long SYM(_uhoh) | 206:
0267 .long SYM(_uhoh) | 207:
0268 .long SYM(_uhoh) | 208:
0269 .long SYM(_uhoh) | 209:
0270 .long SYM(_uhoh) | 210:
0271 .long SYM(_uhoh) | 211:
0272 .long SYM(_uhoh) | 212:
0273 .long SYM(_uhoh) | 213:
0274 .long SYM(_uhoh) | 214:
0275 .long SYM(_uhoh) | 215:
0276 .long SYM(_uhoh) | 216:
0277 .long SYM(_uhoh) | 217:
0278 .long SYM(_uhoh) | 218:
0279 .long SYM(_uhoh) | 219:
0280 .long SYM(_uhoh) | 220:
0281 .long SYM(_uhoh) | 221:
0282 .long SYM(_uhoh) | 222:
0283 .long SYM(_uhoh) | 223:
0284 .long SYM(_uhoh) | 224:
0285 .long SYM(_uhoh) | 225:
0286 .long SYM(_uhoh) | 226:
0287 .long SYM(_uhoh) | 227:
0288 .long SYM(_uhoh) | 228:
0289 .long SYM(_uhoh) | 229:
0290 .long SYM(_uhoh) | 230:
0291 .long SYM(_uhoh) | 231:
0292 .long SYM(_uhoh) | 232:
0293 .long SYM(_uhoh) | 233:
0294 .long SYM(_uhoh) | 234:
0295 .long SYM(_uhoh) | 235:
0296 .long SYM(_uhoh) | 236:
0297 .long SYM(_uhoh) | 237:
0298 .long SYM(_uhoh) | 238:
0299 .long SYM(_uhoh) | 239:
0300 .long SYM(_uhoh) | 240:
0301 .long SYM(_uhoh) | 241:
0302 .long SYM(_uhoh) | 242:
0303 .long SYM(_uhoh) | 243:
0304 .long SYM(_uhoh) | 244:
0305 .long SYM(_uhoh) | 245:
0306 .long SYM(_uhoh) | 246:
0307 .long SYM(_uhoh) | 247:
0308 .long SYM(_uhoh) | 248:
0309 .long SYM(_uhoh) | 249:
0310 .long SYM(_uhoh) | 250:
0311 .long SYM(_uhoh) | 251:
0312 .long SYM(_uhoh) | 252:
0313 .long SYM(_uhoh) | 253:
0314 .long SYM(_uhoh) | 254:
0315 .long SYM(_uhoh) | 255:
0316
0317
0318
0319
0320
0321 PUBLIC (_uhoh)
0322 SYM(_uhoh): nop | Leave spot for breakpoint
0323
0324 move.w #0x2700,sr
0325 move.w (a7),_boot_panic_registers+4 | SR
0326 move.l 2(a7),_boot_panic_registers | PC
0327 move.w 6(a7),_boot_panic_registers+6 | format & vector
0328 movem.l d0-d7/a0-a7, _boot_panic_registers+8
0329 movec sfc, d0
0330 movem.l d0, _boot_panic_registers+72
0331 movec dfc, d0
0332 movem.l d0, _boot_panic_registers+76
0333 movec vbr, d0
0334 movem.l d0, _boot_panic_registers+80
0335 jmp SYM(_dbug_dumpanic)
0336 bra.s _crt0_cold_start
0337
0338
0339
0340
0341 PUBLIC (_spuriousInterrupt)
0342 SYM(_spuriousInterrupt):
0343 addql #1,SYM(_M68kSpuriousInterruptCount)
0344 rte
0345
0346
0347
0348
0349
0350 .align 2
0351 .word 0 | Padding
0352 ethernet_address_buffer:
0353 .word 0x08F3 | Default address
0354 .word 0xDEAD
0355 .word 0xCAFE
0356
0357 BEGIN_DATA
0358
0359
0360
0361 .equ _CPU340, 0x0
0362 .equ _CPU349, 0x31
0363
0364 #ifdef _OLD_ASTECC
0365 .equ _EPLD_CS_BASE, 0x1
0366 .equ _PROM_Start, 0x01000000
0367 .equ _FLEX_Start, 0x08000000
0368 .equ _I2C_Start, 0x0c000000
0369
0370 .equ _BCCram_Start, 0x00000000
0371 .equ _BCCram_Size, 0x00010000
0372
0373 .equ _ExtRam_Start, 0x10000000
0374 .equ _ExtRam_Size, 0x00400000
0375
0376 .equ _FastRam_Start, 0x00000000
0377 .equ _FastRam_Size, 0x00001000
0378
0379 #else
0380
0381 .equ _EPLD_CS_BASE, 0x5
0382 .equ _PROM_Start, 0x50000000
0383 .equ _FLEX_Start, 0x08000000
0384 .equ _I2C_Start, 0x0c000000
0385
0386 .equ _BCCram_Start, 0x00000000
0387 .equ _BCCram_Size, 0x00010000
0388
0389 .equ _ExtRam_Start, 0x80000000
0390 .equ _ExtRam_Size, 0x00400000
0391
0392 .equ _FastRam_Start, 0x00000000
0393 .equ _FastRam_Size, 0x00001000
0394 #endif
0395
0396 .equ _SPEED349, 0xD680
0397 .equ _SPEED340, 0xD700
0398
0399
0400 #define crt0_boot_type d0
0401 #define crt0_temp d1
0402 #define crt0_cpu_type d2
0403 #define crt0_csswitch d3
0404 #define crt0_buswidth d4
0405 #define crt0_pdcs d5
0406 #define crt0_spare6 d6
0407 #define crt0_spare7 d7
0408 #define crt0_sim_base a0
0409 #define crt0_glue a1
0410 #define crt0_dram a2
0411 #define crt0_ptr3 a3
0412 #define crt0_ptr4 a4
0413 #define crt0_ptr5 a5
0414 #define crt0_ptr6 a6
0415
0416
0417 .equ pdcs_mask, 0x1F
0418 .equ pdcs_sw12, 7
0419 .equ pdcs_sw11, 6
0420 .equ pdcs_sw14, 5
0421
0422 .equ bit_cache, pdcs_sw12
0423 .equ bit_meminit, pdcs_sw11
0424
0425
0426
0427
0428 #if 1
0429 _AsteccBusWidth: ds.w 0x0101
0430 _AsteccCsSwitch: ds.w 0x0101
0431 #else
0432 _AsteccBusWidth: ds.b 1
0433 _AsteccCsSwitch: ds.b 1
0434 #endif
0435 _AsteccCpuName: ds.l 1
0436
0437 .align 4
0438
0439 _crt0_init_stack:
0440 ds.l 500
0441 _crt0_init_stktop:
0442
0443
0444 BEGIN_CODE
0445
0446 .align 4
0447 dc.l _crt0_init_stktop
0448 dc.l _crt0_cold_start
0449 dc.l _crt0_warm_start
0450
0451
0452 .ascii "BOOT XHM68K/Spectra for ASTECC 68349 and 68340 boards "
0453 .text
0454 dc.w 0
0455 .align 4
0456
0457 .globl start
0458 start:
0459
0460 _crt0_cold_start:
0461 moveq.l #0,crt0_boot_type | signal cold reset
0462 bra.s _crt0_common_start
0463
0464 _crt0_warm_start:
0465 moveq.l #1,crt0_boot_type | signal warm reset
0466
0467 _crt0_common_start:
0468 move.w #0x2700,sr | disable interrupts and switch to interrupt mode
0469 movea.l #_crt0_init_stktop,sp | set up initialization stack
0470
0471 move.l #Entry,crt0_temp | VBR initialization
0472 movec.l crt0_temp,vbr |
0473 moveq.l #0x07,crt0_temp
0474 movec.l crt0_temp,dfc | prepare access in CPU space
0475 move.l #(BASE_SIM+0x111),crt0_temp | mask CPU, RESERVED USER SPACES
0476 moves.l crt0_temp,BASE_REG | base initialization (must be MOVES, PCC-130795)
0477
0478 movea.l #BASE_SIM,crt0_sim_base
0479
0480
0481 move.b #0,SIM_SYPCR(crt0_sim_base) | system protection control register
0482
0483
0484 clr.b SIM_PPRA1(crt0_sim_base)
0485
0486
0487 move.w #0x427F,SIM_MCR(crt0_sim_base)
0488
0489
0490 move.b #0xE8,SIM_PPRB(crt0_sim_base)
0491
0492
0493 move.b #0x80,SIM_AVR(crt0_sim_base)
0494
0495
0496 cmp.b #_CPU349,SIM_IDR(crt0_sim_base)
0497 bne cpu_is_68340
0498
0499
0500 cpu_is_68349:
0501
0502
0503 move.w #_SPEED349,SIM_SYNCR(crt0_sim_base) | clock
0504
0505 sync_wait349:
0506 btst.b #3,(SIM_SYNCR+1)(crt0_sim_base)
0507 beq sync_wait349
0508
0509
0510
0511
0512
0513
0514
0515
0516
0517
0518
0519
0520
0521
0522
0523
0524
0525 move.l #0x00000000,QDMM_MCR(crt0_sim_base)
0526 move.l #_FastRam_Start+0x0005,QDMM_QBAR0(crt0_sim_base)
0527 move.l #_FastRam_Start+0x0405,QDMM_QBAR1(crt0_sim_base)
0528 move.l #_FastRam_Start+0x0805,QDMM_QBAR2(crt0_sim_base)
0529 move.l #_FastRam_Start+0x0c05,QDMM_QBAR3(crt0_sim_base)
0530
0531
0532
0533
0534 lea.l _copy_start_code(%pc),crt0_ptr3
0535 lea.l _copy_end_code(%pc),crt0_ptr4
0536 move.l crt0_ptr4,crt0_temp
0537 sub.l crt0_ptr3,crt0_temp
0538 add.l #3,crt0_temp | adjust to next long word
0539 lsr.l #2,crt0_temp
0540
0541 move.l #_FastRam_Start,crt0_ptr4
0542 _copy_loop:
0543 move.l (crt0_ptr3)+,(crt0_ptr4)+
0544 subq.l #1,crt0_temp
0545 bne.s _copy_loop
0546 bra.l _FastRam_Start | jump to code in internal RAM
0547
0548
0549
0550
0551 _copy_start_code:
0552 bra.l _begin_68349_init
0553
0554
0555
0556
0557 _table_csepld:
0558
0559 #if 1
0560 dc.w (((_EPLD_CS_BASE&0x0F)+0x80) << 8) | 0x80 | 16 bits, 0ws
0561 dc.w 0x9090 | 16 bits, ext /dsack
0562
0563 #else
0564 dc.b (_EPLD_CS_BASE&0x0F)+0x80 | 16 bits, 0ws
0565 dc.b 0x80 | 16 bits, 0 ws
0566 dc.b 0x90 | 16 bits, ext /dsack
0567 dc.b 0x90 | 16 bits, ext /dsack
0568 #endif
0569
0570 _table_cs349:
0571 dc.l 0x003FFFF4 | Mask CS0 (4Mbytes PROM, 32bits, 1WS)
0572 dc.l (_PROM_Start&0xFFFFFF00)+0x00000003 | Base CS0
0573 dc.l 0x003FFFF1 | MASK CS1 (4Mbytes RAM, 16bits, 0WS)
0574 dc.l (_BCCram_Start&0xFFFFFF00)+0x00000003 | Base CS1
0575 dc.l 0x000000FF | MASK CS2 (FLEX, ext DTACK, 256 bytes)
0576 dc.l (_FLEX_Start&0xFFFFFF00)+0x00000003 | Base CS2
0577 dc.l 0x000000FF | Mask CS3 (I2C, ext DTACK, 256 bytes)
0578 dc.l (_I2C_Start&0xFFFFFF00)+0x00000003 | Base CS3
0579
0580
0581 _begin_68349_init:
0582
0583
0584
0585
0586
0587
0588
0589
0590 _cs68349_init:
0591 lea.l SIM_MASKH0(crt0_sim_base),crt0_ptr4
0592 lea.l _table_cs349(%pc),crt0_ptr3
0593
0594 moveq.l #0x07,crt0_temp
0595 _cs349_init2:
0596 move.l (crt0_ptr3)+,(crt0_ptr4)+
0597 dbra crt0_temp,_cs349_init2
0598
0599
0600
0601 moveq.l #EPLD_SPACE,crt0_temp
0602 movec.l crt0_temp,dfc
0603 movec.l crt0_temp,sfc
0604 move.l #GLUE_EPLD,crt0_glue
0605 move.l #DRAM_EPLD,crt0_dram
0606
0607
0608
0609
0610 _csepld_clear:
0611 move.l crt0_glue,crt0_ptr4
0612 move.w #3,crt0_spare6
0613 clr.b crt0_temp
0614
0615 _csepld_clear1:
0616 moves.b crt0_temp,(crt0_ptr4)+
0617 dbra crt0_spare6,_csepld_clear1
0618
0619
0620
0621 moves.b REG_BUSWIDTH(crt0_dram),crt0_csswitch
0622 move.b crt0_csswitch,crt0_buswidth
0623
0624
0625
0626 and.b #1,crt0_csswitch
0627
0628
0629
0630 rol.b #2,crt0_buswidth
0631 and.b #3,crt0_buswidth
0632
0633
0634
0635 lea.l SIM_MASKH0(crt0_sim_base),crt0_ptr4
0636 lea.l _table_cs349(%pc),crt0_ptr3
0637 move.l (crt0_ptr3)+,crt0_temp
0638 and.b #0xFC,crt0_temp | clear PS0 & PS1
0639 or.b crt0_buswidth,crt0_temp | set boot PROM bus width
0640 move.l crt0_temp,(crt0_ptr4)+
0641
0642
0643
0644 moves.b REG_PDCS(crt0_glue),crt0_pdcs
0645
0646
0647
0648
0649
0650 btst.b #0,crt0_csswitch
0651 beq _cs_init_end
0652
0653
0654
0655 lea.l SIM_MASKH0(crt0_sim_base),crt0_ptr4
0656 lea.l _table_cs349(%pc),crt0_ptr3
0657 moveq.l #0x03,crt0_temp
0658 _cs349_clear:
0659 move.l (crt0_ptr3)+,(crt0_ptr4)+
0660 move.l (crt0_ptr3)+,crt0_spare6
0661 and.b #0xFE,crt0_spare6 | disable chip-select
0662 move.l crt0_spare6,(crt0_ptr4)+
0663 dbra crt0_temp,_cs349_clear
0664
0665
0666
0667 _csepld_init:
0668 move.l crt0_glue,crt0_ptr4
0669 lea.l _table_csepld(%pc),crt0_ptr3
0670
0671 move.b (crt0_ptr3)+,crt0_temp
0672 or.b #0x20,crt0_temp | default width is 32 bits
0673 tst.b crt0_buswidth | is boot PROM bus width 32 bits ?
0674 beq _csepld1 | if not
0675 and.b #0xDF,crt0_temp | set width to 16 bits
0676 _csepld1:
0677 moves.b crt0_temp,(crt0_ptr4)+
0678
0679 moveq.l #0x02,crt0_spare6
0680 _csepld2:
0681 move.b (crt0_ptr3)+,crt0_temp
0682 moves.b crt0_temp,(crt0_ptr4)+
0683 dbra crt0_spare6,_csepld2
0684
0685 _cs_init_end:
0686
0687
0688
0689 _dram_init:
0690 move.w #15,crt0_temp
0691 move.l #_ExtRam_Start,crt0_ptr3
0692
0693 _dram_init1:
0694 clr.l (crt0_ptr3)+ | must access DRAM
0695 dbra crt0_temp,_dram_init1 | prior to init refresh
0696
0697 _dram_init2:
0698 move.b #3,crt0_temp
0699 moves.b crt0_temp,REG_WS(crt0_dram) | set 3 wait-states
0700
0701 move.b #0x81,crt0_temp
0702 moves.b crt0_temp,REG_REFRESH(crt0_dram) | refresh every 10ยตs
0703
0704 move.b #0,crt0_temp
0705 moves.b crt0_temp,REG_CONFIG(crt0_dram) | default size = 4Mbytes
0706
0707
0708
0709 _init_cache:
0710 move.l #0x000001E0,CACHE_MCR(crt0_sim_base)
0711 btst.b #bit_cache,crt0_pdcs
0712 bne _init_cache_end
0713 or.l #0x00000001,CACHE_MCR(crt0_sim_base)
0714
0715 _init_cache_end:
0716
0717
0718
0719
0720 clr.b crt0_temp
0721 moves.b crt0_temp,REG_TIMER1(crt0_glue) | disable timer 1
0722 moves.b crt0_temp,REG_TIMER2(crt0_glue) | disable timer 2
0723
0724
0725
0726 move.b #3,crt0_temp
0727 moves.b crt0_temp,REG_I2C(crt0_glue) | tri-states I2C ports
0728
0729
0730
0731 move.b #2,crt0_temp
0732 moves.b crt0_temp,REG_BAUDRATE(crt0_glue) | baudrate = 38400
0733
0734
0735
0736 clr.b crt0_temp
0737 moves.b crt0_temp,REG_IO(crt0_glue) | set port as input
0738
0739
0740
0741 move.l #68349,crt0_cpu_type
0742
0743
0744
0745 jmp.l (_fill_test) | must be absolute long
0746
0747 _copy_end_code:
0748
0749
0750
0751
0752
0753
0754 _table_cs340:
0755 dc.l 0x003FFFF0
0756 dc.l ((_PROM_Start&0xFFFFFF00)+0x00000003)
0757 dc.l 0x0000FFFD
0758 dc.l ((_BCCram_Start&0xFFFFFF00)+0x00000003)
0759 dc.l 0x000000FF
0760 dc.l ((_FLEX_Start&0xFFFFFF00)+0x00000003)
0761 dc.l 0x000000FF
0762 dc.l ((_I2C_Start&0xFFFFFF00)+0x00000003)
0763
0764 cpu_is_68340:
0765
0766
0767 move.w #_SPEED340,SIM_SYNCR(crt0_sim_base) | clock
0768 sync_wait340:
0769 btst.b #3,(SIM_SYNCR+1)(crt0_sim_base)
0770 beq sync_wait340
0771
0772
0773 lea.l SIM_MASKH0(crt0_sim_base),crt0_ptr4
0774 lea.l _table_cs340(%pc),crt0_ptr3
0775 moveq.l #0x07,crt0_temp
0776 _b_cs340:
0777 move.l (crt0_ptr3)+,crt0_ptr5
0778 move.l crt0_ptr5,(crt0_ptr4)+ | pour test
0779 dbra crt0_temp,_b_cs340
0780
0781 move.l #68340,crt0_cpu_type
0782 move.b #0,crt0_csswitch | CPU
0783 move.b #1,crt0_buswidth | 16 bits
0784
0785
0786
0787
0788 _fill_test:
0789
0790 tst.l crt0_boot_type
0791 bne _dont_fill
0792
0793 cmp.b #_CPU349,SIM_IDR(crt0_sim_base)
0794 bne _fill
0795 btst.b #bit_meminit,crt0_pdcs
0796 bne _dont_fill
0797
0798
0799 _fill:
0800 move.l #_crt0_init_stack,crt0_ptr3 | skip Astecc vars
0801 move.l #_ExtRam_Start,crt0_temp
0802 sub.l #_crt0_init_stack,crt0_temp
0803 add.l #_ExtRam_Size,crt0_temp | get size
0804 lsr.l #2,crt0_temp | ajust for long word
0805 _fill_loop:
0806 clr.l (crt0_ptr3)+
0807 subq.l #1,crt0_temp
0808 bne _fill_loop
0809
0810 cmp.b #_CPU349,SIM_IDR(crt0_sim_base)
0811 bne _fill_bccram
0812
0813
0814 movea.l #_FastRam_Start,crt0_ptr3 | get start
0815 move.l #_FastRam_Size,crt0_temp | get size
0816 lsr.l #2,crt0_temp | ajust for long word
0817
0818 _QDMMfill_loop:
0819 clr.l (crt0_ptr3)+
0820 subq.l #1,crt0_temp
0821 bne _QDMMfill_loop
0822 bra _dont_fill
0823
0824
0825 _fill_bccram:
0826 movea.l #_BCCram_Start,crt0_ptr3 | get start
0827 move.l #_BCCram_Size,crt0_temp | get size
0828 lsr.l #2,crt0_temp | ajust for long word
0829 _BCCfill_loop:
0830 clr.l (crt0_ptr3)+
0831 subq.l #1,crt0_temp
0832 bne _BCCfill_loop
0833
0834
0835 _dont_fill:
0836 move.b crt0_csswitch,_AsteccCsSwitch
0837 move.b crt0_buswidth,_AsteccBusWidth
0838 move.l crt0_cpu_type,_AsteccCpuName
0839
0840 jmp SYM(_Init68340) | Start C code (which never returns)
0841
0842
0843
0844
0845
0846
0847 PUBLIC (_CopyDataClearBSSAndStart)
0848 SYM(_CopyDataClearBSSAndStart):
0849 lea SYM(_copy_start),a0 | Get start of DATA in RAM
0850 lea SYM(_etext),a2 | Get start of DATA in ROM
0851 cmpl a0,a2 | Are they the same?
0852 beq.s NOCOPY | Yes, no copy necessary
0853 lea SYM(_copy_end),a1 | Get end of DATA in RAM
0854 bra.s COPYLOOPTEST | Branch into copy loop
0855 COPYLOOP:
0856 movel a2@+,a0@+ | Copy word from ROM to RAM
0857 COPYLOOPTEST:
0858 cmpl a1,a0 | Done?
0859 bcs.s COPYLOOP | No, skip
0860 NOCOPY:
0861
0862 lea _clear_start,a0 | Get start of BSS
0863 lea _clear_end,a1 | Get end of BSS
0864 clrl d0 | Value to set
0865 bra.s ZEROLOOPTEST | Branch into clear loop
0866 ZEROLOOP:
0867 movel d0,a0@+ | Clear a word
0868 ZEROLOOPTEST:
0869 cmpl a1,a0 | Done?
0870 bcs.s ZEROLOOP | No, skip
0871
0872 movel #_ISR_Stack_area_end,a7 | set master stack pointer
0873 movel d0,a7@- | command line
0874 jsr SYM(boot_card) | Call C main
0875
0876 PUBLIC (_mainDone)
0877 SYM(_mainDone):
0878 nop | Leave spot for breakpoint
0879 movew #1,a7 | Force a double bus error
0880 movel d0,a7@- | This should cause a RESET
0881
0882 move.w #0x2700,sr
0883 bra.l SYM(_mainDone) | Stuck forever
0884
0885 .align 2
0886 BEGIN_DATA_DCL
0887 .align 2
0888 PUBLIC (environ)
0889 SYM (environ):
0890 .long 0
0891 PUBLIC (_M68kSpuriousInterruptCount)
0892 SYM (_M68kSpuriousInterruptCount):
0893 .long 0
0894 END_DATA_DCL
0895
0896 END