if_vlan.h
上传用户:luoyougen
上传日期:2008-05-12
资源大小:23136k
文件大小:7k
源码类别:

VxWorks

开发平台:

C/C++

  1. /* if_vlan.h - VLAN ethernet board transparent mode library */
  2.  
  3. /* Copyright 1990-1994, PEP Modular Computers */
  4. /* Copyright 1984-1994, Wind River Systems, Inc. */
  5. /*
  6. modification history
  7. --------------------
  8. 01e,07jan19,haw  removed include of copyright, fixed spacing, indentation
  9. 01d,14apr93,haw  renamed to if_vlan.h (used to be vlanLib.h),
  10.                  moved it to this directory, copyied definition of 
  11.                  VLAN structure to this file, moved all includes to the driver
  12. 01c,02jul92,haw  added definition of TM_V104, added version in COMMON_WS
  13. 01b,04feb92,haw  changed LAN_MAX_SIZE from 1512 to 1514
  14. 01a,18dec91,haw  modified from EMOD version to transparent mode
  15. */
  16.  
  17. #ifndef __INCif_vlanh
  18. #define __INCif_vlanh
  19. #ifdef __cplusplus
  20. extern "C" {
  21. #endif /* __cplusplus */
  22. #define VLAN_VERSION
  23. #define TM_V104         0x104
  24. #define EADDRS          6
  25. #define GOTTRAILERTYPE  0
  26. #define GOTTYPE         1
  27. #define GOTNOTYPE       2
  28.  
  29. /* VLAN address offsets and constants */
  30. #define VLAN_START_ADDR         0xFFFC
  31. #define VLAN_ID_ADDR            0xFFFA
  32. #define VLAN_SOFT_START_ADDR1   0xFF04  /* see VLAN firmware by MAT */
  33. #define VLAN_SOFT_START_ADDR2   0xFF00
  34. #define VLAN_FIRM_ADDR          0x00007026
  35. #define VLAN_FIRM_CODE          1789
  36. /* AMD 7990 ETHERNET CONTROLLER (LANCE) EQUATES */
  37. #define LAN_MIN_SIZE    60
  38. #define LAN_MAX_SIZE    1514
  39. /* CSR0 EQUATES */
  40. #define CSR0_ERR        0x8000           
  41. #define CSR0_BABL       0x4000           
  42. #define CSR0_CERR       0x2000           
  43. #define CSR0_MISS       0x1000           
  44. #define CSR0_MERR       0x0800           
  45. #define CSR0_RINT       0x0400           
  46. #define CSR0_TINT       0x0200           
  47. #define CSR0_IDON       0x0100           
  48. #define CSR0_INTR       0x0080           
  49. #define CSR0_INEA       0x0040           
  50. #define CSR0_RXON       0x0020           
  51. #define CSR0_TXON       0x0010           
  52. #define CSR0_TDMD       0x0008           
  53. #define CSR0_STOP       0x0004           
  54. #define CSR0_STRT       0x0002           
  55. #define CSR0_INIT       0x0001           
  56. /* Lance init block definition */
  57. typedef struct
  58.     {
  59.     UINT16  mode;
  60. #define PROM    0x8000
  61.     UINT16  ether_15;
  62.     UINT16  ether_31;
  63.     UINT16  ether_47;
  64.     UINT16  filter_15;
  65.     UINT16  filter_31;
  66.     UINT16  filter_47;
  67.     UINT16  filter_63;
  68.     UINT16  rdra_15;
  69.     UINT8   rlen;
  70.     UINT8   rdra_23;
  71.     UINT16  tdra_15;
  72.     UINT8   tlen;
  73.     UINT8   tdra_23;
  74.     } INIT_BLOCK;
  75. /* Receiver ring descriptor definition */
  76. typedef struct
  77.     {
  78.     UINT16  addr_15;
  79.     UINT8   mode;
  80.     UINT8   addr_23;
  81.     UINT16  bcnt;
  82.     UINT16  mcnt;
  83.     } RECV_DESC;
  84. /* Receiver mode definitions */
  85. #define RRD_OWN        0x80           
  86. #define RRD_ERR        0x40           
  87. #define RRD_FRAM       0x20           
  88. #define RRD_OFLO       0x10           
  89. #define RRD_CRC        0x08           
  90. #define RRD_BUFF       0x04           
  91. #define RRD_STP        0x02           
  92. #define RRD_ENP        0x01           
  93. /* Transmitter ring descriptor definition */
  94. typedef struct
  95.     {
  96.     UINT16  addr_15;    /* bits 15:00 of transmit buffer */
  97.     UINT8   mode;       /* mode */
  98.     UINT8   addr_23;    /* bits 23:16 of transmit buffer */
  99.     UINT16  bcnt;       /* message byte count */
  100.     UINT16  tdra_6;     /* errors */
  101.     } TRAN_DESC;
  102. /* Transmitter mode definitions */
  103. #define TRD_OWN        0x80           
  104. #define TRD_ERR        0x40           
  105. #define TRD_MORE       0x10           
  106. #define TRD_ONE        0x08           
  107. #define TRD_DEF        0x04           
  108. #define TRD_STP        0x02           
  109. #define TRD_ENP        0x01           
  110. /* Transmit tdra_6 definitions */
  111. #define TRD_BUFF       0x8000           
  112. #define TRD_UFLO       0x4000           
  113. #define TRD_LCOL       0x1000           
  114. #define TRD_LCAR       0x0800           
  115. #define TRD_RTRY       0x0400           
  116. /* Communication Workspace used by the driver */
  117. #define SEND          8     /* number of send buffers */
  118. #define RECV         16     /* number of recv buffers */
  119. #define RECV_SIZE 0x600     /* size of buffers (recv/send) */
  120. /* this struct must be located in VLAN VME ram at first address */
  121. typedef struct
  122.     {
  123.     volatile UINT16 readCSR0;
  124.                             /* = LANCE csr0 after a read request */
  125.     volatile INT16 reqReadCSR0;
  126.                             /* when set to 1 VLAN cpu copies LANCE csr0 */
  127.                             /* to csr0_read and clears req_csr0_read */
  128.     volatile UINT16 writeCSR0;       
  129.                             /* VLAN cpu copies this value to LANCE csr0 */
  130.                             /* when req_csr0_write == 1 and clears req */
  131.     volatile INT16 reqWriteCSR0;
  132.     volatile UINT16 reqClearIRQ;
  133.                             /* set to 1 -> VLAN cpu allowed to give */
  134.                             /* other VME irq (after setting req to 0*/
  135.     UINT8 intLevel;         /* vme irq level to be used by VLAN */
  136.     UINT8 intVector;        /* vme irq vector to be used by VLAN */
  137.     char *vlanBaseVME;      /* address of VLAN VME mem seen by vm20 */
  138.     UINT8 ether_addr_1;     /* addr specific for VLAN board */
  139.     UINT8 ether_addr_2; 
  140.     UINT8 ether_addr_3; 
  141.     UINT8 ether_addr_4; 
  142.     UINT8 ether_addr_5; 
  143.     UINT8 ether_addr_6; 
  144.     INT16 version;
  145.     INT16 res [3];
  146.     INT32 copyFlag;         /* flag for send function: */
  147.                             /* 0 - do not copy, lance can access local data */
  148.                             /* 1 - copy the data */
  149.     RECV_DESC *ringRxFst,   /* pointer to start recv ring */
  150.               *ringRxLst,   /* pointer to last recv ring */
  151.               *ringRxNxt;   /* pointer to current recv ring */
  152.     TRAN_DESC *ringTxFst,   /* pointer to start send ring */
  153.               *ringTxLst,   /* pointer to last send ring */
  154.               *ringTxNxt;   /* pointer to current send ring */
  155.     INT32 r_lock, t_lock;   /* recv/send function locks */
  156.     INIT_BLOCK initBlock;
  157.                             /* this area is used to initialize the */
  158.                             /* lance chip. */
  159.     char descRx [1040],     /* reserved for recv ring, its size */
  160.                             /* must be = 4*rblk_count + 8 */
  161.          descTx [1040];     /* reserved for send ring, its size */
  162.                             /* must be = 4*tblk_count + 8 */
  163.     char recvBuf [RECV_SIZE*RECV];
  164.                             /* reserved for receive data by lance */
  165.     char sendBuf [RECV_SIZE*SEND];
  166.                             /* reserved for send data by lance */
  167.     } COMMON_WS; 
  168. typedef struct
  169.     {
  170.     struct  arpcom vs_ac;       /* common ethernet structures */
  171.     int vlanIntLevel;           /* vme interrupt level */
  172.     int vlanIntVec;             /* vme interrupt vector */
  173.     BOOL taskLevelActive;       /* netTask is currently processing packets */
  174.     COMMON_WS *comWoSp;         /* pointer to VLAN RAM base */
  175.     SEM_ID transmitSem;         /* semaphore to lock transmission */
  176.     } VLAN_SOFTC;
  177. #define vs_if           vs_ac.ac_if     /* network-visible interface */
  178. #define vs_enaddr       vs_ac.ac_enaddr /* hardware ethernet address */
  179. /*
  180.  * the structure arpcom looks in detail this way:
  181.  *  struct ifnet ac_if;         ( struct ifnet )
  182.  *  UINT8 ac_enaddr [6];        ( ethernet hardware address )
  183.  *  UINT32 ac_ipaddr.s_addr;    ( copy of ip address )
  184.  */
  185. #ifdef __cplusplus
  186. }
  187. #endif /* __cplusplus */
  188. #endif /* __INCif_vlanh */