title 'Boot loader module for CP/M 3.0' public hwinit,?init,?ldccp,?rlccp extrn ?boot,?pmsg,?conin extrn ioini1l,msginit,mmuinit,intinit extrn @civec,@covec,@aivec,@aovec,@lovec extrn @cbnk,?bnksl include config.inc include z180reg.inc bdos equ 5 ccpsize equ 0c80h if banked tpa$bank equ 1 else tpa$bank equ 0 endif dseg ; init done from banked memory hwinit: ld a,(INIDONE) cp INIDONEVAL jr z,hwini_skip ld hl,hwini_tab call ioini1l ld a,0c3h ld hl,?boot ld (0),a ld (1),hl hwini_skip: call mmuinit ; setup mmu registers call msginit ret ?init: ld hl,0100000000000000b ; 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 (@aivec),hl ld (@aovec),hl call intinit ; setup interrupts and vectors xor a ld (@cbnk),a ; right now in bank 0 ld hl,signon$msg call ?pmsg ; print signon message ret cseg ; boot loading most 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:). ?ldccp: ; First time, load the A:CCP.COM file into TPA xor a ld (ccp$fcb+15),a ; zero extent ld hl,0 ld (fcb$nr),hl ; start at beginning of file ld de,ccp$fcb call open ; open file containing CCP inc a jp z,no$ccp ; error if no file... ld de,0100h call setdma ; start of TPA ld de,128 call setmulti ; allow up to 16k bytes 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 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 ?rlccp: 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 ret ; 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 ccp$fcb:db 1,'CCP ','COM',0,0,0,0 ds 16 fcb$nr: db 0,0,0 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 hwini0_e: db 0 ;stop mark end