;       SCCSID = @(#)chardd.inc	6.1 90/11/17
;      SCCSID = @(#)chardd.inc	13.5 90/08/03

;****	Character Device management in the system
;
;   This file contains the structure definitions, and equates used for
;   the management of character devices.
;
;   We support three types of character devices in the system, namely
;   real-mode only, bimodal, and pseudo- character devices. In order to
;   keep their management simple, we store all the information that we
;   will need for routing calls in one segment. The segment is managed by
;   RMP, and each record is of the type CharDevEntry (see below).
;   The information for the RMP segment is stored in the variable
;   CharDevRMPRec. This is what is passed to the RMP management routines
;   to identify the segment.
;
;   We also maintain the linked lists of device headers for the physical
;   devices that are installed at system boot time for compatibility
;   reasons.
;

;
; The name of a non-pseudo-character devices is restricted to 8 characters.
;
DEVNAMELEN	EQU	8

;
; The name of pseudo-character devices is limited to 252 bytes.
; i.e. <drive>:\DEV\<device name>NULL should fit into 260 bytes (260 is
; the maximum path length in protected mode).
; Pseudo-Character device names in real-mode are restricted to 8 bytes.
;
PDEVNAMELEN	EQU	253		; one extra byte for NULL

;
; The length of the DevPrefix ("\DEV\") is defined below

DEV_PREFIX_LEN	   EQU	5

;
; Record that is kept in the table for every character device in the system.
;
; The DES_Type and DES_Name fields are used as search keys to identify the
; specific records.
;
; DES_Name contains the uppercased name for fast compares.  We do this
; because CheckThisDevice is called by TransPath for every name-based
; operation.   DES_UserName contains the user-specified name.  It is
; only accessed:  1) when the device is added or replaced and
;		  2) when QFSAttach is called.
;
; DES_RoutePtr contains the pointer to the device:
;	For pseudo-devices, this is the FSC for the file system driver.
;	For physical devices, this is the device header.
;
; WARNING!!! Do not use DES_UserName to access the field since its offset
;	     is dependent on the length of DES_Name, and is only used here
;	     to determine the size of the structure.
;
CharDevEntry	struc
    DES_RoutePtr    DD	    ?	    ; Pointer to device
    DES_DevFsd	    DD	    ?	    ; fsd area for pseudo devices
    DES_Flags	    DB	    ?	    ; flags
    DES_Type	    DB	    ?	    ; Real, Bimodal, Pseudo
    DES_Name	    DB	    PDEVNAMELEN DUP (?) ; NULL terminated uppercased name
    DES_UserName    DB	    PDEVNAMELEN DUP (?) ; NULL terminated user-specified name
CharDevEntry	ends

;
; Ensure that DES_UserName field is the last field in CharDevEntry structure.
; Ensure that DES_RoutePtr is the first field in the structure.
; Examine code in CHARDD.ASM in AddCharDevEntry if this changes.
;
.errnz (DES_Name + PDEVNAMELEN + PDEVNAMELEN - size CharDevEntry)
.errnz (DES_UserName - PDEVNAMELEN - DES_Name)
.errnz (DES_RoutePtr)

; Bit equates for DES_Type field
;
DEVTYPE_BIMODAL		EQU	    01H	    ; Bimodal device (physical)
DEVTYPE_PSEUDO		EQU	    02H	    ; Pseudo device
DEVTYPE_REAL		EQU	    04H	    ; Real mode only device (physical)
DEVTYPE_INVISIBLE	EQU	    08H	    ; device is invisible to searches
					    ; but visible to adds
;
; Bit equates for DES_Flags field
;
DEVFLAGS_INSTOVERLAP	EQU	    01H	    ; Pseudo-char device overlapping installed device
DEVFLAGS_INVISIBLE	EQU	    02H	    ; Device is in the process of being
					    ; attached and is not yet valid.
DEVFLAGS_SPOOLED	EQU	    04H	    ; Device is spooler device.

;
; Equates for bits in Action parameter in CHARDD.ASM
;
ACT_DEVREPLACE		EQU	    01H	    ; Replace existing entry with new one
ACT_DEVDONTADD		EQU	    02H	    ; Don't add new entry if one exists
ACT_DEVERREXISTS	EQU	    04H	    ; Error if device already exists

;   Record that is kept for each spooler device.
;
;   The device name to wich a spooler object is attached is used as a key
;   for RMP. Note that the offset of SDE_szSpoolObj depends on the length
;   of SDE_Name ( = DES_NAME).
;
SpoolDevEntry	 struc
    SDE_Sfn	    DW	    ?	    ; SFN of named pipe
    SDE_ulKey	    DD	    ?	    ; Attached key
    SDE_cbDevName   DB	    ?	    ; Length of Device name
    SDE_Name	    DB	    ?	    ; NULL terminated uppercased name of dev.
SpoolDevEntry	 ends

;   Structure passed byt the application to DosFSAttach for
;   spooler operations
;
Struct_SpoolAttach     struc
    SA_hNmPipe	    DW	    ?	    ; Handle of named pipe
    SA_ulKey	    DD	    ?	    ; Attached key
Struct_SpoolAttach     ends
