RESIOSFN	EQU	16 
MAXSFN	EQU	(65535  - 256  - 256  - RESIOSFN + 1 )
SFN_NULL	EQU	(-1 )          
SFN_BUSY	EQU	(-2 )          
MAXJFN	EQU	32768 
MAX3XJFN	EQU	256 
SF_DEFAULT_NUMBER	EQU	80 
SFTINCR	EQU	8 
SFNAMELEN	EQU	11             
SPECSFDWORKAREASIZE	EQU	30           
SFDWORKAREASIZE	EQU	50          
.errnz        (not (SFDWORKAREASIZE ge SPECSFDWORKAREASIZE))
 

sftsfi	STRUC
sfi_mode	DW	?
sfi_mode2	DW	?
sfi_hVPB	DW	?
sfi_ctime	DW	?
sfi_cdate	DW	?
sfi_atime	DW	?
sfi_adate	DW	?
sfi_mtime	DW	?
sfi_mdate	DW	?
sfi_size	DD	?
sfi_position	DD	?
sfi_UID	DW	?
sfi_PID	DW	?
sfi_PDB	DW	?
sfi_selfsfn	DW	?
sfi_tstamp	DB	?
sfi_type	DW	?
pPVDBFil	DD	?
sfi_DOSattr	DB	?
sftsfi	ENDS


sftfsd	STRUC
sfd_work	DB	SFDWORKAREASIZE DUP (?)
sftfsd	ENDS


sfdFATFS	STRUC
sfdFAT_firFILEclus	DW	?
sfdFAT_cluspos	DW	?
sfdFAT_lstclus	DW	?
sfdFAT_dirsec	DD	?
sfdFAT_dirpos	DB	?
sfdFAT_EAHandle	DW	?
sfdFAT_name	DB	SFNAMELEN DUP (?)
sfdFAT_bRAReads	DD	?
sfdFAT_bRABigReads	DD	?
sfdFAT_fldMask	DD	?
sfdFAT_pSFT	DD	?
sfdFAT_ulNextRA	DD	?
sfdFAT_bBufRun	DD	?
sfdFAT_LastFATSec	DW	?
sfdFATFS	ENDS

.errnz        (SFDWORKAREASIZE lt size sfdFATFS)
 

SFT	STRUC
sft_link	DW	?
sft_count	DW	?
sft_handle	DW	?
sft_inshutdown	DW	?
SFT	ENDS


sf_entry	STRUC
sf_ref_count	DW	?
sf_usercnt	DW	?
reserved	DB	?
sf_flags	DW	?
sf_flags2	DW	?
sf_devptr	DD	?
sf_FSC	DD	?
sf_cookie	DD	?
sf_chain	DD	?
sf_MFT	DD	?
sf_fsd	DB	SIZE sftfsd DUP (?)
sf_fsi	DB	SIZE sftsfi DUP (?)
sf_plock	DW	?
sf_NmPipeSfn	DW	?
sf_codepage	DW	?
sf_LockID	DD	?
sf_entry	ENDS

.errnz        (sf_fsd - sf_MFT - (size sf_MFT))
.errnz        (sf_fsd - sf_ref_count - 29)
 
MAXSFNPERSEG	EQU	((65535  - (SIZE   SFT ))/(SIZE   sf_entry ))
SFNPERSEG	EQU	((65535  - (SIZE   SFT ))/(SIZE   sf_entry ))
MAXSFNPERSEG    EQU ((65535 - (size SFT)) / (size sf_entry))
SFNPERSEG       EQU ((65535 - (size SFT)) / (size sf_entry))
 
        .erre   SFNPERSEG le MAXSFNPERSEG       
 
sizeGDTSFT = MAXSFN / SFNPERSEG

  sizeGDTSFT = sizeGDTSFT + 1

sizeGDTSFT = (sizeGDTSFT * 2)+2         
 
