1433d6423SLionel Sambuc /* 2433d6423SLionel Sambuc ** File: eth.h Version 1.00, Jan. 14, 1997 3433d6423SLionel Sambuc ** 4433d6423SLionel Sambuc ** Author: Giovanni Falzoni <gfalzoni@inwind.it> 5433d6423SLionel Sambuc ** 6433d6423SLionel Sambuc ** Interface description for ethernet device driver 7433d6423SLionel Sambuc ** 8433d6423SLionel Sambuc ** $Log$ 9433d6423SLionel Sambuc ** Revision 1.5 2006/07/10 12:43:38 philip 10433d6423SLionel Sambuc ** Safecopy support in ethernet drivers. 11433d6423SLionel Sambuc ** 12433d6423SLionel Sambuc ** Revision 1.4 2005/09/04 18:52:16 beng 13433d6423SLionel Sambuc ** Giovanni's fixes to dpeth: 14433d6423SLionel Sambuc ** Date: Sat, 03 Sep 2005 11:05:22 +0200 15433d6423SLionel Sambuc ** Subject: Minix 3.0.8 16433d6423SLionel Sambuc ** 17433d6423SLionel Sambuc ** Revision 1.3 2005/08/03 11:53:34 jnherder 18433d6423SLionel Sambuc ** Miscellaneous cleanups. 19433d6423SLionel Sambuc ** 20433d6423SLionel Sambuc ** Revision 1.2 2005/08/02 15:30:35 jnherder 21433d6423SLionel Sambuc ** Various updates to support dynamically starting drivers. 22433d6423SLionel Sambuc ** Output during initialization should be suppressed. Unless an error occurs. 23433d6423SLionel Sambuc ** Note that main() can now be main(int argc, char **argv) and arguments can 24433d6423SLionel Sambuc ** be passed when bringing up the driver. 25433d6423SLionel Sambuc ** 26433d6423SLionel Sambuc ** Revision 1.1 2005/06/29 10:16:46 beng 27433d6423SLionel Sambuc ** Import of dpeth 3c501/3c509b/.. ethernet driver by 28433d6423SLionel Sambuc ** Giovanni Falzoni <fgalzoni@inwind.it>. 29433d6423SLionel Sambuc ** 30433d6423SLionel Sambuc ** Revision 2.0 2005/06/26 16:16:46 lsodgf0 31433d6423SLionel Sambuc ** Initial revision for Minix 3.0.6 32433d6423SLionel Sambuc */ 33433d6423SLionel Sambuc 34433d6423SLionel Sambuc #include <sys/null.h> 35433d6423SLionel Sambuc 36433d6423SLionel Sambuc #undef ENABLE_3C501 37433d6423SLionel Sambuc #undef ENABLE_3C503 38433d6423SLionel Sambuc #undef ENABLE_3C509 39433d6423SLionel Sambuc #undef ENABLE_NE2000 40433d6423SLionel Sambuc #undef ENABLE_WDETH 41433d6423SLionel Sambuc #undef ENABLE_DP8390 42433d6423SLionel Sambuc 43433d6423SLionel Sambuc #define ENABLE_3C501 1 /* enable 3Com Etherlink I board */ 44433d6423SLionel Sambuc #define ENABLE_3C503 1 /* enable 3Com Etherlink II board */ 45433d6423SLionel Sambuc #define ENABLE_3C509 1 /* enable 3Com Etherlink III board */ 46433d6423SLionel Sambuc #define ENABLE_NE2000 1 /* enable Novell N2000 board */ 47433d6423SLionel Sambuc #define ENABLE_WDETH 1 /* enable Western Digital WD80x3 */ 48433d6423SLionel Sambuc 49433d6423SLionel Sambuc #define ENABLE_DP8390 (ENABLE_3C503|ENABLE_WDETH|ENABLE_NE2000) 50433d6423SLionel Sambuc #define HAVE_BUFFERS (ENABLE_3C501|ENABLE_3C509) 51433d6423SLionel Sambuc 52433d6423SLionel Sambuc #define NOT(x) (~(x)) 53433d6423SLionel Sambuc 5491c4db25SDavid van Moolenbroek #if VERBOSE == 1 55433d6423SLionel Sambuc # define DEBUG(statm) statm 56433d6423SLionel Sambuc #else 57433d6423SLionel Sambuc # define DEBUG(statm) 58433d6423SLionel Sambuc #endif 59433d6423SLionel Sambuc 60433d6423SLionel Sambuc typedef struct _m_hdr_t { /* Buffer handling header */ 61433d6423SLionel Sambuc struct _m_hdr_t *next; 62433d6423SLionel Sambuc int size; 63433d6423SLionel Sambuc } m_hdr_t; 64433d6423SLionel Sambuc 65433d6423SLionel Sambuc typedef struct _buff_t { /* Receive/Transmit buffer header */ 66433d6423SLionel Sambuc struct _buff_t *next; 67433d6423SLionel Sambuc int size; 68433d6423SLionel Sambuc int client; 69433d6423SLionel Sambuc char buffer[2]; 70433d6423SLionel Sambuc } buff_t; 71433d6423SLionel Sambuc 72433d6423SLionel Sambuc struct dpeth; 73433d6423SLionel Sambuc typedef void (*dp_eth_t)(struct dpeth *); 7491c4db25SDavid van Moolenbroek typedef int (*dp_send_t)(struct dpeth *, struct netdriver_data *, size_t); 7591c4db25SDavid van Moolenbroek typedef ssize_t (*dp_recv_t)(struct dpeth *, struct netdriver_data *, size_t); 76433d6423SLionel Sambuc 77433d6423SLionel Sambuc #if ENABLE_DP8390 == 1 7891c4db25SDavid van Moolenbroek typedef void (*dp_user2nicf_t)(struct dpeth *, int, struct netdriver_data *, 7991c4db25SDavid van Moolenbroek size_t); 8091c4db25SDavid van Moolenbroek typedef void (*dp_nic2userf_t)(struct dpeth *, int, struct netdriver_data *, 8191c4db25SDavid van Moolenbroek size_t); 82433d6423SLionel Sambuc typedef void (*dp_getblock_t)(struct dpeth *, u16_t, int, void *); 83433d6423SLionel Sambuc #endif 84433d6423SLionel Sambuc 85433d6423SLionel Sambuc #define SENDQ_NR 2 /* Size of the send queue */ 86433d6423SLionel Sambuc 87433d6423SLionel Sambuc typedef struct dpeth { 88433d6423SLionel Sambuc /* The de_base_port field is the starting point of the probe. The 89433d6423SLionel Sambuc * conf routine also fills de_linmem and de_irq. If the probe routine 90433d6423SLionel Sambuc * knows the irq and/or memory address because they are hardwired in 91433d6423SLionel Sambuc * the board, the probe should modify these fields. Futhermore, the 92433d6423SLionel Sambuc * probe routine should also fill in de_initf and de_stopf fields 93433d6423SLionel Sambuc * with the appropriate function pointers and set de_prog_IO iff 94433d6423SLionel Sambuc * programmed I/O is to be used. 95433d6423SLionel Sambuc * 96433d6423SLionel Sambuc * The initf function fills the following fields. Only cards that do 97433d6423SLionel Sambuc * programmed I/O fill in the de_data_port field. In addition, the 98433d6423SLionel Sambuc * init routine has to fill in the sendq data structures. */ 99433d6423SLionel Sambuc 100433d6423SLionel Sambuc /* Board hardware interface */ 101433d6423SLionel Sambuc port_t de_base_port; 102433d6423SLionel Sambuc port_t de_data_port; /* For boards using Prog. I/O for xmit/recv */ 103433d6423SLionel Sambuc 104*f7df02e7SDavid van Moolenbroek unsigned int de_irq; 105433d6423SLionel Sambuc int de_hook; /* interrupt hook at kernel */ 106433d6423SLionel Sambuc 107433d6423SLionel Sambuc #define DEI_DEFAULT 0x8000 108433d6423SLionel Sambuc 109433d6423SLionel Sambuc phys_bytes de_linmem; /* For boards using shared memory */ 11091c4db25SDavid van Moolenbroek char *de_locmem; /* Locally mapped (virtual) address */ 111*f7df02e7SDavid van Moolenbroek unsigned int de_ramsize; /* Size of on board memory */ 112*f7df02e7SDavid van Moolenbroek unsigned int de_offset_page; /* Offset of shared memory page */ 113433d6423SLionel Sambuc 114433d6423SLionel Sambuc /* Board specific functions */ 115433d6423SLionel Sambuc dp_eth_t de_initf; 116433d6423SLionel Sambuc dp_eth_t de_stopf; 117433d6423SLionel Sambuc dp_eth_t de_resetf; 118433d6423SLionel Sambuc dp_eth_t de_flagsf; 119433d6423SLionel Sambuc dp_eth_t de_getstatsf; 120433d6423SLionel Sambuc dp_eth_t de_dumpstatsf; 121433d6423SLionel Sambuc dp_eth_t de_interruptf; 12291c4db25SDavid van Moolenbroek dp_recv_t de_recvf; 12391c4db25SDavid van Moolenbroek dp_send_t de_sendf; 124433d6423SLionel Sambuc 125*f7df02e7SDavid van Moolenbroek netdriver_addr_t de_address; /* Ethernet Address */ 126433d6423SLionel Sambuc unsigned long bytes_Tx; /* Total bytes sent/received */ 127433d6423SLionel Sambuc unsigned long bytes_Rx; 128433d6423SLionel Sambuc 129*f7df02e7SDavid van Moolenbroek #define SA_ADDR_LEN sizeof(netdriver_addr_t) 130433d6423SLionel Sambuc 131433d6423SLionel Sambuc int de_flags; /* Send/Receive mode (Configuration) */ 132433d6423SLionel Sambuc 13391c4db25SDavid van Moolenbroek #define DEF_EMPTY 0x00 13491c4db25SDavid van Moolenbroek #define DEF_XMIT_BUSY 0x01 13591c4db25SDavid van Moolenbroek #define DEF_PROMISC 0x02 13691c4db25SDavid van Moolenbroek #define DEF_MULTI 0x04 13791c4db25SDavid van Moolenbroek #define DEF_BROAD 0x08 138433d6423SLionel Sambuc 139433d6423SLionel Sambuc #if ENABLE_DP8390 == 1 140433d6423SLionel Sambuc /* For use by NS DP8390 driver */ 141433d6423SLionel Sambuc port_t de_dp8390_port; 142433d6423SLionel Sambuc int de_prog_IO; 143433d6423SLionel Sambuc int de_16bit; 144*f7df02e7SDavid van Moolenbroek unsigned int de_startpage; 145*f7df02e7SDavid van Moolenbroek unsigned int de_stoppage; 146433d6423SLionel Sambuc 147433d6423SLionel Sambuc /* Do it yourself send queue */ 148433d6423SLionel Sambuc struct sendq { 149433d6423SLionel Sambuc int sq_filled; /* This buffer contains a packet */ 150433d6423SLionel Sambuc int sq_size; /* with this size */ 151433d6423SLionel Sambuc int sq_sendpage; /* starting page of the buffer */ 152433d6423SLionel Sambuc } de_sendq[SENDQ_NR]; 153*f7df02e7SDavid van Moolenbroek unsigned int de_sendq_nr; 154*f7df02e7SDavid van Moolenbroek unsigned int de_sendq_head; /* Enqueue at the head */ 155*f7df02e7SDavid van Moolenbroek unsigned int de_sendq_tail; /* Dequeue at the tail */ 156433d6423SLionel Sambuc 157433d6423SLionel Sambuc dp_user2nicf_t de_user2nicf; 158433d6423SLionel Sambuc dp_nic2userf_t de_nic2userf; 159433d6423SLionel Sambuc dp_getblock_t de_getblockf; 160433d6423SLionel Sambuc #endif 161433d6423SLionel Sambuc 162433d6423SLionel Sambuc #if ENABLE_3C509 == 1 163433d6423SLionel Sambuc /* For use by 3Com Etherlink III (3c509) driver */ 164433d6423SLionel Sambuc port_t de_id_port; 165433d6423SLionel Sambuc port_t de_if_port; 166433d6423SLionel Sambuc #endif 167433d6423SLionel Sambuc 168433d6423SLionel Sambuc #if ENABLE_3C501 == 1 || ENABLE_3C509 == 1 169433d6423SLionel Sambuc /* For use by 3Com Etherlink (3c501 and 3c509) driver */ 170433d6423SLionel Sambuc buff_t *de_recvq_head; 171433d6423SLionel Sambuc buff_t *de_recvq_tail; 172433d6423SLionel Sambuc u16_t de_recv_mode; 173433d6423SLionel Sambuc clock_t de_xmit_start; 174433d6423SLionel Sambuc #endif 175433d6423SLionel Sambuc 176433d6423SLionel Sambuc } dpeth_t; 177433d6423SLionel Sambuc 178433d6423SLionel Sambuc /* 179433d6423SLionel Sambuc * Function definitions 180433d6423SLionel Sambuc */ 181433d6423SLionel Sambuc 182433d6423SLionel Sambuc /* devio.c */ 183433d6423SLionel Sambuc #if defined USE_IOPL 184433d6423SLionel Sambuc #include <machine/portio.h> 185433d6423SLionel Sambuc #else 186433d6423SLionel Sambuc unsigned int inb(unsigned short int); 187433d6423SLionel Sambuc unsigned int inw(unsigned short int); 18891c4db25SDavid van Moolenbroek void insb(unsigned short int, void *, int); 18991c4db25SDavid van Moolenbroek void insw(unsigned short int, void *, int); 190433d6423SLionel Sambuc void outb(unsigned short int, unsigned long); 191433d6423SLionel Sambuc void outw(unsigned short int, unsigned long); 19291c4db25SDavid van Moolenbroek void outsb(unsigned short int, void *, int); 193433d6423SLionel Sambuc #endif 194433d6423SLionel Sambuc 195433d6423SLionel Sambuc /* netbuff.c */ 196433d6423SLionel Sambuc void *alloc_buff(dpeth_t *, int); 197433d6423SLionel Sambuc void free_buff(dpeth_t *, void *); 198433d6423SLionel Sambuc void init_buff(dpeth_t *, buff_t **); 199433d6423SLionel Sambuc 200433d6423SLionel Sambuc /* 3c501.c */ 201433d6423SLionel Sambuc #if ENABLE_3C501 == 1 202433d6423SLionel Sambuc int el1_probe(dpeth_t *); 203433d6423SLionel Sambuc #else 204433d6423SLionel Sambuc #define el1_probe(x) (0) 205433d6423SLionel Sambuc #endif 206433d6423SLionel Sambuc 207433d6423SLionel Sambuc /* 3c503.c */ 208433d6423SLionel Sambuc #if ENABLE_3C503 == 1 209433d6423SLionel Sambuc int el2_probe(dpeth_t *); 210433d6423SLionel Sambuc #else 211433d6423SLionel Sambuc #define el2_probe(x) (0) 212433d6423SLionel Sambuc #endif 213433d6423SLionel Sambuc 214433d6423SLionel Sambuc /* 3c509.c */ 215433d6423SLionel Sambuc #if ENABLE_3C509 == 1 216433d6423SLionel Sambuc int el3_probe(dpeth_t *); 217433d6423SLionel Sambuc #else 218433d6423SLionel Sambuc #define el3_probe(x) (0) 219433d6423SLionel Sambuc #endif 220433d6423SLionel Sambuc 221433d6423SLionel Sambuc /* ne.c */ 222433d6423SLionel Sambuc #if ENABLE_NE2000 == 1 223433d6423SLionel Sambuc int ne_probe(dpeth_t * dep); 224433d6423SLionel Sambuc #else 225433d6423SLionel Sambuc #define ne_probe(x) (0) 226433d6423SLionel Sambuc #endif 227433d6423SLionel Sambuc 228433d6423SLionel Sambuc /* wd.c */ 229433d6423SLionel Sambuc #if ENABLE_WDETH == 1 230433d6423SLionel Sambuc int wdeth_probe(dpeth_t * dep); 231433d6423SLionel Sambuc #else 232433d6423SLionel Sambuc #define wdeth_probe(x) (0) 233433d6423SLionel Sambuc #endif 234433d6423SLionel Sambuc 235433d6423SLionel Sambuc /** dp.h **/ 236