📄 comdef.h
字号:
/*++
THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
PARTICULAR PURPOSE.
Copyright (c) 1995-1998 Microsoft Corporation
Module Name:
comdef.h
Abstract:
P1284 common data definitions
Notes:
--*/
#ifdef DEBUG
#define TRAP DebugBreak();
#else
#define TRAP
#endif
typedef (*PFN)(); // pfn
typedef PFN *PPFN; // ppfn
typedef struct _PortData {
WORD PDLength; /* sizeof (PortData) */
WORD PDVersion; /* version of struct */
DWORD dwLastError; /* what was the error
for the last operation */
DWORD dwClientEventMask; /* event mask set by client */
DWORD lpClientEventNotify; /* address set by client for
event notification */
DWORD lpClientReadNotify; /* adress set by client for
read threshold notification */
DWORD lpClientWriteNotify; /* address set by client for
write threshold notification */
DWORD dwClientRefData; /* Client's reference data */
DWORD dwWin31Req; /* Used for WIN3.1 specific reasons */
DWORD dwClientEvent; /* Event to send to client */
DWORD dwCallerVMId; /* Used for supporting all VMs */
DWORD dwDetectedEvents; /* mask of detected and
enabled events */
DWORD dwCommError; /* non-zero if I/O error. */
BYTE bMSRShadow; /* the shadow of Modem Status
Register */
WORD wFlags; /* flags for the port */
BYTE LossByte; /* For COMM ports 1-4 VCD flags this
byte telling port driver that it
has lost the port */
DWORD QInAddr; /* Address of the queue */
DWORD QInSize; /* Length of queue in bytes */
DWORD QOutAddr; /* Address of the queue */
DWORD QOutSize; /* Length of queue in bytes */
DWORD QInCount; /* # of bytes currently in queue */
DWORD QInGet; /* Offset into q to get bytes from */
DWORD QInPut; /* Offset into q to put bytes in */
DWORD QOutCount; /* Number of bytes currently in q */
DWORD QOutGet; /* Offset into q to get bytes from */
DWORD QOutPut; /* Offset into q to put bytes in */
DWORD ValidPortData; /* For checking validity etc. */
DWORD lpLoadHandle; /* load handle of the owner VxD */
COMMTIMEOUTS cmto; /* Commtimeouts struct */
DWORD lpReadRequestQueue; /* Pointer to pending Read requests */
DWORD lpWriteRequestQueue; /* Pointer to pending Write requests */
DWORD dwLastReceiveTime; /* Time of last reception of data */
} PortData;
typedef char* LPSTR;
typedef DWORD* LPDWORD;
//---------------------------------------------------------------------------
// Constant definitions
//---------------------------------------------------------------------------
#define MAX_LPT_PORTS 3 // by specs, from 80h to 0FFh
#define MEM_BUFFER_SIZE 8192 // 8K bytes for Tx and Rx buffers
#define DMA_TRANSFER_FLAG 512 // 512 bytes for using DMA threshold
#define MLTPLE 4 // programmed I/O multiplier
// ResetECP mask
#define ECP_RESET_HW 0xCC // 1100 1100 nSelectIn Lo
// ResetLPT mask
#define P1284_RESET_HW 0x08 // 0000 1000 Init Lo
//
// Values of PortInformation.dwHost
#define HOST_NO_ECP 1
#define HOST_HAS_ECP 2
//
// Values of PortInformation.dwTxNotify
#define CN_Notify 0x40
//
// Values of PortInformation.dwPortSharing
#define PORT_SHARE_ENABLED 0x01
#define PORT_IN_USE 0x80
//
// Values of PortInformation.bFwdProtocolID
#define ID_ECP 0x10
#define ID_NIBBLE 0x00
#define ID_BYTE 0x01
#define ID_LPT 0xff
//
// Values of PortInformation.bCurrentMode
#define ECP_MODE 0x10
#define NIBBLE_MODE 0x00
#define BYTE_MODE 0x01
#define ELPT_MODE 0x40
#define LPT_MODE 0x80
//
// Values of PortInformation.bCurrentPhase
// Compatibility mode
#define FORWARD_IDLE 0x03
#define REVERSE_MASK 0x04
// ECP mode -- x x ECP Nibble DataAvail Re Idle Frd
#define ECP_HOST_RECOVERY 0x20
#define ECP_F_IDLE 0x23
#define ECP_R_IDLE 0x26
#define ECP_R_DATA_AVAIL 0x2C
// Nibble/Byte mode
#define NB_DATA_AVAILABLE 0x1C
#define NB_DATA_NOT_AVAIL 0x14
#define NB_REVERSE_IDLE 0x16
//
// Error Flags for dwCommError
#define CE_FIFO 0x00010000
// Values of lpFIFO->wFifoSize
#define ECP_8BIT 0x0001
#define ECP_16BIT 0x0002
#define ECP_32BIT 0x0004
//---------------------------------------------------------------------------
// Data structure definitions
//---------------------------------------------------------------------------
typedef struct _DEVICEID
{
ULONG ulSize; //string length
LPSTR pdeviceID; //device ID string
} DEVICEID;
// Main structure of port information
typedef struct _PortInformation
{
PortData pPortData; //common info used by VCOMM and port driver
ULONG ulBase; //base address
WORD wHost; //host ECP capable flag (irq and dma available)
WORD wHostHw; //host has ECP hardware
DWORD Number; //port number, should be between 0h and 04h
char Name[4]; //port name
DEVICEID pDeviceID; //device ID info
DWORD dwDevId; //flag of request device ID
BYTE bFrdProtocol; //forward transmission protocol
BYTE bRevProtocol; //reverse transmission protocol
BYTE bCurrentMode; //current mode set in hardware
BYTE bCurrentPhase; //current phase set in hardware
PFN pfnWrite; //write function entry
PFN pfnRead; //read function entry
PFN pfnTimeout; //timeout functions
PFN pfnIOCompletion; //deviceIoControl callback function entry
PFN EventNotifyFn; //callback function address of event notification
PFN TxcallbackFn; //callback function address of write
PFN RxcallbackFn; //callback function address of read
ULONG IORefData; //deviceIoControl callback refdata
ULONG EventData; //event callback reference data
ULONG TxRefData; //write callback reference data
ULONG RxRefData; //read callback reference data
LONG EventMask; //event mask
LPSTR RxBuffer; //internal input buffer address
DWORD RxSize; //internal input buffer size
LONG TxLO; //low write threshold
LONG RxHI; //high read threshold
ULONG hOEvent; //schedule write event handle
ULONG hIEvent; //schedule read event handle
DWORD dwDirecFlag; //DMA programming direction flag
DWORD dwNotifyFlags; //notification flag
BOOL blInTransfer; //data in transmittion
BOOL blPortOpen; //set for opened port
DWORD dwPortSharing; //set 1000 0001 if port is allowed to share
BYTE bWaitBusy; //delay tick to wait for busy high in LPT mode
DWORD dwFlags; //check flag for select line from printer
COMMTIMEOUTS CommTimeouts; // comm timeouts
} PortInformation, *PPortInformation;
// dwFlags
#define IgnoreSelect 0x00000001
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -