X-Git-Url: http://cloudbase.mooo.com/gitweb/z180-stamp-cpm3.git/blobdiff_plain/50f3b8f0cb6ccbdc5c1ea8f916f3d95b197d3d04..aa1cd3a9e22307c7f0733c3c80c85d3329f5038b:/cbios/bioskrnl.180 diff --git a/cbios/bioskrnl.180 b/cbios/bioskrnl.180 index f2cfde8..989b53c 100644 --- a/cbios/bioskrnl.180 +++ b/cbios/bioskrnl.180 @@ -2,8 +2,8 @@ ; version 1.0 15 Sept 82 - include config.inc - include z180reg.inc + maclib z180reg.inc + maclib config.inc ; Copyright (C), 1982 @@ -44,6 +44,7 @@ ccp equ 0100h ; Console Command Processor gets loaded extrn ?ci,?co,?cist,?cost ; each take device in extrn ?cinit ; (re)initialize device in + extrn ioctl extrn @ctbl ; physical character device table ; disk communication data items @@ -51,6 +52,7 @@ ccp equ 0100h ; Console Command Processor gets loaded extrn @dtbl ; table of pointers to XDPHs public @adrv,@rdrv,@trk,@sect ; parameters for disk I/O public @dma,@dbnk,@cnt ; '' '' '' '' + public @xdph,@op ; memory control @@ -62,18 +64,22 @@ ccp equ 0100h ; Console Command Processor gets loaded extrn ?time ; signal time operation - include modebaud.inc ; define mode bits + extrn stampf + extrn ijphl ; vectored call + + maclib modebaud.inc ; define mode bits ; External names for BIOS entry points - public ?boot,?wboot,?const,?conin,?cono,?list,?auxo,?auxi + public ?boot,?wboot,boot,?const,?conin,?cono,?list,?auxo,?auxi public ?home,?sldsk,?sttrk,?stsec,?stdma,?read,?write public ?lists,?sctrn public ?conos,?auxis,?auxos,?dvtbl,?devin,?drtbl public ?mltio,?flush,?mov,?tim,?bnksl,?stbnk,?xmov - public bs$stack + extrn bs$stack + extrn _b0hlcall ; BIOS Jump vector. @@ -118,9 +124,17 @@ ccp equ 0100h ; Console Command Processor gets loaded ?stbnk: jp setbnk ; select different bank for disk I/O DMA operations ?xmov: jp ?xmove ; set source and destination banks for one operation + jp stampf ; stamp system specific functions + ; reserved for system implementor jp 0 ; reserved for future expansion jp 0 ; reserved for future expansion - jp 0 ; reserved for future expansion +?ioctl jp ioctl ; + + + rept 32 + db '|' + endm +boot$stack: ; BOOT @@ -129,6 +143,10 @@ ccp equ 0100h ; Console Command Processor gets loaded dseg ; this part can be banked boot: + ld a,SYS$CBR + out0 (cbr),a + ld a,USR$CBAR + out0 (cbar),a ld sp,bs$stack call hwinit ; first time hardware initialisation @@ -156,27 +174,13 @@ d$init$loop: or d jr z,d$init$next ; if null, no drive push hl ; save @drv pointer - if 0 - ex de,hl ; XDPH address in - dec hl - dec hl - ld b,(hl) ; get relative drive code - ld (@ADRV),bc ; save absolute and relative drive code - dec hl ; point to init pointer - ld d,(hl) - dec hl - ld e,(hl) ; get init pointer - ex de,hl - call ipchl ; call init routine - else push de - pop ix + pop ix ; XDPH address in ld b,(ix-2) ld (@ADRV),bc ; save absolute and relative drive code ld l,(ix-4) ld h,(ix-3) ; get init pointer - call ipchl ; call init routine - endif + call ijphl ; call init routine pop hl ; recover @drv pointer d$init$next: pop bc ; recover counter and drive # @@ -187,6 +191,7 @@ d$init$next: cseg ; following in resident memory boot$1: + ld sp,boot$stack call set$jumps call ?ldccp ; fetch CCP for first time jp ccp @@ -196,7 +201,7 @@ boot$1: ; Entry for system restarts. wboot: - ld sp,bs$stack + ld sp,boot$stack call set$jumps ; initialize page zero call ?rlccp ; reload CCP jp ccp ; then reset jmp vectors and exit to ccp @@ -219,9 +224,6 @@ set$jumps: ret - ds bs$stack$size -bs$stack equ $ - ; DEVTBL ; Return address of character device table @@ -240,13 +242,12 @@ getdrv: - ; CONOUT - ; Console Output. Send character in - ; to all selected devices - -conout: + ; LIST + ; List Output. Send character in + ; to all selected devices. - ld hl,(@covec) ; fetch console output bit vector +list: + ld hl,(@lovec) ; fetch list output bit vector jr out$scan @@ -259,12 +260,13 @@ auxout: jr out$scan - ; LIST - ; List Output. Send character in - ; to all selected devices. + ; CONOUT + ; Console Output. Send character in + ; to all selected devices -list: - ld hl,(@lovec) ; fetch list output bit vector +conout: + + ld hl,(@covec) ; fetch console output bit vector out$scan: ld b,0 ; start with device 0 @@ -272,13 +274,7 @@ co$next: add hl,hl ; shift out next bit jr nc,not$out$device push hl ; save the vector -; push bc ; save the count and character -;not$out$ready: -; call coster -; or a -; jr z,not$out$ready -; pop bc - push bc ; restore and resave the character and device + push bc ; save device num and the character call ?co ; if device selected, print it pop bc ; recover count and character pop hl ; recover the rest of the vector @@ -290,13 +286,13 @@ not$out$device: ret - ; CONOST - ; Console Output Status. Return true if - ; all selected console output devices + ; LISTST + ; List Output Status. Return true if + ; all selected list output devices ; are ready. -conost: - ld hl,(@covec) ; get console output bit vector +listst: + ld hl,(@lovec) ; get list output bit vector jr ost$scan @@ -310,13 +306,13 @@ auxost: jr ost$scan - ; LISTST - ; List Output Status. Return true if - ; all selected list output devices + ; CONOST + ; Console Output Status. Return true if + ; all selected console output devices ; are ready. -listst: - ld hl,(@lovec) ; get list output bit vector +conost: + ld hl,(@covec) ; get console output bit vector ost$scan: ld b,0 ; start with device 0 @@ -325,7 +321,7 @@ cos$next: push hl ; save the vector push bc ; save the count ld a,0FFh ; assume device ready - call c,coster ; check status for this device + call c,?cost ; check status for this device pop bc ; recover count pop hl ; recover bit vector or a ; see if device ready @@ -337,38 +333,6 @@ cos$next: or 0FFh ; all selected were ready, return true ret - ; check for output device ready, including optional - ; xon/xoff support -coster: - ld l,b - ld h,0 ; make device code 16 bits - push hl ; save it in stack - add hl,hl - add hl,hl - add hl,hl ; create offset into device characteristics tbl - ld de,@ctbl+6 - add hl,de ; make address of mode byte - ld a,(hl) - and mb$xon$xoff - pop hl ; recover console number in - jp z,?cost ; not a xon device, go get output status direct - ld de,xofflist - add hl,de ; make pointer to proper xon/xoff flag - call cist1 ; see if this keyboard has character - ld a,(hl) - call nz,ci1 ; get flag or read key if any - cp ctlq - jr nz,not$q ; if its a ctl-Q, - ld a,0FFh ; set the flag ready -not$q: - cp ctls - jr nz,not$s ; if its a ctl-S, - ld a,00h ; clear the flag -not$s: - ld (hl),a ; save the flag - call cost1 ; get the actual output status, - and (hl) ; and mask with ctl-Q/ctl-S flag - ret ; return this as the status cist1: ; get input status with and saved push bc @@ -379,22 +343,15 @@ cist1: ; get input status with and saved or a ret -cost1: ; get output status, saving & - push bc - push hl - call ?cost - pop hl - pop bc - or a - ret -ci1: ; get input, saving & - push bc - push hl - call ?ci - pop hl - pop bc - ret + ; AUXIST + ; Auxiliary Input Status. Return true if + ; any selected auxiliary input device + ; has an available character. + +auxist: + ld hl,(@aivec) ; get aux input bit vector + jr ist$scan ; CONST @@ -404,31 +361,28 @@ ci1: ; get input, saving & const: ld hl,(@civec) ; get console input bit vector - jr ist$scan - - - ; AUXIST - ; Auxiliary Input Status. Return true if - ; any selected auxiliary input device - ; has an available character. - -auxist: - ld hl,(@aivec) ; get aux input bit vector ist$scan: ld b,0 ; start with device 0 cis$next: - add hl,hl ; check next bit - ld a,0 ; assume device not ready - call c,cist1 ; check status for this device - or a + xor a ; assume next device not ready + add hl,hl ; check next bit (lets z flag unaffected) + call c,cist1 ; check status for this device ret nz ; if any ready, return true inc b ; next device number ld a,h or l ; see if any more selected devices - jr nz,cis$next - xor a ; all selected were not ready, return false - ret + ret z ; all selected were not ready, return false + jr cis$next + + + ; AUXIN + ; Auxiliary Input. Return character from first + ; ready auxiliary input device. + +auxin: + ld hl,(@aivec) + jr in$scan ; CONIN @@ -437,24 +391,33 @@ cis$next: conin: ld hl,(@civec) - jr in$scan - - ; AUXIN - ; Auxiliary Input. Return character from first - ; ready auxiliary input device. + ;check if only one device assigned -auxin: - ld hl,(@aivec) + push hl ; save bit vector + ld b,0 +insc_0: + or a ; clear carry + adc hl,hl ; shift out next bit + jr nc,insc_1 ; + jr z,ci$rdy ; single device + jr ci$check ; + +insc_1: + inc b ; else, next device + ld a,h + or l ; see if any more devices + jr nz,insc_0 ; no, + pop hl in$scan: push hl ; save bit vector ld b,0 ci$next: + xor a ; assume next device not ready add hl,hl ; shift out next bit - ld a,0 ; insure zero a (nonexistant device not ready). +ci$check: call c,cist1 ; see if the device has a character - or a jr nz,ci$rdy ; this device has a character inc b ; else, next device ld a,h @@ -471,12 +434,6 @@ ci$rdy: ;------------------------------------------------------------------------------- ; Utility Subroutines - -ipchl: ; vectored CALL point - jp (hl) - - - ; BNKSEL ; Bank Select. Select CPU bank for further execution. @@ -485,11 +442,6 @@ bnksel: jp ?bank ; and go exit through users ; physical bank select routine - -xofflist: - db -1,-1,-1,-1,-1,-1,-1,-1 ; ctl-s clears to zero - db -1,-1,-1,-1,-1,-1,-1,-1 - dseg ; following resides in banked memory ; Disk I/O interface routines @@ -505,7 +457,10 @@ xofflist: seldsk: ld a,c ; save drive select code ld (@adrv),a - ld b,0 ; create index from drive code + xor a + ld (@op),a + ld (@cnt),a + ld b,a ; create index from drive code ld hl,@dtbl add hl,bc ; get pointer to dispatch table add hl,bc @@ -517,19 +472,23 @@ seldsk: or h ret z ; if no entry in table, no disk - ld a,e ; examine login bit - and 1 - ret nz - - push ix - ld ix,(@xdph) - ld a,(ix-2) - ld (@RDRV),a ; get relative drive - ld l,(ix-6) ; get address of LOGIN routine - ld h,(ix-5) - ex (sp),ix - pop de - call ipchl ; call LOGIN + bit 0,e ; login bit to zero flag + ex de,hl + ld hl,-2 ; get relative drive + add hl,de + ld a,(hl) + ld (@RDRV),a + jr nz,notfirst ; examine login bit + + ld hl,-6 ; call LOGIN + add hl,de + ld a,(hl) + inc hl + ld h,(hl) + ld l,a + call _b0hlcall + +notfirst: ld hl,(@xdph) ; recover DPH pointer ret @@ -606,11 +565,14 @@ sectrn: ; extended disk parameter header (XDPH). read: + ld a,1 + ld (@op),a ld ix,(@xdph) ; get drive descriptor pointer ld l,(ix-8) ; get read routine entry ld h,(ix-7) - jp (hl) + call _b0hlcall + ret ; WRITE ; Write physical sector from currently selected drive. @@ -618,10 +580,14 @@ read: ; extended disk parameter header (XDPH). write: + ld a,2 + ld (@op),a ld ix,(@xdph) ; get drive descriptor pointer ld l,(ix-10) ; get write routine entry ld h,(ix- 9) - jp (hl) + + call _b0hlcall + ret @@ -646,6 +612,7 @@ flush: ; do not change order. sd driver depends on this @xdph: ds 2 ; pointer to currently selected drives dph +@op ds 1 ; current disk operation 0:select, 1:read, 2 write @adrv: ds 1 ; currently selected disk drive @rdrv: ds 1 ; controller relative disk drive @trk: ds 2 ; current track number @@ -659,5 +626,4 @@ flush: @cbnk: db 0 ; bank for processor operations - end