1 | /* $NetBSD: lancevar.h,v 1.16 2015/04/13 16:33:24 riastradh Exp $ */ |
2 | |
3 | /*- |
4 | * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc. |
5 | * All rights reserved. |
6 | * |
7 | * This code is derived from software contributed to The NetBSD Foundation |
8 | * by Charles M. Hannum and by Jason R. Thorpe of the Numerical Aerospace |
9 | * Simulation Facility, NASA Ames Research Center. |
10 | * |
11 | * Redistribution and use in source and binary forms, with or without |
12 | * modification, are permitted provided that the following conditions |
13 | * are met: |
14 | * 1. Redistributions of source code must retain the above copyright |
15 | * notice, this list of conditions and the following disclaimer. |
16 | * 2. Redistributions in binary form must reproduce the above copyright |
17 | * notice, this list of conditions and the following disclaimer in the |
18 | * documentation and/or other materials provided with the distribution. |
19 | * |
20 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS |
21 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
22 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
23 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS |
24 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
30 | * POSSIBILITY OF SUCH DAMAGE. |
31 | */ |
32 | |
33 | #include <sys/rndsource.h> |
34 | |
35 | struct lance_softc { |
36 | device_t sc_dev; /* base device glue */ |
37 | struct ethercom sc_ethercom; /* Ethernet common part */ |
38 | struct ifmedia sc_media; /* our supported media */ |
39 | |
40 | /* |
41 | * Memory functions: |
42 | * |
43 | * copy to/from descriptor |
44 | * copy to/from buffer |
45 | * zero bytes in buffer |
46 | */ |
47 | void (*sc_copytodesc) |
48 | (struct lance_softc *, void *, int, int); |
49 | void (*sc_copyfromdesc) |
50 | (struct lance_softc *, void *, int, int); |
51 | void (*sc_copytobuf) |
52 | (struct lance_softc *, void *, int, int); |
53 | void (*sc_copyfrombuf) |
54 | (struct lance_softc *, void *, int, int); |
55 | void (*sc_zerobuf) |
56 | (struct lance_softc *, int, int); |
57 | |
58 | /* |
59 | * Machine-dependent functions: |
60 | * |
61 | * read/write CSR |
62 | * hardware reset hook - may be NULL |
63 | * hardware init hook - may be NULL |
64 | * no carrier hook - may be NULL |
65 | * media change hook - may be NULL |
66 | */ |
67 | uint16_t (*sc_rdcsr) |
68 | (struct lance_softc *, uint16_t); |
69 | void (*sc_wrcsr) |
70 | (struct lance_softc *, uint16_t, uint16_t); |
71 | void (*sc_hwreset)(struct lance_softc *); |
72 | void (*sc_hwinit)(struct lance_softc *); |
73 | void (*sc_nocarrier)(struct lance_softc *); |
74 | int (*sc_mediachange)(struct lance_softc *); |
75 | void (*sc_mediastatus)(struct lance_softc *, struct ifmediareq *); |
76 | |
77 | /* |
78 | * Media-supported by this interface. If this is NULL, |
79 | * the only supported media is assumed to be "manual". |
80 | */ |
81 | const int *sc_supmedia; |
82 | int sc_nsupmedia; |
83 | int sc_defaultmedia; |
84 | |
85 | /* PCnet bit to use software selection of a port */ |
86 | int sc_initmodemedia; |
87 | |
88 | int sc_havecarrier; /* carrier status */ |
89 | |
90 | uint16_t sc_conf3; /* CSR3 value */ |
91 | uint16_t sc_saved_csr0;/* Value of csr0 at time of interrupt */ |
92 | |
93 | void *sc_mem; /* base address of RAM -- CPU's view */ |
94 | u_long sc_addr; /* base address of RAM -- LANCE's view */ |
95 | |
96 | u_long sc_memsize; /* size of RAM */ |
97 | |
98 | int sc_nrbuf; /* number of receive buffers */ |
99 | int sc_ntbuf; /* number of transmit buffers */ |
100 | int sc_last_rd; |
101 | int sc_first_td, sc_last_td, sc_no_td; |
102 | |
103 | int sc_initaddr; |
104 | int sc_rmdaddr; |
105 | int sc_tmdaddr; |
106 | int *sc_rbufaddr; |
107 | int *sc_tbufaddr; |
108 | |
109 | #ifdef LEDEBUG |
110 | int sc_debug; |
111 | #endif |
112 | uint8_t sc_enaddr[ETHER_ADDR_LEN]; |
113 | uint8_t sc_pad[2]; |
114 | krndsource_t rnd_source; |
115 | |
116 | void (*sc_meminit)(struct lance_softc *); |
117 | void (*sc_start)(struct ifnet *); |
118 | }; |
119 | |
120 | void lance_config(struct lance_softc *); |
121 | void lance_reset(struct lance_softc *); |
122 | int lance_init(struct ifnet *); |
123 | int lance_put(struct lance_softc *, int, struct mbuf *); |
124 | void lance_read(struct lance_softc *, int, int); |
125 | void lance_setladrf(struct ethercom *, uint16_t *); |
126 | |
127 | /* |
128 | * The following functions are only useful on certain CPU/bus |
129 | * combinations. They should be written in assembly language for |
130 | * maximum efficiency, but machine-independent versions are provided |
131 | * for drivers that have not yet been optimized. |
132 | */ |
133 | void lance_copytobuf_contig(struct lance_softc *, void *, int, int); |
134 | void lance_copyfrombuf_contig(struct lance_softc *, void *, int, int); |
135 | void lance_zerobuf_contig(struct lance_softc *, int, int); |
136 | |
137 | #if 0 /* Example only - see lance.c */ |
138 | void lance_copytobuf_gap2(struct lance_softc *, void *, int, int); |
139 | void lance_copyfrombuf_gap2(struct lance_softc *, void *, int, int); |
140 | void lance_zerobuf_gap2(struct lance_softc *, int, int); |
141 | |
142 | void lance_copytobuf_gap16(struct lance_softc *, void *, int, int); |
143 | void lance_copyfrombuf_gap16(struct lance_softc *, void *, int, int); |
144 | void lance_zerobuf_gap16(struct lance_softc *, int, int); |
145 | #endif /* Example only */ |
146 | |