;       SCCSID = @(#)fileio.inc	6.1 90/11/17
;      SCCSID = @(#)fileio.inc	13.3 89/09/22
BREAK	<DOSFILEIO Definitions>

;****	  DOSFILEIO definitions
;
; This file contains the structure definitions and equates used for DOSFILEIO
; and DOSFILELOCKS apis.
;
; DOSFILEIO allows an application writer the ability to perform multiple
; operations (Lock,Unlock,Seek,Read,Write) on a single file using 1 api call.
; It specifically suited for the networking environment where performance is
; critical.They benefit by having only one call made across their communication
; medium while they may perform multiple operations. For the FAT File System
; and local FSDs' we break up the DOSFILEIO buffer into separate operations.
;
; The user passes the commands and their parameters in a single buffer. If an
; error occurs we store the offset of the failing command in an area
; designated by the user.
;
; The following is a pictorial view of how 2 buffers might look:
;
;	  -------------
;	  |  Cmd      | Lock Header
;	  |  Lockcount|
;	  |  Timeout  |
;	  ------------- <-----------FIO_LockListOff
;	  |  Share    | Lock 1
;	  |  Start    |
;	  |  Length   |
;	  -------------
;	  |  Cmd      | Seek Packet
;	  |  Method   |
;	  |  Position |
;	  |  Actual   |
;	  -------------
;	  |  Cmd      | Read Packet
;	  |  BufferPtr|
;	  |  BufferLen|
;	  |  Actual   |
;	  -------------
;	       |
;	       | <-----------------------User Modifies Data
;	       |
;	  -------------
;	  |  Cmd      | Seek Packet
;	  |  Method   |
;	  |  Position |
;	  |  Actual   |
;	  -------------
;	  |  Cmd      | Write Packet
;	  |  BufferPtr|
;	  |  BufferLen|
;	  |  Actual   |
;	  -------------
;	  |  Cmd      | UnLock Header
;	  |  Lockcount|
;	  -------------<-----------FIO_UnLockListOff
;	  |  Start    | Lock 1
;	  |  Length   |
;	  -------------
;
; The first word in each command packet is the command itself. This is the
; header for all commands.
;
FIOCmdHeader	   STRUC
   FIO_Hdr_Cmd	   dw	   ?		; 0=lock 1=unlock 2=seek 3=read 4=write
FIOCmdHeader	   ENDS

; The following structure is used when a Seek command is being processed. It
; includes the command header field along other necessary fields.
;
FIOCmdSeek	STRUC
   FIO_Seek_Cmd	     db	  size FIOCmdHeader dup (?)
   FIO_Seek_Method   dw	     ?		   ; 0 for absolute
					   ; 1 for relative to current
					   ; 2 for relative to EOF.
   FIO_Seek_Position dd	     ?		   ; file seek position or delta
   FIO_Seek_Actual   dd	     ?		   ; actual position seeked to
FIOCmdSeek	ENDS

; The following structure is used when a IO command is being processed. Either
; Read or Write. It includes the command header field along with other IO
; fields.
;
FIOCmdIO	STRUC
   FIO_IO_Cmd	    db	 size FIOCmdHeader dup (?)
   FIO_IO_BufferPtr dd	    ?		   ; ptr to data buffer for I/O
   FIO_IO_BufferLen dw	    ?		   ; size of data buffer
   FIO_IO_Actual    dw	    ?		   ; actual number of bytes transfered
FIOCmdIO	ENDS

; The following structure is used as the lock header for Lock and Unlock
; commands. It includes the command header field and the count of the locks
; that follow in the buffer.
;
FIOLockHeader	STRUC
		   db	size FIOCmdHeader dup (?)
   FIO_LockCnt	   dw	   ?		   ; number of locks in list
FIOLockHeader	ENDS

; The following structure is used when a Lock command is being processed. It
; includes the Lock header along with the timeout value to be used for the
; entire lock list to complete.
;
FIOCmdLock	STRUC
		       db   size FIOLockHeader dup (?)
   FIO_Lock_Timeout    dd      ?	   ; ms timeout for lock list success
FIOCmdLock	ENDS
FIO_LockListOff	 equ	 size FIOCmdLock    ; offset to first lock entry

; The following structure is used when a Unlock command is being processed
; Its field are defined in the lock header. No other fields are defined.
;
FIOCmdUnLock	STRUC
		db   size FIOLockHeader dup (?)
FIOCmdUnLock	ENDS
FIO_UnLockListOff equ	  size FIOCmdUnLock  ; offset to first unlock entry

; The following structure is used when referencing a particular lock in the
; lock list. The share field indicates the type of lock to be set.
;
FIOLock		STRUC
   FIO_Lock_Share  dw	   ?		; 0 = exclusive 1 = shared
   FIO_Lock_Start  dd	   ?		; start of locked region
   FIO_Lock_Length dd	   ?		; length of locked region
FIOLock		ENDS

; The following equates are used to reference the two kinds of locks supported
; They are Shared and Exclusive.

FIO_LOCK_SHARE_SHR    equ  1
FIO_LOCK_SHARE_EXCL   equ  0

; The following structure is used when referencing a particular lock in the
; unlock list.
;
FIOUnlock	   STRUC
   FIO_Unlock_Start    dd      ?	 ; start of locked region
   FIO_Unlock_Length   dd      ?	 ; length of locked region
FIOUnlock	   ENDS

; The following structure is used by DOSFILELOCKS. If both fields are zero
; this means that no locking or unlocking needs to be done.
;
Filelock	STRUC
   FLK_Start	   dd	   ?		; start of locked region
   FLK_Length	   dd	   ?		; length of locked region
Filelock	  ENDS

; FIO_Lock_Size is the size of a lock command packet with 1 lock list entry
; in the list. FIO_Unlock_Size is the size of an unlock command packet with
; 1 unlock list entry in the list. FIO_Lock_Unlock_Size is total of the two.
; These equates are used by w_FileLocks since it calls w_FileIO.

FIO_Lock_Size = (size FIOCmdLock) + (size FIOLock)
FIO_UnLock_Size = (size FIOCmdUnLock) + (size FIOUnlock)
FIO_Lock_Unlock_Size = FIO_Lock_Size + FIO_UnLock_Size

; MAXFILEIOSIZE is the maximum space occupied by a FileIO command. This does
; not include lock lists. It is used when coping a command packet onto the
; temporary buffer by FileIORouter. The temporary buffer is defined to be the
; size of MAXFILEIOSIZE.

MAXFILEIOSIZE = size FIOCmdSeek

; Command codes for DOSFILEIO

FIO_CMD_LOCK	    EQU	    0
FIO_CMD_UNLOCK	    EQU	    1
FIO_CMD_SEEK	    EQU	    2
FIO_CMD_READ	    EQU	    3
FIO_CMD_WRITE	    EQU	    4
FIO_MAXCMD	    EQU	    FIO_CMD_WRITE
