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.

184 lines
4.1 KiB

  1. /*
  2. ************************************************************************
  3. *
  4. * COMM.h
  5. *
  6. *
  7. * Portions Copyright (C) 1996-1998 National Semiconductor Corp.
  8. * All rights reserved.
  9. * Copyright (C) 1996-1998 Microsoft Corporation. All Rights Reserved.
  10. *
  11. *
  12. *
  13. *************************************************************************
  14. */
  15. #ifndef COMM_H
  16. #define COMM_H
  17. /*
  18. * Size of the 16550 read and write FIFOs
  19. */
  20. #define FIFO_SIZE 16
  21. /*
  22. * The programming interface to a UART (COM serial port)
  23. * consists of eight consecutive registers.
  24. * These are the port offsets from the UART's base I/O address.
  25. */
  26. typedef enum comPortRegOffsets {
  27. XFER_REG_OFFSET = 0,
  28. INT_ENABLE_REG_OFFSET = 1,
  29. INT_ID_AND_FIFO_CNTRL_REG_OFFSET = 2,
  30. LINE_CONTROL_REG_OFFSET = 3,
  31. MODEM_CONTROL_REG_OFFSET = 4,
  32. LINE_STAT_REG_OFFSET = 5,
  33. MODEM_STAT_REG_OFFSET = 6,
  34. SCRATCH_REG_OFFSET = 7
  35. } comPortRegOffset;
  36. /*
  37. * Bits in the UART Interrupt-Id register.
  38. */
  39. #define INTID_INTERRUPT_NOT_PENDING (UCHAR)(1 << 0)
  40. /*
  41. * Values for bits 2-1 of Interrupt-Id register:
  42. * 00 Modem Stat reg interrupt
  43. * 01 Transmitter holding reg interrupt
  44. * 10 Receive data ready interrupt
  45. * 11 Receive line status interrupt
  46. *
  47. */
  48. #define INTID_INTIDMASK (UCHAR)(3 << 1)
  49. #define INTID_MODEMSTAT_INT (UCHAR)(0 << 1)
  50. #define INTID_XMITREG_INT (UCHAR)(1 << 1)
  51. #define INTID_RCVDATAREADY_INT (UCHAR)(2 << 1)
  52. #define INTID_RCVLINESTAT_INT (UCHAR)(3 << 1)
  53. /*
  54. * Bits in the UART line-status register.
  55. */
  56. #define LINESTAT_DATAREADY (UCHAR)(1 << 0)
  57. #define LINESTAT_OVERRUNERROR (UCHAR)(1 << 1)
  58. #define LINESTAT_PARITYERROR (UCHAR)(1 << 2)
  59. #define LINESTAT_FRAMINGERROR (UCHAR)(1 << 3)
  60. #define LINESTAT_BREAK (UCHAR)(1 << 4)
  61. #define LINESTAT_XMIT_HOLDING_REG_EMPTY (UCHAR)(1 << 5)
  62. #define LINESTAT_XMIT_SHIFT_AND_HOLDING_REG_EMPTY (UCHAR)(1 << 6)
  63. /*
  64. * These are bits in the UART's interrupt-enable register (INT_ENABLE_REG_OFFSET).
  65. */
  66. #define DATA_AVAIL_INT_ENABLE (1 << 0)
  67. #define READY_FOR_XMIT_INT_ENABLE (1 << 1)
  68. #define RCV_LINE_STAT_INT_ENABLE (1 << 2)
  69. #define MODEM_STAT_INT_ENABLE (1 << 3)
  70. #define RCV_MODE_INTS_ENABLE (DATA_AVAIL_INT_ENABLE)
  71. #define XMIT_MODE_INTS_ENABLE (READY_FOR_XMIT_INT_ENABLE|DATA_AVAIL_INT_ENABLE)
  72. #define ALL_INTS_ENABLE (RCV_MODE_INTS_ENABLE | XMIT_MODE_INTS_ENABLE)
  73. #define ALL_INTS_DISABLE 0
  74. /*
  75. * These are fine-tuning parameters for the COM port ISR.
  76. * Number of times we poll a COM port register waiting
  77. * for a value which may/must appear.
  78. */
  79. #define REG_POLL_LOOPS 2
  80. #define REG_TIMEOUT_LOOPS 1000000
  81. typedef enum {
  82. STATE_INIT = 0,
  83. STATE_GOT_BOF,
  84. STATE_ACCEPTING,
  85. STATE_ESC_SEQUENCE,
  86. STATE_SAW_EOF,
  87. STATE_CLEANUP
  88. } portRcvState;
  89. /*
  90. * This is the information that we need to keep for each COMM port.
  91. */
  92. typedef struct _comPortInfo {
  93. /*
  94. * HW resource settings for COM port.
  95. */
  96. //
  97. // Physical address of the ConfigIoBaseAddress
  98. //
  99. ULONG ConfigIoBasePhysAddr;
  100. //
  101. // Virtual address of the ConfigIoBaseAddress
  102. //
  103. PUCHAR ConfigIoBaseAddr;
  104. //
  105. // Physical address of the UartIoBaseAddress
  106. //
  107. ULONG ioBasePhys;
  108. //
  109. // Virtual address of the UartIoBaseAddress
  110. //
  111. PUCHAR ioBase;
  112. //
  113. // Interrupt number this adapter is using.
  114. //
  115. UINT irq;
  116. //
  117. // DMA Cnannel Number.
  118. //
  119. UCHAR DMAChannel;
  120. /*
  121. * Is this COM port a 16550 with a 16-byte FIFO or
  122. * a 16450/8250 with no FIFO ?
  123. */
  124. BOOLEAN haveFIFO;
  125. /*
  126. * Data for our rcv state machine.
  127. */
  128. UCHAR rawBuf[FIFO_SIZE];
  129. PUCHAR readBuf;
  130. UINT readBufPos;
  131. portRcvState rcvState;
  132. //
  133. // Debug counter for packets received correctly.
  134. //
  135. UINT PacketsReceived_DEBUG;
  136. /*
  137. * Data for send state machine
  138. */
  139. PUCHAR writeComBuffer;
  140. UINT writeComBufferPos;
  141. UINT writeComBufferLen;
  142. UINT SirWritePending;
  143. UINT IsrDoneWithPacket;
  144. /*
  145. * Dongle or part-specific information
  146. */
  147. dongleCapabilities hwCaps;
  148. UINT dongleContext;
  149. } comPortInfo;
  150. #endif COMM_H