if_mcvar.h revision 1.5 1 /* $NetBSD: if_mcvar.h,v 1.5 2001/07/11 22:11:29 briggs 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 #if defined(_KERNEL_OPT)
29 #include "opt_ddb.h"
30 #include "opt_kgdb.h"
31 #endif
32
33 #include <macppc/dev/dbdma.h>
34
35 #if defined(DDB) || defined(KGDB)
36 #define integrate
37 #define hide
38 #else
39 #define integrate static /*__inline*/
40 #define hide static
41 #endif
42
43 #define MC_REGSPACING 16
44 #define MC_REGSIZE MACE_NREGS * MC_REGSPACING
45 #define MACE_REG(x) ((x)*MC_REGSPACING)
46
47 #define NIC_GET(sc, reg) (bus_space_read_1((sc)->sc_regt, \
48 (sc)->sc_regh, MACE_REG(reg)))
49 #define NIC_PUT(sc, reg, val) (bus_space_write_1((sc)->sc_regt, \
50 (sc)->sc_regh, MACE_REG(reg), (val)))
51
52 #ifndef MC_RXDMABUFS
53 #define MC_RXDMABUFS 4
54 #endif
55 #if (MC_RXDMABUFS < 2)
56 #error Must have at least two buffers for DMA!
57 #endif
58
59 #define MC_NPAGES ((MC_RXDMABUFS * 0x800 + NBPG - 1) / NBPG)
60
61 struct mc_rxframe {
62 u_int8_t rx_rcvcnt;
63 u_int8_t rx_rcvsts;
64 u_int8_t rx_rntpc;
65 u_int8_t rx_rcvcc;
66 u_char *rx_frame;
67 };
68
69 struct mc_softc {
70 struct device sc_dev; /* base device glue */
71 struct ethercom sc_ethercom; /* Ethernet common part */
72 #define sc_if sc_ethercom.ec_if
73 struct ifmedia sc_media;
74
75 struct mc_rxframe sc_rxframe;
76 u_int8_t sc_biucc;
77 u_int8_t sc_fifocc;
78 u_int8_t sc_plscc;
79 u_int8_t sc_enaddr[6];
80 u_int8_t sc_pad[2];
81 int sc_havecarrier; /* carrier status */
82 void (*sc_bus_init) __P((struct mc_softc *));
83 void (*sc_putpacket) __P((struct mc_softc *, u_int));
84 int (*sc_mediachange) __P((struct mc_softc *));
85 void (*sc_mediastatus) __P((struct mc_softc *,
86 struct ifmediareq *));
87
88 bus_space_tag_t sc_regt;
89 bus_space_handle_t sc_regh;
90
91 u_char *sc_txbuf, *sc_rxbuf;
92 int sc_txbuf_phys, sc_rxbuf_phys;
93 int sc_tail;
94
95 int sc_node;
96 dbdma_regmap_t *sc_txdma;
97 dbdma_command_t *sc_txdmacmd;
98 dbdma_regmap_t *sc_rxdma;
99 dbdma_command_t *sc_rxdmacmd;
100 };
101
102 int mcsetup __P((struct mc_softc *, u_int8_t *));
103 int mcintr __P((void *arg));
104 void mc_rint __P((struct mc_softc *sc));
105