supply instance to 2nd at_wini instance.
[minix3.git] / drivers / dpeth / dp.h
bloba18f9240c721a7d1bbd18a5c96133aeb8a6fb016
1 /*
2 ** File: eth.h Version 1.00, Jan. 14, 1997
3 **
4 ** Author: Giovanni Falzoni <gfalzoni@inwind.it>
5 **
6 ** Interface description for ethernet device driver
7 **
8 ** $Log$
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
33 ** $Id$
36 #undef ENABLE_3C501
37 #undef ENABLE_3C503
38 #undef ENABLE_3C509
39 #undef ENABLE_NE2000
40 #undef ENABLE_WDETH
41 #undef ENABLE_DP8390
43 #define ENABLE_3C501 1 /* enable 3Com Etherlink I board */
44 #define ENABLE_3C503 1 /* enable 3Com Etherlink II board */
45 #define ENABLE_3C509 1 /* enable 3Com Etherlink III board */
46 #define ENABLE_NE2000 1 /* enable Novell N2000 board */
47 #define ENABLE_WDETH 1 /* enable Western Digital WD80x3 */
49 #define ENABLE_DP8390 (ENABLE_3C503|ENABLE_WDETH|ENABLE_NE2000)
50 #define HAVE_BUFFERS (ENABLE_3C501|ENABLE_3C509)
52 #undef NULL
53 #define NULL ((void *)0)
54 #define NOT(x) (~(x))
56 #if debug == 1
57 # define DEBUG(statm) statm
58 #else
59 # define DEBUG(statm)
60 #endif
62 typedef struct _m_hdr_t { /* Buffer handling header */
63 struct _m_hdr_t *next;
64 int size;
65 } m_hdr_t;
67 typedef struct _buff_t { /* Receive/Transmit buffer header */
68 struct _buff_t *next;
69 int size;
70 int client;
71 char buffer[2];
72 } buff_t;
74 struct dpeth;
75 struct iovec_dat;
76 typedef void (*dp_eth_t) (struct dpeth *);
77 typedef void (*dp_send_recv_t) (struct dpeth *, int, int);
79 #if ENABLE_DP8390 == 1
80 typedef void (*dp_user2nicf_t) (struct dpeth *, int, int);
81 typedef void (*dp_nic2userf_t) (struct dpeth *, int, int);
82 typedef void (*dp_getblock_t) (struct dpeth *, u16_t, int, void *);
83 #endif
85 #define DE_PORT_NR 2 /* Number of devices supported */
86 #define SENDQ_NR 2 /* Size of the send queue */
87 #define IOVEC_NR 16 /* Number of IOVEC entries at a time */
89 typedef struct iovec_dat_s {
90 iovec_s_t iod_iovec[IOVEC_NR];
91 int iod_iovec_s;
92 int iod_proc_nr;
93 cp_grant_id_t iod_grant;
94 vir_bytes iod_iovec_offset;
95 } iovec_dat_s_t;
97 typedef struct dpeth {
98 /* The de_base_port field is the starting point of the probe. The
99 * conf routine also fills de_linmem and de_irq. If the probe routine
100 * knows the irq and/or memory address because they are hardwired in
101 * the board, the probe should modify these fields. Futhermore, the
102 * probe routine should also fill in de_initf and de_stopf fields
103 * with the appropriate function pointers and set de_prog_IO iff
104 * programmed I/O is to be used.
106 * The initf function fills the following fields. Only cards that do
107 * programmed I/O fill in the de_data_port field. In addition, the
108 * init routine has to fill in the sendq data structures. */
110 /* Board hardware interface */
111 port_t de_base_port;
112 port_t de_data_port; /* For boards using Prog. I/O for xmit/recv */
114 int de_irq;
115 int de_int_pending;
116 int de_hook; /* interrupt hook at kernel */
118 char de_name[8];
120 #define DEI_DEFAULT 0x8000
122 phys_bytes de_linmem; /* For boards using shared memory */
123 unsigned short de_memsegm;
124 vir_bytes de_memoffs;
125 int de_ramsize; /* Size of on board memory */
126 int de_offset_page; /* Offset of shared memory page */
128 /* Board specific functions */
129 dp_eth_t de_initf;
130 dp_eth_t de_stopf;
131 dp_eth_t de_resetf;
132 dp_eth_t de_flagsf;
133 dp_eth_t de_getstatsf;
134 dp_eth_t de_dumpstatsf;
135 dp_eth_t de_interruptf;
136 dp_send_recv_t de_recvf;
137 dp_send_recv_t de_sendf;
139 ether_addr_t de_address; /* Ethernet Address */
140 eth_stat_t de_stat; /* Ethernet Statistics */
141 unsigned long bytes_Tx; /* Total bytes sent/received */
142 unsigned long bytes_Rx;
144 #define SA_ADDR_LEN sizeof(ether_addr_t)
146 int de_flags; /* Send/Receive mode (Configuration) */
148 #define DEF_EMPTY 0x0000
149 #define DEF_READING 0x0001
150 #define DEF_RECV_BUSY 0x0002
151 #define DEF_ACK_RECV 0x0004
152 #define DEF_SENDING 0x0010
153 #define DEF_XMIT_BUSY 0x0020
154 #define DEF_ACK_SEND 0x0040
155 #define DEF_PROMISC 0x0100
156 #define DEF_MULTI 0x0200
157 #define DEF_BROAD 0x0400
158 #define DEF_ENABLED 0x2000
159 #define DEF_STOPPED 0x4000
161 int de_mode; /* Status of the Interface */
163 #define DEM_DISABLED 0x0000
164 #define DEM_SINK 0x0001
165 #define DEM_ENABLED 0x0002
167 /* Temporary storage for RECV/SEND requests */
168 iovec_dat_s_t de_read_iovec;
169 iovec_dat_s_t de_write_iovec;
170 vir_bytes de_read_s;
171 vir_bytes de_send_s;
172 int de_client;
174 message de_sendmsg;
175 iovec_dat_t de_tmp_iovec;
177 #if ENABLE_DP8390 == 1
178 /* For use by NS DP8390 driver */
179 port_t de_dp8390_port;
180 int de_prog_IO;
181 int de_16bit;
182 int de_startpage;
183 int de_stoppage;
185 /* Do it yourself send queue */
186 struct sendq {
187 int sq_filled; /* This buffer contains a packet */
188 int sq_size; /* with this size */
189 int sq_sendpage; /* starting page of the buffer */
190 } de_sendq[SENDQ_NR];
191 int de_sendq_nr;
192 int de_sendq_head; /* Enqueue at the head */
193 int de_sendq_tail; /* Dequeue at the tail */
195 dp_user2nicf_t de_user2nicf;
196 dp_nic2userf_t de_nic2userf;
197 dp_getblock_t de_getblockf;
198 #endif
200 #if ENABLE_3C509 == 1
201 /* For use by 3Com Etherlink III (3c509) driver */
202 port_t de_id_port;
203 port_t de_if_port;
204 #endif
206 #if ENABLE_3C501 == 1 || ENABLE_3C509 == 1
207 /* For use by 3Com Etherlink (3c501 and 3c509) driver */
208 buff_t *de_recvq_head;
209 buff_t *de_recvq_tail;
210 buff_t *de_xmitq_head;
211 buff_t *de_xmitq_tail;
212 u16_t de_recv_mode;
213 clock_t de_xmit_start;
214 #endif
216 } dpeth_t;
219 * Function definitions
222 /* dp.c */
223 void dp_next_iovec(iovec_dat_s_t * iovp);
225 /* devio.c */
226 #if defined USE_IOPL
227 #include <ibm/portio.h>
228 #else
229 unsigned int inb(unsigned short int);
230 unsigned int inw(unsigned short int);
231 void insb(unsigned short int, int, void *, int);
232 void insw(unsigned short int, int, void *, int);
233 void outb(unsigned short int, unsigned long);
234 void outw(unsigned short int, unsigned long);
235 void outsb(unsigned short int, int, void *, int);
236 void outsw(unsigned short int, int, void *, int);
237 #endif
239 /* netbuff.c */
240 void *alloc_buff(dpeth_t *, int);
241 void free_buff(dpeth_t *, void *);
242 void init_buff(dpeth_t *, buff_t **);
243 void mem2user(dpeth_t *, buff_t *);
244 void user2mem(dpeth_t *, buff_t *);
246 /* 3c501.c */
247 #if ENABLE_3C501 == 1
248 int el1_probe(dpeth_t *);
249 #else
250 #define el1_probe(x) (0)
251 #endif
253 /* 3c503.c */
254 #if ENABLE_3C503 == 1
255 int el2_probe(dpeth_t *);
256 #else
257 #define el2_probe(x) (0)
258 #endif
260 /* 3c509.c */
261 #if ENABLE_3C509 == 1
262 int el3_probe(dpeth_t *);
263 #else
264 #define el3_probe(x) (0)
265 #endif
267 /* ne.c */
268 #if ENABLE_NE2000 == 1
269 int ne_probe(dpeth_t * dep);
270 #else
271 #define ne_probe(x) (0)
272 #endif
274 /* wd.c */
275 #if ENABLE_WDETH == 1
276 int wdeth_probe(dpeth_t * dep);
277 #else
278 #define wdeth_probe(x) (0)
279 #endif
281 #define lock() (++dep->de_int_pending,sys_irqdisable(&dep->de_hook))
282 #define unlock() do{int i=(--dep->de_int_pending)?0:sys_irqenable(&dep->de_hook);}while(0)
283 #define milli_delay(t) tickdelay(1)
285 /** dp.h **/