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.

240 lines
13 KiB

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