home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ndissrc.zip / UM9008HW.H < prev    next >
Text File  |  1996-02-07  |  14KB  |  545 lines

  1. /*++
  2.  
  3. Module Name:
  4.  
  5.     um9008hw.h
  6.  
  7. Abstract:
  8.  
  9.     The main program for an UM9008 miniport driver.
  10.  
  11.  
  12. --*/
  13.  
  14. #ifndef _UM9008HARDWARE_
  15. #define _UM9008HARDWARE_
  16.  
  17.  
  18. //
  19. // Definitions for supporting clone adapters.
  20. //
  21.  
  22. //
  23. // Valid value ranges for the IoBaseAddress.
  24. //
  25. #ifdef NE1000
  26. #define MIN_IOBASEADDR 0x0200
  27. #else
  28. #define MIN_IOBASEADDR 0x0120
  29. #endif
  30.  
  31. #define MAX_IOBASEADDR 0xc3d0
  32.  
  33.  
  34.  
  35. //
  36. // Valid value ranges for the InterruptNumber.
  37. //
  38. #define MIN_IRQ 2
  39.  
  40. #ifdef NE1000
  41. #define MAX_IRQ 9
  42. #else
  43. #define MAX_IRQ 15
  44. #endif
  45.  
  46.  
  47. //
  48. //  Types of UM9008 cards.
  49. //
  50. #define UM9008_ISA                  0
  51. #define UM9008_PCMCIA               1
  52.  
  53. //
  54. // ID for MCA UM9008 clone cards
  55. //
  56. #define AE2_ADAPTER_ID               0x67b0
  57. #define UB_ADAPTER_ID                0x611f
  58. #define NE2_ADAPTER_ID               0x7154
  59.  
  60. //
  61. // Microchannel IRQ POS register mask and shift count
  62. //
  63. #define MC_IRQ_MASK     0x60
  64. #define MC_IRQ_MASK_UB  0x0E
  65.  
  66.  
  67. //
  68. // Microchannel I/O base address mask and shift count
  69. //
  70. #define MC_IO_BASE_MASK      0x0E
  71. #define MC_IO_BASE_MASK_UB   0xE0
  72.  
  73. //
  74. // Default value for Adapter->IoBaseAddr
  75. //
  76. #define DEFAULT_IOBASEADDR (PVOID)0x300
  77.  
  78. #define CIS_NET_ADDR_OFFSET 0xff0
  79.  
  80. //
  81. // Default value for Adapter->InterruptNumber
  82. //
  83. #define DEFAULT_INTERRUPTNUMBER 3
  84.  
  85.  
  86. //
  87. // Default value for Adapter->MulticastListMax
  88. //
  89. #define DEFAULT_MULTICASTLISTMAX 8
  90.  
  91.  
  92. //
  93. // Offsets from Adapter->IoPAddr of the ports used to access
  94. // the 8390 NIC registers.
  95. //
  96. // The names in parenthesis are the abbreviations by which
  97. // the registers are referred to in the 8390 data sheet.
  98. //
  99. // Some of the offsets appear more than once
  100. // because they have have relevant page 0 and page 1 values,
  101. // or they are different registers when read than they are
  102. // when written. The notation MSB indicates that only the
  103. // MSB can be set for this register, the LSB is assumed 0.
  104. //
  105.  
  106. #define NIC_COMMAND         0x0     // (CR)
  107. #define NIC_PAGE_START      0x1     // (PSTART)   MSB, write-only
  108. #define NIC_PHYS_ADDR       0x1     // (PAR0)     page 1
  109. #define NIC_PAGE_STOP       0x2     // (PSTOP)    MSB, write-only
  110. #define NIC_BOUNDARY        0x3     // (BNRY)     MSB
  111. #define NIC_XMIT_START      0x4     // (TPSR)     MSB, write-only
  112. #define NIC_XMIT_STATUS     0x4     // (TSR)      read-only
  113. #define NIC_XMIT_COUNT_LSB  0x5     // (TBCR0)    write-only
  114. #define NIC_XMIT_COUNT_MSB  0x6     // (TBCR1)    write-only
  115. #define NIC_FIFO            0x6     // (FIFO)     read-only
  116. #define NIC_INTR_STATUS     0x7     // (ISR)
  117. #define NIC_CURRENT         0x7     // (CURR)     page 1
  118. #define NIC_MC_ADDR         0x8     // (MAR0)     page 1
  119. #define NIC_CRDA_LSB        0x8     // (CRDA0)
  120. #define NIC_RMT_ADDR_LSB    0x8     // (RSAR0)
  121. #define NIC_CRDA_MSB        0x9     // (CRDA1)
  122. #define NIC_RMT_ADDR_MSB    0x9     // (RSAR1)
  123. #define NIC_RMT_COUNT_LSB   0xa     // (RBCR0)    write-only
  124. #define NIC_RMT_COUNT_MSB   0xb     // (RBCR1)    write-only
  125. #define NIC_RCV_CONFIG      0xc     // (RCR)      write-only
  126. #define NIC_RCV_STATUS      0xc     // (RSR)      read-only
  127. #define NIC_XMIT_CONFIG     0xd     // (TCR)      write-only
  128. #define NIC_FAE_ERR_CNTR    0xd     // (CNTR0)    read-only
  129. #define NIC_DATA_CONFIG     0xe     // (DCR)      write-only
  130. #define NIC_CRC_ERR_CNTR    0xe     // (CNTR1)    read-only
  131. #define NIC_INTR_MASK       0xf     // (IMR)      write-only
  132. #define NIC_MISSED_CNTR     0xf     // (CNTR2)    read-only
  133. #define NIC_RACK_NIC        0x10    // Byte to read or write
  134. #define NIC_RESET           0x1f    // (RESET)
  135.  
  136.  
  137. //
  138. // Constants for the NIC_COMMAND register.
  139. //
  140. // Start/stop the card, start transmissions, and select
  141. // which page of registers was seen through the ports.
  142. //
  143.  
  144. #define CR_STOP         (UCHAR)0x01        // reset the card
  145. #define CR_START        (UCHAR)0x02        // start the card
  146. #define CR_XMIT         (UCHAR)0x04        // begin transmission
  147. #define CR_NO_DMA       (UCHAR)0x20        // stop remote DMA
  148.  
  149. #define CR_PS0          (UCHAR)0x40        // low bit of page number
  150. #define CR_PS1          (UCHAR)0x80        // high bit of page number
  151. #define CR_PAGE0        (UCHAR)0x00        // select page 0
  152. #define CR_PAGE1        CR_PS0             // select page 1
  153. #define CR_PAGE2        CR_PS1             // select page 2
  154.  
  155. #define CR_DMA_WRITE    (UCHAR)0x10        // Write
  156. #define CR_DMA_READ     (UCHAR)0x08        // Read
  157. #define CR_SEND         (UCHAR)0x18        // send
  158.  
  159.  
  160. //
  161. // Constants for the NIC_XMIT_STATUS register.
  162. //
  163. // Indicate the result of a packet transmission.
  164. //
  165.  
  166. #define TSR_XMIT_OK     (UCHAR)0x01        // transmit with no errors
  167. #define TSR_COLLISION   (UCHAR)0x04        // collided at least once
  168. #define TSR_ABORTED     (UCHAR)0x08        // too many collisions
  169. #define TSR_NO_CARRIER  (UCHAR)0x10        // carrier lost
  170. #define TSR_NO_CDH      (UCHAR)0x40        // no collision detect heartbeat
  171.  
  172.  
  173. //
  174. // Constants for the NIC_INTR_STATUS register.
  175. //
  176. // Indicate the cause of an interrupt.
  177. //
  178.  
  179. #define ISR_EMPTY       (UCHAR)0x00        // no bits set in ISR
  180. #define ISR_RCV         (UCHAR)0x01        // packet received with no errors
  181. #define ISR_XMIT        (UCHAR)0x02        // packet transmitted with no errors
  182. #define ISR_RCV_ERR     (UCHAR)0x04        // error on packet reception
  183. #define ISR_XMIT_ERR    (UCHAR)0x08        // error on packet transmission
  184. #define ISR_OVERFLOW    (UCHAR)0x10        // receive buffer overflow
  185. #define ISR_COUNTER     (UCHAR)0x20        // MSB set on tally counter
  186. #define ISR_DMA_DONE    (UCHAR)0x40        // RDC
  187. #define ISR_RESET       (UCHAR)0x80        // (not an interrupt) card is reset
  188.  
  189.  
  190. //
  191. // Constants for the NIC_RCV_CONFIG register.
  192. //
  193. // Configure what type of packets are received.
  194. //
  195.  
  196. #define RCR_REJECT_ERR  (UCHAR)0x00        // reject error packets
  197. #define RCR_BROADCAST   (UCHAR)0x04        // receive broadcast packets
  198. #define RCR_MULTICAST   (UCHAR)0x08        // receive multicast packets
  199. #define RCR_ALL_PHYS    (UCHAR)0x10        // receive ALL directed packets
  200. #define RCR_MONITOR     (UCHAR)0x20        // don't collect packets
  201.  
  202.  
  203. //
  204. // Constants for the NIC_RCV_STATUS register.
  205. //
  206. // Indicate the status of a received packet.
  207. //
  208. // These are also used to interpret the status byte in the
  209. // packet header of a received packet.
  210. //
  211.  
  212. #define RSR_PACKET_OK   (UCHAR)0x01        // packet received with no errors
  213. #define RSR_CRC_ERROR   (UCHAR)0x02        // packet received with CRC error
  214. #define RSR_MULTICAST   (UCHAR)0x20        // packet received was multicast
  215. #define RSR_DISABLED    (UCHAR)0x40        // received is disabled
  216. #define RSR_DEFERRING   (UCHAR)0x80        // receiver is deferring
  217.  
  218.  
  219. //
  220. // Constants for the NIC_XMIT_CONFIG register.
  221. //
  222. // Configures how packets are transmitted.
  223. //
  224.  
  225. #define TCR_NO_LOOPBACK (UCHAR)0x00        // normal operation
  226. #define TCR_LOOPBACK    (UCHAR)0x02        // loopback (set when NIC is stopped)
  227.  
  228. #define TCR_INHIBIT_CRC (UCHAR)0x01        // inhibit appending of CRC
  229.  
  230. #define TCR_NIC_LBK     (UCHAR)0x02        // loopback through the NIC
  231. #define TCR_SNI_LBK     (UCHAR)0x04        // loopback through the SNI
  232. #define TCR_COAX_LBK    (UCHAR)0x06        // loopback to the coax
  233.  
  234.  
  235. //
  236. // Constants for the NIC_DATA_CONFIG register.
  237. //
  238. // Set data transfer sizes.
  239. //
  240.  
  241. #define DCR_BYTE_WIDE   (UCHAR)0x00        // byte-wide DMA transfers
  242. #define DCR_WORD_WIDE   (UCHAR)0x01        // word-wide DMA transfers
  243.  
  244. #define DCR_LOOPBACK    (UCHAR)0x00        // loopback mode (TCR must be set)
  245. #define DCR_NORMAL      (UCHAR)0x08        // normal operation
  246.  
  247. #define DCR_FIFO_2_BYTE (UCHAR)0x00        // 2-byte FIFO threshhold
  248. #define DCR_FIFO_4_BYTE (UCHAR)0x20        // 4-byte FIFO threshhold
  249. #define DCR_FIFO_8_BYTE (UCHAR)0x40        // 8-byte FIFO threshhold
  250. #define DCR_FIFO_12_BYTE (UCHAR)0x60       // 12-byte FIFO threshhold
  251. #define DCR_AUTO_INIT   (UCHAR)0x10        // Auto-init to remove packets from ring
  252.  
  253.  
  254. //
  255. // Constants for the NIC_INTR_MASK register.
  256. //
  257. // Configure which ISR settings actually cause interrupts.
  258. //
  259.  
  260. #define IMR_RCV         (UCHAR)0x01        // packet received with no errors
  261. #define IMR_XMIT        (UCHAR)0x02        // packet transmitted with no errors
  262. #define IMR_RCV_ERR     (UCHAR)0x04        // error on packet reception
  263. #define IMR_XMIT_ERR    (UCHAR)0x08        // error on packet transmission
  264. #define IMR_OVERFLOW    (UCHAR)0x10        // receive buffer overflow
  265. #define IMR_COUNTER     (UCHAR)0x20        // MSB set on tally counter
  266.  
  267.  
  268. //++
  269. //
  270. // VOID
  271. // CardStart(
  272. //    IN PUM9008_ADAPTER Adapter
  273. //    )
  274. //
  275. //
  276. // Routine Description:
  277. //
  278. //    Starts the card.
  279. //
  280. // Arguments:
  281. //
  282. //    Adapter - pointer to the adapter block
  283. //
  284. // Return Value:
  285. //
  286. //    None.
  287. //
  288. //--
  289.     //
  290.     // Assume that the card has been stopped as in CardStop.
  291.     //
  292.  
  293. #define CardStart(Adapter) \
  294.     NdisRawWritePortUchar(((Adapter->IoPAddr)+NIC_XMIT_CONFIG), TCR_NO_LOOPBACK)
  295.  
  296.  
  297.  
  298. //++
  299. //
  300. // VOID
  301. // CardSetAllMulticast(
  302. //     IN PUM9008_ADAPTER Adapter
  303. //     )
  304. //
  305. // Routine Description:
  306. //
  307. //  Enables every bit in the card multicast bit mask.
  308. //  Calls SyncCardSetAllMulticast.
  309. //
  310. // Arguments:
  311. //
  312. //  Adapter - The adapter block.
  313. //
  314. // Return Value:
  315. //
  316. //  None.
  317. //
  318. //--
  319.  
  320. #define CardSetAllMulticast(Adapter) \
  321.     NdisMSynchronizeWithInterrupt(&(Adapter)->Interrupt, \
  322.                 SyncCardSetAllMulticast, (PVOID)(Adapter))
  323.  
  324.  
  325. //++
  326. //
  327. // VOID
  328. // CardCopyMulticastRegs(
  329. //     IN PUM9008_ADAPTER Adapter
  330. //     )
  331. //
  332. // Routine Description:
  333. //
  334. //  Writes out the entire multicast bit mask to the card from
  335. //  Adapter->NicMulticastRegs.  Calls SyncCardCopyMulticastRegs.
  336. //
  337. // Arguments:
  338. //
  339. //  Adapter - The adapter block.
  340. //
  341. // Return Value:
  342. //
  343. //  None.
  344. //
  345. //--
  346.  
  347. #define CardCopyMulticastRegs(Adapter) \
  348.     NdisMSynchronizeWithInterrupt(&(Adapter)->Interrupt, \
  349.                 SyncCardCopyMulticastRegs, (PVOID)(Adapter))
  350.  
  351.  
  352.  
  353. //++
  354. //
  355. // VOID
  356. // CardGetInterruptStatus(
  357. //     IN PUM9008_ADAPTER Adapter,
  358. //     OUT PUCHAR InterrupStatus
  359. //     )
  360. //
  361. // Routine Description:
  362. //
  363. //  Reads the interrupt status (ISR) register from the card. Only
  364. //  called at IRQL INTERRUPT_LEVEL.
  365. //
  366. // Arguments:
  367. //
  368. //  Adapter - The adapter block.
  369. //
  370. //  InterruptStatus - Returns the value of ISR.
  371. //
  372. // Return Value:
  373. //
  374. //--
  375.  
  376. #define CardGetInterruptStatus(_Adapter,_InterruptStatus) \
  377.     NdisRawReadPortUchar(((_Adapter)->IoPAddr+NIC_INTR_STATUS), (_InterruptStatus))
  378.  
  379.  
  380. //++
  381. //
  382. // VOID
  383. // CardSetReceiveConfig(
  384. //     IN PUM9008_ADAPTER Adapter
  385. //     )
  386. //
  387. // Routine Description:
  388. //
  389. //  Sets the receive configuration (RCR) register on the card.
  390. //  The value used is Adapter->NicReceiveConfig. Calls
  391. //  SyncCardSetReceiveConfig.
  392. //
  393. // Arguments:
  394. //
  395. //  Adapter - The adapter block.
  396. //
  397. // Return Value:
  398. //
  399. //  None.
  400. //
  401. //--
  402.  
  403. #define CardSetReceiveConfig(Adapter) \
  404.     NdisMSynchronizeWithInterrupt(&(Adapter)->Interrupt, \
  405.                 SyncCardSetReceiveConfig, (PVOID)(Adapter))
  406.  
  407.  
  408. //++
  409. //
  410. // VOID
  411. // CardBlockInterrupts(
  412. //     IN PUM9008_ADAPTER Adapter
  413. //     )
  414. //
  415. // Routine Description:
  416. //
  417. //  Blocks all interrupts from the card by clearing the
  418. //  interrupt mask (IMR) register. Only called from
  419. //  IRQL INTERRUPT_LEVEL.
  420. //
  421. // Arguments:
  422. //
  423. //  Adapter - The adapter block.
  424. //
  425. // Return Value:
  426. //
  427. //  None.
  428. //
  429. //--
  430.  
  431. #define CardBlockInterrupts(Adapter) \
  432.     NdisRawWritePortUchar(((Adapter)->IoPAddr+NIC_INTR_MASK), 0)
  433.  
  434.  
  435. //++
  436. //
  437. // VOID
  438. // CardUnblockInterrupts(
  439. //     IN PUM9008_ADAPTER Adapter
  440. //     )
  441. //
  442. // Routine Description:
  443. //
  444. //  Unblocks all interrupts from the card by setting the
  445. //  interrupt mask (IMR) register. Only called from IRQL
  446. //  INTERRUPT_LEVEL.
  447. //
  448. // Arguments:
  449. //
  450. //  Adapter - The adapter block.
  451. //
  452. // Return Value:
  453. //
  454. //  None.
  455. //
  456. //--
  457.  
  458. #define CardUnblockInterrupts(Adapter) \
  459.     NdisRawWritePortUchar(\
  460.             ((Adapter)->IoPAddr+NIC_INTR_MASK), \
  461.             (Adapter)->NicInterruptMask)
  462.  
  463. //++
  464. //
  465. // VOID
  466. // CardAcknowledgeOverflowInterrupt(
  467. //     IN PUM9008_ADAPTER Adapter
  468. //     )
  469. //
  470. // Routine Description:
  471. //
  472. //  Acknowledges an overflow interrupt by setting the bit in
  473. //  the interrupt status (ISR) register. Calls
  474. //  SyncCardAcknowledgeOverflow.
  475. //
  476. // Arguments:
  477. //
  478. //  Adapter - The adapter block.
  479. //
  480. // Return Value:
  481. //
  482. //  None.
  483. //
  484. //--
  485.  
  486. #define CardAcknowledgeOverflowInterrupt(Adapter) \
  487.      SyncCardAcknowledgeOverflow(Adapter)
  488.  
  489.  
  490. //++
  491. //
  492. // VOID
  493. // CardAcknowledgeCounterInterrupt(
  494. //     IN PUM9008_ADAPTER Adapter
  495. //     )
  496. //
  497. // Routine Description:
  498. //
  499. //  Acknowledges a counter interrupt by setting the bit in
  500. //  the interrupt status (ISR) register.
  501. //
  502. // Arguments:
  503. //
  504. //  Adapter - The adapter block.
  505. //
  506. // Return Value:
  507. //
  508. //  None.
  509. //
  510. //--
  511.  
  512. #define CardAcknowledgeCounterInterrupt(Adapter) \
  513.     NdisRawWritePortUchar(((Adapter)->IoPAddr+NIC_INTR_STATUS), ISR_COUNTER)
  514.  
  515. //++
  516. //
  517. // VOID
  518. // CardUpdateCounters(
  519. //     IN PUM9008_ADAPTER Adapter
  520. //     )
  521. //
  522. // Routine Description:
  523. //
  524. //  Updates the values of the three counters (frame alignment
  525. //  errors, CRC errors, and missed packets) by reading in their
  526. //  current values from the card and adding them to the ones
  527. //  stored in the Adapter structure. Calls SyncCardUpdateCounters.
  528. //
  529. // Arguments:
  530. //
  531. //  Adapter - The adapter block.
  532. //
  533. // Return Value:
  534. //
  535. //  None.
  536. //
  537. //--
  538.  
  539. #define CardUpdateCounters(Adapter) \
  540.     NdisMSynchronizeWithInterrupt(&(Adapter)->Interrupt, \
  541.                 SyncCardUpdateCounters, (PVOID)(Adapter))
  542.  
  543.  
  544. #endif // _UM9008HARDWARE_
  545.