Windows NT 4.0 source code leak
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.

254 lines
7.9 KiB

4 years ago
  1. #ifndef _IEPROSW_
  2. #define _IEPROSW_
  3. #define EPRO_NDIS_MAJOR_VERSION 3
  4. #define EPRO_NDIS_MINOR_VERSION 0
  5. #define EPRO_USE_32_BIT_IO
  6. ////////////////////////////////////////////////////////////
  7. // Internal data structures used by the driver...
  8. ////////////////////////////////////////////////////////////
  9. // do i really need this?
  10. typedef struct EPRO_DRIVER {
  11. NDIS_HANDLE EProWrapperHandle;
  12. } EPRO_DRIVER, *PEPRO_DRIVER;
  13. ////////////////////////////////////////////////////////////
  14. typedef struct _EPRO_TRANSMIT_BUFFER {
  15. // This is basically to make computing the next and last buffer
  16. // faster... Maybe saves us a few instructions, but makes a
  17. // lot of code a lot easier to read...
  18. struct _EPRO_TRANSMIT_BUFFER *LastBuf;
  19. struct _EPRO_TRANSMIT_BUFFER *NextBuf;
  20. BOOLEAN fEmpty; // TRUE if this is an empty buffer,
  21. // This is valid iff !fEmpty
  22. PNDIS_PACKET TXPacket;
  23. // These are addresses ON THE NIC
  24. USHORT TXBaseAddr;
  25. USHORT TXSendAddr;
  26. // USHORT TXBottomAddr;
  27. USHORT TXSize;
  28. } EPRO_TRANSMIT_BUFFER, *PEPRO_TRANSMIT_BUFFER;
  29. ////////////////////////////////////////////////////////////
  30. // The header is supposed to be "compatible with the 8595tx'
  31. // transmit buffer structure. Whatever.
  32. typedef struct _EPRO_MC_HEADER {
  33. UCHAR CommandField;
  34. UCHAR NullBytes[5];
  35. // do it this way for endian-safety
  36. UCHAR ByteCountLo;
  37. UCHAR ByteCountHi;
  38. } EPRO_MC_HEADER, *PEPRO_MC_HEADER;
  39. ////////////////////////////////////////////////////////////
  40. typedef struct _EPRO_MC_ADDRESS {
  41. UCHAR AddrByte[EPRO_LENGTH_OF_ADDRESS];
  42. } EPRO_MC_ADDRESS, *PEPRO_MC_ADDRESS;
  43. ////////////////////////////////////////////////////////////
  44. // These are the structures to be copied onto the NIC -- they
  45. // are documented in the 82595 documentation
  46. typedef struct _EPRO_TX_FRAME_HEADER {
  47. // High dword
  48. UCHAR XmitOp;
  49. UCHAR NULLByte;
  50. UCHAR Status0;
  51. UCHAR Status1;
  52. // Low dword
  53. UCHAR XMTChainLo;
  54. UCHAR XMTChainHi;
  55. } EPRO_TX_FRAME_HEADER, *PEPRO_TX_FRAME_HEADER;
  56. ////////////////////////////////////////////////////////////
  57. // Same as above...
  58. typedef struct _EPRO_RCV_HEADER {
  59. UCHAR Event;
  60. UCHAR NullByte;
  61. UCHAR Status0;
  62. UCHAR Status1;
  63. UCHAR NextFrmLo;
  64. UCHAR NextFrmHi;
  65. UCHAR ByteCountLo;
  66. UCHAR ByteCountHi;
  67. } EPRO_RCV_HEADER, *PEPRO_RCV_HEADER;
  68. ////////////////////////////////////////////////////////////
  69. // This is an ETHERNET 802.3 frame header.
  70. typedef struct _EPRO_ETH_HEADER {
  71. UCHAR DestAddress[EPRO_LENGTH_OF_ADDRESS];
  72. UCHAR SourceAddress[EPRO_LENGTH_OF_ADDRESS];
  73. USHORT Length;
  74. } EPRO_ETH_HEADER, *PEPRO_ETH_HEADER;
  75. ////////////////////////////////////////////////////////////
  76. // This is the context that gets passed to EProTransferData
  77. // through NdisMIndicateReceive
  78. typedef struct _EPRO_RCV_CONTEXT {
  79. USHORT RXCurrentAddress;
  80. USHORT RXFrameSize;
  81. USHORT LookAheadSize;
  82. } EPRO_RCV_CONTEXT, *PEPRO_RCV_CONTEXT;
  83. ////////////////////////////////////////////////////////////
  84. // The EPro adapter structure...
  85. typedef struct EPRO_ADAPTER {
  86. NDIS_HANDLE MiniportAdapterHandle;
  87. NDIS_MINIPORT_INTERRUPT Interrupt;
  88. // NDIS_MINIPORT_TIMER MiniportTimer;
  89. PVOID IoBaseAddr;
  90. ULONG TransceiverType;
  91. ULONG IoPAddr; // Returned by NdisMRegisterIoPortRange - handle to mapped ports
  92. ULONG IoChannelReady;
  93. // What version of 82595 is this?
  94. ULONG EProStepping;
  95. // Can we use 32-bit IO? (ie is this a new enough version of the 82595
  96. // chip?)
  97. BOOLEAN EProUse32BitIO;
  98. ULONG CurrentHardwareStatus;
  99. // what is our current packet filter?
  100. ULONG CurrentPacketFilter;
  101. // are promiscuous receptions currently enabled?
  102. BOOLEAN fPromiscuousEnable;
  103. // are broadcast receptions currently enabled?
  104. BOOLEAN fBroadcastEnable;
  105. // are multicast receptions currently enabled?
  106. BOOLEAN fMulticastEnable;
  107. // are we hung? NOTUSED
  108. BOOLEAN fHung;
  109. // are receives currently enabled?
  110. BOOLEAN fReceiveEnabled;
  111. // do we really need this?
  112. // BOOLEAN fTransmitInProgress;
  113. // statistics
  114. ULONG FramesXmitOK;
  115. ULONG FramesRcvOK;
  116. ULONG FramesXmitErr;
  117. ULONG FramesRcvErr;
  118. ULONG FramesMissed;
  119. ULONG FrameAlignmentErrors;
  120. ULONG FramesXmitOneCollision;
  121. ULONG FramesXmitManyCollisions;
  122. // transmit info
  123. // these are our transmit buffers - structures which basically
  124. // keep track of what frames are where in the NIC's memory.
  125. EPRO_TRANSMIT_BUFFER TXBuf[EPRO_NUM_TX_BUFFERS];
  126. // this is the first free transmit buffer pointer.
  127. PEPRO_TRANSMIT_BUFFER CurrentTXBuf;
  128. // This is the frame that is currently in the process of
  129. // being transmitted onto the wire.
  130. PEPRO_TRANSMIT_BUFFER TXChainStart;
  131. // Multicast info
  132. UCHAR MCAddress[EPRO_MAX_MULTICAST][EPRO_LENGTH_OF_ADDRESS];
  133. // how many mc addresses are currently set?
  134. USHORT NumMCAddresses;
  135. // receive info
  136. // how big is our lookahead buffer currently?
  137. USHORT RXLookAheadSize;
  138. // our lookahead buffer data
  139. UCHAR RXLookAhead[EPRO_GEN_MAXIMUM_LOKAHEAD];
  140. // what address ON THE NIC are we currently receiveing at?
  141. // ie where do we check when we get a receive interrupt.
  142. USHORT RXCurrentAddress;
  143. // Is there an exec int pending? If so, why?
  144. // right now only used to resolve pended set-mc calls...
  145. ULONG IntPending;
  146. // This is our context for a pended set-mc call
  147. PVOID IntContext;
  148. // set based on result of IOCHRDY test
  149. BOOLEAN Use8Bit;
  150. // set in ReadConfigInfo
  151. BOOLEAN UseDefaultAddress;
  152. // the MAC address burned into the eeprom
  153. UCHAR PermanentIndividualAddress[EPRO_LENGTH_OF_ADDRESS];
  154. // the address we are currently receiving at
  155. UCHAR CurrentIndividualAddress[EPRO_LENGTH_OF_ADDRESS];
  156. // always 00 aa 00 for intel
  157. UCHAR vendorID[3];
  158. UCHAR InterruptNumber;
  159. UCHAR BusType;
  160. // This is only used at initialization time
  161. BOOLEAN fUpdateIOAddress;
  162. PVOID OldIOAddress;
  163. UCHAR CurrentInterruptMask;
  164. } EPRO_ADAPTER, *PEPRO_ADAPTER;
  165. ////////////////////////////////////////////////////////////
  166. // Sync contexts
  167. ////////////////////////////////////////////////////////////
  168. typedef struct _EPRO_COPYBUF_CONTEXT {
  169. PEPRO_ADAPTER Adapter;
  170. PVOID Buffer;
  171. UINT Len;
  172. } EPRO_COPYBUF_CONTEXT, *PEPRO_COPYBUF_CONTEXT;
  173. typedef struct _EPRO_SETINTERRUPT_CONTEXT {
  174. PEPRO_ADAPTER Adapter;
  175. UCHAR NewMask;
  176. } EPRO_SETINTERRUPT_CONTEXT, *PEPRO_SETINTERRUPT_CONTEXT;
  177. typedef struct _EPRO_BRDPROM_CONTEXT {
  178. PEPRO_ADAPTER Adapter;
  179. UCHAR Reg2Flags;
  180. } EPRO_BRDPROM_CONTEXT, *PEPRO_BRDPROM_CONTEXT;
  181. ////////////////////////////////////////////////////////////
  182. // Some macros for commonly used stuff....
  183. #define EPRO_WR_PORT_UCHAR(adapter, port, ch) \
  184. NdisRawWritePortUchar(adapter->IoPAddr + port, ch)
  185. #define EPRO_RD_PORT_UCHAR(adapter, port, ch) \
  186. NdisRawReadPortUchar(adapter->IoPAddr + port, ch)
  187. #define EPRO_WR_PORT_USHORT(adapter, port, us) \
  188. NdisRawWritePortUshort(adapter->IoPAddr + port, us)
  189. #define EPRO_RD_PORT_USHORT(adapter, port, us) \
  190. NdisRawReadPortUshort(adapter->IoPAddr + port, us)
  191. ////////////////////////////////////////////////////////////
  192. // The EPro is a bank-switching card. These macros switch between the banks...
  193. #define EPRO_SWITCH_BANK_0(adapter) \
  194. EPRO_WR_PORT_UCHAR(adapter, I82595_CMD_REG, I82595_CMD_BANK0)
  195. #define EPRO_SWITCH_BANK_1(adapter) \
  196. EPRO_WR_PORT_UCHAR(adapter, I82595_CMD_REG, I82595_CMD_BANK1)
  197. #define EPRO_SWITCH_BANK_2(adapter) \
  198. EPRO_WR_PORT_UCHAR(adapter, I82595_CMD_REG, I82595_CMD_BANK2)
  199. // Set the Host Address Register (0,c) -- use this to set up the NIC address
  200. // for PIO through the register via COPY_BUFFER macros.
  201. #define EPRO_SET_HOST_ADDR(adapter, addr) \
  202. EPRO_WR_PORT_USHORT(adapter, I82595_HOST_ADDR_REG, addr);
  203. #define EPRO_COPY_BUFFER_TO_NIC_USHORT(adapter, buffer, len) \
  204. NdisRawWritePortBufferUshort((adapter->IoPAddr + I82595_MEM_IO_REG), \
  205. (buffer), \
  206. (len))
  207. #define EPRO_READ_BUFFER_FROM_NIC_USHORT(adapter, buffer, len) \
  208. NdisRawReadPortBufferUshort((adapter->IoPAddr + I82595_MEM_IO_REG), \
  209. (buffer), \
  210. len)
  211. #endif _IEPROSW_