home *** CD-ROM | disk | FTP | other *** search
/ Openstep 4.2 (Developer) / Openstep Developer 4.2.iso / NextDeveloper / Examples / DriverKit / SMC16 / SMC16_reloc.tproj / wd83C690.h < prev   
Encoding:
Text File  |  1997-03-29  |  5.8 KB  |  297 lines

  1. /*
  2.  * Copyright (c) 1992-1996 NeXT Software, Inc.
  3.  *
  4.  * WD83C690 Network Interface Chip.
  5.  *
  6.  * HISTORY
  7.  *
  8.  * 25 July 1992 
  9.  *    Created.
  10.  */
  11.  
  12. #import "SMC16Hdw.h"
  13.  
  14. #define NIC_PAGE_SIZE    256
  15.  
  16. /*
  17.  * NIC access inlines
  18.  */
  19.  
  20. static __inline__
  21. vm_offset_t
  22. nic_page_addr(SMC16_off_t page, vm_offset_t base)
  23. {
  24.     return (vm_offset_t)(base + (page * NIC_PAGE_SIZE));
  25. }
  26.  
  27. static __inline__
  28. vm_offset_t
  29. nic_page_round(SMC16_off_t addr)
  30. {
  31.     return  (vm_offset_t)(((vm_offset_t)(addr) + NIC_PAGE_SIZE - 1) & 
  32.         ~(NIC_PAGE_SIZE - 1));
  33. }
  34.  
  35.  
  36.  
  37. /*
  38.  * Register definitions
  39.  */
  40.  
  41. /*
  42.  * Command register.
  43.  */
  44.  
  45. #define NIC_CMD_REG_OFF        0x00
  46.  
  47. typedef struct {
  48.     unsigned char    stp    :1,    /* stop device */
  49.             sta    :1,    /* start device */
  50.             txp    :1,    /* begin packet xmt */
  51.                 :3,
  52.             psel    :2;    /* register page select */
  53. } nic_cmd_reg_t;
  54.  
  55. /*
  56.  * Interrupt status register.
  57.  */
  58.  
  59. #define NIC_ISTAT_REG_OFF    0x07
  60. #define NIC_ISTAT_REG_R_PG    0x00    
  61. #define NIC_ISTAT_REG_W_PG    0x00    
  62.  
  63. typedef struct {
  64.     unsigned char    prx    :1,    /* packet recvd */
  65.             ptx    :1,    /* packet xmtd */
  66.             rxe    :1,    /* packet recvd w/error */
  67.             txe    :1,    /* packet xmt error */
  68.             ovw    :1,    /* recv ring overwrite warning */
  69.             cnt    :1,    /* counter overflow warning */
  70.                 :1,
  71.             rst    :1;    /* device stopped */
  72. } nic_istat_reg_t;
  73.  
  74. /*
  75.  * Interrupt mask register.
  76.  */
  77.  
  78. #define NIC_IMASK_REG_OFF    0x0f
  79. #define NIC_IMASK_REG_R_PG    0x02
  80. #define NIC_IMASK_REG_W_PG    0x00
  81.  
  82. typedef struct {
  83.     unsigned char    prxe    :1,    /* packet recvd enable */
  84.             ptxe    :1,    /* packet xmtd enable */
  85.             rxee    :1,    /* packet recvd w/error enable */
  86.             txee    :1,    /* packet xmt error enable */
  87.             ovwe    :1,    /* recv ring overwrite warning enb */
  88.             cnte    :1,    /* counter overflow waring enable */
  89.                 :2;
  90. } nic_imask_reg_t;
  91.  
  92. /*
  93.  * Receive status register.
  94.  */
  95.  
  96. #define NIC_RSTAT_REG_OFF    0x0C
  97. #define NIC_RSTAT_REG_R_PG    0x00
  98.  
  99. typedef struct {
  100.     unsigned char    prx    :1,    /* packet recvd w/o error */
  101.                 crc    :1,    /* packet recvd w/crc error */
  102.             fae    :1,    /* packet recvd w/framing error */
  103.             over    :1,    /* recv fifo overflow */
  104.             mpa    :1,    /* missed packet occurred */
  105.             group    :1,    /* packet recvd is bcast or mcast */
  106.             dis    :1,    /* receiver is in mon mode */
  107.             dfr    :1;    /* jabber condition on wire */
  108. } nic_rstat_reg_t;
  109.  
  110. /*
  111.  * Transmit status register.
  112.  */
  113.  
  114. #define NIC_TSTAT_REG_OFF    0x04
  115. #define NIC_TSTAT_REG_R_PG    0x00
  116.  
  117. typedef struct {
  118.     unsigned char    ptx    :1,    /* packet xmtd on wire */
  119.             ndt    :1,    /* packet xmtd w/o initial deferment */
  120.             twc    :1,    /* xmtd with collisions */
  121.             abort    :1,    /* not xmtd due to excess. coll. */
  122.             crl    :1,    /* packet xmtd but carrier was lost */
  123.             under    :1,    /* xmt fifo underrun */
  124.             cdh    :1,    /* heartbeat detected */
  125.             owc    :1;    /* out of win. collision occurred */
  126. } nic_tstat_reg_t;
  127.  
  128. /*
  129.  * 83690 features register
  130.  */
  131.  
  132. #define NIC_ENH_REG_OFF        0x27
  133. #define NIC_ENH_REG_R_PG    0x02
  134. #define NIC_ENH_REG_W_PG    0x02
  135.  
  136. typedef struct {
  137.     unsigned char        :3,    
  138.             slot    :2,    /* slot time */
  139. #define NIC_SLOT_512_BIT    0
  140. #define NIC_SLOT_256_BIT    2
  141. #define NIC_SLOT_1024_BIT    3
  142.                 :1,    
  143.             wait    :2;    /* wait states inserted into DMA */
  144. } nic_enh_reg_t;
  145.  
  146.  
  147. /*
  148.  * Memory block register
  149.  */
  150.  
  151. #define NIC_BLOCK_REG_OFF    0x06
  152. #define NIC_BLOCK_REG_R_PG    0x02
  153. #define NIC_BLOCK_REG_W_PG    0x02
  154.  
  155. /*
  156.  * Receive boundary page register.
  157.  */
  158.  
  159. #define NIC_BOUND_REG_OFF    0x03
  160. #define NIC_BOUND_REG_R_PG    0x00
  161. #define NIC_BOUND_REG_W_PG    0x00
  162.  
  163. /*
  164.  * Receive current page register.
  165.  */
  166.  
  167. #define NIC_CURR_REG_OFF    0x07
  168. #define NIC_CURR_REG_R_PG    0x01
  169. #define NIC_CURR_REG_W_PG    0x01
  170.  
  171. /*
  172.  * Receive ring start page register.
  173.  */
  174.  
  175. #define NIC_RSTART_REG_OFF    0x01
  176. #define NIC_RSTART_REG_R_PG    0x02
  177. #define NIC_RSTART_REG_W_PG    0x00
  178.  
  179. /*
  180.  * Receive ring stop page register.
  181.  */
  182.  
  183. #define NIC_RSTOP_REG_OFF    0x02
  184. #define NIC_RSTOP_REG_R_PG    0x02
  185. #define NIC_RSTOP_REG_W_PG    0x00
  186.  
  187. /*
  188.  * Transmit start page register.
  189.  */
  190.  
  191. #define NIC_TSTART_REG_OFF    0x04
  192. #define NIC_TSTART_REG_R_PG    0x02
  193. #define NIC_TSTART_REG_W_PG    0x00
  194.  
  195. /*
  196.  * Transmit count registers.
  197.  */
  198.  
  199. #define NIC_TCNTL_REG_OFF    0x05
  200. #define NIC_TCNTH_REG_OFF    0x06
  201. #define NIC_TCNT_REG_W_PG    0x00
  202.  
  203. /*
  204.  * Station address registers.
  205.  */
  206.  
  207. #define NIC_STA_REG_OFF        0x01
  208. #define NIC_STA_REG_R_PG    0x01
  209. #define NIC_STA_REG_W_PG    0x01
  210.  
  211. /*
  212.  * Receive configuration register.
  213.  */
  214.  
  215. #define NIC_RCON_REG_OFF    0x0c
  216. #define NIC_RCON_REG_R_PG    0x02
  217. #define NIC_RCON_REG_W_PG    0x00
  218.  
  219. typedef struct {
  220.     unsigned char    sep    :1,    /* save error packets */
  221.             runts    :1,    /* save runt packets */
  222.             broad    :1,    /* receive broadcast packets */
  223.             group    :1,    /* receive *all* multicast packets */
  224.             prom    :1,    /* receive all packets */
  225.             mon    :1,    /* monitor network */
  226.                 :2;
  227. } nic_rcon_reg_t;
  228.  
  229. /*
  230.  * Transmit configuration register.
  231.  */
  232.  
  233. #define NIC_TCON_REG_OFF    0x0d
  234. #define NIC_TCON_REG_R_PG    0x02
  235. #define NIC_TCON_REG_W_PG    0x00
  236.  
  237. typedef struct {
  238.     unsigned char    crcn    :1,    /* no CRC generation */
  239.             lb    :2,    /* loopback mode */
  240. #define NIC_XMT_LOOPB_NONE    0
  241. #define NIC_XMT_LOOPB_INTER    1
  242. #define NIC_XMT_LOOPB_EXTER_HI    2
  243. #define NIC_XMT_LOOPB_EXTER_LO    3
  244.                 :5;
  245. } nic_tcon_reg_t;
  246.  
  247. /*
  248.  * Data configuration register.
  249.  */
  250.  
  251. #define NIC_DCON_REG_OFF    0x0e
  252. #define NIC_DCON_REG_R_PG    0x02
  253. #define NIC_DCON_REG_W_PG    0x00
  254.  
  255. typedef struct {
  256.     unsigned char    bus16    :1,    /* 16 bit DMA transfers */
  257.                 :4,
  258.             bsize    :2,    /* DMA burst length */
  259. #define NIC_DMA_BURST_2b    0
  260. #define NIC_DMA_BURST_4b    1
  261. #define NIC_DMA_BURST_8b    2
  262. #define NIC_DMA_BURST_12b    3
  263.                 :1;
  264. } nic_dcon_reg_t;
  265.  
  266. /*
  267.  * Counter registers.
  268.  */
  269.  
  270. /* Receive alignment errors */
  271. #define NIC_ALICNT_REG_OFF    0x0d
  272. #define NIC_ALICNT_REG_R_PG    0x00
  273.  
  274. /* Transmit collisions (last transmit) */
  275. #define NIC_COLCNT_REG_OFF    0x05
  276. #define NIC_COLCNT_REG_R_PG    0x00
  277.  
  278. /* Receive CRC errors */
  279. #define NIC_CRCCNT_REG_OFF    0x0e
  280. #define NIC_CRCCNT_REG_R_PG    0x00
  281.  
  282. /* Missed receive packets */
  283. #define NIC_MPCNT_REG_OFF    0x0f
  284. #define NIC_MPCNT_REG_R_PG    0x00
  285.  
  286. /*
  287.  * Receive packet buffer header.
  288.  */
  289.  
  290. typedef struct {
  291.     nic_rstat_reg_t    rstat;
  292.     unsigned char    next;
  293.     unsigned short    len;
  294.     unsigned char    data[0];
  295. } nic_recv_hdr_t;
  296.  
  297.