6 extrn $coninit,$cists,$ci
21 ;----------------------------------------------------------------------
36 ;----------------------------------------------------------------------
44 dmclrt: ;clear ram per dma
47 dw nullbyte ;src (fixed)
50 dw romend ;dst (inc), start after "rom" code
52 dw 0-romend ;count (64k)
57 INIWAITS defl INIWAITS+CWAITROM
62 db rcr,CREFSH ;configure DRAM refresh
63 db dcntl,INIWAITS ;wait states
66 ;----------------------------------------------------------------------
70 in0 a,(itc) ;003d Illegal opcode trap?
73 jp bpent ;0044 yes, handle
76 ld a,i ;0047 I register == 0 ?
77 jr z,??st02 ;004b yes, harware reset
79 jp bpent ;004e no, allready set up
84 out0 (rcr),a ; configure DRAM refresh
86 out0 (dcntl),a ; wait states
88 ld a,M_NCD ;No Clock Divide
90 ld a,M_X2CM ;X2 Clock Multiplier
93 ; search warm start mark
95 ld ix,mark_55AA ;00b8 ; top of common area
99 ex af,af' ;00be ;for cbr = 0x70 downto 0x40
104 jr z,kstart ;00c3 ; break (mark not found)
117 ld sp,$stack ;00e0 mark found, check
118 call checkcrc_alv ;00e3
119 jp z,wstart ;00e6 check ok,
122 ; ram not ok, initialize -- kstart --
126 ld a,088h ;00e9 0000-7fff: common 0
127 out0 (cbar),a ;00eb 8000-ffff: common 1
129 ld a,0 ;00f1 start at 008000 (2. phys. 32k block)
137 add a,8 ;010a next 'bank'
138 cp 078h ;010c stop at 078000
141 ld de,8000h ;0114 first block not tested, but mark as ok
142 ld a,0 ;00f1 start at 008000 (2. phys. 32k block)
159 cp 078h ; stop at 078000
163 ; ram test found 1 or more error free blocks (32k)
171 ld c,070h ;01ce highest block
175 jr c,alloc ;01d4 highest "error free" block
181 slp ;01dc should never be reached
187 ; Clear RAM using DMA0
189 ld hl,dmclrt ;load DMA registers
191 ld a,0cbh ;01ef dst +1, src fixed, burst
195 ld a,062h ;01f4 enable dma0,
197 out0 (dstat),a ;01f9 clear (up to) 64k
198 djnz ??cl_1 ; end of RAM?
202 ld hl,banktabsys ;020f
203 ld (hl),c ; Common area
205 ld (hl),c ; System work area
206 inc hl ;0215 Point to bank 0 entry
209 ld (hl),0ffh ;0218 Mark all banks as unassigned
214 ld b,8 ; 8*4k ie. first 32k
216 ld (hl),0e0h ; mark as sys ("rom"/monitor)
220 rr d ; shift out bit for block 0
222 ld c,15 ;022c 15*32k remaining blocks
224 ld a,0feh ; 0xfe == block with error(s)
227 adc a,0 ; ==> 0xff : block ok
228 ld b,32/4 ; 32k == 8 * 4k
234 jr nz,l022eh ;next 32k block
236 ld hl,memalv+0ch ;memalv+0ch
241 ld (hl),0ech ;alloc system ram
244 ld (hl),0efh ;alloc common
248 ld bc,0f0fh ; size (?) (4k blocks)
250 call sub_0420h ;alloc mem for bank 0
263 ld hl,055AAh ;set warm start mark
268 ; crc ok -- wstart --
271 call sysram_init ;027f
299 ;----------------------------------------------------------------------
302 ;TODO: Make a ringbuffer module.
312 ;----------------------------------------------------------------------
316 extrn msginit,msg.sout,msg_fifo
368 ;----------------------------------------------------------------------
374 ld bc,sysrame-sysramw
379 ;----------------------------------------------------------------------
387 ; Let all vectors point to spurious int routines.
401 ;----------------------------------------------------------------------
418 db prt0it_e-prt0itab-2
422 db M_TIE0+M_TDE0 ;enable timer 0 interrupt and down count.
427 ;----------------------------------------------------------------------
432 ld b,0 ;high byte port adress
436 ld c,(hl) ;port address
439 inc b ;outi decrements b
458 ;----------------------------------------------------------------------
508 ld hl,banktabsys ;03f9
524 ld hl,banktabsys ;040d
525 ld bc,crc_len+2 ;0410
532 ;----------------------------------------------------------------------
545 ; 2 == no bank # in requested range
550 call checkcrc_alv ;0420
551 jr nz,l049ch ;0424 crc error, tables corrupt
553 call sub_049dh ;0427 bank # in req. range available?
570 inc a ;043e free blocks are marked 0ffh
578 pop ix ;0447 free blocks start here
581 l044dh: ; count free blocks
591 ; end of free blocks run.
595 cp e ;0458 nr of blocks >= requested ?
636 call gencrc_alv ;048e
651 ; search a free bank number in range
655 ; l: bank number available
656 ; nc, if found, bank nr. in l
665 inc e ;04a1 test next #
672 cpir ;04ad bank# allready allocated?
673 jr z,l04a1h ;04af if yes, search for next
690 call gencrc_alv ;04c4
692 or a ;04c8 clear carry
696 ;--------------------------------------------------------------
701 ;out ahl: Phys. (linear) Address
712 ;--------------------------------------------------------------
717 ; OP: ahl = (a<<12) + (d<<8) + e
719 ;out ahl: Phys. (linear) Address
729 add hl,bc ;bc + d == a<<4 + d
737 ;--------------------------------------------------------------
751 ; ---------------------------------------------------------
758 ; Trampoline for interrupt routines in banked ram.
759 ; Switch stack pointer to "system" stack in top ram
763 ex (sp),hl ; save hl, return adr in hl
800 ; ---------------------------------------------------------
824 ; ---------------------------------------------------------
829 sp.int.len equ $-sp.int0
857 ;-----------------------------------------------------
868 ds 512/4 ;Number of 4k blocks
870 crc_len equ $-banktabsys
878 ;ivtab equ 0ffc0h ; 0ffc0h ;int vector table