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
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)
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 */
73 typedef void (*dp_eth_t
)(struct dpeth
*);
74 typedef int (*dp_send_t
)(struct dpeth
*, struct netdriver_data
*, size_t);
75 typedef ssize_t (*dp_recv_t
)(struct dpeth
*, struct netdriver_data
*, size_t);
77 #if ENABLE_DP8390 == 1
78 typedef void (*dp_user2nicf_t
)(struct dpeth
*, int, struct netdriver_data
*,
80 typedef void (*dp_nic2userf_t
)(struct dpeth
*, int, struct netdriver_data
*,
82 typedef void (*dp_getblock_t
)(struct dpeth
*, u16_t
, int, void *);
85 #define SENDQ_NR 2 /* Size of the send queue */
87 typedef struct dpeth
{
88 /* The de_base_port field is the starting point of the probe. The
89 * conf routine also fills de_linmem and de_irq. If the probe routine
90 * knows the irq and/or memory address because they are hardwired in
91 * the board, the probe should modify these fields. Futhermore, the
92 * probe routine should also fill in de_initf and de_stopf fields
93 * with the appropriate function pointers and set de_prog_IO iff
94 * programmed I/O is to be used.
96 * The initf function fills the following fields. Only cards that do
97 * programmed I/O fill in the de_data_port field. In addition, the
98 * init routine has to fill in the sendq data structures. */
100 /* Board hardware interface */
102 port_t de_data_port
; /* For boards using Prog. I/O for xmit/recv */
105 int de_hook
; /* interrupt hook at kernel */
107 #define DEI_DEFAULT 0x8000
109 phys_bytes de_linmem
; /* For boards using shared memory */
110 char *de_locmem
; /* Locally mapped (virtual) address */
111 unsigned int de_ramsize
; /* Size of on board memory */
112 unsigned int de_offset_page
; /* Offset of shared memory page */
114 /* Board specific functions */
119 dp_eth_t de_getstatsf
;
120 dp_eth_t de_dumpstatsf
;
121 dp_eth_t de_interruptf
;
125 netdriver_addr_t de_address
; /* Ethernet Address */
126 unsigned long bytes_Tx
; /* Total bytes sent/received */
127 unsigned long bytes_Rx
;
129 #define SA_ADDR_LEN sizeof(netdriver_addr_t)
131 int de_flags
; /* Send/Receive mode (Configuration) */
133 #define DEF_EMPTY 0x00
134 #define DEF_XMIT_BUSY 0x01
135 #define DEF_PROMISC 0x02
136 #define DEF_MULTI 0x04
137 #define DEF_BROAD 0x08
139 #if ENABLE_DP8390 == 1
140 /* For use by NS DP8390 driver */
141 port_t de_dp8390_port
;
144 unsigned int de_startpage
;
145 unsigned int de_stoppage
;
147 /* Do it yourself send queue */
149 int sq_filled
; /* This buffer contains a packet */
150 int sq_size
; /* with this size */
151 int sq_sendpage
; /* starting page of the buffer */
152 } de_sendq
[SENDQ_NR
];
153 unsigned int de_sendq_nr
;
154 unsigned int de_sendq_head
; /* Enqueue at the head */
155 unsigned int de_sendq_tail
; /* Dequeue at the tail */
157 dp_user2nicf_t de_user2nicf
;
158 dp_nic2userf_t de_nic2userf
;
159 dp_getblock_t de_getblockf
;
162 #if ENABLE_3C509 == 1
163 /* For use by 3Com Etherlink III (3c509) driver */
168 #if ENABLE_3C501 == 1 || ENABLE_3C509 == 1
169 /* For use by 3Com Etherlink (3c501 and 3c509) driver */
170 buff_t
*de_recvq_head
;
171 buff_t
*de_recvq_tail
;
173 clock_t de_xmit_start
;
179 * Function definitions
184 #include <machine/portio.h>
186 unsigned int inb(unsigned short int);
187 unsigned int inw(unsigned short int);
188 void insb(unsigned short int, void *, int);
189 void insw(unsigned short int, void *, int);
190 void outb(unsigned short int, unsigned long);
191 void outw(unsigned short int, unsigned long);
192 void outsb(unsigned short int, void *, int);
196 void *alloc_buff(dpeth_t
*, int);
197 void free_buff(dpeth_t
*, void *);
198 void init_buff(dpeth_t
*, buff_t
**);
201 #if ENABLE_3C501 == 1
202 int el1_probe(dpeth_t
*);
204 #define el1_probe(x) (0)
208 #if ENABLE_3C503 == 1
209 int el2_probe(dpeth_t
*);
211 #define el2_probe(x) (0)
215 #if ENABLE_3C509 == 1
216 int el3_probe(dpeth_t
*);
218 #define el3_probe(x) (0)
222 #if ENABLE_NE2000 == 1
223 int ne_probe(dpeth_t
* dep
);
225 #define ne_probe(x) (0)
229 #if ENABLE_WDETH == 1
230 int wdeth_probe(dpeth_t
* dep
);
232 #define wdeth_probe(x) (0)