home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.update.uu.se
/
ftp.update.uu.se.2014.03.zip
/
ftp.update.uu.se
/
pub
/
rainbow
/
msdos
/
latrobe
/
b
/
biodif.arc
/
UDISKDRV.DIF
< prev
next >
Wrap
Text File
|
1987-06-20
|
13KB
|
440 lines
----------UDISKDRV.OLD
;
;--
----------UDISKDRV.ASM
; RGT 17 Jan 1987 Allow it to reference double-sided disks.
;
; RGT 8 Feb 1987 Added calls to disk cache routines
;
;--
-----------------------------------------------
----------UDISKDRV.OLD
;
----------UDISKDRV.ASM
; ;RGT
; Include the disk definition file ;RGT
; ;RGT
INCLUDE FDISK.H ;RGT
;
-----------------------------------------------
----------UDISKDRV.OLD
TMRCNT EQU 002H ;2-second timeout
;
; Dfine the IOCTL packet offsets
;
IOFUN EQU 0 ;IOCTL packet function offset
IODRV EQU 1 ;IOCTL packet driver offset
IOSEC EQU 2 ;IOCTL packet sector offset
IOTRK EQU 4 ;IOCTL packet track offset
IOCNT EQU 6 ;IOCTL packet sector count offset
IOOFF EQU 8 ;IOCTL buffer offset offset
IOSEG EQU 00AH ;IOCTL buffer segment offset
----------UDISKDRV.ASM
TMRCNT EQU 005H ;5-second timeout ;RGT
;
-----------------------------------------------
----------UDISKDRV.OLD
;
----------UDISKDRV.ASM
EXTRN DISK_CTYP_OFF:ABS ;Pointer to media type holder ;RGT
EXTRN READ_BLOCK_FROM_CACHE:NEAR ;Routine to read cache ;RGT
EXTRN WRITE_BLOCK_TO_CACHE:NEAR ;Routine to write cache ;RGT
EXTRN INVALIDATE_DISK_CACHE:NEAR ;Routine to invalidate ;RGT
;disk in cache ;RGT
;
-----------------------------------------------
----------UDISKDRV.OLD
CALL PHYSBUF ;Do buffered read or write
JC RDWRRET ;Exit if error
MOV AL,DSKDRV ;No error -- reset timer/drive
----------UDISKDRV.ASM
; ;RGT
; If this is a read, then try to read the data from the disk cache ;RGT
; ;RGT
CMP BYTE PTR COMMAND,FREAD ;Check if this is a read ;RGT
JNE READWRITE_110 ;If not, check write ;RGT
LES DI,DWORD PTR DMAOFF ;Get address of user buffer ;RGT
MOV DX,SECTOR ;Get logical sector ;RGT
MOV AL,DRIVER ;Get driver code ;RGT
CALL READ_BLOCK_FROM_CACHE ;Call routine to read cache ;RGT
JC READWRITE_210 ;If not in cache, read from disk;RGT
; ;RGT
; Disk block was in cache -- no need to read from disk ;RGT
; ;RGT
JMP SHORT READWRITE_310 ;Skip over disk read ;RGT
; ;RGT
; If this is a write, then write the data to the disk cache ;RGT
; ;RGT
READWRITE_110: ;RGT
LES DI,DWORD PTR DMAOFF ;Get address of user buffer ;RGT
MOV DX,SECTOR ;Get logical sector ;RGT
MOV AL,DRIVER ;Get driver code ;RGT
CALL WRITE_BLOCK_TO_CACHE ;Call routine to write cache ;RGT
READWRITE_210: ;RGT
CALL PHYSBUF ;Do buffered read or write
JC RDWRRET ;Exit if error
; ;RGT
; If this was a read, and the buffer was not in cache, ;RGT
; then the routine was called to read the disk. ;RGT
; Now that the disk has been read, write it to cache. ;RGT
; ;RGT
CMP BYTE PTR COMMAND,FREAD ;Check if this is a read ;RGT
JNE READWRITE_310 ;If not, check write ;RGT
LES DI,DWORD PTR DMAOFF ;Get address of user buffer ;RGT
MOV DX,SECTOR ;Get logical sector ;RGT
MOV AL,DRIVER ;Get driver code ;RGT
CALL WRITE_BLOCK_TO_CACHE ;Call routine to write cache ;RGT
; ;RGT
; Disk has been read or written, and not error occured. ;RGT
; Reset disk timer and get ready for next read or write. ;RGT
; ;RGT
READWRITE_310: ;RGT
MOV AL,DSKDRV ;No error -- reset timer/drive
-----------------------------------------------
----------UDISKDRV.OLD
MOV SI,[BX+6] ;SI = type pointer (current type)
MOV TYPPTR,SI ;Save type pointer
MOV AL,[SI] ;Get current format
AND AX,7 ;Three choices
ADD BX,AX ;Add word offset
----------UDISKDRV.ASM
MOV SI,[BX+DISK_CTYP_OFF] ;SI = type pointer (current type)
MOV TYPPTR,SI ;Save type pointer
MOV AL,[SI] ;Get current format
AND AX,7 ;Six choices ;RGT
ADD BX,AX ;Add word offset
-----------------------------------------------
----------UDISKDRV.OLD
MOV AH,-1 ;SEt change to unknown
JC SAMDSK ;If error, return error
----------UDISKDRV.ASM
MOV AH,-1 ;Set change to unknown
JC SAMDSK ;If error, return error
-----------------------------------------------
----------UDISKDRV.OLD
;
; Set return code to no error
;
MAYBEC:
CLC ;Clear carry for no error
----------UDISKDRV.ASM
JMP SHORT NOCHANGE ;And return success ;RGT
;
; Disk changed -- invalidate cache for disk and set return code to no error
;
MAYBEC:
PUSH AX ;Save result of check ;RGT
MOV AL,BL ;Get current disk in reg AL ;RGT
CALL INVALIDATE_DISK_CACHE ;Invalidate cache for this disk ;RGT
POP AX ;Restore result of check ;RGT
NOCHANGE: ;RGT
CLC ;Clear carry for no error
-----------------------------------------------
----------UDISKDRV.OLD
RET ;Return to caller
----------UDISKDRV.ASM
; ;RGT
; Disk information has been stored -- invalidate cache for this disk;RGT
; ;RGT
XOR CX,CX ;Clear count ;RGT
MOV CL,AL ;Get count of number of disks ;RGT
DEC AL ;Decrement to get disk number ;RGT
FDSKINIT_010: ;RGT
PUSH CX ;Save count of disks ;RGT
CALL INVALIDATE_DISK_CACHE ;Invalidate cache for this disk ;RGT
DEC AL ;Decrement to next disk ;RGT
POP CX ;Restore count of disks ;RGT
LOOP FDSKINIT_010 ;Loop for all floppy disks ;RGT
RET ;Return to caller
-----------------------------------------------
----------UDISKDRV.OLD
; ?
----------UDISKDRV.ASM
; DRIVER -- Disk drive to be checked.
;
; Exit Parameters:
;
; Carry -- Set if error occured on read or write
; If set, Reg AL contains MS-DOS error code.
;
; Side Effects:
;
; Sets disk drive type to the disk type found.
;
; Registers Changed: All
;
; Disk types returned by Z80:
;
; Rainbow = 0
; Robin = 2
; IBM 9 = 4 (Not used -- returns ROBIN)
; IBM 8 = 8
; Mongrel = 00AH
; Double-Sided = 010H (Set in addition to others)
; Unknown = 0FFH
;
; Disk types that are set by this routine:
;
; Rainbow Single-sided = 0
; IBM 8 Single-sided = 1
; IBM 9 Single-sided = 2
; Rainbow Double-sided = 4
; IBM 8 Double-sided = 5
; IBM 9 Double-sided = 6
;
;--
;
CHKMED:
MOV AL,DRIVER ;Get current drive to check
CMP AL,BYTE PTR FDSKTBL ;See if it is a valid drive
JB CKMDA1 ;If so, check it
MOV AL,1 ;Otherwise, set error code to invalid
STC ;Set carry to indicate error
JMP BAILOUT ;And bail out of routine
;
; Drive is valid -- check media check flag
;
CKMDA1:
CMP BYTE PTR MC_FLG,1 ;Check media check flag
JNZ NORMAL ;If not set, do check
XOR AX,AX ;Otherwise, assume Rainbow media
JMP SHORT OKMDIA ;And skip media check codes
;
; Normal operation -- check media type
;
NORMAL:
MOV BX,OFFSET IOPKT ;Get offset of I/O packet
MOV IOCTL_DMASEG_OFF[BX],DS ;Store I/O transfer buf seg ;RGT
MOV WORD PTR IOCTL_DMAOFF_OFF[BX],OFFSET BUFFER ;RGT
;I/O transfer buf off
MOV IOCTL_DRIVE_OFF[BX],AL ;Drive to check ;RGT
MOV BYTE PTR IOCTL_CMD_OFF[BX],IOCTL_CMD_MEDIA_CHK ;RGT
;Check media function
INT DSKDRCT ;Direct disk driver interrupt
;
; Performed media check function by direct disk function
;
MOV AL,01 ;In case of error, set error code
JC BAILOUT ;If error, bailout
MOV BX,OFFSET BUFFER ;Media type is in first byte of buffer
XOR AX,AX ;Clear field for weird
MOV AL,[BX] ;Get media type
; AND AL,AL ;If Rainbow or IBM8, then OK
AND AL,AL ;Check if Rainbow, then OK ;RGT
JZ OKMDIA ;Return that media type
CMP AL,010H ;See if double-sided ;RGT
JNZ CALLSOFT ;If not, then check type ;RGT
MOV AL,4 ;Otherwise, set double-sided ;RGT
JMP SHORT OKMDIA ;And return rainbow double ;RGT
; ;RGT
; Not a Rainbow diskette -- read disk media type ;RGT
; ;RGT
CALLSOFT: ;RGT
CALL SOFTCHK ;Otherwise, find out what type it is
JB BAILOUT ;If not succesful, then just return
;
; Found media type -- return it to caller
;
OKMDIA:
XOR BX,BX ;Clear pointer
MOV BL,DRIVER ;Get current disk again
SHL BX,1 ;Make it a word index
MOV BX,FDSKTBL[BX+1] ;Get media type table for drive
MOV SI,[BX+DISK_CTYP_OFF] ;Get pointer to media type holder
MOV [SI],AL ;Save media type
XOR AL,AL ;Clear status for no error
CLC ;Clear carry for no error
;
; Done or error occured -- return to caller
;
BAILOUT:
RET ;Return to caller
;++
;
; Function: SOFTCHK
;
; Abstract:
;
; Soft media check to see if it is a real 9-sector disk.
; Read the disk ID byte to check if logical.
;
; Entry Parameters:
;
; ?
-----------------------------------------------
----------UDISKDRV.OLD
; Registers Changed: All
----------UDISKDRV.ASM
; Reg AL -- Media type
;
; Registers Changed: All
-----------------------------------------------
----------UDISKDRV.OLD
CHKMED:
MOV AL,DRIVER ;Get current drive to check
CMP AL,BYTE PTR FDSKTBL ;See if it is a valid drive
JB CKMDA1 ;If so, check it
MOV AL,1 ;Otherwise, set error code to invalid
STC ;Set carry to indicate error
JMP BAILOUT ;And bail out of routine
;
; Drive is valid -- check media check flag
;
CKMDA1:
CMP BYTE PTR MC_FLG,1 ;Check media check flag
JNZ NORMAL ;If not set, do check
XOR AX,AX ;Otherwise, assume Rainbow media
JMP SHORT OKMDIA ;And skip media check codes
;
; Normal operation -- check media type
;
NORMAL:
MOV BX,OFFSET IOPKT ;Get offset of I/O packet
MOV IOSEG[BX],DS ;Store I/O transfer buffer segment
MOV WORD PTR IOOFF[BX],OFFSET BUFFER ;I/O transfer buf off
MOV IODRV[BX],AL ;Drive to check
MOV BYTE PTR IOFUN[BX],04 ;Check media function
INT DSKDRCT ;Direct disk driver interrupt
;
; Performed media check function by direct disk function
;
MOV AL,01 ;In case of error, set error code
JC BAILOUT ;If error, bailout
MOV BX,OFFSET BUFFER ;Media type is in first byte of buffer
XOR AX,AX ;Clear field for weird
MOV AL,[BX] ;Get media type
AND AL,AL ;If Rainbow or IBM8, then OK
JZ OKMDIA ;Return that media type
CALL SOFTCHK ;Otherwise, find out what type it is
JB BAILOUT ;If not succesful, then just return
;
; Found media type -- return it to caller
;
OKMDIA:
XOR BX,BX ;Clear pointer
MOV BL,DRIVER ;Get current disk again
SHL BX,1 ;Make it a word index
MOV BX,FDSKTBL[BX+1] ;Get media type table for drive
MOV SI,[BX+6] ;Get pointer to media type holder
MOV [SI],AL ;Save media type
XOR AL,AL ;Clear status for no error
CLC ;Clear carry for no error
;
; Done or error occured -- return to caller
;
BAILOUT:
RET ;Return to caller
;++
;
; Function: SOFTCHK
;
; Abstract:
;
; Soft media check to see if it is a real 9-sector disk.
; Read the disk ID byte to check if logical.
;
; Entry Parameters:
;
; ?
;
; Exit Parameters:
;
; Carry -- Set if error occured on read or write
; If set, Reg AL contains MS-DOS error code.
;
; Reg AL -- Media type
;
; Registers Changed: All
;
;
;--
;
SOFTCHK:
----------UDISKDRV.ASM
SOFTCHK:
-----------------------------------------------
----------UDISKDRV.OLD
MOV IODRV[BX],AL ;Drive to be read
MOV BYTE PTR IOSEC[BX],2 ;Type byte is on sector 2
MOV WORD PTR IOTRK[BX],0 ;On track zero
MOV WORD PTR IOCNT[BX],1 ;Only read one sector, of course
MOV WORD PTR IOOFF[BX],OFFSET BUFFER ;Default sector buff
MOV IOSEG[BX],DS ;Default data segment
MOV BYTE PTR IOFUN[BX],0 ;Read data command
;
----------UDISKDRV.ASM
MOV IOCTL_DRIVE_OFF[BX],AL ;Drive to be read ;RGT
MOV BYTE PTR IOCTL_SECTOR_OFF[BX],2 ;Type byte is on sec 2 ;RGT
MOV WORD PTR IOCTL_TRACK_OFF[BX],0 ;On track zero ;RGT
MOV WORD PTR IOCTL_COUNT_OFF[BX],1 ;Only read one sector, ;RGT
;of course
MOV WORD PTR IOCTL_DMAOFF_OFF[BX],OFFSET BUFFER ;RGT
;Default sector buff
MOV IOCTL_DMASEG_OFF[BX],DS ;Default data segment ;RGT
MOV BYTE PTR IOCTL_CMD_OFF[BX],IOCTL_CMD_READ ;RGT
;Read data command
;
-----------------------------------------------
----------UDISKDRV.OLD
;
----------UDISKDRV.ASM
; ;RGT
; Check for double-sided IBM disk types ;RGT
; ;RGT
MOV AL,5 ;Set to IBM 8-sector double ;RGT
CMP BYTE PTR [BX],0FFH ;See if IBM 8-sector double ;RGT
JZ EXITO ;If so, then return type ;RGT
INC AL ;Increment to IBM 9-sect double ;RGT
CMP BYTE PTR [BX],0FDH ;See if IBM 9-sector doulbe ;RGT
JZ EXITO ;If so, then return type ;RGT
;
-----------------------------------------------