Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

243 lines
14 KiB

  1. /*************************************************************************
  2. **
  3. ** Miscelaneous definitions.
  4. */
  5. typedef unsigned short ushort;
  6. typedef unsigned char uchar;
  7. #define NULL 0
  8. #define FALSE 0
  9. #define TRUE 1
  10. #define LPTx 0x80 /* Mask to indicate cid is for LPT device */ /*081985*/
  11. #define LPTxMask 0x7F /* Mask to get cid for LPT device */ /*081985*/
  12. #define PIOMAX 3 /* Max number of LPTx devices in high level */ /*081985*/
  13. #define CDEVMAX 10 /* Max number of COMx devices in high level */
  14. #define DEVMAX 13 /* Max number of devices in high level */ /*081985*/
  15. /*************************************************************************
  16. **
  17. ** device control block.
  18. ** This block of information defines the functional parameters of the
  19. ** communications software and hardware.
  20. **
  21. ** Fields in the DCB are defined as follows:
  22. **
  23. ** Id - Comm device ID, set by the device driver.
  24. ** BaudRate - Baud rate at which operating.
  25. ** ByteSize - Number of bits per transmitted/received byte. (4-8)
  26. ** Received data is also masked off to this size.
  27. ** Parity - Transmitt/Receive Parity. (0,1,2,3,4) = (None, Odd,
  28. ** Even, Mark, Space)
  29. ** StopBits - Number of stop bits. (0,1,2) = (1, 1.5, 2)
  30. ** RlsTimeout - Amount of time, in milleseconds, to wait for RLSD to
  31. ** become high. RLSD, Receive Line Signal Detect is also
  32. ** known as CD, Carrier Detect. RLSD flow control can be
  33. ** achieved by specifying infinite timeout.
  34. ** CtsTimeout - Amount of time, in milleseconds, to wait for CTS,
  35. ** Clear To Send, to become high. CTS flow control can
  36. ** be achieved by specifying infinite timeout.
  37. ** DsrTimeout - Amount of time, in milleseconds, to wait for DSR,
  38. ** Data Set Ready, to become high. DSR flow control can
  39. ** be acheived by specifying infinite timeout.
  40. ** fBinary - Binary Mode flag. In non-binary mode, EofChar is
  41. ** recognized and remembered as end of data.
  42. ** fRtsDisable - Disable RTS flag. If set, Request To Send is NOT
  43. ** used, and remains low. Normally, RTS is asserted when
  44. ** the device is openned, and dropped when closed.
  45. ** fParity - Enable Parity Checking. Parity errors are not
  46. ** reported when 0.
  47. ** fOutxCtsFlow - enable output xon/xoff(hardware) using cts
  48. ** fOutxDsrFlow - enable output xon/xoff(hardware) using dsr
  49. ** fOutX - Indicates that X-ON/X-OFF flow control is to be used
  50. ** during transmission. The transmitter will halt if
  51. ** an X-OFF character is received, and will start again
  52. ** when an X-ON character is received.
  53. ** fInX - Indicates that X-ON/X-OFF flow control is to be used
  54. ** during reception. An X-OFF character will be
  55. ** transmitted when the receive queue comes within 10
  56. ** characters of being full, after which an X-ON will be
  57. ** transmitted when the queue comes with 10 characters
  58. ** of being empty.
  59. ** fPeChar - Indicates that characters received with parity errors
  60. ** are to be replaced with the character specified in
  61. ** PeChar, below.
  62. ** fNull - Indicates that received NULL characters are to be
  63. ** discarded.
  64. ** fChEvt - Indicates that the reception of EvtChar is to be
  65. ** flagged as an event by cevt.
  66. ** fDtrFlow - Indicates that the DTR signal is to be used for
  67. ** receive flow control. (cextfcn can be used to set and
  68. ** clear DTR, overriding this definition).
  69. ** fRtsFlow - Indicates that the RTS signal is to be used for
  70. ** receive flow control. (cextfcn can be used to set and
  71. ** clear RTS, overriding this definition).
  72. ** XonChar - X-ON character for both transmit and receive
  73. ** XoffChar - X-OFF character for both transmit and receive
  74. ** XonLim - When the number of characters in the receive queue
  75. ** drops below this value, then an X-ON character is
  76. ** sent, if enabled, and DTR is set, if enabled.
  77. ** XoffLim - When the number of characters in the receive queue
  78. ** exceeds this value, then an X-OFF character is sent,
  79. ** if enabled, and DTR is dropped, if enabled.
  80. ** PeChar - Parity Error replacement character.
  81. ** EvtChar - Character which triggers an event flag.
  82. ** EofChar - Character which specifies end of input.
  83. ** TxDelay - Specifies the minimum amount of time that must pass
  84. ** between transmission of characters.
  85. **
  86. ** Timeouts are in milleseconds. 0 means ignore the signal. 0xffff means
  87. ** infinite timeout.
  88. **
  89. *************************************************************************/
  90. typedef struct {
  91. char Id; /* Internal Device ID */
  92. ushort BaudRate; /* Baudrate at which runing */
  93. char ByteSize; /* Number of bits/byte, 4-8 */
  94. char Parity; /* 0,1,2,3,4 = None,Odd,Even,Mark,Sp*/
  95. char StopBits; /* 0,1,2 = 1, 1.5, 2 */
  96. ushort RlsTimeout; /* Timeout for RLSD to be set */
  97. ushort CtsTimeout; /* Timeout for CTS to be set */
  98. ushort DsrTimeout; /* Timeout for DSR to be set */
  99. uchar fBinary: 1; /* CTRL-Z as EOF flag */
  100. uchar fRtsDisable:1; /* Suppress RTS */
  101. uchar fParity: 1; /* Enable parity check */
  102. uchar fOutxCtsFlow: 1; /* Enable output xon/xoff with cts */
  103. uchar fOutxDsrFlow: 1; /* Enable output xon/xoff with dsr */
  104. uchar fDummy: 3;
  105. uchar fOutX: 1; /* Enable output X-ON/X-OFF */
  106. uchar fInX: 1; /* Enable input X-ON/X-OFF */
  107. uchar fPeChar: 1; /* Enable Parity Err Replacement */
  108. uchar fNull: 1; /* Enable Null stripping */
  109. uchar fChEvt: 1; /* Enable Rx character event. */
  110. uchar fDtrflow: 1; /* Enable DTR flow control */
  111. uchar fRtsflow: 1; /* Enable RTS flow control */
  112. uchar fDummy2: 1;
  113. char XonChar; /* Tx and Rx X-ON character */
  114. char XoffChar; /* Tx and Rx X-OFF character */
  115. ushort XonLim; /* Transmit X-ON threshold */
  116. ushort XoffLim; /* Transmit X-OFF threshold */
  117. char PeChar; /* Parity error replacement char */
  118. char EofChar; /* End of Input character */
  119. char EvtChar; /* Recieved Event character */
  120. ushort TxDelay; /* Amount of time between chars */
  121. } DCB;
  122. /*************************************************************************
  123. **
  124. ** COMSTAT
  125. ** Status record returned by GetCommError
  126. **
  127. *************************************************************************/
  128. typedef struct {
  129. uchar fCtsHold: 1; /* Transmit is on CTS hold */
  130. uchar fDsrHold: 1; /* Transmit is on DSR hold */
  131. uchar fRlsdHold: 1; /* Transmit is on RLSD hold */
  132. uchar fXoffHold: 1; /* Transmit is on X-Off hold */
  133. uchar fXoffSent: 1; /* Recieve in X-Off or DTR hold */
  134. uchar fEof: 1; /* End of file character found */
  135. uchar fTxim: 1; /* Character being transmitted */
  136. uchar fPerr:1; /* Printer error */ /*081985*/
  137. ushort cbInQue; /* count of characters in Rx Que*/
  138. ushort cbOutQue; /* count of characters in Tx Que*/
  139. } COMSTAT;
  140. /*************************************************************************
  141. **
  142. ** DCB field definitions.
  143. **
  144. *************************************************************************/
  145. #define NOPARITY 0
  146. #define ODDPARITY 1
  147. #define EVENPARITY 2
  148. #define MARKPARITY 3
  149. #define SPACEPARITY 4
  150. #define ONESTOPBIT 0
  151. #define ONE5STOPBITS 1
  152. #define TWOSTOPBITS 2
  153. #define IGNORE 0 /* Ignore signal */
  154. #define INFINITE 0xffff /* Infinite timeout */
  155. /*************************************************************************
  156. **
  157. ** Comm Device Driver Error Bits.
  158. **
  159. *************************************************************************/
  160. #define CE_RXOVER 0x0001 /* Receive Queue overflow */
  161. #define CE_OVERRUN 0x0002 /* Receive Overrun Error */
  162. #define CE_RXPARITY 0x0004 /* Receive Parity Error */
  163. #define CE_FRAME 0x0008 /* Receive Framing error */
  164. #define CE_CTSTO 0x0020 /* CTS Timeout */
  165. #define CE_DSRTO 0x0040 /* DSR Timeout */
  166. #define CE_RLSDTO 0x0080 /* RLSD Timeout */
  167. #define CE_PTO 0x0100 /* LPTx Timeout */ /*081985*/
  168. #define CE_IOE 0x0200 /* LPTx I/O Error */ /*081985*/
  169. #define CE_DNS 0x0400 /* LPTx Device not selected */ /*081985*/
  170. #define CE_OOP 0x0800 /* LPTx Out-Of-Paper */ /*081985*/
  171. #define CE_MODE 0x8000 /* Requested mode unsupported */
  172. /*************************************************************************
  173. **
  174. ** Initialization Error Codes
  175. **
  176. *************************************************************************/
  177. #define IE_BADID -1 /* Invalid or unsupported id */
  178. #define IE_OPEN -2 /* Device Already Open */
  179. #define IE_NOPEN -3 /* Device Not Open */
  180. #define IE_MEMORY -4 /* Unable to allocate queues */
  181. #define IE_DEFAULT -5 /* Error in default parameters */
  182. #define IE_HARDWARE -10 /* Hardware Not Present */
  183. #define IE_BYTESIZE -11 /* Illegal Byte Size */
  184. #define IE_BAUDRATE -12 /* Unsupported BaudRate */
  185. /*************************************************************************
  186. **
  187. ** Event mask definitions. Used by SetCommEventMask and GetCommEventMask
  188. **
  189. ** RXCHAR - Set when any character is received and placed in the input
  190. ** queue.
  191. ** RXFLAG - Set when a particular character, as defined in the dcb, is
  192. ** received and placed in the input queue.
  193. ** TXEMPTY - Set when the last character in the transmit queue is
  194. ** transmitted.
  195. ** CTS - Set when the CTS signal changes state.
  196. ** DSR - Set when the DSR signal changes state.
  197. ** RLSD - Set when the RLSD signal changes state.
  198. ** BREAK - Set when a break is detected on input.
  199. ** ERR - Set when a line status error occurs.
  200. **
  201. *************************************************************************/
  202. #define EV_RXCHAR 0x0001 /* Any Character received */
  203. #define EV_RXFLAG 0x0002 /* Received certain character */
  204. #define EV_TXEMPTY 0x0004 /* Transmitt Queue Empty */
  205. #define EV_CTS 0x0008 /* CTS changed state */
  206. #define EV_DSR 0x0010 /* DSR changed state */
  207. #define EV_RLSD 0x0020 /* RLSD changed state */
  208. #define EV_BREAK 0x0040 /* BREAK received */
  209. #define EV_ERR 0x0080 /* Line Status Error Occurred */
  210. #define EV_RING 0x0100 /* Ring signal detected */
  211. #define EV_PERR 0x0200 /* LPTx error occured */ /*081985*/
  212. /*************************************************************************
  213. **
  214. ** Extended Functions
  215. **
  216. ** SETXOFF - Causes transmit to behave as if an X-OFF character had
  217. ** been received. Valid only if transmit X-ON/X-OFF specified
  218. ** in the dcb.
  219. ** SETXON - Causes transmit to behave as if an X-ON character had
  220. ** been received. Valid only if transmit X-ON/X-OFF specified
  221. ** in the dcb.
  222. *************************************************************************/
  223. #define SETXOFF 1 /* Set X-Off for output control */
  224. #define SETXON 2 /* Set X-ON for output control */
  225. #define SETRTS 3 /* Set RTS high */
  226. #define CLRRTS 4 /* Set RTS low */
  227. #define SETDTR 5 /* Set DTR high */
  228. #define CLRDTR 6 /* Set DTR low */
  229. #define RESETDEV 7 /* Reset device if possible */ /*081985*/