1*f2a0e423Sstsp /* $OpenBSD: lancevar.h,v 1.3 2015/09/11 13:02:28 stsp Exp $ */ 20ec3b04cSmiod /* $NetBSD: lancevar.h,v 1.15 2012/02/02 19:43:03 tls Exp $ */ 30ec3b04cSmiod 40ec3b04cSmiod /*- 50ec3b04cSmiod * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc. 60ec3b04cSmiod * All rights reserved. 70ec3b04cSmiod * 80ec3b04cSmiod * This code is derived from software contributed to The NetBSD Foundation 90ec3b04cSmiod * by Charles M. Hannum and by Jason R. Thorpe of the Numerical Aerospace 100ec3b04cSmiod * Simulation Facility, NASA Ames Research Center. 110ec3b04cSmiod * 120ec3b04cSmiod * Redistribution and use in source and binary forms, with or without 130ec3b04cSmiod * modification, are permitted provided that the following conditions 140ec3b04cSmiod * are met: 150ec3b04cSmiod * 1. Redistributions of source code must retain the above copyright 160ec3b04cSmiod * notice, this list of conditions and the following disclaimer. 170ec3b04cSmiod * 2. Redistributions in binary form must reproduce the above copyright 180ec3b04cSmiod * notice, this list of conditions and the following disclaimer in the 190ec3b04cSmiod * documentation and/or other materials provided with the distribution. 200ec3b04cSmiod * 210ec3b04cSmiod * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 220ec3b04cSmiod * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 230ec3b04cSmiod * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 240ec3b04cSmiod * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 250ec3b04cSmiod * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 260ec3b04cSmiod * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 270ec3b04cSmiod * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 280ec3b04cSmiod * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 290ec3b04cSmiod * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 300ec3b04cSmiod * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 310ec3b04cSmiod * POSSIBILITY OF SUCH DAMAGE. 320ec3b04cSmiod */ 330ec3b04cSmiod 340ec3b04cSmiod struct lance_softc { 350ec3b04cSmiod struct device sc_dev; /* base device glue */ 360ec3b04cSmiod struct arpcom sc_arpcom; /* Ethernet common part */ 370ec3b04cSmiod struct ifmedia sc_ifmedia; /* our supported media */ 380ec3b04cSmiod 390ec3b04cSmiod /* 400ec3b04cSmiod * Memory functions: 410ec3b04cSmiod * 420ec3b04cSmiod * copy to/from descriptor 430ec3b04cSmiod * copy to/from buffer 440ec3b04cSmiod * zero bytes in buffer 450ec3b04cSmiod */ 460ec3b04cSmiod void (*sc_copytodesc)(struct lance_softc *, void *, int, int); 470ec3b04cSmiod void (*sc_copyfromdesc)(struct lance_softc *, void *, int, int); 480ec3b04cSmiod void (*sc_copytobuf)(struct lance_softc *, void *, int, int); 490ec3b04cSmiod void (*sc_copyfrombuf)(struct lance_softc *, void *, int, int); 500ec3b04cSmiod void (*sc_zerobuf)(struct lance_softc *, int, int); 510ec3b04cSmiod 520ec3b04cSmiod /* 530ec3b04cSmiod * Machine-dependent functions: 540ec3b04cSmiod * 550ec3b04cSmiod * read/write CSR 560ec3b04cSmiod * hardware reset hook - may be NULL 570ec3b04cSmiod * hardware init hook - may be NULL 580ec3b04cSmiod * no carrier hook - may be NULL 590ec3b04cSmiod * media change hook - may be NULL 600ec3b04cSmiod */ 610ec3b04cSmiod uint16_t (*sc_rdcsr)(struct lance_softc *, uint16_t); 620ec3b04cSmiod void (*sc_wrcsr)(struct lance_softc *, uint16_t, uint16_t); 630ec3b04cSmiod void (*sc_hwreset)(struct lance_softc *); 640ec3b04cSmiod void (*sc_hwinit)(struct lance_softc *); 650ec3b04cSmiod void (*sc_nocarrier)(struct lance_softc *); 660ec3b04cSmiod int (*sc_mediachange)(struct lance_softc *); 670ec3b04cSmiod void (*sc_mediastatus)(struct lance_softc *, struct ifmediareq *); 680ec3b04cSmiod 690ec3b04cSmiod /* 700ec3b04cSmiod * Media-supported by this interface. If this is NULL, 710ec3b04cSmiod * the only supported media is assumed to be "manual". 720ec3b04cSmiod */ 73*f2a0e423Sstsp const uint64_t *sc_supmedia; 740ec3b04cSmiod int sc_nsupmedia; 75*f2a0e423Sstsp uint64_t sc_defaultmedia; 760ec3b04cSmiod 770ec3b04cSmiod /* PCnet bit to use software selection of a port */ 780ec3b04cSmiod int sc_initmodemedia; 790ec3b04cSmiod 800ec3b04cSmiod int sc_havecarrier; /* carrier status */ 810ec3b04cSmiod 820ec3b04cSmiod uint16_t sc_conf3; /* CSR3 value */ 830ec3b04cSmiod uint16_t sc_saved_csr0;/* Value of csr0 at time of interrupt */ 840ec3b04cSmiod 850ec3b04cSmiod void *sc_mem; /* base address of RAM -- CPU's view */ 860ec3b04cSmiod u_long sc_addr; /* base address of RAM -- LANCE's view */ 870ec3b04cSmiod 880ec3b04cSmiod u_long sc_memsize; /* size of RAM */ 890ec3b04cSmiod 900ec3b04cSmiod int sc_nrbuf; /* number of receive buffers */ 910ec3b04cSmiod int sc_ntbuf; /* number of transmit buffers */ 920ec3b04cSmiod int sc_last_rd; 930ec3b04cSmiod int sc_first_td, sc_last_td, sc_no_td; 940ec3b04cSmiod 950ec3b04cSmiod int sc_initaddr; 960ec3b04cSmiod int sc_rmdaddr; 970ec3b04cSmiod int sc_tmdaddr; 980ec3b04cSmiod int *sc_rbufaddr; 990ec3b04cSmiod int *sc_tbufaddr; 1000ec3b04cSmiod 1010ec3b04cSmiod #ifdef LEDEBUG 1020ec3b04cSmiod int sc_debug; 1030ec3b04cSmiod #endif 1040ec3b04cSmiod uint8_t sc_enaddr[ETHER_ADDR_LEN]; 1050ec3b04cSmiod 1060ec3b04cSmiod void (*sc_meminit)(struct lance_softc *); 1070ec3b04cSmiod void (*sc_start)(struct ifnet *); 1080ec3b04cSmiod }; 1090ec3b04cSmiod 1100ec3b04cSmiod extern struct cfdriver le_cd; 1110ec3b04cSmiod 1120ec3b04cSmiod void lance_config(struct lance_softc *); 1130ec3b04cSmiod void lance_reset(struct lance_softc *); 1140ec3b04cSmiod int lance_init(struct lance_softc *); 1150ec3b04cSmiod int lance_put(struct lance_softc *, int, struct mbuf *); 1160d918b5eSmpi struct mbuf *lance_read(struct lance_softc *, int, int); 1170ec3b04cSmiod void lance_setladrf(struct arpcom *, uint16_t *); 1180ec3b04cSmiod 1190ec3b04cSmiod /* 1200ec3b04cSmiod * The following functions are only useful on certain CPU/bus 1210ec3b04cSmiod * combinations. They should be written in assembly language for 1220ec3b04cSmiod * maximum efficiency, but machine-independent versions are provided 1230ec3b04cSmiod * for drivers that have not yet been optimized. 1240ec3b04cSmiod */ 1250ec3b04cSmiod void lance_copytobuf_contig(struct lance_softc *, void *, int, int); 1260ec3b04cSmiod void lance_copyfrombuf_contig(struct lance_softc *, void *, int, int); 1270ec3b04cSmiod void lance_zerobuf_contig(struct lance_softc *, int, int); 1280ec3b04cSmiod 1290ec3b04cSmiod #if 0 /* Example only - see lance.c */ 1300ec3b04cSmiod void lance_copytobuf_gap2(struct lance_softc *, void *, int, int); 1310ec3b04cSmiod void lance_copyfrombuf_gap2(struct lance_softc *, void *, int, int); 1320ec3b04cSmiod void lance_zerobuf_gap2(struct lance_softc *, int, int); 1330ec3b04cSmiod 1340ec3b04cSmiod void lance_copytobuf_gap16(struct lance_softc *, void *, int, int); 1350ec3b04cSmiod void lance_copyfrombuf_gap16(struct lance_softc *, void *, int, int); 1360ec3b04cSmiod void lance_zerobuf_gap16(struct lance_softc *, int, int); 1370ec3b04cSmiod #endif /* Example only */ 138