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.

267 lines
8.4 KiB

  1. /*****************************************************************************
  2. ** **
  3. ** COPYRIGHT (C) 2000, 2001 MKNET CORPORATION **
  4. ** DEVELOPED FOR THE MK7100-BASED VFIR PCI CONTROLLER. **
  5. ** **
  6. *****************************************************************************/
  7. /**********************************************************************
  8. Module Name:
  9. MK7.H
  10. Comments:
  11. Include file for the MK7100 controller. Also includes Phoenix stuff.
  12. **********************************************************************/
  13. #ifndef _MK7_H
  14. #define _MK7_H
  15. #include <ndis.h>
  16. #define MK7REG USHORT
  17. #define PHOENIX_REG_CNT 0x34 // 52
  18. #define PHOENIX_REG_SIZE 2 // 2 bytes
  19. #define MK7_IO_SIZE (PHOENIX_REG_CNT * PHOENIX_REG_SIZE)
  20. //#define MISC_REG_CNT 4
  21. //#define MISC_REG_SIZE 2
  22. //#define MK7_IO_SIZE ( (PHOENIX_REG_CNT * PHOENIX_REG_SIZE) + \
  23. // (MISC_REG_CNT * MISC_REG_SIZE) )
  24. //******************************
  25. // Phoenix Definitions
  26. //******************************
  27. //
  28. // Registers
  29. //
  30. #define REG_BASE 0x00000000
  31. #define REG_RPRB_OFFSET 0x00 // Ring Pointer Readback
  32. #define REG_RBAU_OFFSET 0x02 // Ring Base Addr - Upper
  33. #define REG_RBAL_OFFSET 0x04 // Ring Base Addr - Lower
  34. #define REG_RSIZ_OFFSET 0x06 // Ring Size
  35. #define REG_PRMT_OFFSET 0x08 // PROMPT
  36. #define REG_ACMP_OFFSET 0x0A // Addr Compare
  37. #define REG_TXCL_OFFSET 0x0C // Clear TX Interrupt
  38. #define REG_RXCL_OFFSET 0x0D // Clear RX Interrupt
  39. #define REG_CFG0_OFFSET 0x10 // Config Reg 0 (IR Config Reg 0)
  40. #define REG_SFLG_OFFSET 0x12 // SIR Flag
  41. #define REG_ENAB_OFFSET 0x14 // Enable
  42. #define REG_CPHY_OFFSET 0x16 // Config to Physical
  43. #define REG_CFG2_OFFSET 0x18 // Phy Config Reg 2 (IRCONFIG2)
  44. #define REG_MPLN_OFFSET 0x1A // Max Packet Length
  45. #define REG_RCNT_OFFSET 0x1C // Recv Byte Count
  46. #define REG_CFG3_OFFSET 0x1E // Phy Config Reg 3 (IRCONFIG3)
  47. #define REG_INTS_OFFSET 0x30 // Interrupt Status
  48. #define REG_GANA_OFFSET 0x31 // General & Analog Transceiver Control // B3.1.0-pre
  49. #define R_RPRB (REG_BASE + REG_RPRB_OFFSET)
  50. #define R_RBAU (REG_BASE + REG_RBAU_OFFSET)
  51. #define R_RBAL (REG_BASE + REG_RBAL_OFFSET)
  52. #define R_RSIZ (REG_BASE + REG_RSIZ_OFFSET)
  53. #define R_PRMT (REG_BASE + REG_PRMT_OFFSET)
  54. #define R_ACMP (REG_BASE + REG_ACMP_OFFSET)
  55. #define R_TXCL (REG_BASE + REG_TXCL_OFFSET)
  56. #define R_RXCL (REG_BASE + REG_RXCL_OFFSET)
  57. #define R_CFG0 (REG_BASE + REG_CFG0_OFFSET)
  58. #define R_SFLG (REG_BASE + REG_SFLG_OFFSET)
  59. #define R_ENAB (REG_BASE + REG_ENAB_OFFSET)
  60. #define R_CPHY (REG_BASE + REG_CPHY_OFFSET)
  61. #define R_CFG2 (REG_BASE + REG_CFG2_OFFSET)
  62. #define R_MPLN (REG_BASE + REG_MPLN_OFFSET)
  63. #define R_RCNT (REG_BASE + REG_RCNT_OFFSET)
  64. #define R_CFG3 (REG_BASE + REG_CFG3_OFFSET)
  65. #define R_INTS (REG_BASE + REG_INTS_OFFSET)
  66. #define R_GANA (REG_BASE + REG_GANA_OFFSET)
  67. // Use the above definitions for register access or the
  68. // following structure.
  69. //
  70. // (NOTE: This is useful if we used memory mapped access to the registers.)
  71. //
  72. //typedef struct _MK7REG {
  73. // USHORT MK7REG_RPRB;
  74. // USHORT MK7REG_RBAU;
  75. // USHORT MK7REG_RBAL;
  76. // USHORT MK7REG_RSIZ;
  77. // USHORT MK7REG_RPMP;
  78. // USHORT MK7REG_ACMP;
  79. // USHORT MK7REG_CFG0;
  80. // USHORT MK7REG_SFLG;
  81. // USHORT MK7REG_ENAB;
  82. // USHORT MK7REG_CPHY;
  83. // USHORT MK7REG_CFG2;
  84. // USHORT MK7REG_MPLN;
  85. // USHORT MK7REG_RCNT;
  86. // USHORT MK7REG_CFG3;
  87. // USHORT MK7REG_INTM;
  88. // USHORT MK7REG_INTE;
  89. //} MK7REG, PMK7REG;
  90. //
  91. // Ring Entry Formats
  92. //
  93. // (A Ring entry is referred to as TRD (Transmit Ring Descriptor) &
  94. // RRD (Receive Ring Descriptor)).
  95. //
  96. typedef struct TRD {
  97. unsigned count:16;
  98. unsigned unused:8;
  99. unsigned status:8;
  100. unsigned addr:32;
  101. } TRD, *PTRD;
  102. typedef struct RRD {
  103. unsigned count:16;
  104. unsigned unused:8;
  105. unsigned status:8;
  106. unsigned addr:32;
  107. } RRD, *PRRD;
  108. // Bit mask definitions for the TX and RX Ring Buffer Descriptor Status field.
  109. #define B_TRDSTAT_UNDER 0x01 // underrun
  110. #define B_TRDSTAT_CLRENTX 0x04 // R/W REQ_TO_CLEAR_ENTX
  111. #define B_TRDSTAT_FORCEUNDER 0x08 // R/W FORCE_UNDERRUN
  112. #define B_TRDSTAT_NEEDPULSE 0x10 // R/W NEED_PULSE
  113. #define B_TRDSTAT_BADCRC 0x20 // R/W BAD_CRC
  114. #define B_TRDSTAT_DISTXCRC 0x40 // R/W DISTX-CRC
  115. #define B_TRDSTAT_HWOWNS 0x80 // R/W HW OWNS
  116. #define B_RRDSTAT_SIRBAD 0x04 // R SIR BAD (if SIR Filter is on)
  117. #define B_RRDSTAT_OVERRUN 0x08 // R RCV FIFO overflow
  118. #define B_RRDSTAT_LEN 0x10 // R Max length packet encountered
  119. #define B_RRDSTAT_CRCERR 0x20 // R CRC_ERROR (16- or 32-bit)
  120. #define B_RRDSTAT_PHYERR 0x40 // R PHY_ERROR (encoding error)
  121. #define B_RRDSTAT_HWOWNS 0x80 // R/W HW OWNS
  122. #define B_CFG0_ENRX 0x0800 // ENTX - enable TX [R_CFG0]
  123. #define B_CFG0_ENTX 0x1000 // ENRX - enable RX [R_CFG0]
  124. #define B_CFG0_INVTTX 0x0002 // INVERTTX
  125. // Bits for TX & RX interrupt enable mask and Interrupt Status registers
  126. // [R_INTS] (@ 0x30)
  127. #define B_TX_INTS 0x0001 // TX_int (bit 0) [R_INTS]
  128. #define B_RX_INTS 0x0002 // RX_int (bit 1) [R_INTS]
  129. #define B_TEST_INTS 0x0004 // TEST_int for testing (R/W)
  130. // Enable RX & TX interrupts
  131. #define B_ENAB_INT 0x0100 // Enable/Dislabe both RX/TX interrupt (bit 8)
  132. // [R_CFG3]
  133. // Bits in IR Enable Reg [R_ENAB] (@ 0x14)
  134. #define B_ENAB_IRENABLE 0x8000 // IR_ENABLE (bit 15) [R_ENAB]
  135. // B3.1.0-pre This bit mask (0x0020) was set wrong.
  136. // Bit for >SIR TX (fast = >SIR)
  137. #define B_FAST_TX 0x0200 // IRCONFIG (bit 9) -- bit set to 0 - SIR
  138. // -- set to 1 - >SIR
  139. // B3.1.0-pre New SEL0/1 power level control
  140. #define B_GANA_SEL01 0x0003 // Bits 0 (SEL0) & 1 (SEL1)
  141. // Ring Size settings
  142. #define RINGSIZE_4 0x00
  143. #define RINGSIZE_8 0x01
  144. #define RINGSIZE_16 0x03
  145. #define RINGSIZE_32 0x07
  146. #define RINGSIZE_64 0x0F
  147. #define RINGSIZE_RX4 (RINGSIZE_4 << 8)
  148. #define RINGSIZE_RX8 (RINGSIZE_8 << 8)
  149. #define RINGSIZE_RX16 (RINGSIZE_16 << 8)
  150. #define RINGSIZE_RX32 (RINGSIZE_32 << 8)
  151. #define RINGSIZE_RX64 (RINGSIZE_64 << 8)
  152. #define RINGSIZE_TX4 (RINGSIZE_4 << 12)
  153. #define RINGSIZE_TX8 (RINGSIZE_8 << 12)
  154. #define RINGSIZE_TX16 (RINGSIZE_16 << 12)
  155. #define RINGSIZE_TX32 (RINGSIZE_32 << 12)
  156. #define RINGSIZE_TX64 (RINGSIZE_64 << 12)
  157. // Set IrDA speeds to IRCONFIG2
  158. #define HW_SIR_SPEED_2400 ((47<<10) | (12<<5))
  159. #define HW_SIR_SPEED_9600 ((11<<10) | (12<<5))
  160. #define HW_SIR_SPEED_19200 ((5<<10) | (12<<5))
  161. #define HW_SIR_SPEED_38400 ((2<<10) | (12<<5))
  162. #define HW_SIR_SPEED_57600 ((1<<10) | (12<<5))
  163. #define HW_SIR_SPEED_115200 ((12<<5))
  164. // Additional defs
  165. #define HW_MIR_SPEED_576000 ((1<<10) | (16<<5))
  166. #define HW_MIR_SPEED_1152000 ((8<<5))
  167. // RRD Macros
  168. #define GrantRrdToHw(x) (x->status = B_RRDSTAT_HWOWNS)
  169. #define GrantTrdToHw(x) (x->status = B_TRDSTAT_HWOWNS)
  170. #define GrantRrdToDrv(x) (x->status &= ~B_RRDSTAT_HWOWNS)
  171. #define GrantTrdToDrv(x) (x->status &= ~B_TRDSTAT_HWOWNS)
  172. #define HwOwnsRrd(x) ((x->status & B_RRDSTAT_HWOWNS))
  173. #define HwOwnsTrd(x) ((x->status & B_TRDSTAT_HWOWNS))
  174. #define RrdError(x) (x->status & 0x6C) // PHY_ERROR, CRC_ERROR, Rx Overrun, Rx SIRBAD
  175. #define RrdAnyError(x) (x->status & 0x7C) // Any error at all (for debug)
  176. #define TrdError(x) (x->status & 0x01) // Underrun
  177. #define TrdAnyError(x) (x->status & 0x01) // Underrun
  178. // Macros to access MK7 hw registers
  179. // 16-bit registers
  180. #if !DBG
  181. #define MK7Reg_Write(adapter, _port, _val) \
  182. NdisRawWritePortUshort( (PUCHAR)(adapter->MappedIoBase+_port), (USHORT)(_val) )
  183. #define MK7Reg_Read(adapter, _port, _pval) \
  184. NdisRawReadPortUshort( (PUCHAR)(adapter->MappedIoBase+_port), (PUSHORT)(_pval) )
  185. //#define MK7Reg_Write(_port, _val) DEBUGSTR(("MK7Write\n"))
  186. //#define MK7Reg_Read(_port, _pval) DEBUGSTR(("MK7Read\n"))
  187. #endif
  188. #define MK7DisableIr(adapter) (MK7Reg_Write(adapter, R_ENAB, ~B_ENAB_IRENABLE))
  189. #define MK7EnableIr(adapter) (MK7Reg_Write(adapter, R_ENAB, B_ENAB_IRENABLE))
  190. #define MK7OurInterrupt(x) (x != 0)
  191. #if DBG
  192. #define MK7RXInterrupt(x) ( (x & B_RX_INTS) || (x & B_TEST_INTS) )
  193. #define MK7TXInterrupt(x) ( (x & B_TX_INTS) || (x & B_TEST_INTS) )
  194. #else
  195. #define MK7RXInterrupt(x) (x & B_RX_INTS)
  196. #define MK7TXInterrupt(x) (x & B_TX_INTS)
  197. #endif
  198. //******************************
  199. // Phoenix End
  200. //******************************
  201. #include "winpci.h"
  202. #include "mk7comm.h"
  203. #include "wincomm.h"
  204. #include "dbg.h"
  205. #include "queue.h"
  206. #endif // _MK7_H