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

VxWorks

开发平台:

C/C++

  1. /* if_eex.h - Intel EtherExpress 16 interface header */
  2. /* Copyright 1990-1993 Wind River Systems, Inc. */
  3. /*
  4. modification history
  5. --------------------
  6. 01d,25jan95,hdn  added RB_OFFSET and RB_LINK for the Simpact's patch.
  7. 01c,20feb94,bcs  relabel, recomment extended control register, define AUTODETECT
  8.  and remove old connector type symbols
  9. 01b,04dec93,bcs  made functional, added AL_LOC compile-time option
  10. 01a,28nov93,bcs  created from if_ei.h (rev. 02h,22sep92)
  11. */
  12. #ifndef __INCif_eexh
  13. #define __INCif_eexh
  14. #ifdef __cplusplus
  15. extern "C" {
  16. #endif
  17. #if ((CPU_FAMILY==I960) && (defined __GNUC__))
  18. #pragma align 1                 /* tell gcc960 not to optimize alignments */
  19. #endif  /* CPU_FAMILY==I960 */
  20. /* constants needed within this file */
  21. #define EEX_AL_LOC                      /* define to use header-in-data */
  22.                                         /* feature of 82586 */
  23. #define EA_SIZE         6
  24. #define EH_SIZE         14              /* avoid structure padding issues */
  25. #define N_MCAST         12
  26. /* Size of frame buffers in this driver
  27.  * Made even to simplify structure alignment in code */
  28. #define FRAME_SIZE      ( ( ETHERMTU + EH_SIZE + 1 ) & ~1 )
  29. /* Intel EtherExpress 16 board port and bit definitions */
  30. /* I/O ports relative to board base port address */
  31. /* Word registers unless otherwise noted */
  32. #define DXREG           0x00            /* Data transfer register */
  33. #define WRPTR           0x02            /* Write address pointer */
  34. #define RDPTR           0x04            /* Read address pointer */
  35. #define CA_CTRL         0x06            /* (byte) Channel Attention */
  36. #define SEL_IRQ         0x07            /* (byte) IRQ select and enable */
  37. #define SMB_PTR         0x08            /* Shadow memory bank pointer */
  38. #define MEMDEC          0x0a            /* (byte) Memory address decode */
  39. #define MEMCTRL         0x0b            /* (byte) Memory mapped control */
  40. #define MEMPC           0x0c            /* (byte) MEMCS16 page control */
  41. #define CONFIG          0x0d            /* (byte) Configuration test */
  42. #define EE_CTRL         0x0e            /* (byte) EEPROM control and reset */
  43. #define MEMECTRL        0x0f            /* (byte) Memory control 0xE000 seg*/
  44. #define AUTOID          0x0f            /* (byte) Auto ID register */
  45. #define ECR1            0x300e          /* (byte) extended control: conn.type */
  46.                                         /* only exists on newer boards */
  47. #define SHADOWID        0x300f          /* (byte) board subtype/rev. */
  48. #define SCB_STATUS      0xc008          /* SCB status word */
  49. #define SCB_COMMAND     0xc00a          /* SCB command word */
  50. #define SCB_CBL         0xc00c          /* SCB command block list head */
  51. #define SCB_RFA         0xc00e          /* SCB received frame area */
  52. /* Register bits and bit masks */
  53. #define IRQ_SEL         0x07            /* SEL_IRQ: interrupt line code bits */
  54. #define IRQ_ENB         0x08            /* SEL_IRQ: interrupt enable */
  55. #define EEPROM_CLOCK    0x01            /* EE_CTRL: Shift clock pin */
  56. #define EEPROM_CHIPSEL  0x02            /* EE_CTRL: Chip select for EEPROM */
  57. #define EEPROM_OUTPUT   0x04            /* EE_CTRL: Data out to EEPROM */
  58. #define EEPROM_INPUT    0x08            /* EE_CTRL: Data in from EEPROM */
  59. #define RESET_ASIC      0x40            /* EE_CTRL: Reset board ASIC */
  60. #define RESET_82586     0x80            /* EE_CTRL: Reset pin of 82586 */
  61. /* defined bits in ECR1 port; leave others alone! */
  62. #define CONN_INTEGRITY  0x02            /* bit in ECR1 to enable */
  63.                                         /* link integrity for RJ-45 */
  64. #define CONN_TRANSCEIVER 0x80           /* write-only bit to enable */
  65.                                         /* on-board transceiver power */
  66.                                         /* for BNC or RJ-45 connection */
  67. /* Hyundai serial EEPROM operation codes */
  68. #define EEPROM_OP_READ  0x06            /* 3 bits, read data */
  69. #define EEPROM_OP_WRITE 0x05            /* 3 bits, write data */
  70. #define EEPROM_OP_ERASE 0x07            /* 3 bits, erase data */
  71. #define EEPROM_OP_EWEN  0x13            /* 5 bits, erase/write enable */
  72. #define EEPROM_OP_EWDIS 0x10            /* 5 bits, erase/write enable */
  73. /* EtherExpress 16 EEPROM memory registers */
  74. #define EEX_EEPROM_SETUP        0       /* I/O, IRQ, AUI setup etc. */
  75. #define EEX_EEPROM_MEMPAGE      1       /* mempage bits, base and select bits */
  76. #define EEX_EEPROM_EA_LOW       2       /* low-order 16 bits of Ethernet addr.*/
  77. #define EEX_EEPROM_EA_MID       3       /* middle 16 bits */
  78. #define EEX_EEPROM_EA_HIGH      4       /* high-order 16 bits */
  79. #define EEX_EEPROM_TPE_BIT      5       /* bit 0 sez if TPE in use */
  80. #define EEX_EEPROM_MEMDECODE    6       /* mem decode bits, page 0xe000 bits */
  81. /* Important bits in the EERPOM words */
  82. #define SETUP_BNC               0x1000  /* set for BNC, clear for AUI/TPE */
  83. #define MEMPAGE_AUTODETECT      0x0080  /* set for auto-detect of attachment */
  84. #define TPE_BIT                 0x0001  /* set for TPE, clear for other */
  85. /* data structure to convert memory setup EEPROM words into register bytes */
  86. typedef union mem_setup
  87.     {
  88.     struct
  89.         {
  90.         UINT16  memPage;                /* from EEX_EEPROM_MEMPAGE */
  91.         UINT16  memDecode;              /* from EEX_EEPROM_MEMDECODE */
  92.         } wordView;
  93.     struct
  94.         {
  95.         UINT8   memCtrl;                /* to MEMCTRL register */
  96.         UINT8   memPC;                  /* to MEMPC register */
  97.         UINT8   memDec;                 /* to MEMDEC register */
  98.         UINT8   memECtrl;               /* to MEMECTRL register */
  99.         } byteView;
  100.     } MEM_SETUP;
  101. /* Intel 82586 endian safe link macros and structure definitions */
  102. #define LINK_WR(pLink,value)                                            
  103.         (((pLink)->lsw = (UINT16)((UINT32)(value) & 0x0000ffff)),       
  104.         ((pLink)->msw  = (UINT16)(((UINT32)(value) >> 16) & 0x0000ffff)))
  105. #define LINK_RD(pLink) ((pLink)->lsw | ((pLink)->msw << 16))
  106. #define STAT_RD LINK_RD                 /* statistic read is a link read */
  107. #define STAT_WR LINK_WR                 /* statistic write is a link write */
  108. typedef UINT16 EEX_SHORTLINK;           /* 82586 "offset" field */
  109. typedef struct eex_link                         /* EEX_LINK - endian resolvable link */
  110.     {
  111.     UINT16              lsw;            /* least significant word */
  112.     UINT16              msw;            /* most significant word */
  113.     } EEX_LINK;
  114. typedef struct eex_node                         /* EEX_NODE - common linked list object */
  115.     {
  116.     UINT16                              field1;
  117.     UINT16                              field2;
  118.     EEX_LINK                            lNext;                                          /* link to next node */
  119.     EEX_LINK                            field4;
  120.     UINT16                              field5;
  121.     UINT16                              field6;
  122.     UINT8                               field7 [EH_SIZE];
  123.     char                                field8 [ETHERMTU];
  124.         struct eex_node         *pNext;                                         /* ptr to next node */
  125.     } EEX_NODE;
  126. typedef UINT16 EEX_STAT;        /* EEX_STAT - 82586 error statistic */
  127. /* Intel 82586 structure and bit mask definitions */
  128. /* System Configuration Pointer and bit field defines */
  129. typedef struct scp              /* SCP - System Configuration Pointer */
  130.     {
  131.     UINT16 scpSysbus;                   /* SYSBUS */
  132.     UINT16 scpRsv1;                     /* reserved */
  133.     UINT16 scpRsv2;                     /* reserved */
  134.     EEX_LINK pIscp;                     /* ISCP address */
  135.     } SCP;
  136. /* Intermediate System Configuration Pointer */
  137. typedef struct iscp             /* ISCP - Intermediate System Config. Ptr. */
  138.     {
  139.     volatile UINT16     iscpBusy;       /* i82586 is being initialized */
  140.     EEX_SHORTLINK       offsetScb;      /* SCB offset */
  141.     EEX_LINK            pScb;           /* SCB address */
  142.     } ISCP;
  143. /* System Control Block and bit field defines */
  144. typedef struct scb              /* SCB - System Control Block */
  145.     {
  146.     volatile UINT16     scbStatus;      /* Status Word */
  147.     volatile UINT16     scbCommand;     /* Command Word */
  148.     EEX_SHORTLINK       pCB;            /* command block address */
  149.     EEX_SHORTLINK       pRF;            /* receive frame area address */
  150.     EEX_STAT            crcErr;         /* CRC error count */
  151.     EEX_STAT            allignErr;      /* frames misaligned and CRC err cnt */
  152.     EEX_STAT            noResErr;       /* no resources error count */
  153.     EEX_STAT            ovErr;          /* overrun error count */
  154.     } SCB;
  155. #define SCB_S_RUMASK    0x00f0          /* state mask */
  156. #define SCB_S_RUIDLE    0x0000          /* RU is idle */
  157. #define SCB_S_RUSUSP    0x0010          /* RU is suspended */
  158. #define SCB_S_RUNORSRC  0x0020          /* RU has no resources */
  159. #define SCB_S_RURSV1    0x0030          /* reserved */
  160. #define SCB_S_RUREADY   0x0040          /* RU is ready */
  161. #define SCB_S_CUMASK    0x0f00          /* state mask */
  162. #define SCB_S_CUIDLE    0x0000          /* CU is idle */
  163. #define SCB_S_CUSUSP    0x0100          /* CU is suspended */
  164. #define SCB_S_CUACTIVE  0x0200          /* CU is active */
  165. #define SCB_S_CURSV1    0x0300          /* reserved */
  166. #define SCB_S_CURSV2    0x0400          /* reserved */
  167. #define SCB_S_CURSV3    0x0500          /* reserved */
  168. #define SCB_S_CURSV4    0x0600          /* reserved */
  169. #define SCB_S_CURSV5    0x0700          /* reserved */
  170. #define SCB_S_XMASK     0xf000          /* state mask */
  171. #define SCB_S_RNR       0x1000          /* RU left the ready state */
  172. #define SCB_S_CNA       0x2000          /* CU left the active state */
  173. #define SCB_S_FR        0x4000          /* RU finished receiveing a frame */
  174. #define SCB_S_CX        0x8000          /* CU finished a cmd with I bit set */
  175. #define SCB_C_RUNOP     0x0000          /* NOP */
  176. #define SCB_C_RUSTART   0x0010          /* start reception of frames */
  177. #define SCB_C_RURESUME  0x0020          /* resume reception of frames */
  178. #define SCB_C_RUSUSPEND 0x0030          /* suspend reception of frames */
  179. #define SCB_C_RUABORT   0x0040          /* abort receiver immediately */
  180. #define SCB_C_RURSV1    0x0050          /* reserved */
  181. #define SCB_C_RURSV2    0x0060          /* reserved */
  182. #define SCB_C_RURSV3    0x0070          /* reserved */
  183. #define SCB_C_RESET     0x0080          /* reset chip */
  184. #define SCB_C_CUNOP     0x0000          /* NOP */
  185. #define SCB_C_CUSTART   0x0100          /* start execution */
  186. #define SCB_C_CURESUME  0x0200          /* resume execution */
  187. #define SCB_C_CUSUSPEND 0x0300          /* suspend execution after cur. cmd */
  188. #define SCB_C_CUABORT   0x0400          /* abort current cmd immediately */
  189. #define SCB_C_CURSV1    0x0700          /* reserved */
  190. #define SCB_C_ACK_RNR   0x1000          /* ACK that RU became not ready */
  191. #define SCB_C_ACK_CNA   0x2000          /* ACK that CU bacame not active */
  192. #define SCB_C_ACK_FR    0x4000          /* ACK that RU received a frame */
  193. #define SCB_C_ACK_CX    0x8000          /* ACK that CU completed an action */
  194. /* Action Command Descriptions */
  195. typedef struct ac_iasetup       /* AC_IASETUP - Individual Address Setup */
  196.     {
  197.     UINT8  ciAddress[EA_SIZE];          /* local ethernet address */
  198.     UINT16 ciFill;
  199.     } AC_IASETUP;
  200. typedef struct ac_config        /* AC_CONFIG - i82586 Configure */
  201.     {
  202.     UINT8 byteCount;                    /* byte count */
  203.     UINT8 fifoLimit;                    /* FIFO limit */
  204.     UINT8 srdy_saveBad;                 /* SRD/~ARDY, save bad frames */
  205.     UINT8 addrLen_loopback;             /* address length, loopback */
  206.     UINT8 backoff;                      /* backoff method */
  207.     UINT8 interframe;                   /* interframe spacing */
  208.     UINT8 slotTimeLow;                  /* slot time -low byte */
  209.     UINT8 slotTimeHi_retry;             /* slot time -upper 3 bits, max retry */
  210.     UINT8 promiscuous;                  /* promiscuous mode, other stuff */
  211.     UINT8 carrier_collision;            /* carrier sense, collision detect */
  212.     UINT8 minFrame;                     /* minimum frame length */
  213.     UINT8 notUsed;
  214.     UINT16 ccFill;
  215.     } AC_CONFIG;
  216. typedef struct ac_mcast         /* AC_MCAST - Multicast Setup */
  217.     {
  218.     UINT16 cmMcCount;                   /* the number of bytes in MC list */
  219.     UINT8  cmAddrList[6 * N_MCAST];     /* mulitcast address list */
  220.     } AC_MCAST;
  221. typedef struct ac_tdr           /* AC_TDR - Time Domain Reflectometry */
  222.     {
  223.     UINT16 ctInfo;                      /* time, link OK, tx err, line err */
  224.     UINT16 ctReserve1;                  /* reserved */
  225.     } AC_TDR;
  226. typedef struct ac_dump          /* AC_DUMP - Dump */
  227.     {
  228.     EEX_SHORTLINK bufAddr;              /* address of dump buffer */
  229.     } AC_DUMP;
  230. /* Command Frame Description and defines */
  231. typedef struct cfd              /* CFD - Command Frame Descriptor */
  232.     {
  233.     volatile UINT16     cfdStatus;      /* command status */
  234.     UINT16              cfdCommand;     /* command */
  235.     EEX_SHORTLINK       link;           /* address of next CB */
  236.     union                               /* command dependent section */
  237.         {
  238.         struct ac_iasetup       cfd_iasetup;    /* IA setup */
  239.         struct ac_config        cfd_config;     /* config */
  240.         struct ac_mcast         cfd_mcast;      /* multicast setup */
  241.         struct ac_tdr           cfd_tdr;        /* TDR */
  242.         struct ac_dump          cfd_dump;       /* dump */
  243.         } cfd_cmd;
  244.     } CFD;
  245. #define cfdIASetup      cfd_cmd.cfd_iasetup
  246. #define cfdConfig       cfd_cmd.cfd_config
  247. #define cfdMcast        cfd_cmd.cfd_mcast
  248. #define cfdTransmit     cfd_cmd.cfd_transmit
  249. #define cfdTDR          cfd_cmd.cfd_tdr
  250. #define cfdDump         cfd_cmd.cfd_dump
  251. #define CFD_C_NOP       0x0000          /* No Operation */
  252. #define CFD_C_IASETUP   0x0001          /* Individual Address Setup */
  253. #define CFD_C_CONFIG    0x0002          /* Configure Chip */
  254. #define CFD_C_MASETUP   0x0003          /* Multicast Setup */
  255. #define CFD_C_XMIT      0x0004          /* Transmit (see below too ...) */
  256. #define CFD_C_TDR       0x0005          /* Time Domain Reflectometry */
  257. #define CFD_C_DUMP      0x0006          /* Dump Registers */
  258. #define CFD_C_DIAG      0x0007          /* Diagnose */
  259. #define CFD_C_INT       0x2000          /* 586 interrupts CPU after execution */
  260. #define CFD_C_SE        0x4000          /* CU should suspend after execution */
  261. #define CFD_C_EL        0x8000          /* End of command list */
  262. #define CFD_S_ABORTED   0x1000          /* Command was aborted via CU Abort */
  263. #define CFD_S_OK        0x2000          /* Command completed successfully */
  264. #define CFD_S_BUSY      0x4000          /* CU is executing this command */
  265. #define CFD_S_COMPLETE  0x8000          /* Command complete */
  266. /* 82586 Transmit/Receive Frames */
  267. typedef struct tfd              /* TFD - Transmit Frame Descriptor */
  268.     {
  269.     volatile UINT16     status;                 /* status field */
  270.     UINT16              command;                /* command field */
  271.     EEX_SHORTLINK       lNext;                  /* link to next desc. */
  272.     EEX_SHORTLINK       lBufDesc;               /* link to buf desc. */
  273.     } TFD;
  274. /* special TFD specific command block bit masks */
  275. #define CFD_S_COLL_MASK 0x000f          /* to access number of collisions */
  276. #define CFD_S_RETRY     0x0020          /* reached the max number of retries */
  277. #define CFD_S_HBEAT     0x0040          /* Heartbeat Indicator */
  278. #define CFD_S_TRDEF     0x0080          /* Transmission Deferred */
  279. #define CFD_S_DMA_UNDR  0x0100          /* DMA Underrun (no data) */
  280. #define CFD_S_NO_CTS    0x0200          /* Lost Clear To Send signal */
  281. #define CFD_S_NO_CRS    0x0400          /* No Carrier Sense */
  282. typedef struct tbd              /* TBD - Transmit Buffer Descriptor */
  283.     {
  284.     volatile UINT16     actCount;       /* Actual byte count */
  285.     EEX_SHORTLINK       lNext;          /* Address of next buffer descr. */
  286.     EEX_LINK            lBufAddr;       /* Address of this data buffer */
  287.     } TBD;
  288. /* TBD bits */
  289. #define ACT_COUNT_MASK  ~0xc000         /* length fields are 14 bits */
  290. #define TBD_S_EOF       0x8000          /* End-of-frame bit */
  291. #ifdef  EEX_AL_LOC
  292. typedef struct tframe           /* TFRAME - all-in-one transmit frame */
  293.     {
  294.     TFD                 tfd;
  295.     TBD                 tbd;
  296.     char                buffer [FRAME_SIZE];
  297.     } TFRAME;
  298. #else
  299. typedef struct tframe           /* TFRAME - all-in-one transmit frame */
  300.     {
  301.     TFD                 tfd;
  302.     union
  303.         {
  304.         struct
  305.             {
  306.             char                header [EH_SIZE];
  307.             char                data [ETHERMTU];
  308.             } buff_struct;
  309.         char                buffer [FRAME_SIZE];
  310.         } buff_union;
  311.     TBD                 tbd;
  312.     } TFRAME;
  313. #endif  /* EEX_AL_LOC */
  314. typedef struct rfd              /* RFD - Receive Frame Descriptor */
  315.     {
  316.     volatile UINT16     status;                 /* status field */
  317.     UINT16              command;                /* command field */
  318.     EEX_SHORTLINK       lNext;                  /* link to next desc. */
  319.     EEX_SHORTLINK       lBufDesc;               /* link to buf desc. */
  320.     } RFD;
  321. /* RFD bit masks */
  322. #define RFD_S_EOP       0x0040          /* no EOP flag */
  323. #define RFD_S_SHORT     0x0080          /* fewer bytes than configured min. */
  324. #define RFD_S_DMA       0x0100          /* DMA Overrun failure to get bus */
  325. #define RFD_S_RSRC      0x0200          /* received, but ran out of buffers */
  326. #define RFD_S_ALGN      0x0400          /* received misaligned with CRC error */
  327. #define RFD_S_CRC       0x0800          /* received with CRC error */
  328. #define RFD_S_OK        0x2000          /* frame received successfully */
  329. #define RFD_S_BUSY      0x4000          /* frame reception ready/in progress */
  330. #define RFD_S_COMPLETE  0x8000          /* frame reception complete */
  331. #define RFD_M_SUSPEND   0x4000          /* suspend RU after receiving frame */
  332. #define RFD_M_EL        0x8000          /* end of RFD list */
  333. typedef struct rbd              /* RBD - Receive Buffer Descriptor */
  334.     {
  335.     volatile UINT16     actCount;       /* Actual byte count */
  336.     EEX_SHORTLINK       lNext;          /* Address of next buffer descr. */
  337.     EEX_LINK            lBufAddr;       /* Address of this data buffer */
  338.     UINT16              bufSize;        /* Size of data buffer */
  339.     } RBD;
  340. #define RBD_S_CNT_MASK  0x3fff          /* Mask for actual byte count */
  341. #define RBD_S_F_BIT     0x4000          /* actual count is valid */
  342. #define RBD_S_EOF       0x8000          /* end of frame */
  343. #define RBD_M_EL        0x8000          /* end of RBD list */
  344. #ifdef  EEX_AL_LOC
  345. typedef struct rframe           /* RFRAME - all-in-one received frame */
  346.     {
  347.     RFD                 rfd;
  348.     RBD                 rbd;
  349.     char                buffer [FRAME_SIZE];
  350.     } RFRAME;
  351. #else
  352. typedef struct rframe           /* RFRAME - all-in-one received frame */
  353.     {
  354.     RFD                 rfd;
  355.     union
  356.         {
  357.         struct
  358.             {
  359.             char                header [EH_SIZE];
  360.             char                data [ETHERMTU];
  361.             } buff_struct;
  362.         char                buffer [FRAME_SIZE];
  363.         } buff_union;
  364.     RBD                 rbd;
  365.     } RFRAME;
  366. #endif  /* EEX_AL_LOC */
  367. /* Offsets into xFRAME structures to compute board emmory offsets */
  368. #define RF_COMMAND      2               /* command word */
  369. #define RF_LINK         4               /* link to next RFD */
  370. #define RB_OFFSET       6               /* dhe 10/24/94 offset of first RBD */
  371. #define RB_LINK         2               /* dhe 10/24/94 link to next RBD */
  372. #ifdef  EEX_AL_LOC
  373. #define RF_ACT_COUNT    8               /* actual count in RBD */
  374. #define RF_BUFFER       18              /* frame data buffer */
  375. #else
  376. #define RF_BUFFER       8               /* frame data buffer */
  377. #define RF_ACT_COUNT    (RF_BUFFER + FRAME_SIZE)
  378. #endif  /* EEX_AL_LOC */
  379. #define TF_COMMAND      2               /* command word */
  380. #define TF_LINK         4               /* link to next TFD */
  381. #ifdef  EEX_AL_LOC
  382. #define TF_ACT_COUNT    8               /* actual count in TBD */
  383. #define TF_BUFFER       16              /* frame data buffer */
  384. #else
  385. #define TF_BUFFER       8               /* frame header starts here */
  386. #define TF_OLDLENGTH    20              /* Take length from here */
  387. #define TF_NEWLENGTH    14              /* put it here to be part of TFD */
  388. #define TF_ACT_COUNT    (RF_BUFFER + FRAME_SIZE)
  389. #endif  /* EEX_AL_LOC */
  390. #if ((CPU_FAMILY==I960) && (defined __GNUC__))
  391. #pragma align 0                 /* turn off alignment requirement */
  392. #endif  /* CPU_FAMILY==I960 */
  393. #ifdef __cplusplus
  394. }
  395. #endif
  396. #endif /* __INCif_eexh */