X-Git-Url: http://cloudbase.mooo.com/gitweb/z180-stamp-cpm3.git/blobdiff_plain/ea5293bb6ce484bf1ec9ab70befe10c3a36a70c2..afbcea2d821d1166ae347338ae52a64f3ee51e57:/cbios/boot.180 diff --git a/cbios/boot.180 b/cbios/boot.180 index 0e36bcd..566f190 100644 --- a/cbios/boot.180 +++ b/cbios/boot.180 @@ -3,20 +3,32 @@ public hwinit,?init,?ldccp,?rlccp + public f_cpu - extrn ?boot,?pmsg,?conin - extrn ioini1l,msginit,mmuinit,intinit + extrn boot,?conin + extrn pr.inln,pr.crlf,pr.dec,pr.decl + extrn ioini1l,msginit,mmuinit,intinit,cpu_frq + extrn prt0ini,gs_rtc extrn @civec,@covec,@aivec,@aovec,@lovec - extrn @cbnk,?bnksl + extrn @cbnk,?move,?xmove - include config.inc - include z180reg.inc + maclib z180reg.inc + maclib config.inc + maclib version.inc -bdos equ 5 - ccpsize equ 0c80h + ; CP/M BDOS Function Interfaces + +resetdsk equ 13 +open equ 15 +read equ 20 +setdma equ 26 +setmulti equ 44 +bdos equ 5 + + if banked tpa$bank equ 1 else @@ -28,136 +40,107 @@ tpa$bank equ 0 hwinit: ld a,(INIDONE) + and 80h cp INIDONEVAL jr z,hwini_skip ld hl,hwini_tab call ioini1l ld a,0c3h - ld hl,?boot + ld hl,boot ld (0),a ld (1),hl hwini_skip: - call mmuinit ; setup mmu registers call msginit + call cpu_frq + ld (f_cpu),hl + ld (f_cpu+2),de + call intinit ; setup interrupts and vectors ret ?init: - ld hl,0100000000000000b ; assign console to ASCI1: +; ld hl,1000000000000000b ; assign console to AVRCON: + ld hl,0010000000000000b ; assign console to ASCI1: ld (@civec),hl ld (@covec),hl ld hl,0000000000000000b ; assign printer to nothing: ld (@lovec),hl - ld hl,0100000000000000b ; assign AUX to ASCI0: + ld hl,0000000000000000b ; assign AUX to ASCI0: ld (@aivec),hl ld (@aovec),hl - call intinit ; setup interrupts and vectors + call prt0ini ; init timer + ei + ld c,2 + call gs_rtc ; get time and date xor a - ld (@cbnk),a ; right now in bank 0 - - ld hl,signon$msg - call ?pmsg ; print signon message + ld (@cbnk),a ; right now in bank 0 + + call pr.inln ; print signon message + db 13,10,13,10,'CP/M Version 3.0, Z180-Stamp BIOS v' + defvers + db 13,10 + db 'Estimated CPU clock [Hz]: ',0 + + ld hl,(f_cpu) + ld de,(f_cpu+2) + call pr.decl + call pr.crlf ret - cseg ; boot loading most be done from resident memory + cseg ; boot loading must be done from resident memory ; This version of the boot loader loads the CCP from a file ; called CCP.COM on the system drive (A:). - + ; First time, load the A:CCP.COM file into TPA ?ldccp: - ; First time, load the A:CCP.COM file into TPA + ld c,resetdsk + call bdos xor a - ld (ccp$fcb+15),a ; zero extent + ld (ccp$fcb+15),a ; zero extent ld hl,0 - ld (fcb$nr),hl ; start at beginning of file + ld (fcb$nr),hl ; start at beginning of file ld de,ccp$fcb - call open ; open file containing CCP + ld c,open ; open file containing CCP + call bdos inc a - jp z,no$ccp ; error if no file... + jp z,no$ccp ; error if no file... ld de,0100h - call setdma ; start of TPA + ld c,setdma ; start of TPA + call bdos ld de,128 - call setmulti ; allow up to 16k bytes + ld c,setmulti ; allow up to 16k bytes + call bdos ld de,ccp$fcb - call read ; load the thing - ; now, - ; copy CCP to bank 0 for reloading - ld hl,0100h - ld bc,ccpsize ; clone 3K, just in case - ld a,(@cbnk) - push af ; save current bank -ld$1: - ld a,tpa$bank - call ?bnksl ; select TPA - ld a,(hl) - push af ; get a byte - ld a,2 - call ?bnksl ; select extra bank - pop af - ld (hl),a ; save the byte - inc hl - dec bc ; bump pointer, drop count - ld a,b - or c ; test for done - jp nz,ld$1 - pop af - call ?bnksl ; restore original bank - ret + ld c,read ; load the thing + call bdos ; read records -no$ccp: ; here if we couldn't find the file - ld hl,ccp$msg - call ?pmsg ; report this... - call ?conin ; get a response - jp ?ldccp ; and try again + ; now, copy CCP to bank 0 for reloading + ld bc,2*256 + tpa$bank ; c: src$bnk, b: dst$bnk + jr mov_ccp + ; just copy in the other direction ?rlccp: + ld bc,tpa$bank*256 + 2 ; c: src$bnk, b: dst$bnk +mov_ccp: + call ?xmove ld hl,0100h - ld bc,ccpsize ; clone 3K -rl$1: - ld a,2 - call ?bnksl ; select extra bank - ld a,(hl) - push af ; get a byte - ld a,tpa$bank - call ?bnksl ; select TPA - pop af - ld (hl),a ; save the byte - inc hl - dec bc ; bump pointer, drop count - ld a,b - or c ; test for done - jp nz,rl$1 + ld d,h + ld e,l + ld bc,ccpsize ; clone 3K, just in case + call ?move ret +no$ccp: ; here if we couldn't find the file + call pr.inln ; report this... + db 13,10,'BIOS Err on A: No CCP.COM file',0 - ; CP/M BDOS Function Interfaces - -open: - ld c,15 - jp bdos ; open file control block - -setdma: - ld c,26 - jp bdos ; set data transfer address - -setmulti: - ld c,44 - jp bdos ; set record count - -read: - ld c,20 - jp bdos ; read records - - -signon$msg: - db 13,10,13,10,'CP/M Version 3.0, Z180-Stamp BIOS',13,10,0 - -ccp$msg:db 13,10,'BIOS Err on A: No CCP.COM file',0 + call ?conin ; get a response + jr ?ldccp ; and try again ccp$fcb:db 1,'CCP ','COM',0,0,0,0 @@ -165,15 +148,18 @@ ccp$fcb:db 1,'CCP ','COM',0,0,0,0 fcb$nr: db 0,0,0 + dseg hwini_tab: db (hwini0_e-$)/2 ;count db rcr,CREFSH ;configure DRAM refresh db dcntl,CWAITIO ;wait states db ccr,M_NCD ;No Clock Divide db cmr,PHI_X2 ;X2 Clock Multiplier -;TODO: db omr, ;Operation Mode Control Register + db omcr,~M_IOC ;Operation Mode Control Register hwini0_e: db 0 ;stop mark + cseg +f_cpu dw 0,0 ;detected CPU clock frequency [Hz] end