ndif fwritin:lda secsiz ;Check for 128 byte sectors dcr a ;(doesn't affect the carry flag) rz ;No deblocking (carry cleared by last ora) fread: mvi a,d$read sta rwop call prep ;Read the physical sector the buffer ret ;(carry and accm set by prep) ;Flush the Disk Buffer ;--------------------- ; Flush writes the contents of the buffer out to the disk if ; it has ever been written into. If there are any errors then ; the carry is returned set else it is cleared. ; flush: mvi a,0 ;The 0 is modified to reflect if bufwrtn equ $-1 ; the buffer has been written into ora a ;Test if written into rz ;Not written, all done (or clears the carry) mvi a,d$write sta rwop call prep ;Do the physical write ret ;(carry and accm set by prep) ;Prepare the Disk for Reading and/or Writing ;------------------------------------------- ; 1) This is actually the place where disks are read/written (contrary ; to the name of this routine) ; 2) Prep prepares to read/write the disk. Retries are attempted. ; If there are any errors then the carry is returned ; set and the location ERROR is set to 0FFh, else the carry is ; returned cleared ERROR is reset to zero. ; prep: call alt ;Check for alternate sectors di ;Resat interrupts xra a ;Reset buffer written flag sta bufwrtn mvi b,retries ;Maximum number of retries to attempt retrylp:push b ;Save the retry count mvi l,d$sel2 ;Select drive call jumpbuf lhld alttrk ;Track number -> (hl) mov b,h mov c,l mvi l,d$strk call jumpbuf lhld altsec ;Sector -> (hl) mov b,h mov c,l mvi l,d$ssec call jumpbuf lxi b,buffer ;Set the DMA address mvi l,d$sdma call jumpbuf mvi l,0 ;Get operation address offset (8 or 9) rwop equ $-1 ;(set by FREAD [read=8] and FLUSH [write=9]) call jumpbuf ;Read or write to the disk pop b ;Restore the retry counter mvi a,0 ;No error exit status jnc prpret ;Return NO ERROR (accm=0, carry=clear) dcr b ;Update the retry counter stc ;Assume retry count expired mvi a,0ffh ;Error return jz prpret ;Return ERROR (accm=ff, carry=set) mov a,b cpi retries/2 jnz retrylp ;Try again push b ;Save retry count mvi l,d$home ;Home drive after (retries/2) errors call jumpbuf pop b jmp retrylp ;Try again prpret: sta error ;save the error flag ret ;Access a lo-level driver subroutine ;----------------------------------- ; Jumpbuf, jumper are used to dispatch to a low level device ; subroutine. Jumper is called with the drive in (h) and the ; routine number (ree description above) in (l). It passes ; along the (bc) and (de) registers unaltered. Jumpbuf is ; a call to jumper with the drive number from bufdrv. ; ;Entry Point_1 jumpbuf:lda bufdrv ;Dispatch with bufdrv for drive mov h,a ;Entry Point_2 jumper: push d push b push h mov a,h ;Logical drive into (a) lxi d,dsttab ;Drive specification pointer table jumpl: mov c,a ;Save logical in (c) ldax d ;BYTE OF DST BEGINNING ADDRESS mov l,a ; inx d ldax d ;SECOND BYTE OF DST BEGINNING ADDRESS mov h,a ;Get a DST pointer in (hl) inx d ;READY FOR NEXT POINTER TO NEXT DST mov a,c ;Logical in (a) sub m ;Subtract from first entry in DST jnc jumpl ;Keep scanning table till correct driver found inx h ;Bump (hl) to point to start of dispatch table pop d ;Real (hl) -> (de) mov a,e ;Move offset number into (a) rlc ;Each entry is 2 bytes mov e,a ;Make an offset mvi d,0 dad d ;(hl) = **Routine mov a,m ;Pick up address of handler for selected inx h ; function mov h,m mov l,a ;(hl) = *routine mov a,c ;Logical in (a) pop b ;Restore saved registers pop d pchl ;Print a Message ;--------------- ;Utility routine to output the message pointed at by (hl) ;terminated with a null. ; message:mov a,m ;Get a character of the message inx h ;Bump text pointer ora a ;Test for end rz ;Return if done push h ;Save pointer to text mov c,a ;Output character in C call cout ;Outputved for future use. ; They must be zero. ; ; settle This word is similar to the previously defined ; step word. This specifies the head settle timing ; after the heads have been stepped. Example, ; Shugart's SA 850 head settle time is 15 ; milliseconds. The settle constant would be 15 * ; 34.1 or 512. ; ; 3) An assembler macro (DCONF) has been provided to assist in ; generatIng the dparam table. This macros parameters are the ; number of tracks, the step rate in milliseconds, and the head ; settle time in milliseconds. For example: ; ; ;Shugart SA 850 ; dconf 77, 3, 15 ;77 tracks, 3 ms step, 15 ms settle ; ; ;Shugart SA 400 ; dconf 35, 40, 10 ;35 tracks, 40 ms step, 10 ms settle ; ; 4) Note: Caution should be used when defining the drive parameters. ; Incorrect definations may damage the floppy disk drive. Morrow ; Designs takes no responsibility for damage that occures through ; the misuse of this macro. ; dconf macro tracks, step, settle db tracks ;Number of tracks db 0 ;Reset the calibrated flag dw step*341/10 ;Step time dw 0 ;Reserved for future use, must be zero dw 0 ;Reserved for future use, must be zero dw settle*341/10 ;Head settle time endm dmarap: db 0, 10*8 ;Revision 0, length 80 bytes dparam equ $ ;Drive parameter table ; ;Define 8" drive parameters ;-------------------------- ; 1) Use SA800 parameters: 77 tracks, 8 ms step, 8 ms settle ; dconf 77, 8, 8 ;Drive 0 dconf 77, 8, 8 ;Drive 1 dconf 77, 8, 8 ;Drive 2 dconf 77, 8, 8 ;Drive 3 ; ;Define 5.25" drive parameters ;----------------------------- ; 1) Use Tandon parameters: 40 tracks, 5 ms step, 15 ms settle ; 2) Note: Drive 1 is set up for a 20ms step rate and a 25ms head ; settling time so that it will operate properly with our ; soft-sectored drives. ; if mfslow dconf 40, 20, 20 ;Drive 0 dconf 40, 20, 20 ;Drive 1 dconf 40, 20, 20 ;Drive 2 dconf 40, 20, 20 ;Drive 3 else dconf 40, 5, 15 ;Drive 0 dconf 40, 5, 15 ;Drive 1 dconf 40, 5, 15 ;Drive 2 dconf 40, 5, 15 ;Drive 3 endif page ;DJDMA equates ;============= ; ;Define DJDMA i/o ports and default channel address ;-------------------------------------------------- ; dmchan equ 50h ;Default channel address dmkick equ 0efh ;Kick I/O port address serin equ 03eh ;Address of serial input data ;Define the channel commands ;--------------------------- ; dmrsec equ 20h ;Read sector command dmwsec equ 21h ;Write a sector command dmstac equ 22h ;Get drive status dmsdma equ 23h ;Set DMA address intrqc equ 24h ;Set Interrupt request dmhalt equ 25h ;Halt command bracha equ 26h ;Channel branch setcha equ 27h ;Set channel address dmserr equ 28h ;Set CRC retry count rdtrck equ 29h ;Read track command wrtrck equ 2Ah ;Write track command serout equ 2Bh ;Serial character ouput senabl equ 2Ch ;Enable/disable serial input trksiz equ 2Dh ;Set number of tracks dmsetl equ 2Eh ;Set logical drives readm equ 0A0h ;Read from controller memory writem equ 0A1h ;Write to controller memory ;Define stepping rate equates ;---------------------------- ; dmfste equ 3*341/10 ;SA851 stepping rate constant dmfset equ 15*341/10 ;SA851 settling rate constant ;Define Internal status byte fields ;---------------------------------- ; dms$t0 equ 01000000b ;Track 0 status mask (1 = on trk 0) dms$dd equ 00100000b ;Double density mask (1 = double) dms$wr equ 00010000b ;Double sided track wrap (1 = wrap) dms$ds equ 00001000b ;Double sided status mask (1 = double) dms$hs equ 00000100b ;Hard sectored status mask (1 = hard) dms$ss equ 00000011b ;Sector size code mask ... ;... 0 = 128, 1 = 256, 2 = 512, 3 = 1024 ;Define North Star status byte fields ;------------------------------------ ; dmn$dд eqх 10000000в ;Doublе densitщ mask dmn$ds equ 01000000b ;Double sided mask dmn$2x equ 00100000b ;CP/M version 2.x mask dmn$ok equ 00010000b ;Validation mask dmn$40 equ 00001000b ;40/80 track mask dmn$dt equ 00000100b ;Double track density mask dmn$xx equ 00000011b ;RFU mask ;Common Subroutines ;------------------ ; Return a pointer to the current drives drive parameter entry ;------------------------------------------------------------- ; dmdpar: lhld dmdriv ;Get the current drive number mvi h,0 ;Drive number is a byte dad h ;Ten bytes per parameter table entry mov d,h mov e,l dad h dad h dad d lxi d,dparam ;Parameter table address dad d ret page if maxdm ne 0 ;Start 8" drive's unique code section ;==================================================================== ;Devicе Specificatioо Tablе foт DJDMA controlleт witи ё" drives ;============================================================== ; dmdst: db maxdm ;Number of logical drives dw dmwarm ;Warm boot dw dmtran ;Sector translation dw dmldr1 ;Select drive 1 dw dmldr2 ;Select drive 2 dw dmhome ;Home drive dw dmseek ;Seek to specified track dw dmsec ;Set sector dw dmdma ;Set DMA address dw dmread ;Read a sector dw dmwrit ;Write a sector dw nobad ;No bad sector map if 1 EQ 1 ;dmorder ne 1 ;no warm boot possible ;DJDMA 8" warm boot dummy ;------------------------ ; 1) If 8" DJDMA is not drive A (i.e. dmorder not equal 1) then ; it is not possible to warm boot from 8". So routine not needed. ; dmwarm: ret ;return if called else ;DJDMБ 8ў warн booф loader ;------------------------- ; 1) Thiу loadeт loadу froн thе starф oж thе CCР (tracл ° sectoт 5© ; tп thе enд oж thе BDOУ (tracл ± sector 3)® Onlщ 76ё (3/4k© byteу ; oж tracл ± sectoт і iу reaд iо since thе warн booф routinе iу ; noф alloweд tп loaд anщ thе CBIOУ code. ; 2) Sectoт і iу reaд intп thе disл buffeт anд copieд intп itу propeт ; restinз place. ; dmcod8 equ 22*128 ;Amount of code on track 0 to load dmwarm: call dmsel2 ;Select drive 0 dmwbad: lxi h,dmwchn ;Warm boot command channel lxi d,dmwoff call dmcmd ;Exgcute the channel jnz dmwbad ;Retry lda dmwst0 ;Get track read status lhld dmwst1 ;Track ones status in L ora l cpi 40h jnz dmwbad ;Loop on 'terrible' errors like no disk lxi b,300h ;Move .75 Kbytes of sector 3 lxi d,buffer ;Sector 3 is in our buffer lxi h,ccp+1300h ; and this is where we want it to go call movbyt xra a ret dmwchn: db dmsdma ;Set track 0 DMA address dw ccp-512 ;First track DMA address - boot loader db 0 db rdtrck ;Read track command db 0 ;Track 0 db 0 ;Side 0 db 0 ;Drive 0 dw dmwmap ;Sector load/status map db 0 dmwst0: db 0 ;Track read status db dmsdma dw ccp+dmcod8 ;DMA address for track 1 db 0 db rdtrck db 1 ;Track 1 db 0 ;Side 0 db 0 ;Drive 0 dw dmwmap+26 ;Load map right after track 0 map db 0 dmwst1: db 0 ;Track read status db dmsdma dw buffer ;Sector 3 gets loaded in system buffer db 0 db dmrsec db 1 ;Track 1 db 3 ;Side 0, sector 3 db 0 ;Drive 0 db 0 ;Read status db dmhalt ;Controller halt command db 0 dmwoff equ $-dmwchn-1 ;Halt offset for the command channel dmwmap: dw -1, -1, 0, 0, 0, 0, 0 ;Do not load the boot loader dw 0, 0, 0, 0, 0, 0 dw 0, -1, -1, -1 ;First 2 sectors on track 2 endif ;end of 8" DJDMA warm boot ;DJDMA 8" sector translation ;--------------------------- ; dmtran: inx b ;Ajust sectors to start at 1 lda dmpsta ;Test for double sided drives ani dms$ds jz dmtrn0 ;Skip if single sided lda dmcspt ;Get SPT/2 sub c ;Test for side one sectors jnc dmtrn0 ;Skip sector adjustment if on side zero cma ;'Knock off' first sides sectors inr a mov c,a mvi b,80h ;Set side one flag dmtrn0: mov l,c ;Make an index to the SECTRAN table mvi h,0 dad d mov l,m ;Load the translated sector mov h,b ;Set the side bit ret ;DJDMБ 8ў drivе selecф 1 ;----------------------- ; 1) Determinе thе sectoт sizе anд thе numbeт oж sideу oо thе drive® ; 2) Returо correcф DPH. ; dmldr1: call dmsel2 ;Do logical select call dminit ;Test fovi a,0a9h ;double sided config byte jnz mfld1 ;skip if double sided mfsft: mvi a,0a1h ;Morrow Soft sectored floppy jmp mfld1 mfld0: call mfrds1 ;get sector 1 of track 0 lda buffer+5Ch ;Get the North Star configuration byte mfld1: ora a ;Old CP/M 1.4 systems did not have a cz mflcl ; configuration byte. This routine cpi 0E5h ; will make a configuration byte for cz mflcl ; these systems. mov c,a lxi h,mfs ;Pointer to configuration table mfld2: mov a,m ;Get an entry ora a ;Check for end of the table jz zret ;Yes, select error cmp c ;Check if entry matches selected drive jz mfld3 ;Match, get entry inx h ;Skip to the next entry inx h inx h inx h jmp mfld2 mfld3: inx h ;Bump to the true configuration byte lda dmpsta ;Get the physical status ora m ;Fill in the fields the hardware can't sta dmpsta ; figure out push h call dmsptr ;Load the status byte into the table mov m,a pop h inx h ;Bump to the DPB pointer mov a,m ;Load the DPB pointer inx h mov h,m mov l,a push h ;Save DPB address call mfgdph ;Get a DPH pointer lxi d,10 ;Offset to DPB address in DPH dad d pop d mov m,e ;Store DPB address in DPH inx h mov m,d call mfgdph ;Get the DPH pointer lda dmpsta ;Get physical status ani dms$ss ;Mask sector size field inr a ;Make CBIOS sector size code mov c,a ret ; ; routine called by first time select to read sector 1 track 0 ; for disk configuration byte checks for hard/soft sectored ; minifloppies. ; mfrds1: lxi h,1 ;Select sector 1 of track 0 shld truesec dcx h shld cpmtrk xra a ;Make sure we are doing a read sta rdwr call fill ;Flush buffer and refill rnc ;return if no error pop h ;flush return address jmp zret ;do error return ; Get the configuration byte for a North Star Disk ;------------------------------------------------- ; 1) This routine is only used by MFLDR1: (mini-floppy first time ; select ; 2) Nortи Staт configuratioо bytе valuе iу ° oт aо E5® Checл ; physicaм disл densitщ anд generatе correcф configuratioо bytе ; value. ; mflcl: lda dmpsta ;Get physical status ani dms$dd ;Test the double density bit mvi a,10h ;CP/M 1.4 single density configuration rz mvi a,90h ;CP/M 1.4 double density configuration ret ; Return a pointer to the current drives DPH ;------------------------------------------- ; 1) This routine is only used by MFLDR1: (mini-floppy first time ; select ; mfgdph: lda dmdriv ;Get the current drive sui 4 ;5.25 drives start at drive 4 lxi d,dphmf0 call retdph ret ;Selecф drivе #І ;--------------- ; 1) Thiу driveт configureу thе µ 1/ґ" driveу aу driveу ґ tп 7. ; mfsel2: adi 4 ;5.25" drives are drives 4-7 jmp dmsel2 ;Seф track ;--------- ; 1) Nortи Staт implementу doublе sideд driveу bщ doublinз ; thе numbeт oж trackу tп 70® Trackу ° tп 3ґ arе oо sidе ° likе б ; singlе sideд floppy® Trackу 3µ tп 6№ arе oо sidе ± iо reverse ; (e.g® Tracл 3µ iу oо tracл 3ґ sidе 1 and tracл 6№ iу oо tracл ° ; sidе 1). ; mfseek: xra a ;Clear double sided select flag sta mfsid1 lxi h,dmpsta ;Get the drive status mov a,m ani dms$hs ;Test for hard sectored drives jz dmsoft ;Skip if soft sectored mov a,m ;Test for double sided drives ani dms$ds jz dmseek ;Skip if single sided mov a,m ;Test for track wrap mode ani dms$wr jz dmseek ;Skip if not wrapping mov a,c ;Test for tracks 35-69 cpi 35 jc dmseek ;Skip if less than track 35 mvi a,69 ;Adjust tracks 35 -> 69 to 34 -> 0 sub c mov c,a mvi a,080h ;Set side one flag sta mfsid1 jmp dmseek dmsoft: mov a,m ;get drive status again ani dms$ds ;check for double sided (cy = 0) jz dmseek ;skip if not double sided mov a,c ;get track number rar ;divide by 2 for Morrow soft sectored mov c,a jnc dmseek ;skip if on side 1 mvi a,80h sta mfsid1 ;else indicate side 2 jmp dmseek ;DJDMA 5.25" set sector ;---------------------- ; mfssec: lda dmpsta ;if (drive .eq. soft_sectored) ani dms$hs ; goto sector save routine jz dmsec ;else dcr c ; adjust for first sect = zero jmp dmsec ;DJDMA 5.25" read/write sector ;----------------------------- ; mfread: call mfset ;Set up side flag jmp dmread mfwrit: call mfset ;Set up side flag jmp dmwrit mfset: lda mfsid1 ;Get the side flag lxi h,dmsctr ;Merge with the sector number ora m mov m,a ret ;DJDMA 5.25" driver variables ;---------------------------- ; ;Mini-Floppy Configuration/DPB_Lookup table ; 1) This table is used by the mini-floppy first time select routine ; (mfsldr1) and is used to: ; a) validate the drive configuration byte. ; b) fill in the parameters that can't be determined by doing ; sense drive status (like sensing double sided drives). ; c) returning a pointer to the proper DPB for the media. ; 2) There are four fields per entry. ; Field_1: Drive configuration byte. ; Field_2: Additional drive parameters that can't be determined ; by doing a sense drive status (i.e. double_sided and ; track_wrap). ; Field_3: Pointer to the appropriate DPB ; mfs: db 10h ;North Star CP/M 1.4 db 0 ;Single density, 35 tracks, 1-sided dw dpbmf0 ;1K groups db 90h ;North Star CP/M 1.4 db 0 ;Double density, 35 tracks, 1-sided dw dpbmf1 ;1K groups db 0b0h ;North Star CP/M 2.x db 0 ;Double density, 35 tracks, 1-sided dw dpbmf2 ;2K groups db 0f0h ;North Star CP/M 2.x db (dms$ds or dms$wr) ;Double density, 35 tracks, 2-sided dw dpbmf3 ;2K groups db 0a0h ;North Star CP/M 2.x (fake 40 track) db 0 ;Double density, 35 tracks, 1-sided dw dpbmf2 ;2K groups db 0d0h ;North Star CP/M 2.x (fake 40 track) db (dms$ds or dms$wr) ;Double density, 35 tracks, 2-sided dw dpbmf3 ;2K groups db 0a1h ;Morrow Designs CP/M 2.x Soft sectored db 0 ;Double density, 40 tracks, 1-sided dw dpbmf4 db 0a9h ;Morrow Designs CP/M 2.x Soft sectored db dms$ds ;Double density, 40 tracks, 2-sided dw dpbmf5 db 0 ;End of configuration table ; Hard sectored single sided sector translation table ; mfxlts: db 1, 2 db 3, 4 db 5, 6 db 7, 8 db 9, 10 db 11, 12 db 13, 14 db 15, 16 db 17, 18 db 19, 20 ; Hard sectored double sided sector translation table ; mfxltd: db 1, 2, 3, 4 db 21, 22, 23, 24 db 5, 6, 7, 8 db 25, 26, 27, 28 db 9, 10, 11, 12 db 29, 30, 31, 32 db 13, 14, 15, 16 db 33, 34, 35, 36 db 17, 18, 19, 20 db 37, 38, 39, 40 ; Soft sectored single sided translation table ; mfxlt1: db 1, 2, 3, 4, 5, 6, 7, 8 db 25, 26, 27, 28, 29, 30, 31, 32 db 9, 10, 11, 12, 13, 14, 15, 16 db 33, 34, 35, 36, 37, 38, 39, 40 db 17, 18, 19, 20, 21, 22, 23, 24 mfsid1: db 0 ;On side one flag ;disk parameter headers ;---------------------- ; if maxmf ge 1 dphmf0: dw 0 ;translation table address dw 0 dw 0 dw 0 dw dirbuf ;directory buffer dw dpbmf0 ;pointer to disk parameter block dw csvmf0 ;scratch pad area for checking changed disks dw alvmf0 ;scratch pad for allocation information endif if maxmf ge 2 dphmf1: dw 0 ;translation table address dw 0 dw 0 dw 0 dw dirbuf ;`irectory buffer dw dpbmf1 ;pointer to disk parameter block dw csvmf1 ;scratch pad area for checking changed disks dw alvmf1 ;scratch pad for allocation information endif if maxmf ge 3 dphmf2: dw 0 ;translation table address dw 0 dw 0 dw 0 dw dirbuf ;directory buffer dw dpbmf2 ;pointer to disk parameter block dw csvmf2 ;scratch pad area for checking changed disks dw alvmf2 ;scratch pad for allocation information endif if maxmf ge 4 dphmf3: dw 0 ;translation table address dw 0 dw 0 dw 0 dw dirbuf ;directory buffer dw dpbmf3 ;pointer to disk parameter block dw csvmf3 ;scratch pad area for checking changed disks dw alvmf3 ;scratch pad for allocation information endif ;disk parameter buffers ;--------db dmhalt ;Controller halt command db 0 ;Status ;Write a drive's constants into the controller's memory ;------------------------------------------------------ ; dmwcon: db writem ;Write track size dmntrk: dw 0 ;Number of tracks + desync db 0 ;X-address dw 2 ;Two bytes dmloc0: dw 0 ;Local controller address db writem ;Write stepping rate data dmspar: dw 0 ;Pointer to the stepping parameters db 0 dw 8 dmloc1: dw 0 db dmhalt ;Controller halt db 0 ;Status ;Driver variables ;---------------- ; dmpsta: db 0 ;Physical status for the current drive dmstbl: db 0,0,0,0,0,0,0,0 ;Physical status bytes for each drive endif ;End of djdma routines page if maxfd ne 0 ;Include Discus 2D ? ;*********************************************************** ; Begin the DJ2DB Driver (DDRV2) ;******************************* ; ;DJ2DB equates ;------------- ; 1) The following equates relate the Morrow Designs 2D/B ; controller. If the controller is non standard (0F800H) ; only the FDORIG equate need be changed. ; ; --NOTE-- 'fdorig' equate moved to top of source module ;fdorig equ 0xxxxh ;Origin of Disk Jockey PROM fdboot equ fdorig+00h ;Disk Jockey 2D initialization fdcin equ fdorig+03h ;Disk Jockey 2D character input routine fdcout equ fdorig+06h ;Disk Jockey 2D character output routine fdhome equ fdorig+09h ;Disk Jockey 2D track zero seek fdseek equ fdorig+0ch ;Disk Jockey 2D track seek routine fdsec equ fdorig+0fh ;Disk Jockey 2D set sector routine fddma equ fdorig+12h ;Disk Jockey 2D set DMA address fdread equ fdorig+15h ;Disk Jockey 2D read routine fdwrite equ fdorig+18h ;Disk Jockey 2D write routine fdsel equ fdorig+1bh ;Disk Jockey 2D select drive routine fdtstat equ fdorig+21h ;Disk Jockey 2D terminal status routine fdstat equ fdorig+27h ;Disk Jockey 2D status routine fderr equ fdorig+2ah ;Disk Jockey 2D error, flash led fdden equ fdorig+2dh ;Disk Jockey 2D set density routine fdside equ fdorig+30h ;Disk Jockey 2D set side routine fdram equ fdorig+400h ;Disk Jockey 2D RAM address dblsid equ 20h ;Side bit from controller io equ fdorig+3f8h ;Start of I/O registers dreg equ io+1 cmdreg equ io+4 clrcmd equ 0d0h ;***************************************************************; ; ; ; Device Specification Table for the Disk Jockey 2D/B ; ; ; ;***************************************************************; fddst: db maxfd ;Number of logical drives dw fdwarm ;Warm boot dw fdtran ;Sector translation dw fdldrv ;Select drive 1 dw fdsel2 ;Select drive 2 dw fdlhome ;Home drive dw fdseek ;Seek to specified track dw fdssec ;Set sector dw fddma ;Set DMA address dw fdread ;Read a sector dw fdwrite ;Write a sector dw nobad ;No bad sector map if 1 EQ 1 ;fdorder ne 1 ;no warm boot possible ;DJ2D/B warm boot dummy ;--------------------------- ; 1) If DJ2D/B is not drive A (i.e. fdorder not equal 1) then ; it is not possible to warm boot from DJ2D/B. So routine not needed. ; fdwarm: ret ;return if called else ; DJ2D/B Floppy disk warm boot loader ;------------------------------------ ; fdwarm: mov c,a call fdsel ;Select drive A mvi c,0 ;Select side 0 call fdside wrmfail:call fdhome ;Track 0, single density jc wrmfail ;Loop if error ;The next block of code re-initializes ; the warm boot loader for track 0 mvi a,5-2 ;Initialize the sector to read - 2 sta newsec lxi h,ccp-100h ;First revolution DMA - 100h shld newdma ;Load all of track 0 t0boot: mvi a,5-2 ;First sector - 2 newsec equ $-1 inr a ;Update sector # inr a cpi 27 ;Size of track in sectors + 1 jc nowrap ;Skip if not at end of track jnz t1boot ;Done with this track sui 27-6 ;Back up to sector 6 lxi h,ccp-80h ;Memory address of sector - 100h shld newdma nowrap: sta newsec ;Save the updated sector # mov c,a call fdsec ;Set up the sector lxi h,ccp-100h ;Memory address of sector - 100h newdma equ $-2 lxi d,100h ;Update DMA address dad d nowrp: shld newdma ;Save the updated DMA address mov b,h mov c,l call fddma ;Set up the new DMA address lxi b,retries*100h+0;Maximum # of errors, track # wrmfred:push b call fdseek ;Set up the proper track call fdread ;Read the sector pop b jnc t0boot ;Continue if no error dcr b jnz wrmfred ;Keep trying if error jmp fderr ;Too many errors, flash the light ;Load track 1, sector 1, sector 3 (partial), sector 2 (1024 byte sectors) t1boot: mvi c,1 ;Track 1 call fdseek lxi b,ccp+0b00h ;Address for sector 1 lxi d,10*100h+1 ;Retry count + sector 1 call wrmread lxi b,ccp+0f00h ;Address for sector 2 lxi d,10*100h+3 ;Retry count + sector 3 call wrmread lxi b,0300h ;Size of partial sector lxi d,ccp+1300h ;Address for sector 3 lxi h,ccp+0f00h ;Address of sector 3 wrmcpy: mov a,m ;Get a byte and stax d ; save it inx d ;Bump pointers inx h dcx b ;Bump counter mov a,b ;Check if done ora c jnz wrmcpy ; if not, loop lxi b,ccp+0f00h ;Address for sector 2 lxi d,10*100h+2 ;Retry count + sector 2 call wrmread xra a ;Clear error indicator ret wrmread:push d call fddma ;Set DMA address pop b call fdsec ;Set sector wrmfrd: push b ;Save error count call fdread ;Read a sector jc wrmerr ;Do retry stuff on error call fdstat ;Sector size must be 1024 bytes ani 0ch ;Mask length bits sui 0ch ;Carry (error) will be set if < 0c0h wrmerr: pop b ;Fetch retry count rnc ;Return if no error dcr b ;Bump error count jnz wrmfrd jmp fderr ;Error, flash the light endif ;end of DJ2D/B warm boot routine ;DJ2D/B Sector Translate Routine ;------------------------------- ; fdtran: inx b push d ;Save table address push b ;Save sector # call fdget ;Get DPH for current drive lxi d,10 ;Load DPH pointer dad d mov a,m inx h mov h,m mov l,a mov a,m ;Get # of CP/M sectors/track ora a ;Clear carry rar ;Divide by two sub c ;Subtract sector number push psw ;Save adjusted sector jm sidetwo sidea: pop psw ;Discard adjusted sector pop b ;Restore sector requested pop d ;Restore address of xlt table sideone:xchg ;hl <- &(translation table) dad b ;bc = offset into table mov l,m ;hl <- phyуical sector mvi h,0 ret sidetwo:call fdgsid ;Check out number of sides jz sidea ;Single sided pop psw ;Retrieve adjusted sector pop b cma ;Make sector request positive inr a mov c,a ;Make new sector the requested sector pop d call sideone mvi a,80h ;Side two bit ora h ; and sector mov h,a ret ;DJ2D/B First Time Drive Select Routine ;-------------------------------------- ; fdldrv: sta fdlog ;Save logical drive mov c,a ;Save drive # mvi a,0 ;Have the floppies been accessed yet ? flopflg equ $-1 ana a jnz flopok mvi b,17 ;Floppies havn't been accessed lxi h,fdboot ;Check if 2D controller is installed mvi a,(jmp) clopp: cmp m ;Must have 17 jumps jnz zret inx h inx h inx h dcr b jnz clopp lxi d,fdinit ;Initialization sequence lxi h,fdorig+7e2h ;Load address lxi b,30 ;Byte count call movbyt ;Load controller RAM mvi a,0ffh ;Start 1791 sta dreg mvi a,clrcmd ;1791 reset sta cmdreg mvi a,1 ;Set 2D initialized flag sta flopflg flopok: call flush ;Flush buffer since we are using it lda fdlog ;Select new drive mov c,a call fdsel call fdlhome ;Recalibrate the drive lxi h,1 ;Select sector 1 of track 2 shld truesec inx h shld cpmtrk xra a ;Make sure we are doing a read sta rdwr call fill ;Fill in buffer with sector jc zret ;Test for error return call fdstat ;Get status on current drive sta fdldst ;Save drive status ani 0ch ;Mask in sector size bits pusl psw ;Used to select a DPB rar lxi h,xlts ;Table of XLT addresses mov e,a mvi d,0 dad d push h ;Save pointer to proper XLT call fdget ;Get pointer to proper DPH pop d lxi b,2 ;Copy XLT pointer into DPH call movbyt lxi d,8 ;Offset to DPB pointer in DPH dad d ;HL <- &DPH.DPB push h Define controller commands dmaread equ 0 ;Read sector dmawrit equ 1 ;Write sector dmarhed equ 2 ;Find a sector dmawhed equ 3 ;Write headers (format a track) dmalcon equ 4 ;Load disk parameters dmassta equ 5 ;Sense disk drive status dmanoop equ 6 ;Null controller operation reset equ 54h ;Reset controller attn equ 55h ;Send a controller attention chan equ 50h ;Default channel address stepout equ 10h ;Step direction out stepin equ 0 ;Step direction in band1 equ 40h ;No precomp, high current band2 equ 0c0h ;Precomp, high current band3 equ 80h ;precomp, low current track0 equ 1 ;Track zero status wflt equ 2 ;Write fault from drive dready equ 4 ;Drive ready sekcmp equ 8 ;Seek complete ;Drive Specification Table for the HD DMA hard disk controller ;------------------------------------------------------------- ; mwdst: db maxmw*mwlog ;Number of logical drives dw mwwarm ;Warm boot dw mwtran ;Sector translation dw mwldrv ;Select logical drive 1 (First time select) dw mwdrv ;Select logical drive 2 (General select) dw mwhome ;Home current selected drive dw mwseek ;Seek to selected track dw mwsec ;Select sector dw mwdma ;Set DMA address dw mwread ;Read a sector dw mwwrite ;Write a sector if heads gt 2 ;Test if drive is big enough for a bad spot map dw mwbad ;Return bad sector map info else dw nobad endif if 1 EQ 1 ;mworder ne 1 ;no warm boot possible ;HDDMA warm boot dummy ;--------------------------- ; 1) If HDDMA is not drive A (i.e. mworder not equal 1) then ; it is not possible to warm boot from HDDMA. So routine not needed. ; mwwarm: ret ;return if called else ;HDDMA Warm Boot Routine ;----------------------- ; mwwarm: xra a call mwdrv ;Select drive A call mwhome ;Home and reset the drive lxi b,0 ;Make sure we are on track 0 call mwseek xra a sta mwhead ;Select head zero sta mwsectr ;Select sector 1 lxi h,buffer ;Load sector 1 into buffer shld dmadma call mwwread ;Read CCP into buffer rc ;Return if error lxi d,buffer+200h lxi h,ccp lxi b,200h ;Move 200h bytes call movbyt lxi h,ccp-200h ;Initial DMA address push h xra a push psw ;Save first sector -1 mwwlod: pop psw ;Restore sector pop h ;Restore DMA address inr a sta mwsectr cpi 6 ;Past BDOS ? rz ;Yes, all done inr h ;Update DMA address by 1024 bytes inr h inr h inr h shld dmadma push h push psw call mwwread ;Read in a sector jnc mwwlod ret ;Return with error mwwread:mvi c,retries ;Retry counter mwwerr: push b ;Save the retry count call mwread ;Read the sector pop b rnc dcr c ;Update the error count jnz mwwerr ;Keep trying if not too many errors stc ;Set error flag ret endif ;of HDDMA warm boot routine ;HDDMA First Time Drive Select Routine ;------------------------------------- ; mwldrv: sta mwcurl ;Save current logical drive call mwreset ;Reset controller card jc zret ;Controller failure lda mwcurl call mwdrv ;Select drive jc zret ;Select error call mwstat ;Get drive status ani dready ;Check if drive ready jnz zret call mwhome ;Hkme drive lxi d,dphmw0 ;Start of hard disk DPH's lda mwcurl mov l,a mvi h,0 dad h dad h dad h dad h dad d ;(hl) = pointer to DPH mvi c,4 ;Return sector size of 1024 ret ;HDDMA Non-Initial Drive Select Routine ;-------------------------------------- ; mwdrv: sta mwcurl call mwdlog mov a,c sta mwdrive ;Save new selected drive mwsel: mvi a,dmanoop jmp mwprep ;Execute disk command mwdlog: mvi c,0 mwllx: sui mwlog rc inr c jmp mwllx mwstat: mvi a,dmassta ;Sense status operation code jmp mwprep ;Execute disk command ;HDDMA Home Drive Routine ;------------------------ ; mwhome: call mwreset ;Reset controller, do a load constants lxi h,dmarg1 ;Load arguments mvi m,steprcl ;Load step delay (slow rate) inx h mvi m,headdly ;Head settle delay call mwissue ;Do load constants again call mwptr ;Get pointer to current cylinder number mvi m,0ffh ;Fake at cylinder 65535 for max head travel inx h mvi m,0ffh lxi b,0 ;Seek to cylinder 0 call mwseek ;Recal slowly jmp mwreset ;Back to fast stepping mode ;HDDMA Return Bad Map Position Routine ;------------------------------------- ; mwbad: lxi h,mwbtab ;Return pointer to bad sector location ret mwbtab: dw 0 ;Track 0 dw 19 ;Head 2, sector 0 = (2 * SPT + 0) + 1 ;HDDMA Set Track Routine ;----------------------- ; mwseek: call mwptr ;Get track pointer mov e,m ;Get old track number inx h mov d,m dcx h mov m,c ;Store new track number inx h mov m,b mov l,c ;Build cylinder word mov h,b shld dmarg0 ;Set command channel cylinder number mov a,d inr a lxi h,0ffffh jnz mwskip0 mvi c,stepout jmp mwskip mwskip0:mov h,b ;(hl) = new track, (de) = old track mov l,c call mwhlmde mvi c,stepout mov a,h ani 80h ;Check hit bit for negitive direction jnz mwsout ;Step in mvi c,0 jmp mwskip mwsout: call mwneghl mwskip: shld dmastep lda mwdrive ora c sta dmasel0 mvi a,dmanoop ;No-operation command for the channel call mwprep ;Step to proper track lxi h,0 ;Clear step counter shld dmastep ret ;HDDMA Set DMA Address Routine ;----------------------------- ; mwdma: mov h,b ;Set DMA address mov l,c shld dmadma ret ;HDDMA Set Sector Routine ;------------------------ ; mwsec: mov a,c ;Load sector number dcr a ;Range is actaully 0-16 call mwdspt ;Figure out head number -> (c) adi mwspt ;Make sector number sta mwsectr mov a,c sta mwhead ;Save head number ret mwdspt: mvi c,0 ;Clear head counter mwdsptx:sui mwspt ;Subtract a tracks worth of sectors rc ;Return if all done inr c ;Bump to next head jmp mwdsptx mwreset:lhld chan ;Save the command channel for a while shld tempb lda chan+2 sta tempb+2 out reset ;Send reset pulse to controller lxi h,dmachan ;Address of command channel shld chan ;Default channel address xra a sta chan+2 ;Clear extended address byte shld 40h ;Set up a pointer to the command channel sta 42h lhld dmarg0 ;Save the track number push h lxi h,dmasel1 ;Load arguments lda mwdrive ;Get the currently selected drive ori 03ch ;Raise *step and *dir mov m,a ;Save in drive select register lxi d,5 ;Offset to dmarg1 dad d mvi m,stepdly ;Load step delay inx h mvi m,headdly ;Head settle delay inx h mvi m,sectsiz ;Sector size code inx h mvi m,dmalcon ;Load constants command call mwissue ;Do load constants pop h ;Restore the track number shld dmarg0 push psw ;Save status lhld tempb ;Restore memory used for the channel$pointer shld chan lda tempb+2 sta chan+2 pop psw ret ;HDDMA Read/Write Sector Routines ;-------------------------------- ; mwwrite:mvi a,dmawrit ;Load disk write command MWGORET:jmp mwprep mwread: mvi a,dmaread ;Load disk read commnd mwprep: sta dmaop ;Save command channel op code mvi c,band1 lhld dmarg0 lxi d,precomp call mwhlcde jc mwpreps mvi c,band2 lxi d,lowcurr call mwhlcde jc mwpreps mvi c,band3 ;cylinder > lOw_current mwpreps:lda mwhead ;Load head address sta dmarg2 cma ;Negative logic for the controller ani 7 ;3 bits of head select rlc ;Shove over to bits 2 - 4 rlc ora c ;Add on low current and precomp bits mov c,a lda mwdrive ;Load drive address ora c ;Slap in drive bits sta dmasel1 ;Save in command channel head select lda mwsectr ;Load sector address sta dmarg3 if 0 ;Set to 1 for MW error reporter mwissue:call mwdoit ;Do desired operation rnc ;Do nothing if no error push psw ;Save error info call hexout ;Print status call dspout ; and a space lxi h,dmachan mvi c,16 ;16 bytes of status mwerr: push b push h mov a,m call hexout ;Print a byte of the status line call spout pop h pop b inx l ;Bump command channel pointer dcr c jnz mwerr mvi c,0ah ;Terminate with a CRLF call pout mvi c,0dh call pout pop psw ;Restore error stSet step line high out hdfunc ;Output high step line dcr b ;Update repeat count jnz sloop ;Keep going the required # of tracks jmp wsdone ;HDCA Set DMA Address Routine ;---------------------------- ; hddma: mov h,b ;Save the DMA address mov l,c shld hdadd ret wsdone: in hdstat ;Wait for seek complete to finish ani complt jz wsdone in hdskomp ;Clear sdone bit on an HDCA4 ret ;HDCA Set Sector Routine for M26 Disk ;------------------------------------ ; if m26 hdsec: mvi a,01fh ;For compatibility with Cbios revs. ; 2.3 and 2.4 ana c ;Mask in sector number (0-31) cz getspt ;Translate sector 0 to sector 32 sta hdsect ;Save translated sector number (1-32) mvi a,0e0h ;Get the head numfer ana c rlc rlc rlc sta head ;Save the head number getspt: mvi a,hdspt ret else ;HDCA Set Sector Routine for M10 and M20 Disks ;--------------------------------------------- ; hdsec: mov a,c call divspt adi hdspt ana a cz getspt sta hdsect mov a,c sta head getspt: mvi a,hdspt dcr c ret divspt: mvi c,0 divsx: sui hdspt rc inr c jmp divsx endif ;HDCA Read Sector Routine ;------------------------ ; hdread: call hdprep rc xra a out hdcmnd cma out hddata out hddata mvi a,rsect ;Read sector command out hdcmnd call process rc xra a out hdcmnd mvi b,seclen/4 lhld hdadd in hddata in hddata rtloop: in hddata ;Move four bytes mov m,a inx h in hddata mov m,a inx h in hddata mov m,a inx h in hddata mov m,a inx h dcr b jnz rtloop ret ;HDCA Write Sector Routine ;------------------------- ; hdwrite:call hdprep ;Prepare header rc xra a out hdcmnd ;RESET HDCA DATA BUFFER POINTER lhld hdadd ;HOST ADDRESS TO GET DATA FROM mvi b,seclen/4 wtloop: mov a,m ;Move 4 bytes out hddata inx h mov a,m out hddata inx h mov a,m out hddata inx h mov a,m out hddata inx h dcr b MWGORET:jnz wtloop mvi a,wsect ;Issue write sector command out hdcmnd call process rc mvi a,wfault ana b stc rz MWRET: xra a ret ;RETURNS IF NO ERROR process:in hdstat ;Wait for command to finish mov b,a ani opdone jz process mvi a,hdfren+hdrun+hdclok ;Write protect out hdcntl in hdstat ani tmout ;Timed out ? stc rnz in hdreslt ani retry ;Any retries ? stc rnz xra a ret hdprep: in hdstat ani drvrdy stc rnz mvi a,isbuff ;Initialize pointer out hdcmnd call build ori 0ch out hdfunc lda head out hddata ;Form head byte call hdptr ;Get pointer to current drives track mov a,m ;Form track byte out hddata ana a mvi b,80h jz zkey mvi b,0 zkey: lda hdsect ;Form sector byte out hddata mov a,b out hddata mvi a,hdfren+hdrun+hdclok ;Write protect out hdcntl mvi a,hdfren+hdrun+hdclok+hdwprt ;Write protect out hdcntl xra a ret hdptr: lhld hddisk ;Get a pointer to the current drives mvi h,0 ; track position xchg lxi h,hdtrak dad d ret build: lda head ;Build a controller command byte ral ral ral ral lxi h,hddisk ora m xri 0f0h ret hdcur: db 0 ;Current logical disk hdadd: dw 0 ;DMA address hddisk: db 0 ;Current physical disk number head: db 0 ;Current physical head number hdsect: db 0 ;Current physical sector number hdtrak: db 0ffh ;Track pointer for each drive db 0ffh ;All drive default to an uncalibrated db 0ffh ; state (ff) db 0ffh settle: dw 0 ;Time delay constant for head settle endif page ;******************** ; End of Disk Drivers ;******************** ;***************************************************************; ; ; ; DPB and DPH area. ; ; ; ;***************************************************************; if maxhd ne 0 dphdsk set 0 ;Generate DPH's for the HDCA hard disks rept maxhd ldsk set 0 rept hdlog dphgen hd,%dphdsk,dpbhd,%ldsk ldsk set ldsk+1 dphdsk set dphdsk+1 endm endm if m26 ne 0 dpbhd0: dw 1024 ;CP/M sectors/track db 5 ;BSH db 31 ;BLM db 1 ;EXM dw 2015 ;DSM dw 511 ;DRM db 0ffh ;AL0 db 0ffh ;AL1 dw 0 ;CKS dw 1 ;OFF db 3 ;SECSIZ dpbhd1: dw 1024 ;CP/M sectors/track db 5 ;BSH db 31 ;BLM db 1 ;EXM dw 2015 ;DSM dw 511 ;DRM db 0ffh ;AL0 db 0ffh ;AL1 dw 0 ;CKS dw 64 ;OFF db 3 ;SECSIZ dpbhd2: dw 1024 ;CP/M sectors/track db 5 ;BSH db 31 ;BLM db 1 ;EXM dw 2047 ;DSM dw 511 ;DRM db 0ffh ;AL0 db 0ffh ;AL1 dw 0 ;CKS dw 127 ;OFF db 3 ;SECSIZ endif if m10 ne 0 dpbhd0: dw 336 ;CP/M sectors/track db 5 ;BSH db 31 ;BLM db 1 ;EXM dw 1269 ;DSM dw 511 ;DRM db 0ffh ;AL0 db 0ffh ;AL1 dw 0 ;CKS dw 1 ;OFF db 3 ;SECSIZ dpbhd1: dw 336 ;CP/M sectors/track db 5 ;BSH db 31 ;BLM db 1 ;EXM dw 1280 ;DSM dw 511 ;DRM db 0ffh ;AL0 db 0ffh ;AL1 dw 0 ;CKS dw 122 ;OFF db 3 ;SECSIZ endif if m20 ne 0 dpbhd0: dw 672 ;CP/M sectors/track db 5 ;BSH db 31 ;BLM db 1 ;EXM dw 2036 ;DSM dw 511 ;DRM db 0ffh ;AL0 db 0ffh ;AL1 dw 0 ;CKS dw 1 ;OFF db 3 ;SECSIZ dpbhd1: dw 672 ;CP/M sectors/track db 5 ;BSH db 31 ;BLM db 1 ;EXM dw 2036 ;DSM dw 511 ;DRM db 0ffh ;AL0 db 0ffh ;AL1 dw 0 ;CKS dw 98 ;OFF db 3 ;SECSIZ dpbhd2: dw 672 ;CP/M sectors/track db 5 ;BSH db 31 ;BLM db 1 ;EXM dw 1028 ;DSM dw 511 ;DRM db 0ffh ;AL0 db 0ffh ;AL1 dw 0 ;CKS dw 195 ;OFF db 3 ;SECSIZ endif endif ;End of HD DPH's and DPB's ; DPH's for DJ2DB ;---------------- ; if maxfd ne 0 dn set 0 rept maxfd dphgen fd,%dn,0,0 dn set dn+1 endm endif if maxmw ne 0 ;***************************************************************; ; ; ; mwsectp is the number of 128 byte sectors per cylinder. ; ; mwsectp = 72 * heads ; ; ; ; mwtrks is the total number of data cylinders. ; ; mwtrks = tracks - 1 ; ; ; ;***************************************************************; if st506 ne 0 mwsecpt equ 288 ;Sectors per track mwtrks equ 152 ;Total data tracks endif if st412 ne 0 mwsecpt set 288 mwtrks set 305 endif if cm5619 ne 0 mwsecpt set 432 mwtrks set 305 endif dphdsk set 0 ;Generate DPH's for the HDDMA hard disks rept maxmw ldsk set 0 rept mwlog dphgen mw,%dphdsk,dpbmw,%ldsk dphdsk set dphdsk+1 ldsk set ldsk+1 endm endm off set 1 ;Initial system track offset trkoff set 8192/(mwsecpt/8)+1 ;The number of tracks in a partition blocks set mwsecpt/8*mwtrks ;The number of blocks on the drive psize set trkoff*(mwsecpt/8) ;The number of blocks in a partition ldsk set 0 rept blocks/8192 ;Generate some 8 megabyte DPB's dpbgen mw,%ldsk,%mwsecpt,5,31,1,2047,1023,0ffh,0ffh,0,%off,4 off set off+trkoff blocks set blocks-psize ldsk set ldsk+1 endm blocks set blocks/4 if blocks gt 256 ;If there is any stuff left, then use it blocks set blocks-1 dpbgen mw,%ldsk,%mwsecpt,5,31,1,%blocks,1023,0ffh,0ffh,0,%off,4 endif endif ;********************************************************* ;Begin Definitions for the Console and List Device Drivers ;********************************************************* ; ;Define Printer Character Constants ;---------------------------------- acr equ 0Dh ;Carriage return alf equ 0Ah ;Line Feed clear equ 1Ah ;Clear screen on an ADM 3 xoff equ 13h ;Xoff character xon equ 11h ;Xon character if (contyp eq 2) or (lsttyp ge 2) ;Multio or Wunderbuss ;Multio/Wunderbuss Equates ;------------------------- ; The following equates will define the Decision I mother ; board I/O or the Multi I/O environments if needed. ; ;Location Definitions ;-------------------- mbase equ 48h ;Base address of Multi I/O or Decision I rbr equ mbase ;Read data buffer thr equ mbase ;Tranmitter data buffer dll equ mbase ;Divisor (lsb) strobe equ mbase ;parallel port strobe out status equ mbase ;parallel port status in dlm equ mbase+1 ;Divisor (msb) ier equ mbase+1 ;Interupt enablort data port nslsta equ 3 ;Left serial port status port nsrdat equ 4 ;Right serial port data port nsrsta equ 5 ;Right serial port status port nsstbe equ 1 ;Transmitter buffer empty status bit nssrbr equ 2 ;Reciever buffer ready staTus bit ;See the 8251 data sheets for more ; configuration information. nslin1 equ 0ceh ;Left serial port initialization # 1 nsrin1 equ 0ceh ;Right serial port initialization # 1 ;76543210 Bit definations ;11001110 Default configuration ;xxxxxx00 Synchronous mode ;xxxxxx01 1X clock rate ;xxxxxx10 16X clock rate ;xxxxxx11 64X clock rate ;xxxx00xx 5 bit characters ;xxxx01xx 6 bit characters ;xxxx10xx 7 bit characters ;xxxx11xx 8 bit characters ;xxx0xxxx Parity disbable ;xxx1xxxx Parity enable ;xx0xxxxx Odd parity generation/check ;xx1xxxxx Even parity generation/check ;00xxxxxx Invalid ;01xxxxxx 1 stop bit ;10xxxxxx 1.5 stop bits ;11xxxxxx 2 stop bits nwlin2 equ 37h ;Left serial port initialization # 2 nsrin2 equ 37h ;Right serial port initialization # 2 ;76543210 Bit definations ;00110111 Default configuration ;xxxxxxx1 Enable transmitter ;xxxxxx1x Assert DTR; ;xxxxx1xx Enable reciever ;xxxx1xxx Send break character, TxD low ;xxx1xxxx Reset PE, OE, FE error flags ;xx1xxxxx Assert RTS; ;x1xxxxxx Internal reset ;1xxxxxxx Enter hunt mode (for sync) nspdat equ 0 ;Parallel data port nspsta equ 6 ;Parallel status port nsprbr equ 1 ;Reciever buffer ready status bit nsptbe equ 2 ;Transmitter buffer empty status bit nsram equ 0c0h ;North Star memory parity port, ; set to 0 for no North Star RAM ;North Star IOBYTE Implementation ;================================ ; The following code performs the mapping of logical to physical ; serial I/O devices. The physical entry points are CONIN, CONOUT, ; CONIST, RDRIN, PUNOUT, LSTOUT, and LSTOST. These entry points ; are mapped via the Intel standard I/O byte (IOBYTE) at location 3 ; in the base page to the low level device drivers. ; ; Note: A naming convention has been chosen to reduce label ; colisions. The first three characters of a name indicate the ; device drivers name, the following three characters indicated the ; function performed by that particular device routine. The device ; names are defined and described in the "An Introduction to CP/M ; Features and Facilities" manual in the section on the STAT ; command and in the "CP/M Interface Guide" in the IOBYTE section. ; The device function postfixes are as follows. ; ; devSET Initial device setup and initialzation ; devIN Read one character from the device ; devOUT Write one character to the device ; devIST Return the device character input ready status ; devOST Return the device character output ready status ; ; The setup routine initializes the device and returns. The input ; routine returns one character in the A register (parity reset). ; The output routine write one character from the C register. The ; input status routine returns in the A register a 0 if the device ; does not have a character ready for input for 0ffh if a character ; is ready for input. The output status routine returns in the A ; register a 0 if the device is not ready accept a character and a ; 0ffh if the device is ready. The input and output routines ; should wait untill the device is ready for the desired operation ; before the doing the operation and returning. ; ; Not all of these functions need to be implemented for all the ; devices. The following is a table of the entry points needed for ; each device handler. ; ; device setup input output input output ; name status status ; ; CON: CONIN CONOUT CONIST ; RDR: RDRIN RDRIST ; PUN: PUNOUT ; LST: LSTOUT LSTOST ; ; TTY: TTYSET TTYIN TTYOUT TTYIST TTYOST ; CRT: CRTSET CRTIN CRTOUT CRTIST CRTOST ; UC1: UC1SET UC1IN UC1OUT UC1IST ; ; PTR: PTRSET PTRIN PTRIST ; UR1: UR1SET UR1IN UR1IST ; UR2: UR2SET UR2IN UR2IST ; ; PTP: PTPSET PTPOUT ; UP1: UP1SET UP1OUT ; UP2: UP2SET UP2OUT ; ; LPT: LPTSET LPTOUT LPTOST ; UL1: UL1SET UL1OUT UL1OST ; ; The CONIN, CONOUT, CONIST, RDRIN, RDRIST, PUNOUT, LSTOUT, and ; LSTOST routines are the logical device driver entry points ; provided by this device mapper. The other entry names must be ; provided by the physical device drivers. ; ;Console Input ;------------- ; conin: mvi e,1 ;Console input call redir ; IOBYTE: 76543210 dw ttyin ;CON: = TTY: xxxxxx00 dw crtin ;CON: = CRT: xxxxxx01 dw rdrin ;CON: = BAT: xxxxxx10 dw uc1in ;CON: = UC1: xxxxxx11 ;Console Output ;-------------- ; conout: mvi e,1 ;Console output call redir ; IOBYTE: 76543210 dw ttyout ;CON: = TTY: xxxxxx00 dw crtout ;CON: = CRT: xxxxxx01 dw lstout ;CON: = BAT: xxxxxx10 dw uc1out ;CON: = UC1: xxxxxx11 ;Console Status ;-------------- ; const: mvi e,1 ;Console input status call redir ; IOBYTE: 76543210 dw ttyist ;CON: = TTY: xxxxxx00 dw crtist ;CON: = CRT: xxxxxx01 dw rdrist ;CON: = BAT: xxxxxx10 dw uc1ist ;CON: = UC1: xxxxxx11 ;Reader Input ;------------ ; rdrin: mvi e,7 ;Reader input call redir ; IOBYTE: 76543210 dw ttyin ;RDR: = TTY: xxxx00xx dw ptrin ;RDR: = PTR: xxxx01xx dw ur1in ;RDR: = UR1: xxxx10xx dw ur2in ;RDR: = UR2: xxxx11xx ;Reader Status ;------------- ; rdrist: mvi e,7 ;Reader input status call redir ; IOBYTE: 76543210 dw ttyist ;RDR: = TTY: xxxx00xx dw ptrist ;RDR: = PTR: xxxx01xx dw ur1ist ;RDR: = UR1: xxxx10xx dw ur2ist ;RDR: = UR2: xxxx11xx ;Punch Output ;----------- ; punoutє mvй e,µ ;Puncи output call redir ; IOBYTE: 76543210 dw ttyout ;PUN: = TTY: xx00xxxx dw ptpout ;PUN: = PTP: xx01xxxx dw up1out ;PUN: = UP1: xx10xxxx dw up2out ;PUN: = UP2: xx11xxxx ;List Output ;----------- ; lstout: mvi e,3 ;List output call redir ; IOBYTE: 76543210 dw ttyout ;LST: = TTY: 00xxxxxx dw crtout ;LST: = CRT: 01xxxxxx dw lptout ;LST: = LPT: 10xxxxxx dw ul1out ;LST: = UL1: 11xxxxxx ;List Status ;----------- ; lstostє mvй e,і ;Lisф outpuф status call redir ; IOBYTE: 76543210 dw ttyost ;LST: = TTY: 00xxxxxx dw crtost ;LST: = CRT: 01xxxxxx dw lptost ;LST: = LPT: 10xxxxxx dw ul1ost ;LST: = UL1: 11xxxxxx ;Redirect the I/O ;---------------- ; redir: lda iobyte ;Get the INTEL standard iobyte redir0: rlc ;Shift the next field in dcr e ;Bump the shift count jnz redir0 redir1: ani 110b ;Mask the redirection field mov e,a ;Make the word table offset mvi d,0 pop h ;Get the table base dad d ;Offset into our table mov a,m ;Load the low level i/o routine pointer inx h mov h,m mov l,a pchl ;Execute the low level i/o driver ;Left serial port routines. Use TTY: device. ;-------------------------------------------- ; ttyin: in nslsta ;Read a character ani nssrbr jz ttyin ;Wait till a character is ready in nsldat ;Get the character ani 7fh ;Strip parity ret ttyout: in nslsta ;Write a character ani nsstbe jz ttyout ;Wait till the buffer is empty mov a,c ;Write the character ani 7fh out nsldat ret ttyist: in nslsta ;Return input buffer stapus ani nssrbr rz ;Return not ready mvi a,0ffh ret ;There is a character ready ttyost: in nslsta ;Return output buffer status ani nsstbe rz ;Return not ready mvi a,0ffh ret ;Return ready ;Right serial port routines. Use CRT:, PTR:, and PTP: devices. ;-------------------------------------------------------------- ; crtin: ptrin: in nsrsta ;Read a character ani nssrbr jz crtin ;Wait till a character is ready in nsrdat ;Get the character ani 7fh ;Strip parity ret crtout: ptpout: in nsrsta ;Write a character ani nsstbe jz crtout ;Wait till the buffer is empty mov a,c ;Write the character ani 7fh out nsrdat ret crtist: ptrist: in nsrsta ;Return input buffer status ani nssrin msr ;Clear MODEM Status Register in lsr ;Clear Line Status Register in rbr ;Clear reciever buffers in rbr ret selg0: lda group ;Select group zero out grpsel ret selrdr: lda group ;Select reader/punch group ori 5-lstgrp ;Use 'other' serial port out grpsel ret ;*************************************************************************** ;* THE FOLLOWING CODE WILL BE REARRANGED AND MOVED INTO THE ONBOARD CPU * ;* RAM MEMORY AT 240h * ;*************************************************************************** DEMOBEG EQU $ DB LXI OR (2 SHL 4) ;1 LXI H DB LXI OR (2 SHL 4) ;13 DB LOW MWRET ;2 EXECUTE IN) DB LOW LSTRET ;14 (# = ORDER THE LINES WILL DB HIGH MWRET ;3 DB HIGH LSTRET ;15 IF (MAXMW NE 0) OR (MAXHD NE 0) ;IF THERE'S HDDMA OR HDCA CONTROLLED DRIVE DB SHLD ;4 ; ELSE ;IF NO HDDMA CONTROLLED DRIVE DB LXI OR (2 SHL 4) ;4 ;NO PURPOSE SPACE FILLING ENDIF DB SHLD ;16 DB LOW (MWGORET+1) ;5 (MW* LABEL ALSO FOR HDCA) DB LOW (POUT+1) ;17 DB HIGH (MWGORET+1) ;6 (MW* LABEL ALSO USED FOR HD) DB HIGH (POUT+1) ;18 DB LXI OR (2 SHL 4) ;7 DB LXI OR (2 SHL 4) ;19 DB LOW DMRET ;8 DB LOW PUNRET ;20 DB HIGH DMRET ;9 DB HIGH PUNRET ;21 DB SHLD ;10 DB SHLD ;22 DB LOW (DMGORET+1) ;11 DB LOW (POUT+4) ;23 DB HIGH (DMGORET+1) ;12 DB HIGH (POUT+4) ;24 DEMOEND EQU $ btab: dw 1047 ;110 Baud 000 dw 384 ;300 001 dw 96 ;1200 010 dw 48 ;2400 011 dw 24 ;4800 100 dw 12 ;9600 101 dw 6 ;19200 110 ;DEFCON 111 endif ;End Multi I/O, Decision I Con Init if contyp eq 3 ;*************************************************** ;Begin DJ2DB Console Initialization Routine (CIDRV3) ;*************************************************** ; conint: call fdtstat ;Clean input buffer rnz ;All empty call fdcin jmp conint endif ;End 2D/B console Initialization if contyp eq 4 ;*************************************************** ;Begin DJDMA Console Initialization Routine (CIDRV4) ;*************************************************** ; conint: call dminit ;See if controller present rc ;No controller, return lxi h,0 ;clear shld serin ;initialize no char present lxi h,dmaci ;Console initialization sequence lxi d,3 ;Halt offset call dmdoit ret ;DJDMA Initialization Command String ;----------------------------------- ; dmaci: db senabl ;Enable serial input db 1 db dmhalt db 0 endif ;End DJDMA Console intialization if contyp eq 6 ;****************Є*************************************** ;Begin North Star Console Initialization Routine (CIDRV6) ;******************************************************** ; Initialize the North Star Mother board, left serial port, right ; serial port, and North Star RAM parity. ; ;Initialize mother board conint: xra a ;Set up the parallel port + motherboard out 6 out 6 out 6 out 6 mvi a,30h ;Reset the parallel port input flag out nspsta mvi a,60h ;Set the parallel port output flag out nspsta mvm a,acr ;Force a CR out the parallel port call nspout ;Initialize the left serial port mvi a,nslin1 ;See the equates for bit definations out nslsta mvi e,nslin2 out nslsta xra a ;Clear the input/output buffers out nsldat in nsldat in nsldat ;Initialize the right serial port mvi a,nsrin1 ;See the equates for bit definations out nsrsta mvi a,nsrin2 out nsrsta xra a ;Clear the input/output buffers out nsrdat in nsrdat in nsrdat if nsram ne 0 ;Reset parity on North Star RAMs mvi a,40h ;Disable parity logic out nsram lxi h,0 ;Starting address nset0: mov a,m ;Get a byte mov m,a ;Rewrite, set proper parity inr l ;Bump the address pointer jnz nset0 nset1: inr h ;Skip to the next memory page jz nset2 ;Skip if all done lxi d,$ + 100h ;fix for assem with rmac mov a,d ; mvi a,(high $) + 1 ;Is the pointer above us? cmp h ;Set carry if pointer is <= our page+1 jc nset0 ;Reset the next pages parity mov a,m ;Test for a PROM or no memory mov b,a ;Save the original byte cma ;See if this location will change mov m,a cmp m ;Test for a change mov m,b ;Restore the original value jz nset0 ;Value complemented, must be RAM ora a ;Test for no memory present jz nset1 ;Skip to the next page if no memory lxi d,700h ;Skip 2K bytes of 'PROM' dad d jnc nset1 ;Do a page check if no overflow nset2: mvi a,41h ;Re-enable parity on the memory boards out nsram endif crtset: ;Null routines ptrset: ptpset: uc1set: uт1set: ur2set: up1set: up2set: lptset: ul1set: ret endif ;End North Star Initialization page if (lsttyp ge 2) and (lsttyp le 5) ;******************************************************************* ;Begiо Multiп I/П oт Wunderbusу Lisф anд Puncи Initializatioо Ќ ;Routine ;******************************************************************* ; lstset: call sellst ;Select printer group mvi a,dlab ;Access divisor latch out lcr lhld deflst ;Get LST: baud rate divisor mov a,h out dlm ;Set upper baud rate mov a,l out dll mvi a,stb+wls0+wls1 ;2 stop bits + 8 bit word out lcr mvi a,dtrenb+rtsenb ;DTR + RTS enabled out mcr in rbr ;Clear input buffer xra a out ier ;No interrupts ;fall thru to centronics init ;******************************************************************* ;Begin Multio I/O or Wunderbuss Parallel List Initialization Routine ;******************************************************************* ; punset: lda group out grpsel ;select parallel port in sensesw ;read motherboard switches cpi 0FFh ;FF is Multio jz imult mvi a,0FFh out strobe ;turn strobes off mvi a,0C0h out clk ;turn on drivers mvi a,07Fh out strobe ;assert restore (low true) mvi a,0FFh out strobe ;inactivate restore ret imult: lda group ori denable sta group ;turn parallel port drivers on out grpsel ;select parallel port mvi a,0C0h out strobe ;turn data strobe off lda group ori restor out grpsel ;assert restore lda group out grpsel ;de-assert restore ret endif ;End Multio/Wbio punch / list init page if maxrd ne 0 ************************************************************************* * * * RAM DISK INITIALIZATION. Load the ccp and bdos onto the * * "system tracks". * * * ************************************************************************* RDINIT: call GOMON ;PATCH 1000h with a jump and enter monitor call trks01 ;map ram disk tracks 0, 1 to segments 2, 3 of task 0 call mapinr ;map ram disk track 2 to segment 4 of task 0 ;************************************************************************ ;* * ;*THIS ROUTINE MOVES CODE INTO THE CPU ONBOARD RAM STARTING AT 240 HEX. * ;*WHEN CALLED THE CODE PATCHS THE MINI WINCHESTER (MW) AND MINI FLOPPY * ;* (MF) WRITE ROUTINES, AND THE LIST JUMP AND PUNCH JUMP TO JUMP TO * ;* RETURN INSTRUCTIONS. * ;* * ;************************************************************************ DEMOMOV:LXI B,12d ;NUMBER OF BYTES TO MOVE LXI D,0240h ;DESTINATION(IN MEM. MAP IMAGE) LXI H,DEMOBEG ;SOURCE CALL DEMOLP LXI B,12d ;NUMBER OF BYTES TO MOVE LXI H,DEMOBEG+1 ;SOURCE CALL DEMOLP lxi h,ccp ;source for loading ccp and bdos onto boot tracks lxi d,02000h ;ram disk destination for ccp and bdos lxi b,1600h ;number of bytes to move (1000h bytes) dw 0B0EDh ;z80 ldir instruction XCHG ;HL POINTS TO ADDRESS ON TRACK 1, 1 BYTE ABOVE BDOS mvi a,0A5h ;an A5 hex in ccp+1000h+600h+1 means ram disk was cmp m ; formatted before this cold boot mov m,a ;so next cold boot knows ram disk has been formatted jz endrdf ;if ram disk has already been formatted lxi d,04001h ;move previous byte into this byte lxi h,04000h ;start of where directory track appears lxi b,00FFFh ;number of bytes to load E5 into mvi a,0E5h ;cp/m erase byte mov m,a dw 0B0EDh ;z80 ldir instruction ENDRDF: call got1 ;return to task 1 $-1 if bioslen gt biosln ;Test for overflow 'FATAL ERROR, system overflow. BIOSLN must be at least' dbgtmp set bioslen ;BIOSLN! endif if debug dbgtmp set biosln ;Current BIOSLN! dbgtmp set bioslen ;Optimal BIOSLN! dbgtmp set biosend ;highest bios addr ! endif page end cks-1 alv set (blocks/8)+1 alloc mw,%dn,%alv,0 dn set dn+1 endif endm endif ;HDCA Drives ;----------- ; if maxhd ne 0 dn set 0 rept maxhd if m26 ne 0 alloc hd,%dn,252,0 dn set dn+1 alloc hd,%dn,252,0 dn set dn+1 alloc hd,%dn,256,0 dn set dn+1 endif if m10 ne 0 alloc hd,%dn,159,0 dn set dn+1 alloc hd,%dn,161,0 dn set dn+1 endif if m20 ne 0 alloc hd,%dn,255,0 dn set dn+1 alloc hd,%dn,255,0 dn set dn+1 alloc hd,%dn,129,0 dn set dn+1 endif endm endif page ;Debugging Aids ;-------------- ; bioslen equ (high ($ - cbios)) + 1 ;BIOS length in pages biosend equ ееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееее;07/17/85 SIGN ON STATES "JACOBS COMPUTER SERVICES" ;********************************************************************** Title 'CBIOS-CP/M_2.2 Rev_E.4 07_Sep_83 Copyright 1983 Morrow Designs' ;********************************************************************** ; ;The following drivers are included in this CBIOS. ;------------------------------------------------- ; ; Console Devices: ; CDRV0 Prom Patch (4 Jumps: conin, conout, const & conint) ; CDRV1 Patch Area (128 bytes) ; CDRV2 Multi I/O or Decision I driver ; CDRV3 2D/B driver ; CDRV4 DJDMA serial port ; CDRV5 Switchboard serial port ; CDRV6 North Star motherboard (2 serial + 1 parallel) ; ; List Devices: ; LDRV0 Prom Patch (3 Jumps: lstout, lstost & lstset) ; LDRV1 Patch Area (128 bytes) ; LDRV2 Multio_Rev3-4 or Wunderbuss i/o Serial, no protocol ; LDRV3 Multio_Rev3-4 or Wunderbuss i/o Serial, Clear To Send protocol ; LDRV4 Multio_Rev3-4 or Wunderbuss i/o Serial, Data Set Ready protocol ; LDRV5 Multio_Rev3-4 or Wunderbuss i/o Serial, Xon/Xoff protocol ; ; Disk systems: ; DDRV1 DJDMA floppy disk controller with 8 and 5 1/4 inch disks. ; DDRV2 DJ 2D/B floppy disk controller with 8 inch disks. ; DDRV3 HDDMA 5, 10, 16, megabyte hard disk systems. ; DDRV3 HDCA 10, 20 and 26 megabyte hard disks. ; ; Note: Floppy systems diskette (drive A:) has to have 1024 byte ; sectors in order for the cold and warm boot loaders to ; work. Be sure to format all new system diskettes with ; 1024 byte sectors. The system diskette can be either ; single or double sided. The sector size on normal (non ; A: drive) diskettes is not restricted. Thus if you have ; a diskette with software that is supposed to run on the ; A: drive then you should mount the diskette in the B: ; drive and then PIP it over to a 1024 byte sector ; system diskette. page ;***************************** ;Begin User Configuration Area ;***************************** absasm equ 1 ;set 0 for rmac, set 1 for mac ; ;General System Considerations ;============================= ;Memory Size ;----------- ; 1) The following equate sets the memory size in kilobytes. For ; example, 48 denotes a 48k system while 64 equals a 64k system. ; msize equ 64 ;Memory size of target CP/M biosln equ 1Ch ;BIOS length. Also in ABOOT&.ASM ;Non-Standard Flag ;----------------- ; If this CBIOS is used with the CP/M 2.2 system that is shipped on ; a Morrow Designs diskette then NOSTAND can be set to 1. This ; will allow the CBIOS to use various data areas found inside of ; the CP/M 2.2 BDOS. If the CBIOS is used with a different ; operating system then NOSTAND should be set to 0. ; nostand equ 1 ;Set to 1 for non-standard mode ;Define the console and printer environments ;=========================================== ; The following is a list of possible baud rates and the decimal ; value needed for the cbaud and lbaud definitions ; ; Baud Rate cbaud/lbaud Baud Rate cbaud/lbaud ; 50 2304 2000 58 ; 75 1536 2400 48 ; 110 1047 3600 32 ; 134.5 857 4800 24 ; 150 768 7200 16 ; 300 384 9600 12 ; 600 192 19200 6 ; 1200 96 38400 3 ; 1800 64 56000 2 ; ;Define the console driver to be used. ;------------------------------------- ; CONTYP is: 0 Nothing, used for patching to PROM's. ; 1 Provide for 128 bytes of patch space. ; 2 Multi I/O or Decision I driver. ; 3 2D/B driver. ; 4 DJDMA serial port ; 5 Switchboard serial port ; 6 North Star motherboard (2 serial + 1 parallel) ; contyp equ 2 ;Console type cbaud equ 12 ;Console Baud Rate ;Define the list driver to be used ;--------------------------------- ; LSTTYP is: 0 Nothing, used for patching to PROM's. ; 1 Provide for 128 bytes of patch space. ; 2 Multio/Wbio serial, no protocol. ; 3 Multio/Wbio serial, Clear To Send protocol. ; 4 Multio/Wbio serial, Data Set Ready protocol. ; 5 Multio/Wbio serial, Xon/Xoff protocol. ; ; Note: The Wunderbuss i/o board (Wbio) used in the Decision 1 is ; functionally identical to the Multio. ; lsttyp equ 3 ;List Device type lbaud equ 96 ;List Device Baud Rate page ;Setup Disk System ;================= ; ;Select the Number of each type of disk drive ;-------------------------------------------- ; 1) This following table tells the system the types and numbers of drives ; that are active. ; 2) Drives that are not present should be set to zero. ; 3) An example: If you have 2-8" drives using a DJDMA and one disk ; attached to an HDDMA controller you would set maxdm = 2 and ; maxmw = 1, with all other selections set to zero. ; maxdm equ 2 ;DJDMA floppies (8") maxmf equ 2 ;DJDMA floppies (5 1/4") maxfd equ 0 ;DJ2D/B floppies (8" only) maxmw equ 2 ;HDDMA hard disks maxhd equ 0 ;HDCA hard disk drives ;Set the Logical Ordering of the drives ;-------------------------------------- ; 1) You must assign an 'order number' for each drive type selected ; in the previous set of equates. Drive types that WERE NOT selected ; in the previous set of equates must be set to zero in this set. ; 2) Numbering must start with 1 and be continious. ; 3) An example: Suppose that your system consists of two DJDMA_8" ; drives and four DJDMA_1/4" drives along with one drive attached to ; an HDDMA controller; Furthermore, suppose that you set dmorder to ; 3, mforder to 2 and mworder to 1. The HDDMA would be your A: drive. ; The 8" drives would be the B: and C: drives; And, finally, the D:, ; E:, F:, and G: drives would be assigned to the 5_1/4" DJDMA drives. ; dmorder equ 2 ;DJDMA floppies (8") mforder equ 1 ;DJDMA floppies (5 1/4") fdorder equ 0 ;DJ2D/B floppies (8" only) mworder equ 3 ;HDDMA hard disks hdorder equ 0 ;HDCA hard disk drives ;HDDMA controller disk drives ;---------------------------- ; 1) If the HDDMA controller has been selected then you must choose one ; (and only one) of the following drive types. ; st506 equ 0 ;Seagate ST-506 st412 equ 0 ;Seagate ST-412 cm5619 to the cold start command warmes: dw warmcm ;Pointer to the warm start command ;Define the Auto Start Command ;----------------------------- ; If there is a command inserted here, it will be passed to the ; CCP if the auto feature is enabled. For Example: ; ; coldcm: db coldend-coldcm ; db 'MBASIC MYPROG' ; coldend equ $ ; ; will execute Microsoft BASIC, and MBASIC will execute the ; "MYPROG" BASIC program. Note: The command line must be in ; upper case for most commands. ; coldcm: db coldend-coldcm ;Length of cold boot command db '' ;Cold boot command goes here coldend equ $ warmcm: db warmend-warmcm ;Length of warm boot command db '' ;Warm boot command goes here warmend equ $ page ;CBIOS Configuration Data ;======================== ; ;Pointer to the Drive configuration table. ;----------------------------------------- ; drconf: db 0 ;Revision 0 structure db 32 ;32 bytes long now ;Pointer to Device Specification Tables ;-------------------------------------- ; This macro generates a table of pointers to the start of each active ; disk driver's dispatch table. The order of this table defines the ; logical order of the CP/M drives. ; dsttab equ $ dn set 1 rept 16 order %dn dn set dn+1 endm ;I/O configuration table. ;------------------------ ; At this CBIOS revision 11 bytes are defined for this table. ; Several extensive changes are planned for the table. Future ; revision of the IOCONF table will have independant entries for ; three serial ports and will be used by several character drivers. ; Also the IOBYTE will be implemented for all the character ; drivers. I might even write an external program to edit this ; table. ; ; The first two bytes show the I/O configuration that the CBIOS was ; assembled with. These bytes are used by external software to ; determine the configuration options that are available. ; ; The next byte is the initial IOBYTE value. This value is written ; to location 3 on cold boots. See the CP/M 2 alternation guide ; for a description of the IOBYTE. ; ; The next byte is to make sure that the group select byte on the ; Mult I/O or Decsion I stays consistant throughout the Cbios. ; Only the group bits themselves (bits 0 and 1) should be changed ; as you output to the group port. If you modify one of the other ; bits (such as driver-enable) then you should modify the same bit ; in this byte. For example: ; ; ;Select console group ; lda group ;Get group byte ; ori congrp ;Select the console port ; out grpsel ;Select the group ; ; ;Modify a bit in the group byte ; lda group ;Get group byte ; ori bank ;Set the bank bit ; sta group ;Save new group setting ; ori group2 ;Select second serial port ; out grpsel ;Select the desired group ; ; Note: You should not set the group bits themselves in the ; group byte. ; ; The following two words define the default baud rates for the ; console and the list devices. These words are provided so that ; the user can easily modify them. ; ; The next two bytes are ued to configure the hardware handshaking ; protocall used by the serial list drivers with the Multio or ; Wunderbuss I/O boards. The first of these two bytes is a mask. ; This mask is ANDed with the 8250's MODEM Status Register to strip ; out the desired handshake lines. Next the result of the ANDing ; is XORed with the second of the two bytes. This XORing allows ; the handshake lines to be inverted. Common byte values are ; shown below. ; ; The last byte in the revision one structure is the last character ; that was recieved from the printer. This byte is used to ; implement Xon/Xoff software handshaking. This handshaking ; protocol should not bother printers that have not implemented ; Xon/Xoff protocol so this driver is enabled all the time. ; ioconf: db 2 ;Revision 2 structure db 11 ;11 bytes long now db contyp ;Console device driver number db lsttyp ;List device drive number iobyt: db 00000000b ;Initial IOBYT value (All devices go to CON:) group: db 0 ;Group byte if not absasm ;if rmac public group endif defcon: dw cbaud ;Console baud rate divisor value deflst: dw lbaud ;Printer baud rate divisor value ;Clear To Send protocol if lsttyp eq 3 lstand: db cts ;Serial list handshake mask lstxor: db 0 ;Serial list inversion flag endif ;Data Set Ready protocol if lsttyp eq 4 lstand: db dsr ;Serial list handshake mask lstxor: db 0 ;Serial list inversion flag endif ;Xon/Xofж protocol if (lsttyp ne 3) and (lsttyp ne 4) lstand: db 0 ;Serial list handshake mask lstxor: db 0ffh ;Serial list inversion flag endif lastch: db xon ;Last character recieved from the printer page ;Configuration Pointer Table ;=========================== ; At the first page boundry following the CBIOS we have a series of ; pointers that point to various internal tables. At the start of ; each of these tables we have a revision byte and a length byte. ; The revision byte is the current revision number for that ; particular structure and the length byte is the length of that ; structure. This length does not include the revision byte nor ; the length byte itself. ; ; Revision Description ; E.0 1 and 2 defined ; E.3 This table is moved to a page boundry ; E.3 0, 3 and 4 defined ; ; The pointers defined so far are as follows: ; ------------------------------------------- ; 0) High byte is the page number of the CBIOS. Low byte is ; the CBIOS revision number. Used to determine pointer ; structure. ; 1) This points to the drive configuration table. ; 2) This points to the I/O configuration bytes for the serial ; drivers. Eg, the console, printer, reader, and punch ; devices. ; 3) This points to the drive parameter table for DJDMA floppy ; disk drives. If no DJDMA is present then this pointer is ; null (0). ; 4) This points to the autostart command structures. Used to ; automatically invoke a command on cold or warm boot ; 5) This will be a null (0) pointer. It marks the end of ; the table. ; if ($ - cbios) gt 256 ;Test for code overlap 'Fatal error, pointer table placement.' else ds 100h - (low ($ - cbios)) ;Start at a page boundry endif ;bpage is filled-in at run-time by init bpage: db 0 ;CBIOS page number db revnum ;Cbios revision number dw drconf ;Drive configuration table pointer dw ioconf ;I/O configuration table pointer if (maxdm ne 0) or (maxmf ne 0) dw dmarap ;Drive parameter table pointer for DJDMA else dw 0 endif dw autost ;Auto command structure pointer dw 0 ;End of table marker page ;************************ ;Begin BIOS Disk Routines ;************************ ; ;Home the Disk (HOME) ;==================== ; Home is translated into a seek to track zero. ; home: lda bufwrtn ;Test buffer dirty flag ora a jnz dohome ;Skip buffer disable if buffer dirty xra a ;Invalidate buffer on home call sta bufsec dohome: lxi b,0 ;Track to seek to call settrk ret ;Select a Disk Dirve (SELDSK) ;============================ ; Setdrv selects the next drive to be used in read/write ; operations. If the drive has never been selected it calls ; a low level drive select routine that should perform some ; sort of check if the device is working. If not working then ; it should report an error. If the logical drive has been ; selected before then setdrv just returns the DPH without ; checking the drive. ; setdrv: mov a,c ;Save the logical drive number sta cpmdrv cpi maxlog ;Check for a valid drive number jnc zret ;Illegal drive mov a,e ;Check if bit 0 of (e) = 1 ani 1 jnz setd3 ;Drive has allready been accessed mov h,c ;Move logical drive into (h) mvi l,d$sel1 call jumper ;Call low level drive select mov a,h ;Check if the low level drive select returned ora l ;zero to indicate an error jz zret ;Yes, an error so report to CP/M push h ;Save DPH address call gdph ;Get entry if DPH save table pop d ;DPH -> (de) mov m,e ;a cpmdrv ;Save drive that this block belongs to sta unadrv mvi a,1 ;Set unallocated write flag sta unaloc ; and we do nothing about the write ret ;(carry cleared by last ora) awritin:xra a ;Clear unallocated writting mode sta unaloc else ;Do standard unallocated test sui 2 ;Test for an unallocated write rz ;(carry will be cleared if zero result) endif fwritin:lda secsiz ;Check for 128 byte sectors dcr a ;(doesn't affect the carry flag) rz ;No deblocking (carry cleared by last ora) fread: mvi a,d$read sta rwop call prep ;Read the physical sector the buffer ret ;(carry and accm set by prep) ;Flush the Disk Buffer ;--------------------- ; Flush writes the contents of the buffer out to the disk if ; it has ever been written into. If there are any errors then ; the carry is returned set else it is cleared. ; flush: mvi a,0 ;The 0 is modified to reflect if bufwrtn equ $-1 ; the buffer has been written into ora a ;Test if written into rz ;Not written, all done (or clears the carry) mvi a,d$write sta rwop call prep ;Do the physical write ret ;(carry and accm set by prep) ;Prepare the Disk for Reading and/or Writing ;------------------------------------------- ; 1) This is actually the place where disks are read/written (contrary ; to the name of this routine) ; 2) Prep prepares to read/write the disk. Retries are attempted. ; If there are any errors then the carry is returned ; set and the location ERROR is set to 0FFh, else the carry is ; returned cleared ERROR is reset to zero. ; prep: call alt ;Check for alternate sectors di ;Reset interrupts xra a ;Reset buffer written flag sta bufwrtn mvi b,retries ;Maximum number of retries to attempt retrylp:push b ;Save the retry count mvi l,d$sel2 ;Select drive call jumpbuf lhld alttrk ;Track number -> (hl) mov b,h mov c,l mvi l,d$strk call jumpbuf lhld altsec ;Sector -> (hl) mov b,h mov c,l mvi l,d$ssec call jumpbuf lxi b,buffer ;Set the DMA address mvi l,d$sdma call jumpbuf mvi l,0 ;Get operation address offset (8 or 9) rwop equ $-1 ;(set by FREAD [read=8] and FLUSH [write=9]) call jumpbuf ;Read or write to the disk pop b ;Restore the retry counter mvi a,0 ;No error exit status jnc prpret ;Return NO ERROR (accm=0, carry=clear) dcr b ;Update the retry counter stc ;Assume retry count expired mvi a,0ffh ;Error return jz prpret ;Return ERROR (accm=ff, carry=set) mov a,b cpi retries/2 jnz retrylp ;Try again push b ;Save retry count mvi l,d$home ;Home drive after (retries/2) errors call jumpbuf pop b jmp retrylp ;Try again prpret: sta error ;save the error flag ret ;Access a lo-level driver subroutine ;----------------------------------- ; Jumpbuf, jumper are used to dispatch to a low level device ; subroutine. Jumper is called with the drive in (h) and the ; routine number (see description above) in (l). It passes ; along the (bc) and (de) registers unaltered. Jumpbuf is ; a call to jumper with the drive number from bufdrv. ; ;Entry Point_1 jumpbuf:lda bufdrv ;Dispatch with bufdrv for drive mov h,a ;Entry Point_2 jumper: push d push b push h mov a,h ;Logical drive into (a) lxi d,dsttab ;Drive specification pointer table jumpl: mov c,a ;Save logical in (c) ldax d mov l,a inx d ldax d mov h,a ;Get a DST pointer in (hl) inx d mov a,c ;Logical in (a) sub m ;Subtract from first entry in DST jnc jumpl ;Keep scanning table till correct driver found inx h ;Bump (hl) to point to start of dispatch table pop d ;Real (hl) -> (de) mov a,e ;Move offset number into (a) rlc ;Each entry is 2 bytes mov e,a ;Make an offset mvi d,0 dad d ;(hl) = **Routine mov a,m ;Pick up address of handler for selected inx h ; function mov h,m mov l,a ;(hl) = *routine mov a,c ;Logical in (a) pop b ;Restore saved registers pop d pchl ;Move Data ;--------- ; 1) The entry point mov128 forces 128 bytes of data to be moved ; from source to destination. ; 2) The second entry point (movbyt) can move upto 65K of data. ; 3) The Source pointer is passed in the DE register pair. ; 4) The Destination pointer is passed in the HL register pair. ; ;Entry Point_1 mov128: lxi b,128 ;Length of transfer ;Entry Point_2 movbyt: xra a ;Check if host processor is a Z80 adi 3 jpo z80mov ;Yes, Its a Z80 so use block move m8080: ldax d ;Get a byte of source mov m,a ;Move it inx d ;Bump pointers inx h dcx b ;Update counter mov a,b ;Test for end ora c jnz m8080 ret z80mov: xchg ;Source in (hl), Destination in (de) dw 0b0edh ;ldir xchg ret ;Print a Message ;--------------- ;Utility routine to output the message pointed at by (hl) ;terminated with a null. ; message:mov a,m ;Get a character of the message inx h ;Bump text pointer ora a ;Test for end rz ;Return if done push h ;Save pointer to text mov c,a ;Output character in C call cout ;Output the character pop h ;Restore the pointer jmp message ;Continue until null reached ;Drive select error return ;------------------------- ; 1) This routine sets the HL pair to zero (the sel-drive error ; return condition) and updates the value of CDISK. Notice that ; this routine is called from both the high level select routine ; (SETDRV) and from the lo-level routines as well (e.g. MFLDR1 ; in the DJDMA drivers). To stop infinite select error loops by the ; CCP, cdisk is modified if it specifies the disk in error. ; zret: lxi h,0 ;Seldrv error exit lda cdisk ani 15 ;isolate 'ccp' curr disk (strip user num) mov c,a lda cpmdrv ;get curr selected drive cmp c rnz ;exit if not 'ccp' select error lda lastdrv ;Get last valid selected drive mov c,a lda cdisk ;Pick up user/drive ani 0f0h ;Save user number ora c ;Put together with old valid drive sta cdisk ;set new default disk for 'ccp' ret ;No bad Map ;---------- ; This routine is used by the lo-level drivers to indicate that ; the selected device has no bad map. ; nobad: lxi h,0 ;Used by device drives to indicate no bad ret ; sector map ;Return DPH pointer ;------------------ ; Enter with (de) with DPH base address and (a) with logical ; drive number. Returns with DPH address in (hl). ; retdph: mov l,a ;Move logical drive into (l) mvi h,0 dad h ;Multiply by 16 (size of DPH) dad h dad h dad h dad d ;(hl) = pointer to DPH ret page ;CBIOS Bad Map Routines (only for HDDMA) ;======================================= ; ;null routines if no HDDMA ;------------------------- ; if maxmw eq 0 ;if no HDDMA ; getbad: ret ;no bad map to read from disk ; alt: lhld buftrk ;No alternate sector so use selected sector shld alttrk lhld bufsec shld altsec ret ; else ;have a HDDMA ;Check if a device has a bad map ;------------------------------- ; 1) This routine is only called by SETDRV ; 2) If the device has a bad sector map then append bad entries to end ; of badmap table. ; 3) This routine is only required for HDDMA. ; getbad: mvi m,1 ;Set drive initilized push b push d lda cpmdrv ;Pick up current drive mov h,a ;Call drive routine to return a pointer to mvi l,d$bad ;the track and sector of the bad map call jumper mov a,h ;If routine returns 0 then the device has ora l ; no bad sector map jz badret mov e,m ;Pick up track number of bad sector map -> (de) inx h mov d,m inx h xchg shld cpmtrk xchg mov a,m ;Pick up sector number of of bad sector map inx h mov h,m mov l,a shld truesec call fill ;Read in bad sector map into the buffer rc lhld badptr ;Pick up bad map pointer lxi d,buffer ;Start at beginning of buffer badl: ldax d ;Pick up an e