Mercurial > hg > Members > kono > nitros9-code
changeset 3291:c467fd80252c
Moved the emudsk driver into level1/modules.
author | tlindner <tlindner@macmess.org> |
---|---|
date | Tue, 21 Sep 2021 18:20:25 -0700 |
parents | 24bfa6f85ba6 |
children | e54bf7fbc50f |
files | 3rdparty/drivers/emudsk/ddh0.asm 3rdparty/drivers/emudsk/emudsk.asm 3rdparty/drivers/emudsk/h0.asm 3rdparty/drivers/emudsk/h1.asm 3rdparty/drivers/emudsk/makefile 3rdparty/drivers/makefile level1/coco1/bootfiles/makefile level1/coco1/modules/makefile level1/modules/emudsk.asm level1/modules/emudskdesc.asm level2/coco3/bootfiles/makefile level2/coco3/modules/makefile |
diffstat | 12 files changed, 462 insertions(+), 553 deletions(-) [+] |
line wrap: on
line diff
--- a/3rdparty/drivers/emudsk/ddh0.asm Fri Sep 17 20:13:53 2021 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,45 +0,0 @@ -******************************************************************** -* Emudsk - Virtual disk driver for CoCo emulators -* -* $Id$ -* -* Ed. Comments Who YY/MM/DD -* ------------------------------------------------------------------ -* 01 Modified to compile under OS9Source tjl 02/08/28 -* 02 Corrected device address for MESS R.Gault 11/12/24 -* Address not used by driver but still .... - - IFP1 - USE os9.d - ENDC - -type SET Devic+Objct - MOD rend,rnam,type,ReEnt+1,fmnam,drvnam - FCB $FF all access modes - FCB $07,$FF,$80 device address - - FCB optl number of options - -optns EQU * - FCB DT.RBF RBF device - FCB $00 drive number - FCB $00 step rate - FCB $80 type=nonstd,coco - FCB $01 double density - FDB $71c6 tracks - FCB $01 one side - FCB $01 no verify - FDB $0012 sectors/track - FDB $0012 "", track 0 - FCB $03 interleave - FCB $20 min allocation -optl EQU *-optns - -rnam FCS /DD/ -fmnam FCS /RBF/ -drvnam FCS /EmuDsk/ - - EMOD -rend EQU * - end -
--- a/3rdparty/drivers/emudsk/emudsk.asm Fri Sep 17 20:13:53 2021 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,355 +0,0 @@ -******************************************************************** -* Emudsk - Virtual disk driver for CoCo emulators -* -* $Id$ -* -* Ed. Comments Who YY/MM/DD -* ------------------------------------------------------------------ -* 01 Modified to compile under OS9Source tjl 02/08/28 -* 02 Modified to handle two .vhd drives R. Gault 11/12/23 -* Conforms to MESS v1.44 or more recent -* Added and enhanced some comments -* Note the forced > extended addressing in some cases. -* That is required as this code is relocatable but the -* addresses are fixed. Part of original code. -* 03 Corrected minor errors in GetSect. R. Gault 11/12/26 -* 04 Corrected more logic errors. R. Gault 11/12/29 -* & R. Gault 12/02/24 -* 05 Correct frame errors EJJaquay 20/12/29 -* small optimization to branch table LCB 20/12/29 -* 06 Clear drive select in INIT. Rearrange -* getsect slightly to reduce use of stack. EJJaquay 21/01/05 -* -* EmuDisk floppy disk controller driver -* Edition #1 -* 04/18/96 : Written from scratch by Alan DeKok -* aland@sandelman.ocunix.on.ca -* -* This program is Copyright (C) 1996 by Alan DeKok, -* All Rights Reserved. -* License is given to individuals for personal use only. -* -* Comments: Ensure that device descriptors mark it as a hard drive -* -* $FF80-$FF82: logical record number -LSN equ $FF80 where to put the logical sector number - -* -* $FF83: command/status register. -* Output: 0=read, 1=write, 2=close. -* Input: 0=no error, non-zero=error codes (see below). -command equ $FF83 where to put the commands - -* -* $FF84-$FF85: 6809's 16-bit buffer address (cannot cross an 8K boundary due -* to interference from the MMU emulation). -buffer equ $FF84 pointer to the buffer - -* $FF86: controls .vhd drive 0=drive1 1=drive2 -vhdnum equ $FF86 - -* Returns: -* -* 0=successful -* 2=not enabled -* 4=too many MS-DOS files open, -* 5=access denied (virtual HD file locked by another program -* or MS-DOS read-only status) -* 6/12=internal error -* 254=invalid command byte -* 255=power-on state or closed. -* -* The "close" command just flushes all the read/write buffers and -* restores the metacontroller to its power-up state. The hard drive must be -* enabled by the user using the MS-DOS command "ECHO >COCO3.VHD" (another -* crash safeguard), so error code 2 indicates this has not been done. - - nam EmuDsk - ttl os9 device driver - - ifp1 - use os9.d - use rbf.d - endc - -tylg set Drivr+Objct -atrv set ReEnt+rev -rev set $02 - - mod eom,name,tylg,atrv,start,size - - org 0 - rmb DRVBEG+(DRVMEM*2) Normal RBF device mem for 2 drives RG -prevdr rmb 1 previously used drive RG - rmb 255-. residual page RAM for stack etc. RG -size equ . - - fcb $FF This byte is the driver permissions -name fcs /EmuDsk/ - fcb 6 - -************************************************************************** -* Init -* -* Entry: Y=Ptr to device descriptor -* U=Ptr to device mem -* V.PAGE and V.PORT 24 bit device address -* -* Exit: CC carry set on error -* B error code if any -* -* Actions: -* -* Set V.NDRV to number of drives supported (2) -* Set DD.TOT to something non-zero -* Set V.TRACK to $FF -* Initialize device control registers? -* -* Default to only one drive supported, there's really no need for more. -* Since MESS now offers second vhd drive, EmuDsk will support it. RG -************************************************************************** - -INIT ldd #$FF02 'Invalid' value & # of drives - stb V.NDRV,u Tell RBF how many drives - leax DRVBEG,u Point to start of drive tables -init2 sta DD.TOT+2,x Set media size to bogus value $FF0000 - sta V.TRAK,x Init current track # to bogus value - leax DRVMEM,x Move to second drive memory. RG - decb - bne init2 - stb prevdr,u preset previous drive to 1st vhd - stb >vhdnum let emulator know EJJ 05jan21 - -************************************************************************** -* Term -* -* for now, TERM routine goes here. Perhaps it should be pointing to the -* park routine? ... probably not. -************************************************************************** -TERM - -************************************************************************** -* GetSta -* -* Entry: Y = path dsc. ptr -* U = Device mem ptr -* -* Exit: CC carry set on error -* B error code if any -* -************************************************************************** -GETSTA clrb no GetStt calls - return, no error, ignore - rts return to caller - -************************************************************************** -* Module Jump table here to minimize long branches LCB -************************************************************************** - -start bra INIT 3 bytes per entry to keep RBF happy - nop - bra READ - nop - bra WRITE - nop - bra GETSTA - nop - lbra SETSTA - bra TERM - nop - -************************************************************************** -* Read -* -* Entry: B:X = LSN -* Y = path dsc. ptr -* U = Device mem ptr -* -* Exit: CC carry set on error -* B error code if any -* -* Actions: -* Load A with read command and call GetSect -* If error return it in reg B -* if LSN is not zero use GETSTA to return -* If LSN is zero copy first DD.SIZ bytes of sector to drive table -* -************************************************************************** -READ clra READ command value=0 - bsr GetSect Get the sector - bne reterr error return if not zero - tstb test msb of LSN - bne noerr if not sector 0, return - leax ,x sets CC.Z bit if lsw of LSN not $0000 - bne noerr if not sector zero, return -* Copy LSN0 data to the drive table each time LSN0 is read - ldx PD.BUF,y get ptr to sector buffer - leau DRVBEG,u point to first drive table - lda PD.DRV,y get vhd drive number from descriptor RG - beq copy.0 go if first vhd drive - leau DRVMEM,u point to second drive table - IFNE H6309 -copy.0 ldw #DD.SIZ # bytes to copy over - tfm x+,u+ - ELSE -copy.0 ldb #DD.SIZ # bytes to copy over -copy.1 lda ,x+ grab from LSN0 - sta ,u+ save into device static storage - decb - bne copy.1 - ENDC -noerr clrb - rts - -************************************************************************** -* Write -* -* Entry: B:X = LSN -* Y = path dsc. ptr -* U = Device mem ptr -* -* Exit: CC carry set on error -* B error code if any -* -* Actions: -* Load reg A with write command and call get sect -* Return with error if any in reg B -************************************************************************** - -WRITE lda #$01 WRITE command = 1 - bsr GetSect - bne reterr - clrb - rts - -reterr tfr a,b Move error code to reg B - coma Set the carry flag - rts - -************************************************************************** -* GetSect -* -* Entry: A = read/write command code (0/1) -* B,X = LSN to read/write -* Y = path dsc. ptr -* U = Device static storage ptr -* -* Exit: A = Error code, zero if none (also sets CC) -* B,X,Y,U are preserved -* -* Note: Returns from READ or WRITE on errors to preserve stack frame - EJJ -* -* Actions: -* Put buffer address from PD.BUF -* Put drive from PD.DRV -* Put LSN from B,X -* Put command to cause emulator to do syncronous DMA transfer -* Translate and return error code -************************************************************************** - -GetSect pshs x,a Save regs x and a - lda PD.DRV,y Get drive number requested - cmpa #2 Only two drives allowed. RG - bhs DriveErr Too many? - cmpa prevdr,u did the drive change? RG - beq gs.1 no, then don't reset the drive - sta >vhdnum set to new vhd# RG - sta prevdr,u update RG -gs.1 stb >LSN Tell emulator which LSN - stx >LSN+1 - ldx PD.BUF,y Where the 256-byte LSN should go - -* Note: OS-9 allocates buffers from system memory on page boundaries, so -* the low byte of X should now be $00, ensuring that the sector is not -* falling over an 8K MMU block boundary. -* This should be the job of RBF not EmuDsk! RG - - stx >buffer set up the buffer address - puls x,a restore regs - sta >command get the emulator to blast over the sector - lda >command get the error status - bne FixErr if non-zero translate the error and return - rts return with LSN intact and no error - -* Translate emulator error code to OS-9 code and return to caller. - -DriveErr puls x,a restore regs - bra NotRdy not ready - -* Entry: A=error code from emulator -FixErr cmpa #02 not enabled - beq NotRdy - cmpa #255 power on state or closed - beq NotRdy - cmpa #5 access denied or DOS read-only - beq WP - cmpa #6 internal error - beq CRC - cmpa #12 internal error - beq CRC - -* if it's something we don't recognize, it's a seek error -Seek lda #E$Seek seek error - rts - -NotRdy lda #E$NotRdy not ready - rts - -WP lda #E$WP write protect - rts - -CRC lda #E$CRC CRC error - rts - -*L03D4 lda #E$Write write error -* rts - -*L03E0 lda #E$Read Read error -* rts - -************************************************************************** -* SetSta -* -* Entry: Y = path dsc. ptr -* U = Device mem ptr -* -* Exit: CC carry set on error -* B error code if any -* -* Actions: -* Get function code from stack PD.RGS,Y -* Get drive number from stack PD.DRV,Y -* issue park command if requested -* ignore other requests -* -************************************************************************** - -SETSTA ldx PD.RGS,y Get caller's register stack ptr - ldb R$B,x Get function code - cmpb #SS.WTrk Write track? - beq format Yes, ignore it - cmpb #SS.Reset Restore head to track 0? - beq format Yes, ignore it - cmpb #SS.SQD sequence down the drive (i.e. park it)? - beq park - comb set carry for error - ldb #E$UnkSvc return illegal service request error - rts - -* This next is pointless for a virtual drive but probably does not hurt. -* Emulators do not require this if hard drives are swapped in mid-stream. In -* real hardware, this is important as would be closing all open files. RG - -park lda PD.DRV,y get drive number RG - cmpa #2 test for illegal value RG - bhs format ignore if illegal RG - sta >vhdnum tell which drive to halt RG - ldb #$02 close the drive - stb >command save in command register - clr >vhdnum Reset drive to H0 RG - clr prevdr,u Clear prevdr to match vhdnum EJJ -format clrb ignore physical formats. They're not - rts necessary - - emod -eom equ * -
--- a/3rdparty/drivers/emudsk/h0.asm Fri Sep 17 20:13:53 2021 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,45 +0,0 @@ -******************************************************************** -* Emudsk - Virtual disk driver for CoCo emulators -* -* $Id$ -* -* Ed. Comments Who YY/MM/DD -* ------------------------------------------------------------------ -* 01 Modified to compile under OS9Source tjl 02/08/28 -* 02 Corrected device address for MESS R.Gault 11/12/24 -* Address not used by driver but still .... - - IFP1 - USE os9.d - ENDC - -type SET Devic+Objct - MOD rend,rnam,type,ReEnt+1,fmnam,drvnam - FCB $FF all access modes - FCB $07,$FF,$80 device address - - FCB optl number of options - -optns EQU * - FCB DT.RBF RBF device - FCB $00 drive number - FCB $00 step rate - FCB $80 type=nonstd,coco - FCB $01 double density - FDB $71c6 tracks - FCB $01 one side - FCB $01 no verify - FDB $0012 sectors/track - FDB $0012 "", track 0 - FCB $03 interleave - FCB $20 min allocation -optl EQU *-optns - -rnam FCS /H0/ -fmnam FCS /RBF/ -drvnam FCS /EmuDsk/ - - EMOD -rend EQU * - end -
--- a/3rdparty/drivers/emudsk/h1.asm Fri Sep 17 20:13:53 2021 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,45 +0,0 @@ -******************************************************************** -* Emudsk - Virtual disk driver for CoCo emulators -* -* $Id$ -* -* Ed. Comments Who YY/MM/DD -* ------------------------------------------------------------------ -* 01 Modified to compile under OS9Source tjl 02/08/28 -* 02 Corrected device address for MESS R.Gault 11/12/24 -* Address not used by driver but still .... - - IFP1 - USE os9.d - ENDC - -type SET Devic+Objct - MOD rend,rnam,type,ReEnt+1,fmnam,drvnam - FCB $FF all access modes - FCB $07,$FF,$80 device address - - FCB optl number of options - -optns EQU * - FCB DT.RBF RBF device - FCB $01 drive number - FCB $00 step rate - FCB $80 type=nonstd,coco - FCB $01 double density - FDB $71c6 tracks - FCB $01 one side - FCB $01 no verify - FDB $0012 sectors/track - FDB $0012 "", track 0 - FCB $03 interleave - FCB $20 min allocation -optl EQU *-optns - -rnam FCS /H1/ -fmnam FCS /RBF/ -drvnam FCS /EmuDsk/ - - EMOD -rend EQU * - end -
--- a/3rdparty/drivers/emudsk/makefile Fri Sep 17 20:13:53 2021 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,50 +0,0 @@ -include ../../../rules.mak - -DEPENDS = ./makefile - -DRIVERS = emudsk_6809.dr emudsk_6309.dr -DESCS = h0.dd ddh0.dd h1.dd -DSK = Modules_EmuDisk.dsk -ALLOBJS = $(DRIVERS) $(DESCS) $(DSK) - -all: $(ALLOBJS) $(DEPENDS) - -emudsk_6809.dr: emudsk.asm - $(AS) $(ASOUT)$@ $< $(AFLAGS) - -emudsk_6309.dr: emudsk.asm - $(AS) $(ASOUT)$@ $< $(AFLAGS) -DH6309=1 - -dsk: $(DSK) - -$(DSK): all - $(RM) $@ - $(OS9FORMAT_SS35) $@ -n"EmuDsk" - $(MAKDIR) $@,NITROS9 - $(MAKDIR) $@,NITROS9/6809_L2 - $(MAKDIR) $@,NITROS9/6309_L2 - $(MAKDIR) $@,NITROS9/6809_L2/MODULES - $(MAKDIR) $@,NITROS9/6309_L2/MODULES - $(MAKDIR) $@,NITROS9/6809_L2/MODULES/RBF - $(MAKDIR) $@,NITROS9/6309_L2/MODULES/RBF - $(OS9COPY) h0.dd $@,NITROS9/6809_L2/MODULES/RBF/h0_emudisk.dd - $(OS9COPY) h0.dd $@,NITROS9/6309_L2/MODULES/RBF/h0_emudisk.dd - $(OS9COPY) h1.dd $@,NITROS9/6809_L2/MODULES/RBF/h1_emudisk.dd - $(OS9COPY) h1.dd $@,NITROS9/6309_L2/MODULES/RBF/h1_emudisk.dd - $(OS9COPY) ddh0.dd $@,NITROS9/6809_L2/MODULES/RBF/ddh0_emudisk.dd - $(OS9COPY) ddh0.dd $@,NITROS9/6309_L2/MODULES/RBF/ddh0_emudisk.dd - $(OS9COPY) emudsk_6809.dr $@,NITROS9/6809_L2/MODULES/RBF/emudsk.dr - $(OS9COPY) emudsk_6309.dr $@,NITROS9/6309_L2/MODULES/RBF/emudsk.dr - -dskcopy: $(DSK) - $(CP) $(DSK) $(DSKDIR) - -dskclean: - $(RM) $(DSK) - -clean: - $(RM) $(ALLOBJS) - -info: - @$(ECHO) "*** EmuDsk ***" - @$(ECHO) $(DSK)
--- a/3rdparty/drivers/makefile Fri Sep 17 20:13:53 2021 -0700 +++ b/3rdparty/drivers/makefile Tue Sep 21 18:20:25 2021 -0700 @@ -1,6 +1,6 @@ include ../../rules.mak -dirs = burke disto emudsk ide mmc s16550 sdisk sdisk3 tccc nocan compusense +dirs = burke disto ide mmc s16550 sdisk sdisk3 tccc nocan compusense # Make all components all:
--- a/level1/coco1/bootfiles/makefile Fri Sep 17 20:13:53 2021 -0700 +++ b/level1/coco1/bootfiles/makefile Tue Sep 21 18:20:25 2021 -0700 @@ -39,9 +39,9 @@ IDE = $(3PD)/ide SCSI = $(3PD)/scsisys -FLOPPY_40D = $(MD)/rb1773.dr $(MD)/d0_40d.dd $(MD)/d1_40d.dd $(MD)/d2_40d.dd +FLOPPY_40D = $(MD)/rb1773.dr $(MD)/d0_40d.dd $(MD)/d1_40d.dd $(MD)/d2_40d.dd -FLOPPY_80D = $(MD)/rb1773.dr $(MD)/d0_40d.dd $(MD)/d1_40d.dd $(MD)/d2_40d.dd +FLOPPY_80D = $(MD)/rb1773.dr $(MD)/d0_40d.dd $(MD)/d1_40d.dd $(MD)/d2_40d.dd VTIO_COVDG = $(MD)/vtio.dr $(MD)/covdg.io $(MD)/term_vdg.dt VTIO_COVGA = $(MD)/vtio_vga.dr $(MD)/covga.io $(MD)/term_vga.dt @@ -85,9 +85,11 @@ $(MD)/n12_scdwv.dd $(MD)/n13_scdwv.dd $(MD)/midi_scdwv.dd SCDWV_WIN = $(MD)/z1_scdwv.dd $(MD)/z2_scdwv.dd $(MD)/z3_scdwv.dd \ $(MD)/z4_scdwv.dd $(MD)/z5_scdwv.dd $(MD)/z6_scdwv.dd \ - $(MD)/z7_scdwv.dd + $(MD)/z7_scdwv.dd SCDWP = $(MD)/scdwp.dr $(MD)/p_scdwp.dd +EMUDSK = $(MD)/emudsk.dr $(MD)/h0_emudsk.dd $(MD)/h1_emudsk.dd + BOOTFILE_COVDG = $(MD)/ioman \ $(MD)/rbf.mn \ $(FLOPPY_40D) \ @@ -746,6 +748,19 @@ $(CLOCK60HZ) \ $(MD)/sysgo_dd +BOOTFILE_EMUDSK = $(MD)/ioman \ + $(MD)/rbf.mn \ + $(FLOPPY_40D) \ + $(MD)/ddd0_40d.dd \ + $(MD)/scf.mn \ + $(VTIO_COVDG) \ + $(MD)/scbbp.dr $(MD)/p_scbbp.dd \ + $(MD)/scbbt.dr $(MD)/t1_scbbt.dd \ + $(PIPE) \ + $(CLOCK60HZ) \ + $(MD)/sysgo_dd \ + $(EMUDSK) + BOOTFILES = bootfile_covdg bootfile_cohr bootfile_co42 bootfile_cowprs \ bootfile_dw_headless bootfile_covdg_becker bootfile_covdg_rs232pak \ bootfile_covdg_cocolink bootfile_covdg_directmodempak \ @@ -763,7 +778,7 @@ bootfile_covga_ds80 bootfile_covga_cocosdc bootfile_covga_dw bootfile_covga_rs232pak \ bootfile_covga_directmodempak bootfile_covga_cocolink bootfile_covga_dw_game \ bootfile_covga_cocosdc_game bootfile_covga_rs232pak_game bootfile_covga_directmodempak_game \ - bootfile_covga_cocolink_game bootfile_covga bootfile_covga_arduino + bootfile_covga_cocolink_game bootfile_covga bootfile_covga_arduino bootfile_emudsk KERNELS = kernel_1773 kernel_dw kernel_becker kernel_arduino kernel_cocosdc \ kernel_rs232pak kernel_directmodempak kernel_cocolink @@ -928,6 +943,9 @@ bootfile_cohr_arduino: $(BOOTFILE_COHR_ARDUINO) $(DEPENDS) $(MERGE) $(BOOTFILE_COHR_ARDUINO)>$@ +bootfile_emudsk: $(BOOTFILE_EMUDSK) $(DEPENDS) + $(MERGE) $(BOOTFILE_EMUDSK)>$@ + # WD1773 Kernel kernel_1773: $(KERNEL_1773) $(DEPENDS) $(MERGE) $(KERNEL_1773)>$@ @@ -958,7 +976,7 @@ $(MERGE) $(KERNEL_ARDUINO)>$@ $(PADROM) 4608 $@ -kernel_cocosdc: $(KERNEL_COCOSDC) $(DEPENDS) +kernel_cocosdc: $(KERNEL_COCOSDC) $(DEPENDS) $(MERGE) $(KERNEL_COCOSDC)>$@ $(PADROM) 4608 $@
--- a/level1/coco1/modules/makefile Fri Sep 17 20:13:53 2021 -0700 +++ b/level1/coco1/modules/makefile Tue Sep 21 18:20:25 2021 -0700 @@ -47,7 +47,8 @@ ddi0_ide.dd i0_ide.dd i1_ide.dd ih_ide.dd \ dds0_tc3.dd s0_tc3.dd s1_tc3.dd s2_tc3.dd s3_tc3.dd s4_tc3.dd \ s5_tc3.dd s6_tc3.dd sh_tc3.dd \ - ddsd0_cocosdc.dd sd0_cocosdc.dd sd1_cocosdc.dd + ddsd0_cocosdc.dd sd0_cocosdc.dd sd1_cocosdc.dd \ + emudsk.dr ddh0_emudsk.dd h0_emudsk.dd h1_emudsk.dd SCF = scf.mn \ sc6551.dr vrn.dr scbbp.dr scbbt.dr scdwp.dr sspak.dr vtio.dr vtio_vga.dr \ @@ -161,6 +162,9 @@ rb1773_scii_ff58.dr: rb1773.asm $(AS) $< $(ASOUT)$@ $(AFLAGS) -DSCII=1 -DSCIIALT=1 +emudsk.dr: emudsk.asm + $(AS) $< $(ASOUT)$@ $(AFLAGS) + # TC^3 SCSI Driver lltc3.dr: llscsi.asm $(AS) $(ASOUT)$@ $< $(TC3FLAGS) @@ -219,6 +223,16 @@ d2_80d.dd: rb1773desc.asm $(AS) $< $(ASOUT)$@ $(AFLAGS) $(DSDD80) -DDNum=2 +# Emudsk descriptors +ddh0_emudsk.dd: emudskdesc.asm + $(AS) $< $(ASOUT)$@ $(AFLAGS) -DDNum=0 -DDD=1 + +h0_emudsk.dd: emudskdesc.asm + $(AS) $< $(ASOUT)$@ $(AFLAGS) -DDNum=0 + +h1_emudsk.dd: emudskdesc.asm + $(AS) $< $(ASOUT)$@ $(AFLAGS) -DDNum=1 + # CoCoVGA SCF descriptors term_vga.dt: term_vdg.asm $(AS) $< $(ASOUT)$@ $(AFLAGS) -DCOCOVGA=1
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/level1/modules/emudsk.asm Tue Sep 21 18:20:25 2021 -0700 @@ -0,0 +1,355 @@ +******************************************************************** +* Emudsk - Virtual disk driver for CoCo emulators +* +* $Id$ +* +* Ed. Comments Who YY/MM/DD +* ------------------------------------------------------------------ +* 01 Modified to compile under OS9Source tjl 02/08/28 +* 02 Modified to handle two .vhd drives R. Gault 11/12/23 +* Conforms to MESS v1.44 or more recent +* Added and enhanced some comments +* Note the forced > extended addressing in some cases. +* That is required as this code is relocatable but the +* addresses are fixed. Part of original code. +* 03 Corrected minor errors in GetSect. R. Gault 11/12/26 +* 04 Corrected more logic errors. R. Gault 11/12/29 +* & R. Gault 12/02/24 +* 05 Correct frame errors EJJaquay 20/12/29 +* small optimization to branch table LCB 20/12/29 +* 06 Clear drive select in INIT. Rearrange +* getsect slightly to reduce use of stack. EJJaquay 21/01/05 +* +* EmuDisk floppy disk controller driver +* Edition #1 +* 04/18/96 : Written from scratch by Alan DeKok +* aland@sandelman.ocunix.on.ca +* +* This program is Copyright (C) 1996 by Alan DeKok, +* All Rights Reserved. +* License is given to individuals for personal use only. +* +* Comments: Ensure that device descriptors mark it as a hard drive +* +* $FF80-$FF82: logical record number +LSN equ $FF80 where to put the logical sector number + +* +* $FF83: command/status register. +* Output: 0=read, 1=write, 2=close. +* Input: 0=no error, non-zero=error codes (see below). +command equ $FF83 where to put the commands + +* +* $FF84-$FF85: 6809's 16-bit buffer address (cannot cross an 8K boundary due +* to interference from the MMU emulation). +buffer equ $FF84 pointer to the buffer + +* $FF86: controls .vhd drive 0=drive1 1=drive2 +vhdnum equ $FF86 + +* Returns: +* +* 0=successful +* 2=not enabled +* 4=too many MS-DOS files open, +* 5=access denied (virtual HD file locked by another program +* or MS-DOS read-only status) +* 6/12=internal error +* 254=invalid command byte +* 255=power-on state or closed. +* +* The "close" command just flushes all the read/write buffers and +* restores the metacontroller to its power-up state. The hard drive must be +* enabled by the user using the MS-DOS command "ECHO >COCO3.VHD" (another +* crash safeguard), so error code 2 indicates this has not been done. + + nam EmuDsk + ttl os9 device driver + + ifp1 + use os9.d + use rbf.d + endc + +tylg set Drivr+Objct +atrv set ReEnt+rev +rev set $02 + + mod eom,name,tylg,atrv,start,size + + org 0 + rmb DRVBEG+(DRVMEM*2) Normal RBF device mem for 2 drives RG +prevdr rmb 1 previously used drive RG + rmb 255-. residual page RAM for stack etc. RG +size equ . + + fcb $FF This byte is the driver permissions +name fcs /EmuDsk/ + fcb 6 + +************************************************************************** +* Init +* +* Entry: Y=Ptr to device descriptor +* U=Ptr to device mem +* V.PAGE and V.PORT 24 bit device address +* +* Exit: CC carry set on error +* B error code if any +* +* Actions: +* +* Set V.NDRV to number of drives supported (2) +* Set DD.TOT to something non-zero +* Set V.TRACK to $FF +* Initialize device control registers? +* +* Default to only one drive supported, there's really no need for more. +* Since MESS now offers second vhd drive, EmuDsk will support it. RG +************************************************************************** + +INIT ldd #$FF02 'Invalid' value & # of drives + stb V.NDRV,u Tell RBF how many drives + leax DRVBEG,u Point to start of drive tables +init2 sta DD.TOT+2,x Set media size to bogus value $FF0000 + sta V.TRAK,x Init current track # to bogus value + leax DRVMEM,x Move to second drive memory. RG + decb + bne init2 + stb prevdr,u preset previous drive to 1st vhd + stb >vhdnum let emulator know EJJ 05jan21 + +************************************************************************** +* Term +* +* for now, TERM routine goes here. Perhaps it should be pointing to the +* park routine? ... probably not. +************************************************************************** +TERM + +************************************************************************** +* GetSta +* +* Entry: Y = path dsc. ptr +* U = Device mem ptr +* +* Exit: CC carry set on error +* B error code if any +* +************************************************************************** +GETSTA clrb no GetStt calls - return, no error, ignore + rts return to caller + +************************************************************************** +* Module Jump table here to minimize long branches LCB +************************************************************************** + +start bra INIT 3 bytes per entry to keep RBF happy + nop + bra READ + nop + bra WRITE + nop + bra GETSTA + nop + lbra SETSTA + bra TERM + nop + +************************************************************************** +* Read +* +* Entry: B:X = LSN +* Y = path dsc. ptr +* U = Device mem ptr +* +* Exit: CC carry set on error +* B error code if any +* +* Actions: +* Load A with read command and call GetSect +* If error return it in reg B +* if LSN is not zero use GETSTA to return +* If LSN is zero copy first DD.SIZ bytes of sector to drive table +* +************************************************************************** +READ clra READ command value=0 + bsr GetSect Get the sector + bne reterr error return if not zero + tstb test msb of LSN + bne noerr if not sector 0, return + leax ,x sets CC.Z bit if lsw of LSN not $0000 + bne noerr if not sector zero, return +* Copy LSN0 data to the drive table each time LSN0 is read + ldx PD.BUF,y get ptr to sector buffer + leau DRVBEG,u point to first drive table + lda PD.DRV,y get vhd drive number from descriptor RG + beq copy.0 go if first vhd drive + leau DRVMEM,u point to second drive table + IFNE H6309 +copy.0 ldw #DD.SIZ # bytes to copy over + tfm x+,u+ + ELSE +copy.0 ldb #DD.SIZ # bytes to copy over +copy.1 lda ,x+ grab from LSN0 + sta ,u+ save into device static storage + decb + bne copy.1 + ENDC +noerr clrb + rts + +************************************************************************** +* Write +* +* Entry: B:X = LSN +* Y = path dsc. ptr +* U = Device mem ptr +* +* Exit: CC carry set on error +* B error code if any +* +* Actions: +* Load reg A with write command and call get sect +* Return with error if any in reg B +************************************************************************** + +WRITE lda #$01 WRITE command = 1 + bsr GetSect + bne reterr + clrb + rts + +reterr tfr a,b Move error code to reg B + coma Set the carry flag + rts + +************************************************************************** +* GetSect +* +* Entry: A = read/write command code (0/1) +* B,X = LSN to read/write +* Y = path dsc. ptr +* U = Device static storage ptr +* +* Exit: A = Error code, zero if none (also sets CC) +* B,X,Y,U are preserved +* +* Note: Returns from READ or WRITE on errors to preserve stack frame - EJJ +* +* Actions: +* Put buffer address from PD.BUF +* Put drive from PD.DRV +* Put LSN from B,X +* Put command to cause emulator to do syncronous DMA transfer +* Translate and return error code +************************************************************************** + +GetSect pshs x,a Save regs x and a + lda PD.DRV,y Get drive number requested + cmpa #2 Only two drives allowed. RG + bhs DriveErr Too many? + cmpa prevdr,u did the drive change? RG + beq gs.1 no, then don't reset the drive + sta >vhdnum set to new vhd# RG + sta prevdr,u update RG +gs.1 stb >LSN Tell emulator which LSN + stx >LSN+1 + ldx PD.BUF,y Where the 256-byte LSN should go + +* Note: OS-9 allocates buffers from system memory on page boundaries, so +* the low byte of X should now be $00, ensuring that the sector is not +* falling over an 8K MMU block boundary. +* This should be the job of RBF not EmuDsk! RG + + stx >buffer set up the buffer address + puls x,a restore regs + sta >command get the emulator to blast over the sector + lda >command get the error status + bne FixErr if non-zero translate the error and return + rts return with LSN intact and no error + +* Translate emulator error code to OS-9 code and return to caller. + +DriveErr puls x,a restore regs + bra NotRdy not ready + +* Entry: A=error code from emulator +FixErr cmpa #02 not enabled + beq NotRdy + cmpa #255 power on state or closed + beq NotRdy + cmpa #5 access denied or DOS read-only + beq WP + cmpa #6 internal error + beq CRC + cmpa #12 internal error + beq CRC + +* if it's something we don't recognize, it's a seek error +Seek lda #E$Seek seek error + rts + +NotRdy lda #E$NotRdy not ready + rts + +WP lda #E$WP write protect + rts + +CRC lda #E$CRC CRC error + rts + +*L03D4 lda #E$Write write error +* rts + +*L03E0 lda #E$Read Read error +* rts + +************************************************************************** +* SetSta +* +* Entry: Y = path dsc. ptr +* U = Device mem ptr +* +* Exit: CC carry set on error +* B error code if any +* +* Actions: +* Get function code from stack PD.RGS,Y +* Get drive number from stack PD.DRV,Y +* issue park command if requested +* ignore other requests +* +************************************************************************** + +SETSTA ldx PD.RGS,y Get caller's register stack ptr + ldb R$B,x Get function code + cmpb #SS.WTrk Write track? + beq format Yes, ignore it + cmpb #SS.Reset Restore head to track 0? + beq format Yes, ignore it + cmpb #SS.SQD sequence down the drive (i.e. park it)? + beq park + comb set carry for error + ldb #E$UnkSvc return illegal service request error + rts + +* This next is pointless for a virtual drive but probably does not hurt. +* Emulators do not require this if hard drives are swapped in mid-stream. In +* real hardware, this is important as would be closing all open files. RG + +park lda PD.DRV,y get drive number RG + cmpa #2 test for illegal value RG + bhs format ignore if illegal RG + sta >vhdnum tell which drive to halt RG + ldb #$02 close the drive + stb >command save in command register + clr >vhdnum Reset drive to H0 RG + clr prevdr,u Clear prevdr to match vhdnum EJJ +format clrb ignore physical formats. They're not + rts necessary + + emod +eom equ * +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/level1/modules/emudskdesc.asm Tue Sep 21 18:20:25 2021 -0700 @@ -0,0 +1,50 @@ +******************************************************************** +* Emudsk - Virtual disk driver for CoCo emulators +* Descriptor Template +* +* $Id$ +* +* Ed. Comments Who YY/MM/DD +* ------------------------------------------------------------------ +* 01 Modified to compile under OS9Source tjl 02/08/28 +* 02 Corrected device address for MESS R.Gault 11/12/24 +* Address not used by driver but still .... + + IFP1 + USE defsfile + ENDC + +type SET Devic+Objct + MOD rend,rnam,type,ReEnt+1,fmnam,drvnam + FCB $FF all access modes + FCB $07,$FF,$80 device address + + FCB optl number of options + +optns EQU * + FCB DT.RBF RBF device + FCB DNum drive number + FCB $00 step rate + FCB $80 type=nonstd,coco + FCB $01 double density + FDB $71c6 tracks + FCB $01 one side + FCB $01 no verify + FDB $0012 sectors/track + FDB $0012 "", track 0 + FCB $03 interleave + FCB $20 min allocation +optl EQU *-optns + + IFNE DD +rnam fcs /DD/ + ELSE +rnam fcb 'H,'0+DNum+$80 + ENDC +fmnam FCS /RBF/ +drvnam FCS /EmuDsk/ + + EMOD +rend EQU * + end +
--- a/level2/coco3/bootfiles/makefile Fri Sep 17 20:13:53 2021 -0700 +++ b/level2/coco3/bootfiles/makefile Tue Sep 21 18:20:25 2021 -0700 @@ -2,7 +2,6 @@ # Module directory MD = ../modules -THIRD = ../../../3rdparty DEPENDS = ./makefile @@ -76,9 +75,8 @@ CLOCK60HZ = $(MD)/clock_60hz $(MD)/clock2_soft CLOCK60HZDW = $(MD)/clock_60hz $(MD)/clock2_dw CLOCK60HZCC3FPGA = $(MD)/clock_60hz $(MD)/clock2_coco3fpga -EMUDSK6809 = $(THIRD)/drivers/emudsk/emudsk_6809.dr \ - $(THIRD)/drivers/emudsk/h0.dd \ - $(THIRD)/drivers/emudsk/h1.dd +EMUDSK = $(MD)/emudsk.dr $(MD)/h0_emudsk.dd \ + $(MD)/h1_emudsk.dd # NitrOS-9 disk bootfile to allow booting from DriveWire server # on a DE1 or Xilinx using Gary Becker's CoCo 3 FGPA @@ -416,7 +414,7 @@ $(VTIO_COGRF_80) \ $(PIPE) \ $(CLOCK60HZ) \ - $(EMUDSK6809) + $(EMUDSK) BOOTFILES = bootfile_40d bootfile_40d_50hz bootfile_80d \ bootfile_80d_50hz bootfile_dw bootfile_dw_headless \
--- a/level2/coco3/modules/makefile Fri Sep 17 20:13:53 2021 -0700 +++ b/level2/coco3/modules/makefile Tue Sep 21 18:20:25 2021 -0700 @@ -53,7 +53,8 @@ s5_tc3.dd s6_tc3.dd sh_tc3.dd \ ddsd0_cocosdc.dd sd0_cocosdc.dd sd1_cocosdc.dd \ llcoco3fpga.dr ddsd0_coco3fpga.dd sd0_coco3fpga.dd sd1_coco3fpga.dd \ - ramd_coco3fpga.dr r0_ramd_coco3fpga.dd + ramd_coco3fpga.dr r0_ramd_coco3fpga.dd \ + emudsk.dr ddh0_emudsk.dd h0_emudsk.dd h1_emudsk.dd SCF = scf.mn \ vtio.dr vrn.dr scbbp.dr scbbt.dr scdwp.dr sspak.dr sc6551.dr \ @@ -166,6 +167,9 @@ rb1773_scii_ff58.dr: rb1773.asm $(AS) $< $(ASOUT)$@ $(AFLAGS) -DSCII=1 -DSCIIALT=1 +emudsk.dr: emudsk.asm + $(AS) $< $(ASOUT)$@ $(AFLAGS) + # REL Modules rel_32: rel.asm $(AS) $< $(ASOUT)$@ $(AFLAGS) -DWidth=32 @@ -289,6 +293,16 @@ r0_ramd_coco3fpga.dd: ramddesc_coco3fpga.asm $(AS) $< $(ASOUT)$@ $(AFLAGS) +# Emudsk descriptors +ddh0_emudsk.dd: emudskdesc.asm + $(AS) $< $(ASOUT)$@ $(AFLAGS) -DDNum=0 -DDD=1 + +h0_emudsk.dd: emudskdesc.asm + $(AS) $< $(ASOUT)$@ $(AFLAGS) -DDNum=0 + +h1_emudsk.dd: emudskdesc.asm + $(AS) $< $(ASOUT)$@ $(AFLAGS) -DDNum=1 + # DriveWire SCF descriptors term_scdwv.dt: scdwvdesc.asm $(AS) $< $(ASOUT)$@ $(AFLAGS) -DAddr=0