am7990var.h revision 1.13 1 /* $NetBSD: am7990var.h,v 1.13 1997/03/27 21:01:50 veego Exp $ */
2
3 /*
4 * Copyright (c) 1997 Jason R. Thorpe. All rights reserved.
5 * Copyright (c) 1995 Charles M. Hannum. 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. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by Charles M. Hannum.
18 * 4. The name of the author may not be used to endorse or promote products
19 * derived from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */
32
33 #ifdef DDB
34 #define integrate
35 #define hide
36 #else
37 #define integrate static __inline
38 #define hide static
39 #endif
40
41 /*
42 * Ethernet software status per device.
43 *
44 * Each interface is referenced by a network interface structure,
45 * ethercom.ec_if, which the routing code uses to locate the interface.
46 * This structure contains the output queue for the interface, its address, ...
47 *
48 * NOTE: this structure MUST be the first element in machine-dependent
49 * le_softc structures! This is designed SPECIFICALLY to make it possible
50 * to simply cast a "void *" to "struct le_softc *" or to
51 * "struct am7990_softc *". Among other things, this saves a lot of hair
52 * in the interrupt handlers.
53 */
54 struct am7990_softc {
55 struct device sc_dev; /* base device glue */
56 struct ethercom sc_ethercom; /* Ethernet common part */
57 struct ifmedia sc_media; /* our supported media */
58
59 /*
60 * Memory functions:
61 *
62 * copy to/from descriptor
63 * copy to/from buffer
64 * zero bytes in buffer
65 */
66 void (*sc_copytodesc)
67 __P((struct am7990_softc *, void *, int, int));
68 void (*sc_copyfromdesc)
69 __P((struct am7990_softc *, void *, int, int));
70 void (*sc_copytobuf)
71 __P((struct am7990_softc *, void *, int, int));
72 void (*sc_copyfrombuf)
73 __P((struct am7990_softc *, void *, int, int));
74 void (*sc_zerobuf)
75 __P((struct am7990_softc *, int, int));
76
77 /*
78 * Machine-dependent functions:
79 *
80 * read/write CSR
81 * hardware reset hook - may be NULL
82 * hardware init hook - may be NULL
83 * no carrier hook - may be NULL
84 * media change hook - may be NULL
85 */
86 u_int16_t (*sc_rdcsr)
87 __P((struct am7990_softc *, u_int16_t));
88 void (*sc_wrcsr)
89 __P((struct am7990_softc *, u_int16_t, u_int16_t));
90 void (*sc_hwreset) __P((struct am7990_softc *));
91 void (*sc_hwinit) __P((struct am7990_softc *));
92 void (*sc_nocarrier) __P((struct am7990_softc *));
93 int (*sc_mediachange) __P((struct am7990_softc *));
94 void (*sc_mediastatus) __P((struct am7990_softc *,
95 struct ifmediareq *));
96
97 /*
98 * Media-supported by this interface. If this is NULL,
99 * the only supported media is assumed to be "manual".
100 */
101 int *sc_supmedia;
102 int sc_nsupmedia;
103 int sc_defaultmedia;
104
105 /* PCnet bit to use software selection of a port */
106 int sc_initmodemedia;
107
108 int sc_havecarrier; /* carrier status */
109
110 void *sc_sh; /* shutdownhook cookie */
111
112 u_int16_t sc_conf3; /* CSR3 value */
113 u_int16_t sc_saved_csr0;/* Value of csr0 at time of interrupt */
114
115 void *sc_mem; /* base address of RAM -- CPU's view */
116 u_long sc_addr; /* base address of RAM -- LANCE's view */
117
118 u_long sc_memsize; /* size of RAM */
119
120 int sc_nrbuf; /* number of receive buffers */
121 int sc_ntbuf; /* number of transmit buffers */
122 int sc_last_rd;
123 int sc_first_td, sc_last_td, sc_no_td;
124
125 int sc_initaddr;
126 int sc_rmdaddr;
127 int sc_tmdaddr;
128 int *sc_rbufaddr;
129 int *sc_tbufaddr;
130
131 #ifdef LEDEBUG
132 int sc_debug;
133 #endif
134 u_int8_t sc_enaddr[6];
135 u_int8_t sc_pad[2];
136 };
137
138 /* Export this to machine-dependent drivers. */
139 extern struct cfdriver le_cd;
140
141 void am7990_config __P((struct am7990_softc *));
142 void am7990_init __P((struct am7990_softc *));
143 int am7990_ioctl __P((struct ifnet *, u_long, caddr_t));
144 void am7990_meminit __P((struct am7990_softc *));
145 void am7990_reset __P((struct am7990_softc *));
146 void am7990_setladrf __P((struct ethercom *, u_int16_t *));
147 void am7990_start __P((struct ifnet *));
148 void am7990_stop __P((struct am7990_softc *));
149 void am7990_watchdog __P((struct ifnet *));
150 int am7990_intr __P((void *));
151
152 /*
153 * The following functions are only useful on certain cpu/bus
154 * combinations. They should be written in assembly language for
155 * maximum efficiency, but machine-independent versions are provided
156 * for drivers that have not yet been optimized.
157 */
158 void am7990_copytobuf_contig __P((struct am7990_softc *, void *, int, int));
159 void am7990_copyfrombuf_contig __P((struct am7990_softc *, void *, int, int));
160 void am7990_zerobuf_contig __P((struct am7990_softc *, int, int));
161
162 #if 0 /* Example only - see am7990.c */
163 void am7990_copytobuf_gap2 __P((struct am7990_softc *, void *, int, int));
164 void am7990_copyfrombuf_gap2 __P((struct am7990_softc *, void *, int, int));
165 void am7990_zerobuf_gap2 __P((struct am7990_softc *, int, int));
166
167 void am7990_copytobuf_gap16 __P((struct am7990_softc *, void *, int, int));
168 void am7990_copyfrombuf_gap16 __P((struct am7990_softc *, void *, int, int));
169 void am7990_zerobuf_gap16 __P((struct am7990_softc *, int, int));
170 #endif /* Example only */
171