Home | History | Annotate | Line # | Download | only in dev
if_mcvar.h revision 1.4
      1 /*	$NetBSD: if_mcvar.h,v 1.4 1998/07/04 22:18:27 jonathan Exp $	*/
      2 
      3 /*-
      4  * Copyright (c) 1997 David Huang <khym (at) bga.com>
      5  * All rights reserved.
      6  *
      7  * Redistribution and use in source and binary forms, with or without
      8  * modification, are permitted provided that the following conditions
      9  * are met:
     10  * 1. Redistributions of source code must retain the above copyright
     11  *    notice, this list of conditions and the following disclaimer.
     12  * 2. The name of the author may not be used to endorse or promote products
     13  *    derived from this software without specific prior written permission
     14  *
     15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     16  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     17  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     18  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     19  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     20  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     21  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     22  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     23  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     24  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     25  *
     26  */
     27 
     28 #define	MC_REGSPACING	16
     29 #define	MC_REGSIZE	MACE_NREGS * MC_REGSPACING
     30 #define	MACE_REG(x)	((x)*MC_REGSPACING)
     31 
     32 #define	NIC_GET(sc, reg)	(bus_space_read_1((sc)->sc_regt,	\
     33 				    (sc)->sc_regh, MACE_REG(reg)))
     34 
     35 #define	NIC_PUT(sc, reg, val)	(bus_space_write_1((sc)->sc_regt,	\
     36 				    (sc)->sc_regh, MACE_REG(reg), (val)))
     37 
     38 #ifndef	MC_RXDMABUFS
     39 #define	MC_RXDMABUFS	4
     40 #endif
     41 #if (MC_RXDMABUFS < 2)
     42 #error Must have at least two buffers for DMA!
     43 #endif
     44 
     45 #define	MC_NPAGES	((MC_RXDMABUFS * 0x800 + NBPG - 1) / NBPG)
     46 
     47 struct mc_rxframe {
     48 	u_int8_t	rx_rcvcnt;
     49 	u_int8_t	rx_rcvsts;
     50 	u_int8_t	rx_rntpc;
     51 	u_int8_t	rx_rcvcc;
     52 	u_char		*rx_frame;
     53 };
     54 
     55 struct mc_softc {
     56 	struct device	sc_dev;		/* base device glue */
     57 	struct ethercom	sc_ethercom;	/* Ethernet common part */
     58 #define	sc_if		sc_ethercom.ec_if
     59 
     60 	struct mc_rxframe	sc_rxframe;
     61 	u_int8_t	sc_biucc;
     62 	u_int8_t	sc_fifocc;
     63 	u_int8_t	sc_plscc;
     64 	u_int8_t	sc_enaddr[6];
     65 	u_int8_t	sc_pad[2];
     66 	int		sc_havecarrier; /* carrier status */
     67 	void		(*sc_bus_init) __P((struct mc_softc *));
     68 	void		(*sc_putpacket) __P((struct mc_softc *, u_int));
     69 
     70 	bus_space_tag_t		sc_regt;
     71 	bus_space_handle_t	sc_regh;
     72 
     73 	u_char		*sc_txbuf, *sc_rxbuf;
     74 	int		sc_txbuf_phys, sc_rxbuf_phys;
     75 	int		sc_tail;
     76 	int		sc_rxset;
     77 	int		sc_txset, sc_txseti;
     78 };
     79 
     80 int	mcsetup __P((struct mc_softc *, u_int8_t *));
     81 void	mcintr __P((void *arg));
     82 void	mc_rint __P((struct mc_softc *sc));
     83 u_char	mc_get_enaddr __P((bus_space_tag_t t, bus_space_handle_t h,
     84 	    vm_offset_t o, u_char *dst));
     85