X-Git-Url: http://cloudbase.mooo.com/gitweb/z180-stamp.git/blobdiff_plain/2fa1a7069a9709f8d61a198cec1b1d9b2e275fe1..ef77033ca52647599df6c9053d073216d439780c:/z180/init.180 diff --git a/z180/init.180 b/z180/init.180 index f43aaeb..05c24ff 100644 --- a/z180/init.180 +++ b/z180/init.180 @@ -76,9 +76,10 @@ start: hwini0: if CPU_Z180 - db 3 ;count + db ;count db rcr,CREFSH ;configure DRAM refresh db dcntl,INIWAITS ;wait states + db cbr,SYS$CBR db cbar,SYS$CBAR endif db 0 @@ -151,10 +152,10 @@ hw_reset: kstart: if CPU_Z180 + ld a,SYS$CBR ;TODO: + out0 (cbr),a ld a,SYS$CBAR out0 (cbar),a - ld a,SYS$CBR - out0 (cbr),a endif ld sp,$stack ;01e1 @@ -163,7 +164,7 @@ kstart: if CPU_Z180 if 0 - + ld hl,dmclrt ;load DMA registers call ioiniml ld a,0cbh ;01ef dst +1, src fixed, burst @@ -174,7 +175,7 @@ kstart: ??cl_1: out0 (dstat),a ;01f9 clear (up to) 64k djnz ??cl_1 ; end of RAM? - + endif endif @@ -185,94 +186,108 @@ kstart: ; -- wstart -- wstart: - call sysram_init ;027f + call sysram_init call ivtab_init if CPU_Z180 - call prt0_init +; call prt0_init endif + call msginit call charini - call bufferinit if CPU_Z80 ld a,0 call selbnk endif - im 2 ;?030e - ei ;0282 + ld a,INIDONEVAL ;tell others (CP/M) that hardware and fifos + ld (INIDONE),a ; are allready initialized + + im 2 + ei - call ?const ;0284 - call ?const ;0287 - or a ;028a - call nz,?conin ;028d + call ?const + call ?const + or a + call nz,?conin if CPU_Z180 ld e,0 ;Sys$Bank else ; TODO: endif - jp ddtz ;0290 + jp ddtz if CPU_Z180 ; TODO: SYS$CBR -syscbr: db 1 +syscbr: db 0 endif ; ;---------------------------------------------------------------------- ; -;TODO: Make a ringbuffer module. - - global buf.init + global bufinit -buf.init: - ld (ix+o.in_idx),0 +bufinit: + ld (ix+o.in_idx),0 ;reset pointers (empty fifo) ld (ix+o.out_idx),0 - ld (ix+o.mask),a + ld a,(ix+o.id) + ld hl,fifolst + ld e,a + ld d,0 + add hl,de + add hl,de + push ix + pop de + cp 4 + jr nc,bfi_skip + + ld (hl),e + inc hl + ld (hl),d + +bfi_skip: + ex de,hl + call hwl2phy ;get phys. address of fifo + ld c,a + ld a,(ix+o.id) ;fifo id + or a ;test if fifo 0 + ret z + + ld b,a + push bc ;c: bank-addr, b: ignored + push hl ;address + ld c,0 + push bc ;c: function, b:subf + ld b,5 + ld h,c + ld l,c + add hl,sp + call msg.sm + pop hl + pop hl + pop hl ret + public fifolst +fifolst : + rept 4 + dw 0 + endm + ;---------------------------------------------------------------------- + extrn msg.sm extrn msginit,msg.sout extrn mtx.fifo,mrx.fifo - extrn co.fifo,ci.fifo + extrn ff.init,co.fifo,ci.fifo -bufferinit: +fifoinit: if CPU_Z180 - call msginit - - ld hl,buffers - ld b,buftablen -bfi_1: - ld a,(hl) - inc hl - ld (bufdat+0),a - ld e,(hl) - inc hl - ld d,(hl) - inc hl - ex de,hl - or a - jr nz,bfi_2 - call hwl2phy - ld (40h+0),hl - ld (40h+2),a - out (AVRINT5),a - jr bfi_3 -bfi_2: - call hwl2phy - ld (bufdat+1),hl - ld (bufdat+3),a - ld hl,inimsg - call msg.sout -bfi_3: - ex de,hl - djnz bfi_1 ret else ;CPU_Z180 @@ -316,27 +331,7 @@ bfi_3: ret endif -buffers: - db 0 - dw mtx.fifo - db 1 - dw mrx.fifo - db 2 - dw co.fifo - db 3 - dw ci.fifo -buftablen equ ($ - buffers)/3 - -inimsg: - db inimsg_e - $ -1 - db 0AEh - db inimsg_e - $ -1 - db 0 -bufdat: - db 0 - dw 0 - db 0 -inimsg_e: + ; @@ -377,6 +372,12 @@ ivt_i1: ;---------------------------------------------------------------------- +; Reload value for 10 ms Int. (0.1KHz): +; tc10ms = phi/prescale/0.1KHz = phi / (prescale/10) + +PRT_TC10MS equ 18432 / (PRT_PRE/10) + + if CPU_Z180 prt0_init: ld a,i @@ -426,12 +427,12 @@ ioi_r: dec a jr nz,ioi_r jr ioi_nxt -ioi_e: +ioi_e: pop bc ret - + else ;(if 1/0) - + push bc jr ioi_nxt ioi_l: @@ -449,7 +450,7 @@ ioi_nxt: djnz ioi_l pop bc ret - + endif ;(1/0) else @@ -484,7 +485,7 @@ ioml_lp: inc hl cp b jr z,ioml_e - + ld c,(hl) inc hl otimr @@ -571,6 +572,7 @@ l2p_i: ; ;out ahl: Phys. (linear) Address + public hwl2phy hwl2phy: push bc ; @@ -909,4 +911,3 @@ mark_55AA equ 0 - 2 - 4 ;2 byte for trap stack end -