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
/
CACHECTL.ASM
< prev
next >
Wrap
Assembly Source File
|
1987-06-20
|
8KB
|
404 lines
PAGE 60,132
TITLE MSDOS 2.0 Cache Control Routines
;++
;
; FILE: CACHECTL.ASM
;
; FACILITY: MS-DOS Drivers
;
; ABSTRACT:
;
; This is the set of routines that provide a disk cache
; for the computer disk accesses.
;
; It sets up far calls to the actual cache routines,
; which are an additional driver stored in memory.
;
; It is installed as an additional driver so it can
; use MS-DOS to allocate memory for the cache buffers.
;
; ENVIRONMENT: Rainbow 100+
;
; AUTHOR: Richard Thomsen
;
;
;----------------------------------------------------------------------
;
; CREATION DATE: 2 February 1987
;
; MODIFIED BY:
;
;
;--
;
CGROUP GROUP CODE
;
; Define the global entry points for this routine
;
PUBLIC READ_BLOCK_FROM_CACHE ;Routine to read cache
PUBLIC WRITE_BLOCK_TO_CACHE ;Routine to write cache
PUBLIC INVALIDATE_DISK_CACHE ;Routine to invalidate disk in cache
PUBLIC INVALIDATE_HARD_DISK_CACHE ;Routine to invalidate the
;hard disk in cache
PUBLIC DISK_CACHE_TIMEOUT ;Disk cache timeout
PUBLIC CACHE_IOCTL ;Routine to control cache
;
; Include the Rainbow hard disk controller definition file
;
INCLUDE HCDEF.H
;
;
; Define the code and data segments
;
CODE SEGMENT BYTE PUBLIC 'CODE'
ASSUME CS:CGROUP, DS:CGROUP
;
; Define the externals used by this routine
;
; EXTRN None
;
; Define the FAR entry points for the disk cache routines.
; These will be overwritten when the cache is installed.
;
DISK_ADR_SIZES EQU 24 ;Size of addresses
INV_DISK_CACHE_ADR DD DUMMY_RETURN
INV_HARD_DISK_CACHE_ADR DD DUMMY_RETURN
DISK_CACHE_TIMEOUT_ADR DD DUMMY_RETURN
READ_FROM_CACHE_ADR DD DUMMY_RETURN_CARRY_SET
WRITE_TO_CACHE_ADR DD DUMMY_RETURN
CACHE_IOCTL_ADR DD INSTALL_CACHE
;
; Define the structure for the disk cache control call for installation
; The addresses stored in the call must be in the same order as
; the addresses above.
;
DISK_CACHE_CTL STRUC
;
DCIE_FUNCTION DB ? ;Function code -- must be 10 (decimal)
DCIE_DRIVE DB ? ;Disk drive number (ignored)
DCIE_SUB_FUNCTION DB ? ;Sub-function - must be zero
DCIE_STATUS DB ? ;Status code returned from function
DCIE_INV_DISK_ADR DD ? ;Function to invalidate disk
DCIE_HINV_DISK_ADR DD ? ;Function to inv hard disk
DCIE_DISK_TIME_ADR DD ? ;Function to decrement timeouts
DCIE_READ_DISK_ADR DD ? ;Function to read cache
DCIE_WRITE_DISK_ADR DD ? ;Function to write cache
DCIE_IOCTL_ADR DD ? ;Function to perform IOCTL functions
;
DISK_CACHE_CTL ENDS ;End of structure
;
;++
;
; Function: READ_BLOCK_FROM_CACHE
;
; Abstract:
;
; Read a block from the disk cache and write it to the user buffer.
;
; Entry Parameters:
;
; Reg AL -- Code for disk for this block.
; Reg DX -- Logical sector number of this block.
; Reg ES:DI -- User buffer to be filled from disk cache.
;
; Exit Parameters:
;
; Carry -- Set if block is not in cache.
; Clear if block was filled from cache.
; Reg ES:DI -- If block was filled from cache,
; then DI has been incremented to next
; sector position.
;
; Registers Changed: DI
;
;
;--
;
; Do a FAR call to the actual disk cache control routines.
;
READ_BLOCK_FROM_CACHE PROC NEAR
CALL CS:[READ_FROM_CACHE_ADR] ;Read block from cache
RET ;And return to caller
;
READ_BLOCK_FROM_CACHE ENDP ;End of procedure
;
;++
;
; Function: WRITE_BLOCK_TO_CACHE
;
; Abstract:
;
; Write a block to the disk cache from the user buffer.
;
; Entry Parameters:
;
; Reg AL -- Code for disk for this block.
; Reg DX -- Logical sector number of this block.
; Reg ES:DI -- User buffer to be copied to disk cache.
;
; Exit Parameters:
;
; None
;
; Registers Changed: None
;
;
;--
;
; Do a FAR call to the actual disk cache control routines.
;
WRITE_BLOCK_TO_CACHE PROC NEAR
CALL CS:[WRITE_TO_CACHE_ADR] ;Write block to cache
RET ;And return to caller
;
WRITE_BLOCK_TO_CACHE ENDP ;End of procedure
;
;++
;
; Function: INVALIDATE_DISK_CACHE
;
; Abstract:
;
; Invalidate all blocks in the disk cache for a given disk.
;
; Entry Parameters:
;
; Reg AL -- Code for disk for this block.
;
; Exit Parameters:
;
; None
;
; Registers Changed: None
;
;
;--
;
; Do a FAR call to the actual disk cache control routines.
;
INVALIDATE_DISK_CACHE PROC NEAR
CALL CS:[INV_DISK_CACHE_ADR] ;Invalidate disk in cache
RET ;And return to caller
;
INVALIDATE_DISK_CACHE ENDP ;End of procedure
;
;++
;
; Function: INVALIDATE_HARD_DISK_CACHE
;
; Abstract:
;
; Invalidate all blocks in the disk cache for the hard disk.
;
; Entry Parameters:
;
; None
;
; Exit Parameters:
;
; None
;
; Registers Changed: None
;
;
;--
;
; Do a FAR call to the actual disk cache control routines.
;
INVALIDATE_HARD_DISK_CACHE PROC NEAR
CALL CS:[INV_HARD_DISK_CACHE_ADR] ;Invalidate hard disk in cache
RET ;And return to caller
;
INVALIDATE_HARD_DISK_CACHE ENDP ;End of procedure
;
;++
;
; Function: DISK_CACHE_TIMEOUT
;
; Abstract:
;
; Timeout all disks that can timeout in the cache.
;
; Entry Parameters:
;
; None
;
; Exit Parameters:
;
; None
;
; Registers Changed: None
;
;
;--
;
; Do a FAR call to the actual disk cache control routines.
;
DISK_CACHE_TIMEOUT PROC NEAR
CALL CS:[DISK_CACHE_TIMEOUT_ADR] ;Timeout disks in cache
RET ;And return to caller
;
DISK_CACHE_TIMEOUT ENDP ;End of procedure
;
;++
;
; Function: CACHE_IOCTL
;
; Abstract:
;
; Perform user functions on the cache
;
; Entry Parameters:
;
; None
;
; Exit Parameters:
;
; None
;
; Registers Changed: None
;
;
;--
;
; Do a FAR call to the actual disk cache control routines.
;
CACHE_IOCTL PROC NEAR
CALL CS:[CACHE_IOCTL_ADR] ;Call cache IOCTL routine
RET ;And return to caller
;
CACHE_IOCTL ENDP ;End of procedure
;
;++
;
; Function: DUMMY_RETURN_CARRY_SET
;
; Abstract:
;
; Provide a routine that sets carry and returns.
; This will allow an address and operation without a cache.
; When the cache is installed, the address of the actual
; cache routine replaces the address of this routine.
;
; Entry Parameters:
;
; None
;
; Exit Parameters:
;
; Carry set
;
; Registers Changed: None
;
;
;--
;
; Do nothing, except set carry.
;
DUMMY_RETURN_CARRY_SET PROC FAR
STC ;Set carry for block not found
RET ;And just return to caller
;
DUMMY_RETURN_CARRY_SET ENDP ;End of procedure
;
;++
;
; Function: DUMMY_RETURN
;
; Abstract:
;
; Provide a routine that returns.
; This will allow an address and operation without a cache.
; When the cache is installed, the address of the actual
; cache routine replaces the address of this routine.
;
; Entry Parameters:
;
; None
;
; Exit Parameters:
;
; None
;
; Registers Changed: None
;
;
;--
;
; Do nothing.
;
DUMMY_RETURN PROC FAR
RET ;Just return to caller
;
DUMMY_RETURN ENDP ;End of procedure
;
;++
;
; Function: INSTALL_CACHE
;
; Abstract:
;
; Installation routine for the disk cache.
;
; Entry Parameters:
;
; ES:DI -- Address of IOCTL packet.
;
; Exit Parameters:
;
; None
;
; Registers Changed: All
;
;
;--
;
; Routine to install cache
;
INSTALL_CACHE PROC FAR
MOV AL,ES:[DI].DCIE_SUB_FUNCTION ;Get sub-function
OR AL,AL ;See if zero
JZ INSTALL_CACHE_110 ;If so, then install cache
;
; Not the proper installation code -- return error
;
MOV ES:BYTE PTR [DI].DCIE_STATUS,0FFH ;Return error code
RET ;And return to caller
;
; Proper installation code -- install cache
;
INSTALL_CACHE_110:
PUSH ES ;Save segment registers
PUSH DS
MOV AX,ES ;Move reg ES to DS
MOV DS,AX
MOV AX,CS ;Move reg CS to ES
MOV ES,AX
LEA SI,[DI].DCIE_INV_DISK_ADR ;Move address of disk addresses to SI
MOV CX,DISK_ADR_SIZES ;Get size of addresses to move
CLD ;Set direction forward
REP MOVSW ;Copy addresses to memory
POP DS ;Restore segment registers
POP ES
XOR AX,AX ;Set return code to success
MOV ES:[DI].DCIE_STATUS,AL ;Return function code
RET ;And return to caller
;
INSTALL_CACHE ENDP ;End of procedure
;
CODE ENDS
END