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