vcomm.h
来自「用于查询PC机上的USB端口是否有设备挂接上」· C头文件 代码 · 共 848 行 · 第 1/2 页
H
848 行
#define PST_MODEM ((DWORD)0x00000006)
#define PST_FAX ((DWORD)0x00000021)
#define PST_SCANNER ((DWORD)0x00000022)
#define PST_NETWORK_BRIDGE ((DWORD)0x00000100)
#define PST_LAT ((DWORD)0x00000101)
#define PST_TCPIP_TELNET ((DWORD)0x00000102)
#define PST_X25 ((DWORD)0x00000103)
//
// Provider capabilities flags.
//
#define PCF_DTRDSR ((DWORD)0x0001)
#define PCF_RTSCTS ((DWORD)0x0002)
#define PCF_RLSD ((DWORD)0x0004)
#define PCF_PARITY_CHECK ((DWORD)0x0008)
#define PCF_XONXOFF ((DWORD)0x0010)
#define PCF_SETXCHAR ((DWORD)0x0020)
#define PCF_TOTALTIMEOUTS ((DWORD)0x0040)
#define PCF_INTTIMEOUTS ((DWORD)0x0080)
#define PCF_SPECIALCHARS ((DWORD)0x0100)
#define PCF_16BITMODE ((DWORD)0x0200)
//
// Comm provider settable parameters.
//
#define SP_PARITY ((DWORD)0x0001)
#define SP_BAUD ((DWORD)0x0002)
#define SP_DATABITS ((DWORD)0x0004)
#define SP_STOPBITS ((DWORD)0x0008)
#define SP_HANDSHAKING ((DWORD)0x0010)
#define SP_PARITY_CHECK ((DWORD)0x0020)
#define SP_RLSD ((DWORD)0x0040)
//
// Settable baud rates in the provider.
//
#define BAUD_075 ((DWORD)0x00000001)
#define BAUD_110 ((DWORD)0x00000002)
#define BAUD_134_5 ((DWORD)0x00000004)
#define BAUD_150 ((DWORD)0x00000008)
#define BAUD_300 ((DWORD)0x00000010)
#define BAUD_600 ((DWORD)0x00000020)
#define BAUD_1200 ((DWORD)0x00000040)
#define BAUD_1800 ((DWORD)0x00000080)
#define BAUD_2400 ((DWORD)0x00000100)
#define BAUD_4800 ((DWORD)0x00000200)
#define BAUD_7200 ((DWORD)0x00000400)
#define BAUD_9600 ((DWORD)0x00000800)
#define BAUD_14400 ((DWORD)0x00001000)
#define BAUD_19200 ((DWORD)0x00002000)
#define BAUD_38400 ((DWORD)0x00004000)
#define BAUD_56K ((DWORD)0x00008000)
#define BAUD_128K ((DWORD)0x00010000)
#define BAUD_USER ((DWORD)0x10000000)
//
// Settable Data Bits
//
#define DATABITS_5 ((WORD)0x0001)
#define DATABITS_6 ((WORD)0x0002)
#define DATABITS_7 ((WORD)0x0004)
#define DATABITS_8 ((WORD)0x0008)
#define DATABITS_16 ((WORD)0x0010)
#define DATABITS_16X ((WORD)0x0020)
//
// Settable Stop and Parity bits.
//
#define STOPBITS_10 ((WORD)0x0001)
#define STOPBITS_15 ((WORD)0x0002)
#define STOPBITS_20 ((WORD)0x0004)
#define PARITY_NONE ((WORD)0x0100)
#define PARITY_ODD ((WORD)0x0200)
#define PARITY_EVEN ((WORD)0x0400)
#define PARITY_MARK ((WORD)0x0800)
#define PARITY_SPACE ((WORD)0x1000)
typedef struct _COMSTAT {
DWORD BitMask; /* flags DWORD */
DWORD cbInque; /* Count of characters in receive queue */
DWORD cbOutque; /* Count of characters in transmit queue */
} _COMSTAT;
/* Flags of BitMask */
#define fCtsHold 0x00000001 /* Transmit is on CTS hold */
#define fDsrHold 0x00000002 /* Transmit is on DSR hold */
#define fRlsdHold 0x00000004 /* Transmit is on RLSD hold */
#define fXoffHold 0x00000008 /* Received handshake */
#define fXoffSent 0x00000010 /* Issued handshake */
#define fEof 0x00000020 /* EOF character found */
#define fTximmed 0x00000040 /* Character being transmitted */
typedef struct _QSB {
DWORD ReceiveQueueGetPtr; /* offset into queue to get bytes from */
DWORD ReceiveQueueCount; /* Number of bytes in receive queue */
} _QSB;
/* Following constants are used by COMM.DRV to access the PM apis supported
by VCOMM.
*/
#define VCOMM_PM_API_OpenCom 0
#define VCOMM_PM_API_SetCom 1
#define VCOMM_PM_API_Setup 2
#define VCOMM_PM_API_ctx 3
#define VCOMM_PM_API_TrmCom 4
#define VCOMM_PM_API_StaCom 5
#define VCOMM_PM_API_cextnfcn 6
#define VCOMM_PM_API_cFlush 7
#define VCOMM_PM_API_cevt 8
#define VCOMM_PM_API_cevtget 9
#define VCOMM_PM_API_SetMSRShadow 10
#define VCOMM_PM_API_WriteString 11
#define VCOMM_PM_API_ReadString 12
#define VCOMM_PM_API_EnableNotify 13
#ifndef Not_VxD
/* Escape Functions (extended functions). */
#define Dummy 0 /* Dummy */
#define SETXOFF 1 /* Simulate XOFF received */
#define SETXON 2 /* Simulate XON received */
#define SETRTS 3 /* Set RTS high */
#define CLRRTS 4 /* Set RTS low */
#define SETDTR 5 /* Set DTR high */
#define CLRDTR 6 /* Set DTR low */
#define RESETDEV 7 /* Reset device if possible */
#endif
#ifdef Not_VxD
/* These numbers are reserved for compatibility reasons */
#define GETLPTMAX 8 /* Get maximum LPT supported */
#define GETCOMMAX 9 /* Get maximum COM supported */
#endif
#define GETCOMBASEIRQ 10 /* Get COM base and IRQ */
#define GETCOMBASEIRQ1 11 /* FOR COMPATIBILITY REASONS */
#define SETBREAK 12 /* Set break condition */
#define CLEARBREAK 13 /* Clear break condition */
#ifdef Not_VxD
/* These too are not available to client VxDs and not implemented by
port drivers. */
#define GETPORTHANDLE 14 /* Get handle for Port */
#define GETEXTENDEDFNADDR 15 /* Get the address of extended functions */
#endif
#define CLRTIMERLOGIC 16 /* Clear the timer logic of the port driver */
#define GETDEVICEID 17 /* Get the device ID of the device */
#define SETECPADDRESS 18 /* Set ECP channel address */
#define SETUPDATETIMEADDR 19 /* Set address of update field for
last time a char was received */
#define IGNOREERRORONREADS 20 /* Ignore pending IO errors on reads*/
#define ENABLETIMERLOGIC 21 /* Re-enable timer logic code */
#define IGNORESELECT 22 /* Ignore select bit */
/* used for Peppy driver */
#define SET_PEPPY_RLE_COUNT 23 /* set Peppy burst buffer size */
#define SET_PEPPY_BURST_SIZE 24 /* set Peppy burst buffer size */
#define GETCURRENTMODE 25 /* obtain current channel mode */
#define PREPFLAG 26 /* data prep flag, used in Peppy mode */
#define GETPORTSTATUS 27 /* obtain current channel mode */
/* device power management functions */
#define PM_QUERY_D1 28 /* can you enter D1 */
#define PM_QUERY_D2 29 /* can you enter D2 */
#define PM_QUERY_D3 30 /* can you enter D3 */
#define PM_CANCEL_D1 31 /* abort transition to D1 */
#define PM_CANCEL_D2 32 /* abort transition to D2 */
#define PM_CANCEL_D3 33 /* abort transition to D3 */
#define PM_SET_D0 34 /* enter D0 */
#define PM_SET_D1 35 /* enter D1 */
#define PM_SET_D2 36 /* enter D2 */
#define PM_SET_D3 37 /* enter D3 */
#define PM_ARM_WAKEUP 38 /* become a wake device */
#define PM_DISARM_WAKEUP 39 /* stop acting as a wake device */
/* end of Peppy support */
#define STARTNONSTDESCAPES 200 /* non standard escapes */
#define PEEKCHAR 200 /* peek the Rx Q */
/* END OF ESCAPES for ESCAPECOMMFUNCTION */
#define PM_SUCCESS 0 /* return code from port driver to succeed a PM query */
#define PM_FAILURE 1 /* return code from port driver to fail a PM query */
#ifndef Not_VxD
/* notifications passed in Event of Notification function */
#define CN_RECEIVE 1 /* bytes are available in the input queue */
#define CN_TRANSMIT 2 /* fewer than wOutTrigger bytes still */
/* remain in the output queue waiting */
/* to be transmitted. */
#define CN_EVENT 4 /* an enabled event has occurred */
#endif
/* Other constants */
#ifndef Not_VxD
#define IGNORE 0 /* Ignore signal */
#endif
#define INFINITE32 -1 /* Infinite timeout */
/* Defined ways of supporting a port (return value of PortInquire fn) */
#define PD_UNSUPPORTED 0 /* Port is not supported */
#define PD_DEFAULT 1 /* Port is supported by default */
#define PD_BEST -1 /* Best possible support */
/* Masks for relevant fields of DCB */
#define fBaudRate 0x00000001
#define fBitMask 0x00000002
#define fXonLim 0x00000004
#define fXoffLim 0x00000008
#define fByteSize 0x00000010
#define fbParity 0x00000020
#define fStopBits 0x00000040
#define fXonChar 0x00000080
#define fXoffChar 0x00000100
#define fErrorChar 0x00000200
#define fEofChar 0x00000400
#define fEvtChar1 0x00000800
#define fEvtChar2 0x00001000
#define fRlsTimeout 0x00002000
#define fCtsTimeout 0x00004000
#define fDsrTimeout 0x00008000
#define fTxDelay 0x00010000
#define fTimeout (fRlsTimeout | fDsrTimeout | fCtsTimeout)
#define fLCR 0x00000070
/*
IORequest
VCOMM allows a client to impose a "block" structure on a port
driver in the following way. It can call VCOMM_SetWriteRequest
with the buffer to write. When all the earlier write requests are satisfied
by the port driver, VCOMM will call the port driver to satisfy this
request. A client can also call VCOMM_SetReadRequest with the buffer
to read data into. VCOMM will queue up this request and when all previous
read requests are satisfied, call the port driver to satisfy this request.
So now, clients can get a notification per read/write request. The buffers
passed by client must be in locked memory during the duration of the whole
operation and should not be touched by the client till it receives the
notification.
A client should not use a combination of VCOMM_WriteComm and
VCOMM_SetWriteRequest. This will lead to strange results. VCOMM_WriteComm
goes directly to the port driver without any processing by VCOMM. There
is considerable work done by VCOMM for VCOMM_SetWriteRequest. Similarly,
VCOMM_SetReadRequest and VCOMM_ReadComm should not be used together.
When a client attempts to get the total queued count of characters to write,
VCOMM calls the port driver to find the size of its xmit queue and then
adds up all the pending write operations to return the count.
VCOMM_PurgeComm leads to VCOMM calling each aborted IORequest if TXAbort
parameter is set. For TxClear, it does not do so, it just calls down into
the port driver to clear its transmit queue.
*/
typedef struct IORequest {
DWORD IOBuffer; // address of IO buffer
DWORD IOCount; // the size of IO buffer
DWORD IOCallCompletionRoutine; // whom to call back when done
DWORD NumBytes; // How many bytes were written/read
DWORD dwReserved[8]; // eight reserved words used by VCOMM
DWORD dwSig; // signature dword
} IORequest;
#define WRITE_REQUEST 1
#define READ_REQUEST 0
/* For supporting Plug and Play, a port driver must be dynamically
loadable. It must exist in the system directory (where DOS386.exe
is executed from).
It will be loaded by VCOMM which will be its devloader. During
Sys_Dynamic_Device_Init, it should register with VCOMM via
_VCOMM_Register_Port_Driver. While registering, it should pass
the address of its initialization function. VCOMM will call this
function to initialize a port supported by the port driver. The
port driver should check if such a port exists and call VCOMM to
add this port to its list via _VCOMM_Add_Port. It MUST add the
port in its initialization function before returning to VCOMM.
When all the ports supported by the port driver are closed, VCOMM
will unload the driver. It will call the initialization function of
the driver once per open of each port. So the port driver can allocate
the required data for the port at this time and deallocate it at
the time of closing of the port.
The procedure must be of the form:
void InitFunction(DWORD hDevNode, DWORD AllocPortBase, DWORD AllocPortIrq,
char *PortName);
where:
hDevNode = devnode for the port
AllocPortBase = allocated base port address of the port being initialized.
AllocPortIrq = allocated base Irq of the port being initialized.
PortName -> name of the port. The port driver, if it supports the port
should add the port by using a copy of this name.
It will be later be called to open the port with this name.
*/
/*
The DriverControl function of the port drivers is called by VCOMM to
perform various actions such as initialize all or one port etc.
Following function codes specify various actions.
*/
#define DC_Initialize 0x00000000 /* initialize port. */
/* ASM
IFDEF WIN31COMPAT
VxD_My_Pageable_Code_Seg MACRO
VxD_Locked_Code_Seg
ENDM
VxD_My_Pageable_Code_Ends MACRO
VxD_Locked_Code_Ends
ENDM
VxD_My_Pageable_Data_Seg MACRO
VxD_Locked_Data_Seg
ENDM
VxD_My_Pageable_Data_Ends MACRO
VxD_Locked_Data_Ends
ENDM
ELSE
VxD_My_Pageable_Code_Seg MACRO
VxD_Pageable_Code_Seg
ENDM
VxD_My_Pageable_Code_Ends MACRO
VxD_Pageable_Code_Ends
ENDM
VxD_My_Pageable_Data_Seg MACRO
VxD_Pageable_Data_Seg
ENDM
VxD_My_Pageable_Data_Ends MACRO
VxD_Pageable_Data_Ends
ENDM
ENDIF
*/
#define ERROR_NOT_READY 21L
#define ERROR_OUT_OF_PAPER 28L
#define ERROR_COUNTER_TIMEOUT 1121L
/*XLATOFF*/
#pragma pack()
/*XLATON*/
#endif // _VCOMM_H
typedef struct IOCtlBlock {
DWORD IO_lpOverlapped;
DWORD IO_lpcbBytesReturned;
DWORD IO_Event;
DWORD IO_ThreadHandle;
DWORD IO_NumBytesReturned;
} IOCtlBlock;
/*
* Contention related equates
*/
#define MAP_DEVICE_TO_RESOURCE 0
#define ACQUIRE_RESOURCE 1
#define STEAL_RESOURCE 2
#define RELEASE_RESOURCE 3
#define ADD_RESOURCE 4
#define REMOVE_RESOURCE 5
#define MAX_CONTEND_FUNCTIONS 5
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?