Leaked source code of windows server 2003
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.

330 lines
10 KiB

  1. /*++
  2. Copyright (c) 1990, 1991, 1992, 1993 - 1997 Microsoft Corporation
  3. Module Name :
  4. cyserial.h
  5. Abstract:
  6. Type definitions and data for the serial port driver
  7. Modified to contain only 8250 bit definitions. - Fanny
  8. Author:
  9. --*/
  10. //
  11. // Bitmask definitions for accessing the 8250 device registers.
  12. //
  13. //
  14. // These bits define the number of data bits trasmitted in
  15. // the Serial Data Unit (SDU - Start,data, parity, and stop bits)
  16. //
  17. #define SERIAL_DATA_LENGTH_5 0x00
  18. #define SERIAL_DATA_LENGTH_6 0x01
  19. #define SERIAL_DATA_LENGTH_7 0x02
  20. #define SERIAL_DATA_LENGTH_8 0x03
  21. //
  22. // These masks define the interrupts that can be enabled or disabled.
  23. //
  24. //
  25. // This interrupt is used to notify that there is new incomming
  26. // data available. The SERIAL_RDA interrupt is enabled by this bit.
  27. //
  28. #define SERIAL_IER_RDA 0x01
  29. //
  30. // This interrupt is used to notify that there is space available
  31. // in the transmitter for another character. The SERIAL_THR
  32. // interrupt is enabled by this bit.
  33. //
  34. #define SERIAL_IER_THR 0x02
  35. //
  36. // This interrupt is used to notify that some sort of error occured
  37. // with the incomming data. The SERIAL_RLS interrupt is enabled by
  38. // this bit.
  39. #define SERIAL_IER_RLS 0x04
  40. //
  41. // This interrupt is used to notify that some sort of change has
  42. // taken place in the modem control line. The SERIAL_MS interrupt is
  43. // enabled by this bit.
  44. //
  45. #define SERIAL_IER_MS 0x08
  46. //
  47. // These masks define the values of the interrupt identification
  48. // register. The low bit must be clear in the interrupt identification
  49. // register for any of these interrupts to be valid. The interrupts
  50. // are defined in priority order, with the highest value being most
  51. // important. See above for a description of what each interrupt
  52. // implies.
  53. //
  54. #define SERIAL_IIR_RLS 0x06
  55. #define SERIAL_IIR_RDA 0x04
  56. #define SERIAL_IIR_CTI 0x0c
  57. #define SERIAL_IIR_THR 0x02
  58. #define SERIAL_IIR_MS 0x00
  59. //
  60. // This bit mask get the value of the high two bits of the
  61. // interrupt id register. If this is a 16550 class chip
  62. // these bits will be a one if the fifo's are enbled, otherwise
  63. // they will always be zero.
  64. //
  65. #define SERIAL_IIR_FIFOS_ENABLED 0xc0
  66. //
  67. // If the low bit is logic one in the interrupt identification register
  68. // this implies that *NO* interrupts are pending on the device.
  69. //
  70. #define SERIAL_IIR_NO_INTERRUPT_PENDING 0x01
  71. //
  72. // These masks define access to the fifo control register.
  73. //
  74. //
  75. // Enabling this bit in the fifo control register will turn
  76. // on the fifos. If the fifos are enabled then the high two
  77. // bits of the interrupt id register will be set to one. Note
  78. // that this only occurs on a 16550 class chip. If the high
  79. // two bits in the interrupt id register are not one then
  80. // we know we have a lower model chip.
  81. //
  82. //
  83. #define SERIAL_FCR_ENABLE ((UCHAR)0x01)
  84. #define SERIAL_FCR_RCVR_RESET ((UCHAR)0x02)
  85. #define SERIAL_FCR_TXMT_RESET ((UCHAR)0x04)
  86. //
  87. // This set of values define the high water marks (when the
  88. // interrupts trip) for the receive fifo.
  89. //
  90. #define SERIAL_1_BYTE_HIGH_WATER ((UCHAR)0x00)
  91. #define SERIAL_4_BYTE_HIGH_WATER ((UCHAR)0x40)
  92. #define SERIAL_8_BYTE_HIGH_WATER ((UCHAR)0x80)
  93. #define SERIAL_14_BYTE_HIGH_WATER ((UCHAR)0xc0)
  94. //
  95. // These masks define access to the line control register.
  96. //
  97. //
  98. // This defines the bit used to control the definition of the "first"
  99. // two registers for the 8250. These registers are the input/output
  100. // register and the interrupt enable register. When the DLAB bit is
  101. // enabled these registers become the least significant and most
  102. // significant bytes of the divisor value.
  103. //
  104. #define SERIAL_LCR_DLAB 0x80
  105. //
  106. // This defines the bit used to control whether the device is sending
  107. // a break. When this bit is set the device is sending a space (logic 0).
  108. //
  109. // Most protocols will assume that this is a hangup.
  110. //
  111. #define SERIAL_LCR_BREAK 0x40
  112. //
  113. // These defines are used to set the line control register.
  114. //
  115. #define SERIAL_5_DATA ((UCHAR)0x00)
  116. #define SERIAL_6_DATA ((UCHAR)0x01)
  117. #define SERIAL_7_DATA ((UCHAR)0x02)
  118. #define SERIAL_8_DATA ((UCHAR)0x03)
  119. #define SERIAL_DATA_MASK ((UCHAR)0x03)
  120. #define SERIAL_1_STOP ((UCHAR)0x00)
  121. #define SERIAL_1_5_STOP ((UCHAR)0x04) // Only valid for 5 data bits
  122. #define SERIAL_2_STOP ((UCHAR)0x04) // Not valid for 5 data bits
  123. #define SERIAL_STOP_MASK ((UCHAR)0x04)
  124. #define SERIAL_NONE_PARITY ((UCHAR)0x00)
  125. #define SERIAL_ODD_PARITY ((UCHAR)0x08)
  126. #define SERIAL_EVEN_PARITY ((UCHAR)0x18)
  127. #define SERIAL_MARK_PARITY ((UCHAR)0x28)
  128. #define SERIAL_SPACE_PARITY ((UCHAR)0x38)
  129. #define SERIAL_PARITY_MASK ((UCHAR)0x38)
  130. //
  131. // These masks define access the modem control register.
  132. //
  133. //
  134. // This bit controls the data terminal ready (DTR) line. When
  135. // this bit is set the line goes to logic 0 (which is then inverted
  136. // by normal hardware). This is normally used to indicate that
  137. // the device is available to be used. Some odd hardware
  138. // protocols (like the kernel debugger) use this for handshaking
  139. // purposes.
  140. //
  141. #define SERIAL_MCR_DTR 0x01
  142. //
  143. // This bit controls the ready to send (RTS) line. When this bit
  144. // is set the line goes to logic 0 (which is then inverted by the normal
  145. // hardware). This is used for hardware handshaking. It indicates that
  146. // the hardware is ready to send data and it is waiting for the
  147. // receiving end to set clear to send (CTS).
  148. //
  149. #define SERIAL_MCR_RTS 0x02
  150. //
  151. // This bit is used for general purpose output.
  152. //
  153. #define SERIAL_MCR_OUT1 0x04
  154. //
  155. // This bit is used for general purpose output.
  156. //
  157. #define SERIAL_MCR_OUT2 0x08
  158. //
  159. // This bit controls the loopback testing mode of the device. Basically
  160. // the outputs are connected to the inputs (and vice versa).
  161. //
  162. #define SERIAL_MCR_LOOP 0x10
  163. //
  164. // These masks define access to the line status register. The line
  165. // status register contains information about the status of data
  166. // transfer. The first five bits deal with receive data and the
  167. // last two bits deal with transmission. An interrupt is generated
  168. // whenever bits 1 through 4 in this register are set.
  169. //
  170. //
  171. // This bit is the data ready indicator. It is set to indicate that
  172. // a complete character has been received. This bit is cleared whenever
  173. // the receive buffer register has been read.
  174. //
  175. #define SERIAL_LSR_DR 0x01
  176. //
  177. // This is the overrun indicator. It is set to indicate that the receive
  178. // buffer register was not read befor a new character was transferred
  179. // into the buffer. This bit is cleared when this register is read.
  180. //
  181. #define SERIAL_LSR_OE 0x02
  182. //
  183. // This is the parity error indicator. It is set whenever the hardware
  184. // detects that the incoming serial data unit does not have the correct
  185. // parity as defined by the parity select in the line control register.
  186. // This bit is cleared by reading this register.
  187. //
  188. #define SERIAL_LSR_PE 0x04
  189. //
  190. // This is the framing error indicator. It is set whenever the hardware
  191. // detects that the incoming serial data unit does not have a valid
  192. // stop bit. This bit is cleared by reading this register.
  193. //
  194. #define SERIAL_LSR_FE 0x08
  195. //
  196. // This is the break interrupt indicator. It is set whenever the data
  197. // line is held to logic 0 for more than the amount of time it takes
  198. // to send one serial data unit. This bit is cleared whenever the
  199. // this register is read.
  200. //
  201. #define SERIAL_LSR_BI 0x10
  202. //
  203. // This is the transmit holding register empty indicator. It is set
  204. // to indicate that the hardware is ready to accept another character
  205. // for transmission. This bit is cleared whenever a character is
  206. // written to the transmit holding register.
  207. //
  208. #define SERIAL_LSR_THRE 0x20
  209. //
  210. // This bit is the transmitter empty indicator. It is set whenever the
  211. // transmit holding buffer is empty and the transmit shift register
  212. // (a non-software accessable register that is used to actually put
  213. // the data out on the wire) is empty. Basically this means that all
  214. // data has been sent. It is cleared whenever the transmit holding or
  215. // the shift registers contain data.
  216. //
  217. #define SERIAL_LSR_TEMT 0x40
  218. //
  219. // This bit indicates that there is at least one error in the fifo.
  220. // The bit will not be turned off until there are no more errors
  221. // in the fifo.
  222. //
  223. #define SERIAL_LSR_FIFOERR 0x80
  224. //
  225. // These masks are used to access the modem status register.
  226. // Whenever one of the first four bits in the modem status
  227. // register changes state a modem status interrupt is generated.
  228. //
  229. //
  230. // This bit is the delta clear to send. It is used to indicate
  231. // that the clear to send bit (in this register) has *changed*
  232. // since this register was last read by the CPU.
  233. //
  234. #define SERIAL_MSR_DCTS 0x01
  235. //
  236. // This bit is the delta data set ready. It is used to indicate
  237. // that the data set ready bit (in this register) has *changed*
  238. // since this register was last read by the CPU.
  239. //
  240. #define SERIAL_MSR_DDSR 0x02
  241. //
  242. // This is the trailing edge ring indicator. It is used to indicate
  243. // that the ring indicator input has changed from a low to high state.
  244. //
  245. #define SERIAL_MSR_TERI 0x04
  246. //
  247. // This bit is the delta data carrier detect. It is used to indicate
  248. // that the data carrier bit (in this register) has *changed*
  249. // since this register was last read by the CPU.
  250. //
  251. #define SERIAL_MSR_DDCD 0x08
  252. //
  253. // This bit contains the (complemented) state of the clear to send
  254. // (CTS) line.
  255. //
  256. #define SERIAL_MSR_CTS 0x10
  257. //
  258. // This bit contains the (complemented) state of the data set ready
  259. // (DSR) line.
  260. //
  261. #define SERIAL_MSR_DSR 0x20
  262. //
  263. // This bit contains the (complemented) state of the ring indicator
  264. // (RI) line.
  265. //
  266. #define SERIAL_MSR_RI 0x40
  267. //
  268. // This bit contains the (complemented) state of the data carrier detect
  269. // (DCD) line.
  270. //
  271. #define SERIAL_MSR_DCD 0x80