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. 11 ** 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 16 ** 17 ** Revision 1.3 2005/08/03 11:53:34 jnherder 18 ** Miscellaneous cleanups. 19 ** 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. 25 ** 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>. 29 ** 30 ** Revision 2.0 2005/06/26 16:16:46 lsodgf0 31 ** Initial revision for Minix 3.0.6 32 */ 33 34 #include <sys/null.h> 35 36 #undef ENABLE_3C501 37 #undef ENABLE_3C503 38 #undef ENABLE_3C509 39 #undef ENABLE_NE2000 40 #undef ENABLE_WDETH 41 #undef ENABLE_DP8390 42 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 */ 48 49 #define ENABLE_DP8390 (ENABLE_3C503|ENABLE_WDETH|ENABLE_NE2000) 50 #define HAVE_BUFFERS (ENABLE_3C501|ENABLE_3C509) 51 52 #define NOT(x) (~(x)) 53 54 #if VERBOSE == 1 55 # define DEBUG(statm) statm 56 #else 57 # define DEBUG(statm) 58 #endif 59 60 typedef struct _m_hdr_t { /* Buffer handling header */ 61 struct _m_hdr_t *next; 62 int size; 63 } m_hdr_t; 64 65 typedef struct _buff_t { /* Receive/Transmit buffer header */ 66 struct _buff_t *next; 67 int size; 68 int client; 69 char buffer[2]; 70 } buff_t; 71 72 struct dpeth; 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); 76 77 #if ENABLE_DP8390 == 1 78 typedef void (*dp_user2nicf_t)(struct dpeth *, int, struct netdriver_data *, 79 size_t); 80 typedef void (*dp_nic2userf_t)(struct dpeth *, int, struct netdriver_data *, 81 size_t); 82 typedef void (*dp_getblock_t)(struct dpeth *, u16_t, int, void *); 83 #endif 84 85 #define SENDQ_NR 2 /* Size of the send queue */ 86 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. 95 * 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. */ 99 100 /* Board hardware interface */ 101 port_t de_base_port; 102 port_t de_data_port; /* For boards using Prog. I/O for xmit/recv */ 103 104 unsigned int de_irq; 105 int de_hook; /* interrupt hook at kernel */ 106 107 #define DEI_DEFAULT 0x8000 108 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 */ 113 114 /* Board specific functions */ 115 dp_eth_t de_initf; 116 dp_eth_t de_stopf; 117 dp_eth_t de_resetf; 118 dp_eth_t de_flagsf; 119 dp_eth_t de_getstatsf; 120 dp_eth_t de_dumpstatsf; 121 dp_eth_t de_interruptf; 122 dp_recv_t de_recvf; 123 dp_send_t de_sendf; 124 125 netdriver_addr_t de_address; /* Ethernet Address */ 126 unsigned long bytes_Tx; /* Total bytes sent/received */ 127 unsigned long bytes_Rx; 128 129 #define SA_ADDR_LEN sizeof(netdriver_addr_t) 130 131 int de_flags; /* Send/Receive mode (Configuration) */ 132 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 138 139 #if ENABLE_DP8390 == 1 140 /* For use by NS DP8390 driver */ 141 port_t de_dp8390_port; 142 int de_prog_IO; 143 int de_16bit; 144 unsigned int de_startpage; 145 unsigned int de_stoppage; 146 147 /* Do it yourself send queue */ 148 struct sendq { 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 */ 156 157 dp_user2nicf_t de_user2nicf; 158 dp_nic2userf_t de_nic2userf; 159 dp_getblock_t de_getblockf; 160 #endif 161 162 #if ENABLE_3C509 == 1 163 /* For use by 3Com Etherlink III (3c509) driver */ 164 port_t de_id_port; 165 port_t de_if_port; 166 #endif 167 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; 172 u16_t de_recv_mode; 173 clock_t de_xmit_start; 174 #endif 175 176 } dpeth_t; 177 178 /* 179 * Function definitions 180 */ 181 182 /* devio.c */ 183 #if defined USE_IOPL 184 #include <machine/portio.h> 185 #else 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); 193 #endif 194 195 /* netbuff.c */ 196 void *alloc_buff(dpeth_t *, int); 197 void free_buff(dpeth_t *, void *); 198 void init_buff(dpeth_t *, buff_t **); 199 200 /* 3c501.c */ 201 #if ENABLE_3C501 == 1 202 int el1_probe(dpeth_t *); 203 #else 204 #define el1_probe(x) (0) 205 #endif 206 207 /* 3c503.c */ 208 #if ENABLE_3C503 == 1 209 int el2_probe(dpeth_t *); 210 #else 211 #define el2_probe(x) (0) 212 #endif 213 214 /* 3c509.c */ 215 #if ENABLE_3C509 == 1 216 int el3_probe(dpeth_t *); 217 #else 218 #define el3_probe(x) (0) 219 #endif 220 221 /* ne.c */ 222 #if ENABLE_NE2000 == 1 223 int ne_probe(dpeth_t * dep); 224 #else 225 #define ne_probe(x) (0) 226 #endif 227 228 /* wd.c */ 229 #if ENABLE_WDETH == 1 230 int wdeth_probe(dpeth_t * dep); 231 #else 232 #define wdeth_probe(x) (0) 233 #endif 234 235 /** dp.h **/ 236