1 /* $OpenBSD: lancevar.h,v 1.3 2015/09/11 13:02:28 stsp Exp $ */ 2 /* $NetBSD: lancevar.h,v 1.15 2012/02/02 19:43:03 tls Exp $ */ 3 4 /*- 5 * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc. 6 * All rights reserved. 7 * 8 * This code is derived from software contributed to The NetBSD Foundation 9 * by Charles M. Hannum and by Jason R. Thorpe of the Numerical Aerospace 10 * Simulation Facility, NASA Ames Research Center. 11 * 12 * Redistribution and use in source and binary forms, with or without 13 * modification, are permitted provided that the following conditions 14 * are met: 15 * 1. Redistributions of source code must retain the above copyright 16 * notice, this list of conditions and the following disclaimer. 17 * 2. Redistributions in binary form must reproduce the above copyright 18 * notice, this list of conditions and the following disclaimer in the 19 * documentation and/or other materials provided with the distribution. 20 * 21 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 22 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 23 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 24 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 25 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 * POSSIBILITY OF SUCH DAMAGE. 32 */ 33 34 struct lance_softc { 35 struct device sc_dev; /* base device glue */ 36 struct arpcom sc_arpcom; /* Ethernet common part */ 37 struct ifmedia sc_ifmedia; /* our supported media */ 38 39 /* 40 * Memory functions: 41 * 42 * copy to/from descriptor 43 * copy to/from buffer 44 * zero bytes in buffer 45 */ 46 void (*sc_copytodesc)(struct lance_softc *, void *, int, int); 47 void (*sc_copyfromdesc)(struct lance_softc *, void *, int, int); 48 void (*sc_copytobuf)(struct lance_softc *, void *, int, int); 49 void (*sc_copyfrombuf)(struct lance_softc *, void *, int, int); 50 void (*sc_zerobuf)(struct lance_softc *, int, int); 51 52 /* 53 * Machine-dependent functions: 54 * 55 * read/write CSR 56 * hardware reset hook - may be NULL 57 * hardware init hook - may be NULL 58 * no carrier hook - may be NULL 59 * media change hook - may be NULL 60 */ 61 uint16_t (*sc_rdcsr)(struct lance_softc *, uint16_t); 62 void (*sc_wrcsr)(struct lance_softc *, uint16_t, uint16_t); 63 void (*sc_hwreset)(struct lance_softc *); 64 void (*sc_hwinit)(struct lance_softc *); 65 void (*sc_nocarrier)(struct lance_softc *); 66 int (*sc_mediachange)(struct lance_softc *); 67 void (*sc_mediastatus)(struct lance_softc *, struct ifmediareq *); 68 69 /* 70 * Media-supported by this interface. If this is NULL, 71 * the only supported media is assumed to be "manual". 72 */ 73 const uint64_t *sc_supmedia; 74 int sc_nsupmedia; 75 uint64_t sc_defaultmedia; 76 77 /* PCnet bit to use software selection of a port */ 78 int sc_initmodemedia; 79 80 int sc_havecarrier; /* carrier status */ 81 82 uint16_t sc_conf3; /* CSR3 value */ 83 uint16_t sc_saved_csr0;/* Value of csr0 at time of interrupt */ 84 85 void *sc_mem; /* base address of RAM -- CPU's view */ 86 u_long sc_addr; /* base address of RAM -- LANCE's view */ 87 88 u_long sc_memsize; /* size of RAM */ 89 90 int sc_nrbuf; /* number of receive buffers */ 91 int sc_ntbuf; /* number of transmit buffers */ 92 int sc_last_rd; 93 int sc_first_td, sc_last_td, sc_no_td; 94 95 int sc_initaddr; 96 int sc_rmdaddr; 97 int sc_tmdaddr; 98 int *sc_rbufaddr; 99 int *sc_tbufaddr; 100 101 #ifdef LEDEBUG 102 int sc_debug; 103 #endif 104 uint8_t sc_enaddr[ETHER_ADDR_LEN]; 105 106 void (*sc_meminit)(struct lance_softc *); 107 void (*sc_start)(struct ifnet *); 108 }; 109 110 extern struct cfdriver le_cd; 111 112 void lance_config(struct lance_softc *); 113 void lance_reset(struct lance_softc *); 114 int lance_init(struct lance_softc *); 115 int lance_put(struct lance_softc *, int, struct mbuf *); 116 struct mbuf *lance_read(struct lance_softc *, int, int); 117 void lance_setladrf(struct arpcom *, uint16_t *); 118 119 /* 120 * The following functions are only useful on certain CPU/bus 121 * combinations. They should be written in assembly language for 122 * maximum efficiency, but machine-independent versions are provided 123 * for drivers that have not yet been optimized. 124 */ 125 void lance_copytobuf_contig(struct lance_softc *, void *, int, int); 126 void lance_copyfrombuf_contig(struct lance_softc *, void *, int, int); 127 void lance_zerobuf_contig(struct lance_softc *, int, int); 128 129 #if 0 /* Example only - see lance.c */ 130 void lance_copytobuf_gap2(struct lance_softc *, void *, int, int); 131 void lance_copyfrombuf_gap2(struct lance_softc *, void *, int, int); 132 void lance_zerobuf_gap2(struct lance_softc *, int, int); 133 134 void lance_copytobuf_gap16(struct lance_softc *, void *, int, int); 135 void lance_copyfrombuf_gap16(struct lance_softc *, void *, int, int); 136 void lance_zerobuf_gap16(struct lance_softc *, int, int); 137 #endif /* Example only */ 138