%include "buf2sw.mac"

;	SCCSID = @(#)buffer.asm 1.1 85/04/09
BREAK <Disk I/O Buffer Header>
;----+----+----+----+----+----+----+----+----+----+----+----+----+----+----;
;	     C	A  V  E  A  T	  P  R	O  G  R  A  M  M  E  R		   ;
;									   ;

%ifdef BUF2

; Field definition for I/O buffer information

BUFFINFO        STRUC
NEXTBUF         DD      ?       ; Pointer to next buffer in list
; The next two items are often refed as a word
buf_ID:
BUFDRV          DB      ?       ; Logical drive # assoc with buffer FF = free
buf_flags:
BUFDATAFLAG	db	?
BUFPRI          DB      ?       ; Buffer selection priority (see EQUs below)
	alignb 2
buf_sector:
BUFSECNO        dd      ?       ; Sector number of buffer
	alignb 2
BUFDRVDP        DD      ?       ; Pointer to drive parameters
BUFFINFO        ENDS

BUFINSIZ        EQU     BUFFINFO_struc_size
                                ; Size of structure in bytes
BUFINSIZE equ BUFINSIZ

FREEPRI EQU     0
LBRPRI  EQU     2               ; Last byte of buffer read
LBWPRI  EQU     4               ; Last byte written
RPRI    EQU     6               ; Read but not last byte
WPRI    EQU     8               ; Written but not last byte
DIRPRI  EQU     15              ; Directory Sector
FATPRI  EQU     30              ; FAT sector

buf_dirty	EQU	01000000B
buf_isDATA	EQU	00001000B
buf_isDIR	EQU	00000100B
buf_isFAT	EQU	00000010B
buf_type_0	EQU	11110001B	; AND sets type to "none"

%else

; Field definition for I/O buffer information

BUFFINFO	STRUC
buf_next	DW	?		; Pointer to next buffer in list
buf_prev	DW	?		; Pointer to prev buffer in list
buf_ID		DB	?		; Drive of buffer (bit 7 = 0)
					; SFT table index (bit 7 = 1)
					; = FFH if buffer free
buf_flags	DB	?		; Bit 7 = 1 if Remote file buffer
					;	= 0 if Local device buffer
					; Bit 6 = 1 if buffer dirty
					; Bit 5 = Reserved
					; Bit 4 = Search bit (bit 7 = 1)
					; Bit 3 = 1 if buffer is DATA
					; Bit 2 = 1 if buffer is DIR
					; Bit 1 = 1 if buffer is FAT
					; Bit 0 = Reserved
buf_sector	DD	?		; Sector number of buffer (bit 7 = 0)
; The next two items are often refed as a word (bit 7 = 0)
buf_wrtcnt	DB	?		; For FAT sectors, # times sector written out
buf_wrtcntinc	DW	?		; "   "     "   , # sectors between each write
buf_DPB 	DD	?		; Pointer to drive parameters
buf_fill	DW	?		; How full buffer is (bit 7 = 1)
buf_reserved	DB	?		; make DWORD boundary for 386
BUFFINFO	ENDS

labelsize buf_offset, dword, buf_sector
					;For bit 7 = 1, this is the byte
					;offset of the start of the buffer in
					;the file pointed to by buf_ID.  Thus
					;the buffer starts at location
					;buf_offset in the file and contains
					;buf_fill bytes.

BUFINSIZ	EQU	BUFFINFO_struc_size
					; Size of structure in bytes

buf_Free	EQU	0FFh		; buf_id of free buffer

;Flag byte masks
buf_isnet	EQU	10000000B
buf_dirty	EQU	01000000B

buf_isDATA	EQU	00001000B
buf_isDIR	EQU	00000100B
buf_isFAT	EQU	00000010B
buf_type_0	EQU	11110001B	; AND sets type to "none"

buf_NetID	EQU	BUFINSIZ

;
; Buffer Hash Entry Structure

BUFFER_HASH_ENTRY	STRUC		; DOS 4.00
EMS_PAGE_NUM	DW	?		; logical page number for EMS handle
BUFFER_BUCKET	DD	 ?		; pointer to buffers
DIRTY_COUNT	DB	 ?		; number of dirty buffers
BUFFER_RESERVED DB	 ?		; reserved
BUFFER_HASH_ENTRY	ENDS

MaxBuffinBucket EQU	15		; Max number of buffers per bucket
MaxBucketinPage EQU	 2		; Max number of buckets per 16kb page

%endif

;									   ;
;	     C	A  V  E  A  T	  P  R	O  G  R  A  M  M  E  R		   ;
;----+----+----+----+----+----+----+----+----+----+----+----+----+----+----;