CALLSFN	EQU	(sizeGDTSFT-2 )      

sf_OpenAge            EQU WORD PTR (sf_fsi + sfi_position+2)
sf_LRU                EQU WORD PTR (sf_fsi + sfi_position)

 
SF_ISNET	EQU	8000H   
SF_PIPE	EQU	2000H   
SF_FCB	EQU	1000H   
SF_NMPIPE	EQU	0800H   
SF_INUSE	EQU	0400H   
SF_BLOCKED	EQU	0200H   
SF_NOJFN	EQU	0100H   
SF_FORMAT_MOUNT	EQU	8000H   
SF_BEGINFORMAT_FAILED	EQU	4000H   
SSF2_LDRBINARYSEM	EQU	2000H   
SF_SRVRDR	EQU	1000H   
SFF2_LOCKED_DRIVE	EQU	0800H   
SFF2_SPOOLED	EQU	0400H   
SFF2_DATAWRITTEN	EQU	0200H   
SFF2_Consistency	EQU	0180H   
SFF2_CANCELJOB	EQU	0040H   
SFF2_NONSPOOLED	EQU	0020H   
SFF2_STPTHINFDN	EQU	0010H   
sff2_RA_ON	EQU	0008H   
sff2_UNC	EQU	0004H   
sff2_isfree	EQU	0002H   
sff2_RA_BIG	EQU	0001H   
STYPE_FILE	EQU	0000H           
STYPE_DEVICE	EQU	0001H           
STYPE_NMPIPE	EQU	0002H           
STYPE_FCB	EQU	0004H           
STYPE_USED	EQU	(STYPE_FILE  OR  STYPE_DEVICE  OR  STYPE_NMPIPE  OR  STYPE_FCB)
STYPE_RESERVED	EQU	( NOT  STYPE_USED)  
STYPE_MASK	EQU	(STYPE_FILE  OR  STYPE_DEVICE  OR  STYPE_NMPIPE)
DEVID_FILE_CLEAN	EQU	0040H   
DEVID_FILE_MASK_DRIVE	EQU	003FH   
DEVID_DEVICE	EQU	0080H   
DEVID_DEVICE_EOF	EQU	0040H   
DEVID_DEVICE_RAW	EQU	0020H   
DEVID_DEVICE_SPECIAL	EQU	0010H   
DEVID_DEVICE_CLOCK	EQU	0008H   
DEVID_DEVICE_NULL	EQU	0004H   
DEVID_DEVICE_CON_OUT	EQU	0002H   
DEVID_DEVICE_CON_IN	EQU	0001H   
DEVID_ISDEV	EQU	80H 
DEVID_EOF	EQU	40H 
DEVID_RAW	EQU	20H 
DEVID_SPECIAL	EQU	10H 
DEVID_ISCLK	EQU	08H 
DEVID_ISNUL	EQU	04H 
DEVID_ISCOT	EQU	02H 
DEVID_ISCIN	EQU	01H 
DEVID_BLOCK_DEV	EQU	1FH     
JFN_DIH	EQU	01H     
JFN_FLUSH	EQU	02H     
JFN_FAIL	EQU	40H     
JFN_WRTTHR	EQU	80H     
JFN_NCACHE	EQU	20H     
JFN_RAWIO	EQU	10H     
JFN_ISCON	EQU	08H     
JFN_USED	EQU	(JFN_DIH  OR  JFN_FAIL  OR  JFN_WRTTHR  OR  JFN_NCACHE )
SF_MFT_NULL	EQU	0FFFFFFFFH 
ST_SCREAT	EQU	01H     
ST_PCREAT	EQU	02H     
ST_SWRITE	EQU	04H     
ST_PWRITE	EQU	08H     
ST_SREAD	EQU	10H     
ST_PREAD	EQU	20H     
MIN_READLEN	EQU	32    
MID_READLEN	EQU	512    
MAX_READLEN	EQU	8192    
