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