2 ** File: eth.h Version 1.00, Jan. 14, 1997
4 ** Author: Giovanni Falzoni <gfalzoni@inwind.it>
6 ** Interface description for ethernet device driver
9 ** Revision 1.5 2006/07/10 12:43:38 philip
10 ** Safecopy support in ethernet drivers.
12 ** Revision 1.4 2005/09/04 18:52:16 beng
13 ** Giovanni's fixes to dpeth:
14 ** Date: Sat, 03 Sep 2005 11:05:22 +0200
15 ** Subject: Minix 3.0.8
17 ** Revision 1.3 2005/08/03 11:53:34 jnherder
18 ** Miscellaneous cleanups.
20 ** Revision 1.2 2005/08/02 15:30:35 jnherder
21 ** Various updates to support dynamically starting drivers.
22 ** Output during initialization should be suppressed. Unless an error occurs.
23 ** Note that main() can now be main(int argc, char **argv) and arguments can
24 ** be passed when bringing up the driver.
26 ** Revision 1.1 2005/06/29 10:16:46 beng
27 ** Import of dpeth 3c501/3c509b/.. ethernet driver by
28 ** Giovanni Falzoni <fgalzoni@inwind.it>.
30 ** Revision 2.0 2005/06/26 16:16:46 lsodgf0
31 ** Initial revision for Minix 3.0.6
41 #define ENABLE_3C501 1 /* enable 3Com Etherlink I board */
42 #define ENABLE_3C503 1 /* enable 3Com Etherlink II board */
43 #define ENABLE_3C509 1 /* enable 3Com Etherlink III board */
44 #define ENABLE_NE2000 1 /* enable Novell N2000 board */
45 #define ENABLE_WDETH 1 /* enable Western Digital WD80x3 */
47 #define ENABLE_DP8390 (ENABLE_3C503|ENABLE_WDETH|ENABLE_NE2000)
48 #define HAVE_BUFFERS (ENABLE_3C501|ENABLE_3C509)
51 #define NULL ((void *)0)
55 # define DEBUG(statm) statm
60 typedef struct _m_hdr_t
{ /* Buffer handling header */
61 struct _m_hdr_t
*next
;
65 typedef struct _buff_t
{ /* Receive/Transmit buffer header */
74 typedef void (*dp_eth_t
) (struct dpeth
*);
75 typedef void (*dp_send_recv_t
) (struct dpeth
*, int, int);
77 #if ENABLE_DP8390 == 1
78 typedef void (*dp_user2nicf_t
) (struct dpeth
*, int, int);
79 typedef void (*dp_nic2userf_t
) (struct dpeth
*, int, int);
80 typedef void (*dp_getblock_t
) (struct dpeth
*, u16_t
, int, void *);
83 #define SENDQ_NR 2 /* Size of the send queue */
84 #define IOVEC_NR 16 /* Number of IOVEC entries at a time */
86 typedef struct iovec_dat_s
{
87 iovec_s_t iod_iovec
[IOVEC_NR
];
90 cp_grant_id_t iod_grant
;
91 vir_bytes iod_iovec_offset
;
94 typedef struct dpeth
{
95 /* The de_base_port field is the starting point of the probe. The
96 * conf routine also fills de_linmem and de_irq. If the probe routine
97 * knows the irq and/or memory address because they are hardwired in
98 * the board, the probe should modify these fields. Futhermore, the
99 * probe routine should also fill in de_initf and de_stopf fields
100 * with the appropriate function pointers and set de_prog_IO iff
101 * programmed I/O is to be used.
103 * The initf function fills the following fields. Only cards that do
104 * programmed I/O fill in the de_data_port field. In addition, the
105 * init routine has to fill in the sendq data structures. */
107 /* Board hardware interface */
109 port_t de_data_port
; /* For boards using Prog. I/O for xmit/recv */
113 int de_hook
; /* interrupt hook at kernel */
117 #define DEI_DEFAULT 0x8000
119 phys_bytes de_linmem
; /* For boards using shared memory */
120 unsigned short de_memsegm
;
121 vir_bytes de_memoffs
;
122 int de_ramsize
; /* Size of on board memory */
123 int de_offset_page
; /* Offset of shared memory page */
125 /* Board specific functions */
130 dp_eth_t de_getstatsf
;
131 dp_eth_t de_dumpstatsf
;
132 dp_eth_t de_interruptf
;
133 dp_send_recv_t de_recvf
;
134 dp_send_recv_t de_sendf
;
136 ether_addr_t de_address
; /* Ethernet Address */
137 eth_stat_t de_stat
; /* Ethernet Statistics */
138 unsigned long bytes_Tx
; /* Total bytes sent/received */
139 unsigned long bytes_Rx
;
141 #define SA_ADDR_LEN sizeof(ether_addr_t)
143 int de_flags
; /* Send/Receive mode (Configuration) */
145 #define DEF_EMPTY 0x0000
146 #define DEF_READING 0x0001
147 #define DEF_RECV_BUSY 0x0002
148 #define DEF_ACK_RECV 0x0004
149 #define DEF_SENDING 0x0010
150 #define DEF_XMIT_BUSY 0x0020
151 #define DEF_ACK_SEND 0x0040
152 #define DEF_PROMISC 0x0100
153 #define DEF_MULTI 0x0200
154 #define DEF_BROAD 0x0400
155 #define DEF_ENABLED 0x2000
156 #define DEF_STOPPED 0x4000
158 int de_mode
; /* Status of the Interface */
160 #define DEM_DISABLED 0x0000
161 #define DEM_SINK 0x0001
162 #define DEM_ENABLED 0x0002
164 /* Temporary storage for RECV/SEND requests */
165 iovec_dat_s_t de_read_iovec
;
166 iovec_dat_s_t de_write_iovec
;
172 iovec_dat_t de_tmp_iovec;
174 #if ENABLE_DP8390 == 1
175 /* For use by NS DP8390 driver */
176 port_t de_dp8390_port
;
182 /* Do it yourself send queue */
184 int sq_filled
; /* This buffer contains a packet */
185 int sq_size
; /* with this size */
186 int sq_sendpage
; /* starting page of the buffer */
187 } de_sendq
[SENDQ_NR
];
189 int de_sendq_head
; /* Enqueue at the head */
190 int de_sendq_tail
; /* Dequeue at the tail */
192 dp_user2nicf_t de_user2nicf
;
193 dp_nic2userf_t de_nic2userf
;
194 dp_getblock_t de_getblockf
;
197 #if ENABLE_3C509 == 1
198 /* For use by 3Com Etherlink III (3c509) driver */
203 #if ENABLE_3C501 == 1 || ENABLE_3C509 == 1
204 /* For use by 3Com Etherlink (3c501 and 3c509) driver */
205 buff_t
*de_recvq_head
;
206 buff_t
*de_recvq_tail
;
207 buff_t
*de_xmitq_head
;
208 buff_t
*de_xmitq_tail
;
210 clock_t de_xmit_start
;
216 * Function definitions
220 void dp_next_iovec(iovec_dat_s_t
* iovp
);
224 #include <machine/portio.h>
226 unsigned int inb(unsigned short int);
227 unsigned int inw(unsigned short int);
228 void insb(unsigned short int, endpoint_t
, void *, int);
229 void insw(unsigned short int, int, void *, int);
230 void outb(unsigned short int, unsigned long);
231 void outw(unsigned short int, unsigned long);
232 void outsb(unsigned short int, endpoint_t
, void *, int);
233 void outsw(unsigned short int, int, void *, int);
237 void *alloc_buff(dpeth_t
*, int);
238 void free_buff(dpeth_t
*, void *);
239 void init_buff(dpeth_t
*, buff_t
**);
240 void mem2user(dpeth_t
*, buff_t
*);
241 void user2mem(dpeth_t
*, buff_t
*);
244 #if ENABLE_3C501 == 1
245 int el1_probe(dpeth_t
*);
247 #define el1_probe(x) (0)
251 #if ENABLE_3C503 == 1
252 int el2_probe(dpeth_t
*);
254 #define el2_probe(x) (0)
258 #if ENABLE_3C509 == 1
259 int el3_probe(dpeth_t
*);
261 #define el3_probe(x) (0)
265 #if ENABLE_NE2000 == 1
266 int ne_probe(dpeth_t
* dep
);
268 #define ne_probe(x) (0)
272 #if ENABLE_WDETH == 1
273 int wdeth_probe(dpeth_t
* dep
);
275 #define wdeth_probe(x) (0)
278 #define lock() (++dep->de_int_pending,sys_irqdisable(&dep->de_hook))
279 #define unlock() do{int i=(--dep->de_int_pending)?0:sys_irqenable(&dep->de_hook);(void) i;}while(0)
280 #define milli_delay(t) tickdelay(1)