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

VxWorks

开发平台:

C/C++

  1. /* iOlicomEnd.h - END-style Intel Olicom PCMCIA Ethernet interface header */
  2. /* Copyright 1997-2001 Wind River Systems, Inc. */
  3. /*
  4. modification history
  5. --------------------
  6. 01g,20sep01,dat  Removing ANSI errors for diab compiler
  7. 01f,03aug00,jpd  corrected length of drive name string (SPR #32276).
  8. 01e,11jun00,ham  removed reference to etherLib.
  9. 01d,02sep98,jpd  renamed struct type name to prevent conflict. Improved
  10.  data copying macros efficiency. Add big-endian support.
  11. 01c,02apr98,jpd  made conditionally-compilable version for Brutus and PID.
  12. 01b,16feb98.jpd  modified to work on Brutus, but not yet on both Brutus and PID.
  13. 01a,16dec97,rlp  copied from if_oli.h
  14. */
  15. #ifndef __INCiOlicomEndh
  16. #define __INCiOlicomEndh
  17. #ifdef __cplusplus
  18. extern "C" {
  19. #endif
  20. #include "end.h"
  21. #include "netBufLib.h"
  22. #include "netinet/if_ether.h"
  23. /* Define Constants */
  24. #define PC_SOCKET_A             0x00
  25. #define PC_SOCKET_B             0x40
  26. #define ATTRIBUTE_MEMORY_SLOT   0x01000
  27. #ifndef TARGET_HAS_NO_VADEM
  28. #define PC_INDEX        ((volatile char *)(ctrlBase + 0x00))
  29. #define PC_DATA_READ    ((volatile int *) (ctrlBase + 0x01))
  30. #define PC_DATA_WRITE   ((volatile char *)(ctrlBase + 0x01))
  31. #define MAPPED_MEMORY_BASE      0x10000         /* 64K */
  32. #define ATTRIB_MEMORY_A         MAPPED_MEMORY_BASE
  33. #define ATTRIB_MEMORY_B         ATTRIB_MEMORY_A + ATTRIBUTE_MEMORY_SLOT
  34. #endif /* TARGET_HAS_NO_VADEM */
  35. /*
  36.  * Define to have complete control over the PCMCIA system.
  37.  * These definitions are Access macro, I/O Registers, Control Registers,
  38.  * PCMCIA Structures and Constants.
  39.  */
  40. /* Macro definition for PCMCIA Access */
  41. #ifndef I82595_REGS_CONTIGUOUS
  42. #define PCMCIA_CALC_ADDR(x)     (((((UINT)(x)) & ~0x01) << 1) | 
  43.   (((UINT)(x)) & 0x01))
  44. #define PCMCIA_READ_RAW(x, y)   (*(volatile UINT *) (PCMCIA_CALC_ADDR(x) | (y)))
  45. #define PCMCIA_WRITE_RAW(x, y, z)       (*(volatile UINT8 *)    
  46.                                         (PCMCIA_CALC_ADDR(x) | (y)) = (z))
  47. #define PCMCIA_IO_WRITE(x, y)   ((*(volatile UINT8 *)(x)) = (y))
  48. #define PCMCIA_IO_READ(x)       (((((UINT)(x)) & 0x01) == 0) ?             
  49.                                 (*(volatile UINT *)(x)) & OCT_MSK: 
  50.                                 (*(volatile UINT *)(x)) >> 24)
  51. #define PCMCIA_ATTR_READ(x) (((((UINT)(x)) & ODD_MSK) == 0) ?  
  52.                 PCMCIA_READ_RAW(x, (int)pDrvCtrl->pcmcia.memBaseA) & OCT_MSK :
  53.                 PCMCIA_READ_RAW(x, (int)pDrvCtrl->pcmcia.memBaseA) >> 24)
  54. #define PCMCIA_ATTR_WRITE(x, y)  PCMCIA_WRITE_RAW((x), (int)       
  55.                                         pDrvCtrl->pcmcia.memBaseA, (y))
  56. /* On PID, two apparently consecutive registers cannot be read at once */
  57. #define READ_R14_R15(val) 
  58.     { 
  59.     val =  PCMCIA_IO_READ (pDrvCtrl->pcmcia.oliAddr + I595_R14); 
  60.     val |= (PCMCIA_IO_READ (pDrvCtrl->pcmcia.oliAddr + I595_R15) << 8); 
  61.     }
  62. #if (_BYTE_ORDER == _BIG_ENDIAN)
  63. #define READ_PTR_R14_R15(ptr, pR14) 
  64.     { 
  65.     *(ptr)++ = (0xFF & *((volatile UINT32 *)(pR14))); 
  66.     *(ptr)++ = (*((UINT32 *)((pR14) + 1)) >> 24); 
  67.     }
  68. #else /* (_BYTE_ORDER == _BIG_ENDIAN) */
  69. #define READ_PTR_R14_R15(ptr, pR14) 
  70.     { 
  71.     *(ptr)++ = *((volatile UINT8 *)(pR14)); 
  72.     *(ptr)++ = (*((UINT32 *)((pR14) + 1)) >> 24); 
  73.     }
  74. #endif /* _BYTE_ORDER == _BIG_ENDIAN */
  75. #define WRITE_R14_R15(val) 
  76.     { 
  77.     PCMCIA_IO_WRITE (pDrvCtrl->pcmcia.oliAddr + I595_R14, (val)); 
  78.     PCMCIA_IO_WRITE (pDrvCtrl->pcmcia.oliAddr + I595_R15, ((val) >> 8)); 
  79.     }
  80. #define WRITE_PTR_R14_R15(ptr, pR14) 
  81.     { 
  82.     *(pR14)     =  *(ptr)++; 
  83.     *((pR14) + 1) =  *(ptr)++; 
  84.     }
  85. #else /* I82595_REGS_CONTIGUOUS */
  86. #define PCMCIA_CALC_ADDR(x) (x)
  87. #define PCMCIA_IO_WRITE(x, y) ((*(volatile UINT8 *) (x)) = (y))
  88. #define PCMCIA_IO_WRITE16(x, y) ((*(volatile UINT16 *)(x)) = (y))
  89. #define PCMCIA_IO_READ(x) (* (volatile UINT8 *) (x))
  90. #define PCMCIA_IO_READ16(x) (* (volatile UINT16 *)(x))
  91. #define PCMCIA_ATTR_READ(x) (* (volatile UINT8 *) (x))
  92. #define PCMCIA_ATTR_WRITE(x, y) ((*(volatile UINT8 *) (x)) = (y))
  93. /* On Brutus, R14 and R15 can be read with one 16 bit operation */
  94. #define READ_R14_R15(val) 
  95.     { 
  96.     val = (PCMCIA_IO_READ16 (pDrvCtrl->pcmcia.oliAddr + I595_R14)); 
  97.     }
  98. #define READ_PTR_R14_R15(ptr, pR14) 
  99.     { 
  100.     *((UINT16 *)(ptr))++ = *((volatile UINT16 *)(pR14));
  101.     }
  102. #define WRITE_R14_R15(val) 
  103.     PCMCIA_IO_WRITE16 (pDrvCtrl->pcmcia.oliAddr + I595_R14, (val));
  104. #define WRITE_PTR_R14_R15(ptr, pr14) 
  105. *(volatile UINT16 *)(pR14) = *((UINT16 *)(ptr))++;
  106. #endif /* !I82595_REGS_CONTIGUOUS */
  107. /* General Setup Registers */
  108. #define PCIDREV 0x00 /* Identification & Revision */
  109. #define PCIFSTATUS 0x01 /* Interface Status */
  110. #define PCPWRRSTCTL 0x02 /* Power and RESETDRV Control */
  111. #define PCCSTATCHNG 0x04 /* Card Status Change */
  112. #define PCADDWINEN 0x06 /* Address Window Enable */
  113. #define PCCDGCR 0x16 /* Card Detect and General Control Register */
  114. #define PCGLBCTL 0x1E /* Global Control Register */
  115. #define PCINTGCTL 0x03 /* Interrupt & General Control */
  116. #define PCSTATCHNGINT 0x05 /* Card Status Change Interrupt Configuration */
  117. /* Definitions for fields in general setup registers */
  118. /* Interface Status Register */
  119. #define GSR_CD 0x0C /* Card detect - Complement of CD[2:1] pins */
  120. #define GSR_RDY 0x20 /* Card is ready */
  121. /* Power and RESETDRV control register */
  122. #define GSR_CPE 0x10 /* PC card power enable */
  123. #define GSR_PSE 0x20 /* Auto power switch enable */
  124. #define GSR_OE 0x80 /* Output enable */
  125. /* Interrupt & general control register */
  126. #define GSR_DRT 0x40 /* Deactivates reset signal to the PC card */
  127. /* Card Status Change Register */
  128. #define GSR_CDC 0x08 /* Card detect change */
  129. /* Card status change interrupt configuration register */
  130. #define GSR_IRQ4 0x40 /* IRQ4 enable */
  131. #define GSR_IRQ3 0x30 /* IRQ3 enable */
  132. #define GSR_CDE 0x08 /* Card detect enable */
  133. /* Address window enable register */
  134. #define GSR_WD0 0x01 /* Enable window 0 */
  135. /* I/O Registers */
  136. #define PCIOCTL 0x7 /* I/O Control */
  137. #define PCIOA0STARTL 0x08 /* I/O Addr 0 Start Low */
  138. #define PCIOA0STARTH 0x09 /* I/O Addr 0 Start High */
  139. #define PCIOA0STOPL 0x0A /* I/O Addr 0 Stop Low */
  140. #define PCIOA0STOPH 0x0B /* I/O Addr 0 Stop High */
  141. #define PCIOA1STARTL 0x0C /* I/O Addr 1 Start Low */
  142. #define PCIOA1STARTH 0x0D /* I/O Addr 1 Start High */
  143. #define PCIOA1STOPL 0x0E /* I/O Addr 1 Stop Low */
  144. #define PCIOA1STOPH 0x0F /* I/O Addr 1 Stop High */
  145. #define PCSYSA0MSTARTL 0x10 /* System Memory Addr 0 Mapping Start Low */
  146. #define PCSYSA0MSTARTH 0x11 /* System Memory Addr 0 Mapping Start High */
  147. #define PCSYSA0MSTOPL 0x12 /* System Memory Addr 0 Mapping Stop Low */
  148. #define PCSYSA0MSTOPH 0x13 /* System Memory Addr 0 Mapping Stop High */
  149. #define PCCMEMA0OFFL 0x14 /* Card Memory Offset Addr 0 Low */
  150. #define PCCMEMA0OFFH 0x15 /* Card Memory Offset Addr 0 High */
  151. #define PCSYSA1MSTARTL 0x18 /* System Memory Addr 1 Mapping Start Low */
  152. #define PCSYSA1MSTARTH 0x19 /* System Memory Addr 1 Mapping Start High */
  153. #define PCSYSA1MSTOPL 0x1A /* System Memory Addr 1 Mapping Stop Low */
  154. #define PCSYSA1MSTOPH 0x1B /* System Memory Addr 1 Mapping Stop High */
  155. #define PCCMEMA1OFFL 0x1C /* Card Memory Offset Addr 1 Low */
  156. #define PCCMEMA1OFFH 0x1D /* Card Memory Offset Addr 1 High */
  157. #define PCSYSA2MSTARTL 0x20 /* System Memory Addr 2 Mapping Start Low */
  158. #define PCSYSA2MSTARTH 0x21 /* System Memory Addr 2 Mapping Start High */
  159. #define PCSYSA2MSTOPL 0x22 /* System Memory Addr 2 Mapping Stop Low */
  160. #define PCSYSA2MSTOPH 0x23 /* System Memory Addr 2 Mapping Stop High */
  161. #define PCCMEMA2OFFL 0x24 /* Card Memory Offset Addr 2 Low */
  162. #define PCCMEMA2OFFH 0x25 /* Card Memory Offset Addr 2 High */
  163. #define PCSYSA3MSTARTL 0x28 /* System Memory Addr 3 Mapping Start Low */
  164. #define PCSYSA3MSTARTH 0x29 /* System Memory Addr 3 Mapping Start High */
  165. #define PCSYSA3MSTOPL 0x2A /* System Memory Addr 3 Mapping Stop Low */
  166. #define PCSYSA3MSTOPH 0x2B /* System Memory Addr 3 Mapping Stop High */
  167. #define PCCMEMA3OFFL 0x2C /* Card Memory Offset Addr 3 Low */
  168. #define PCCMEMA3OFFH 0x2D /* Card Memory Offset Addr 3 High */
  169. #define PCSYSA4MSTARTL 0x30 /* System Memory Addr 4 Mapping Start Low */
  170. #define PCSYSA4MSTARTH 0x31 /* System Memory Addr 4 Mapping Start High */
  171. #define PCSYSA4MSTOPL 0x32 /* System Memory Addr 4 Mapping Stop Low */
  172. #define PCSYSA4MSTOPH 0x33 /* System Memory Addr 4 Mapping Stop High */
  173. #define PCCMEMA4OFFL 0x34 /* Card Memory Offset Addr 4 Low */
  174. #define PCCMEMA4OFFH 0x35 /* Card Memory Offset Addr 4 High */
  175. /* Unique Registers */
  176. #define PCCONTROL 0x38 /* Control */
  177. #define PCACTTIM 0x39 /* Activity Timer */
  178. #define PCMISC 0x3A /* Miscellaneous */
  179. #define PCGPIOCON 0x3B /* GPIO Configuration */
  180. #define PCPROGCS 0x3D /* Programmable Chip Select */
  181. #define PCPROGCSCON 0x3E /* Programmable Chip Select
  182.  * Configuration Register */
  183. #define PCATA 0x3F /* ATA */
  184. /* Define PCMCIA structures */
  185. typedef enum
  186.     {
  187.     COMMON, /* Common memory */
  188.     ATTRIBUTE /* Attribute memory */
  189.     }
  190.     MEMTYPE;
  191. typedef struct PCMCIASocket
  192. {
  193.     UINT pcs_attrbase;
  194.     UINT pcs_attrrange;
  195.     UINT pcs_iobase;
  196.     UINT pcs_iorange;
  197. } PCMCIASOCKET;
  198. /* PCMCIA Control Structure */
  199. typedef struct pcmcia_ctrl
  200.     {
  201.     char * ioBaseA; /* I/O space base address for Card A */
  202.     char * attrBaseA; /* Attribute space base address Card A*/
  203.     char * memBaseA; /* Memory space base address Card A */
  204.     char * ioBaseB; /* I/O space base address for Card B */
  205.     char * attrBaseB; /* Attribute space base address Card B*/
  206.     char * memBaseB; /* Memory space base address Card B */
  207.     char * ctrlBase; /* Base of Vadem PCMCIA controller */
  208.     char * oliAddr; /* address of board */
  209.     char * oliAttribMem; /* Address of attribute memory */
  210.     int                 intLevelA;      /* Interrupt level for Card A */
  211.     int                 intVectA;       /* Interrupt vector for Card A */
  212.     int                 intLevelB;      /* Interrupt level for Card B */
  213.     int                 intVectB;       /* Interrupt vector for Card B */
  214.     BOOL                cardPresent;    /* TRUE if a card is in the slot */
  215.     UINT socket;         /* Socket holding card, A or B */
  216.     PCMCIASOCKET        theSocket;      /* PCMCIA Socket descriptor */
  217.     } OLI_PCMCIA_CTRL;
  218. /* Trasmit Buffer Descriptor */
  219. typedef struct tx_bd
  220.     {
  221.     UINT16              statusMode;     /* status and control */
  222.     UINT16              dataLength;     /* length of data buffer in bytes */
  223.     char * dataPointer;    /* points to memory data buffer */
  224.     } TX_BD;
  225. /* Receive Buffer Descriptor */
  226. typedef struct rx_bd
  227.     {
  228.     UINT16              statusMode;     /* status and control */
  229.     UINT16              dataLength;     /* length of data buffer in bytes */
  230.     char * dataPointer;    /* points to memory data buffer */
  231.     } RX_BD;
  232. /* Olicom Card Configuration registers */
  233. #define CARDCONFREG0 0x3F8
  234. #define CARDCONFREG1 0x3FA
  235. /* Definitions for fields in Olicom card configuration registers */
  236. /* Register 1 */
  237. #define CREG1_INT_IO 0x02 /* I/O Interrupt */
  238. /* There are four tuples that we need to read from the card */
  239. #define CARD_FUNCID 0x21 /* Should identify the card as
  240.    an Network Adaptor */
  241. #define CARD_FUNCE 0x22 /* Function extension tuple detailing
  242.    the Ethernet hardware address */
  243. #define CARD_CONFIG 0x1A /* Describes card configuration registers */
  244. #define CARD_CFT_ENTRY 0x1B /* There are several different copies of
  245.    this one tuple, which describe the
  246.    different I/O addresses accepted by the
  247.    Intel 82595 Controller */
  248. /*
  249.  * Register layout of the Intel 82595TX chip
  250.  *
  251.  * Those ever imaginative people at Intel have no other
  252.  * names for the registers on their chip than r1, r2
  253.  * etc..
  254.  *
  255.  */
  256. #ifndef I82595_REGS_CONTIGUOUS
  257. /*
  258.  * To try and optimise I/O to the chip, this structure represents
  259.  * the *real* appearance of the chip in the PID7T NISA I/O space;
  260.  * the weird wiring arrangement described in pid.h means that,
  261.  * although the chip has a sequential collection of registers, they
  262.  * appear to be grouped as two-register pairs, aligned on a word
  263.  * boundary
  264.  */
  265. #define I595_R0 0x00
  266. #define I595_R1 0x01
  267. #define I595_R2 0x04
  268. #define I595_R3 0x05
  269. #define I595_R4 0x08
  270. #define I595_R5 0x09
  271. #define I595_R6 0x0C
  272. #define I595_R7 0x0D
  273. #define I595_R8 0x10
  274. #define I595_R9 0x11
  275. #define I595_R10 0x14
  276. #define I595_R11 0x15
  277. #define I595_R12 0x18
  278. #define I595_R13 0x19
  279. #define I595_R14 0x1C
  280. #define I595_R15 0x1D
  281. #else
  282. /* Normal layout */
  283. #define I595_R0 0x00
  284. #define I595_R1 0x01
  285. #define I595_R2 0x02
  286. #define I595_R3 0x03
  287. #define I595_R4 0x04
  288. #define I595_R5 0x05
  289. #define I595_R6 0x06
  290. #define I595_R7 0x07
  291. #define I595_R8 0x08
  292. #define I595_R9 0x09
  293. #define I595_R10 0x0A
  294. #define I595_R11 0x0B
  295. #define I595_R12 0x0C
  296. #define I595_R13 0x0D
  297. #define I595_R14 0x0E
  298. #define I595_R15 0x0F
  299. #endif /* !I82595_REGS_CONTIGUOUS */
  300. /*
  301.  * Register 0 is special, as it's the same in all banks
  302.  * Access Macro to Register 0.
  303.  */
  304. #define SELECTBANK(c, b)(PCMCIA_IO_WRITE((c) + I595_R0, (b) << 6))
  305. #define RUNCMD(c, o) (PCMCIA_IO_WRITE((c) + I595_R0, 
  306.                                                  ((o) & OPCODE_MASK)))
  307. #define ABORTCMD(c) (PCMCIA_IO_WRITE((c) + I595_R0, (1 << 5)))
  308. /* 82595TX Command Set for register 0 */
  309. #define CMD_MC_SETUP 0x03
  310. #define CMD_TRANSMIT 0x04
  311. #define CMD_TDR 0x05
  312. #define CMD_DUMP 0x06
  313. #define CMD_DIAGNOSE 0x07
  314. #define CMD_RCV_ENABLE 0x08
  315. #define CMD_RCV_DISABLE 0x0A
  316. #define CMD_RCV_STOP 0x0B
  317. #define CMD_ABORT 0x0D
  318. #define CMD_RESET 0x0E
  319. #define CMD_XMIT_RAW 0x14
  320. #define CMD_CONT_XMIT_LIST 0x15
  321. #define CMD_SET_TRISTATE 0x16
  322. #define CMD_RESET_TRISTATE 0x17
  323. #define CMD_POWER_DOWN 0x18
  324. #define CMD_RESUME_XMIT_LIST 0x1C
  325. #define CMD_SEL_RESET 0x1E
  326. #define OPCODE_MASK 0x1F
  327. /* 82595TX result codes for register 0 */
  328. #define RESULT_INIT_DONE 0x0E
  329. /* Definitions for fields and bits in the OLI_DEVICE */
  330. /* I/O Bank 0 */
  331. /* Reg 1 Interrupt/Status Register */
  332. #define BNK0_RX_SIT 0x01 /* RX stop interrupt */
  333. #define BNK0_RX_IT 0x02 /* RX interrupt */
  334. #define BNK0_TX_IT 0x04 /* TX interrupt */
  335. #define BNK0_EXE_IT 0x08 /* Execution interrupt */
  336. #define BNK0_EXE_IDL 0x00 /* Execution state idle */
  337. #define BNK0_EXE_BSY 0x20 /* Execution state busy */
  338. #define BNK0_EXE_ART 0x30 /* Execution state aborting */
  339. #define BNK0_RCV_DIS 0x00 /* Receive state disable */
  340. #define BNK0_RCV_RDY 0x40 /* Receive state ready */
  341. #define BNK0_RCV_ACT 0x80 /* Receive state active */
  342. #define BNK0_RCV_STP 0xC0 /* Receive state stopping */
  343. #define BNK0_ITS_MSK 0x0F /* All interrupts mask */
  344. #define BNK0_EXE_MSK 0x30 /* Execution state mask */
  345. #define BNK0_RCV_MSK 0xC0 /* Receive state mask */
  346. #define BNK0_EXE_STE(r) ((r) & BNK0_EXE_MSK)
  347. #define BNK0_RCV_STE(r) ((r) & BNK0_RCV_MSK)
  348. /* Reg 3 Interrupt Mask Register */
  349. #define BNK0_RX_SMK 0x01 /* RX stop interrupt mask */
  350. #define BNK0_RX_MK 0x02 /* RX interrupt mask */
  351. #define BNK0_TX_MK 0x04 /* TX interrupt mask */
  352. #define BNK0_EXE_MK 0x08 /* Execution interrupt mask */
  353. #define BNK0_HAR_SLT 0x10 /* 32Bit IO port/host address select */
  354. #define BNK0_CBR_SLT 0x20 /* Current/Base register select */
  355. /* I/O Bank 1 */
  356. /* Reg 1 Config ISA Register/Tri-state irq lines */
  357. #define BNK1_ISA_HBW 0x02 /* Host bus width (ISA only) */
  358. #define BNK1_ISA_ART 0x40 /* Alternate ready timing (ISA only) */
  359. #define BNK1_TST_EN 0x80 /* Tri-state interrupt lines */
  360. /* I/O Bank 2 */
  361. /* Reg 1 Control the program features of the 82595TX */
  362. #define BNK2_TCP_DIS 0x01 /* Transmit concurrent processing disable */
  363. #define BNK2_PCM_ISA 0x10 /* PCMCIA/ISA Select */
  364. #define BNK2_TCH_END 0x20 /* Transmit chaining int mode */
  365. #define BNK2_TCH_ERR 0x40 /* Transmit chaining error stop */
  366. #define BNK2_BAD_DSC 0x80 /* Discard bad frames */
  367. /* Reg 2 Control the program features of the 82595TX */
  368. #define BNK2_PCS_EN 0x01 /* Promiscous mode enable */
  369. #define BNK2_BRO_DIS 0x02 /* Disable broadcast */
  370. #define BNK2_RX_CRC 0x04 /* RX CRC in memory */
  371. #define BNK2_LEN_DIS 0x08 /* Length disable */
  372. #define BNK2_SAI_EN 0x10 /* enable source address insertion */
  373. #define BNK2_MIA_EN 0x20 /* Multi individual address enable */
  374. #define BNK2_LP_DIS 0x00 /* Loopback disable */
  375. #define BNK2_LP_INT 0x40 /* Internal loopback */
  376. #define BNK2_LP_EXT 0x80 /* External loopback */
  377. /* Reg 3 Control the program features of the 82595TX */
  378. #define BNK2_LI_DIS 0x01 /* Link integrity disable */
  379. #define BNK2_PC_DIS 0x02 /* disable polarity correction */
  380. #define BNK2_TPE_AUI 0x04 /* TPE/AUI */
  381. #define BNK2_JB_DIS 0x08 /* Jabber disable */
  382. #define BNK2_AP_EN 0x10 /* APORT */
  383. #define BNK2_BNC_TPE 0x20 /* BNC/TPE */
  384. #define BNK2_TST_EN 0xC0 /* Production testing mode */
  385. /* RCV status field*/
  386. #define RCV_EOF 0x08 /* Reception of frame completed */
  387. #define RCV_BOF 0x10 /* Begining of frame bit */
  388. #define RCV_RXCPY 0x20 /* RCV copy threshold */
  389. #define RCV_RECLM 0x40 /* RCV-DMA reclaimes location */
  390. #define RCV_UNDRN 0x80 /* RCV data underrun */
  391. #define RCV_COL_DCT 0x0001 /* Collision detected */
  392. #define RCV_IA_MCH 0x0002 /* Individual address match */
  393. #define RCV_SRT_FRM 0x0080 /* Received frame shorter than 64Bytes */
  394. #define RCV_OVR_RUN 0x0100 /* OVERRUN */
  395. #define RCV_ALG_ERR 0x0400 /* Alignment error */
  396. #define RCV_CRC_ERR 0x0800 /* CRC error */
  397. #define RCV_LEN_ERR 0x1000 /* Length error */
  398. #define RCV_OK 0x2000 /* Frame received OK */
  399. #define RCV_TYP_LEN 0x8000 /* Type field */
  400. /* XMT status field*/
  401. #define XMT_COL_MAX 0x0020 /* Failed due to max collisions */
  402. #define XMT_HRT_BET 0x0040 /* Collision detect test passed after prev Tx */
  403. #define XMT_LN_DEF 0x0080 /* Tx deferred due to link activity */
  404. #define XMT_UND_RUN 0x0100 /* Underrun */
  405. #define XMT_LST_CRS 0x0400 /* Carrier sense lost */
  406. #define XMT_LT_COL 0x0800 /* Later collision */
  407. #define XMT_OK 0x2000 /* Transmit OK */
  408. #define XMT_COLL 0x8000 /* Collision on the last transmit */
  409. #define XMT_COL_MSK 0x000F /* number collisions mask */
  410. #define XMT_CHAIN 0x8000 /* Flag indicates a XMT chaining (16Bit) */
  411. #define XMT_CHAIN_OCT 0x80 /* Flag indicates a XMT chaining (8Bit) */
  412. #define TOTAL_RAM_SIZE (64 * 1024)
  413. #define RAM_TX_BASE (0)
  414. #define RAM_TX_SIZE (32 * 1024)
  415. #define RAM_TX_LIMIT (RAM_TX_BASE + (RAM_TX_SIZE - 1))
  416. #define RAM_RX_SIZE (TOTAL_RAM_SIZE - RAM_TX_SIZE)
  417. #define RAM_RX_BASE (RAM_TX_SIZE)
  418. #define RAM_RX_LIMIT (RAM_RX_BASE + (RAM_RX_SIZE - 1))
  419. /*
  420.  * Macro for converting from packet byte count to length in Tx ring
  421.  * buffer which needs to include 8 bytes of header and half-word
  422.  * alignment
  423.  */
  424. #define COUNT_TO_LEN(x) ((x) + ((((x) & 0x01) == 0) ? 8 : 9))
  425. /* Define Ethernet Network Driver parameters */
  426. #define MAX_UNITS       1       /* max Olicom units */
  427. #define DRV_NAME        "oli"
  428. #define DRV_NAME_LEN    4 /* including null terminator */
  429. #define EADDR_LEN       6
  430. #define OLI_BUFSIZ      (ETHERMTU + SIZEOF_ETHERHEADER + EADDR_LEN)
  431. #define OLI_SPEED       10000000
  432. #define TX_BD_MIN       2       /* minimum number of Tx buffer descriptors */
  433. #define TX_BD_MAX       0x14    /* maximum number of Tx buffer descriptors */
  434. #define RX_BD_MIN       2       /* minimum number of Rx buffer descriptors */
  435. #define TX_BD_DEFAULT   0x10    /* default number of Tx buffer descriptors */
  436. #define RX_BD_DEFAULT   0x10    /* default number of Rx buffer descriptors */
  437. #define OLI_MIN_FBUF    9       /* min. size of the first buffer in a frame */
  438. #define OLI_MAX_XMT     0x600   /* max. size of the XMT block mem. structure */
  439. #define NUM_LOAN        0x10    /* number of Rx loaner buffers in pool */
  440. /* Define control structures */
  441. /* typedefs */
  442. typedef struct free_buf
  443.     {
  444.     void *      pClBuf;                 /* pointer cluster buffer */
  445.     } FREE_BUF;
  446. /* The definition of the driver control structure */
  447. typedef struct end_device
  448.     {
  449.     END_OBJ     endObj;                 /* The class we inherit from. */
  450.     int         unit;                   /* unit number */
  451.     long        flags;                  /* Our local flags. */
  452.     OLI_PCMCIA_CTRL pcmcia;             /* PCMCIA control structure */
  453.     int         ivec;                   /* interrupt vector */
  454.     int         ilevel;                 /* interrupt level */
  455.     int         txBdNum;                /* number of transmit BD */
  456.     TX_BD *     txBdBase;               /* transmit BD base address */
  457.     int         txBdNext;               /* next transmit BD to fill */
  458.     int         txBdIndexC;             /* current transmit BD index */
  459.     int         rxBdNum;                /* number of receive BD */
  460.     RX_BD *     rxBdBase;               /* receive BD base address */
  461.     int         rxBdNext;               /* next receive BD to read */
  462.     char *      pShMem;                 /* real ptr to shared memory */
  463.     ULONG       shMemSize;              /* shared memory size */
  464.     UINT8       enetAddr[EADDR_LEN];    /* ethernet address */
  465.     int         offset;
  466.     CACHE_FUNCS cacheFuncs;             /* cache function pointers */
  467.     FREE_BUF    freeBuf[128];           /* Array of free routines. */
  468.     CL_POOL_ID  clPoolId;
  469.     } END_DEVICE;
  470. #define FLTR_FRM_SIZE 0x180 /* filter frm size 64 Multicast address */
  471. /* Definitions for the flags field */
  472. #define OLI_RCV_HANDLING 0x0001
  473. #define OLI_POLLING 0x0002 /* Poll mode */
  474. #define OLI_TX_CLEANING 0x0004
  475. #define OLI_TX_STOP 0x0008
  476. #define OLI_MEMOWN 0x8000 /* memory allocated by driver */
  477. /* state of transmit BD */
  478. #define TX_BD_READY 0x80
  479. /* state of receive BD */
  480. #define RX_BD_EMPTY 0x01
  481. /* definitions of several mask */
  482. #define OCT_MSK 0xFF /* 8-bit mask */
  483. #define ODD_MSK 0x01 /* Odd mask */
  484. #ifdef __cplusplus
  485. }
  486. #endif
  487. #endif /* __INCiOlicomEndh */