Tue Sep 29 23:59:45 2009 UTC ()
Pull up following revision(s) (requested by bouyer in ticket #1040):
	sys/dev/isa/if_tr_isa.c: revision 1.19
Fix printf format after bus_size_t change


(snj)
diff -r1.18 -r1.18.10.1 src/sys/dev/isa/if_tr_isa.c

cvs diff -r1.18 -r1.18.10.1 src/sys/dev/isa/Attic/if_tr_isa.c (switch to unified diff)

--- src/sys/dev/isa/Attic/if_tr_isa.c 2008/04/28 20:23:52 1.18
+++ src/sys/dev/isa/Attic/if_tr_isa.c 2009/09/29 23:59:45 1.18.10.1
@@ -1,272 +1,272 @@ @@ -1,272 +1,272 @@
1/* $NetBSD: if_tr_isa.c,v 1.18 2008/04/28 20:23:52 martin Exp $ */ 1/* $NetBSD: if_tr_isa.c,v 1.18.10.1 2009/09/29 23:59:45 snj Exp $ */
2 2
3/* XXXJRT changes isa_attach_args too early!! */ 3/* XXXJRT changes isa_attach_args too early!! */
4 4
5/* 5/*
6 * Copyright (c) 1999 The NetBSD Foundation, Inc. 6 * Copyright (c) 1999 The NetBSD Foundation, Inc.
7 * All rights reserved. 7 * All rights reserved.
8 * 8 *
9 * This code is derived from software contributed to The NetBSD Foundation 9 * This code is derived from software contributed to The NetBSD Foundation
10 * by Onno van der Linden. 10 * by Onno van der Linden.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions 13 * modification, are permitted provided that the following conditions
14 * are met: 14 * are met:
15 * 1. Redistributions of source code must retain the above copyright 15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer. 16 * notice, this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright 17 * 2. Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in the 18 * notice, this list of conditions and the following disclaimer in the
19 * documentation and/or other materials provided with the distribution. 19 * documentation and/or other materials provided with the distribution.
20 * 20 *
21 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 21 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
22 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 22 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
23 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 24 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
25 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 * POSSIBILITY OF SUCH DAMAGE. 31 * POSSIBILITY OF SUCH DAMAGE.
32 */ 32 */
33 33
34#include <sys/cdefs.h> 34#include <sys/cdefs.h>
35__KERNEL_RCSID(0, "$NetBSD: if_tr_isa.c,v 1.18 2008/04/28 20:23:52 martin Exp $"); 35__KERNEL_RCSID(0, "$NetBSD: if_tr_isa.c,v 1.18.10.1 2009/09/29 23:59:45 snj Exp $");
36 36
37#undef TRISADEBUG 37#undef TRISADEBUG
38 38
39#include <sys/param.h> 39#include <sys/param.h>
40#include <sys/systm.h> 40#include <sys/systm.h>
41#include <sys/socket.h> 41#include <sys/socket.h>
42#include <sys/device.h> 42#include <sys/device.h>
43 43
44#include <net/if.h> 44#include <net/if.h>
45#include <net/if_ether.h> 45#include <net/if_ether.h>
46#include <net/if_media.h> 46#include <net/if_media.h>
47 47
48#include <sys/cpu.h> 48#include <sys/cpu.h>
49#include <sys/bus.h> 49#include <sys/bus.h>
50#include <sys/intr.h> 50#include <sys/intr.h>
51 51
52#include <dev/isa/isavar.h> 52#include <dev/isa/isavar.h>
53 53
54#include <dev/ic/tropicreg.h> 54#include <dev/ic/tropicreg.h>
55#include <dev/ic/tropicvar.h> 55#include <dev/ic/tropicvar.h>
56 56
57 57
58int tr_isa_probe(struct device *, struct cfdata *, void *); 58int tr_isa_probe(struct device *, struct cfdata *, void *);
59int trtcm_isa_probe(struct device *, struct cfdata *, void *); 59int trtcm_isa_probe(struct device *, struct cfdata *, void *);
60int tribm_isa_probe(struct device *, struct cfdata *, void *); 60int tribm_isa_probe(struct device *, struct cfdata *, void *);
61void tr_isa_attach(struct device *, struct device *, void *); 61void tr_isa_attach(struct device *, struct device *, void *);
62int tr_isa_map_io(struct isa_attach_args *, bus_space_handle_t *, 62int tr_isa_map_io(struct isa_attach_args *, bus_space_handle_t *,
63 bus_space_handle_t *); 63 bus_space_handle_t *);
64void tr_isa_unmap_io(struct isa_attach_args *, bus_space_handle_t, 64void tr_isa_unmap_io(struct isa_attach_args *, bus_space_handle_t,
65 bus_space_handle_t); 65 bus_space_handle_t);
66int trtcm_isa_mediachange(struct tr_softc *); 66int trtcm_isa_mediachange(struct tr_softc *);
67void trtcm_isa_mediastatus(struct tr_softc *, struct ifmediareq *); 67void trtcm_isa_mediastatus(struct tr_softc *, struct ifmediareq *);
68#ifdef TRISADEBUG 68#ifdef TRISADEBUG
69void tr_isa_dumpaip(bus_space_tag_t, bus_space_handle_t); 69void tr_isa_dumpaip(bus_space_tag_t, bus_space_handle_t);
70#endif 70#endif
71 71
72/* 72/*
73 * List of manufacturer specific probe routines. Order is important. 73 * List of manufacturer specific probe routines. Order is important.
74 */ 74 */
75int (*tr_isa_probe_list[])(struct device *, struct cfdata *, void *) = { 75int (*tr_isa_probe_list[])(struct device *, struct cfdata *, void *) = {
76 trtcm_isa_probe, 76 trtcm_isa_probe,
77 tribm_isa_probe, 77 tribm_isa_probe,
78 0 78 0
79 }; 79 };
80 80
81CFATTACH_DECL(tr_isa, sizeof(struct tr_softc), 81CFATTACH_DECL(tr_isa, sizeof(struct tr_softc),
82 tr_isa_probe, tr_isa_attach, NULL, NULL); 82 tr_isa_probe, tr_isa_attach, NULL, NULL);
83 83
84int 84int
85tr_isa_map_io(ia, pioh, mmioh) 85tr_isa_map_io(ia, pioh, mmioh)
86struct isa_attach_args *ia; 86struct isa_attach_args *ia;
87bus_space_handle_t *pioh, *mmioh; 87bus_space_handle_t *pioh, *mmioh;
88{ 88{
89 bus_size_t mmio; 89 bus_size_t mmio;
90 u_int8_t s; 90 u_int8_t s;
91 91
92 if (bus_space_map(ia->ia_iot, ia->ia_io[0].ir_addr, 92 if (bus_space_map(ia->ia_iot, ia->ia_io[0].ir_addr,
93 ia->ia_io[0].ir_size, 0, pioh)) { 93 ia->ia_io[0].ir_size, 0, pioh)) {
94 printf("tr_isa_map_io: can't map PIO ports\n"); 94 printf("tr_isa_map_io: can't map PIO ports\n");
95 return 1; 95 return 1;
96 } 96 }
97 97
98 /* Read adapter switches and calculate addresses of MMIO. */ 98 /* Read adapter switches and calculate addresses of MMIO. */
99 s = bus_space_read_1(ia->ia_iot, *pioh, TR_SWITCH); 99 s = bus_space_read_1(ia->ia_iot, *pioh, TR_SWITCH);
100 100
101 if ((s & 0xfc) < ((TR_MMIO_MINADDR - TR_MMIO_OFFSET) >> 11) || 101 if ((s & 0xfc) < ((TR_MMIO_MINADDR - TR_MMIO_OFFSET) >> 11) ||
102 (s & 0xfc) > ((TR_MMIO_MAXADDR - TR_MMIO_OFFSET) >> 11)) { 102 (s & 0xfc) > ((TR_MMIO_MAXADDR - TR_MMIO_OFFSET) >> 11)) {
103 bus_space_unmap(ia->ia_iot, *pioh, ia->ia_io[0].ir_size); 103 bus_space_unmap(ia->ia_iot, *pioh, ia->ia_io[0].ir_size);
104 return 1; 104 return 1;
105 } 105 }
106 106
107 mmio = ((s & 0xfc) << 11) + TR_MMIO_OFFSET; 107 mmio = ((s & 0xfc) << 11) + TR_MMIO_OFFSET;
108 if (bus_space_map(ia->ia_memt, mmio, TR_MMIO_SIZE, 0, mmioh)) { 108 if (bus_space_map(ia->ia_memt, mmio, TR_MMIO_SIZE, 0, mmioh)) {
109 printf("tr_isa_map_io: can't map MMIO region 0x%05lx/%d\n", 109 printf("tr_isa_map_io: can't map MMIO region 0x%05lx/%d\n",
110 mmio, TR_MMIO_SIZE); 110 (u_long)mmio, TR_MMIO_SIZE);
111 bus_space_unmap(ia->ia_iot, *pioh, ia->ia_io[0].ir_size); 111 bus_space_unmap(ia->ia_iot, *pioh, ia->ia_io[0].ir_size);
112 return 1; 112 return 1;
113 } 113 }
114 return 0; 114 return 0;
115} 115}
116 116
117void 117void
118tr_isa_unmap_io(ia, pioh, mmioh) 118tr_isa_unmap_io(ia, pioh, mmioh)
119struct isa_attach_args *ia; 119struct isa_attach_args *ia;
120bus_space_handle_t pioh, mmioh; 120bus_space_handle_t pioh, mmioh;
121{ 121{
122 bus_space_unmap(ia->ia_memt, mmioh, TR_MMIO_SIZE); 122 bus_space_unmap(ia->ia_memt, mmioh, TR_MMIO_SIZE);
123 bus_space_unmap(ia->ia_iot, pioh, ia->ia_io[0].ir_size); 123 bus_space_unmap(ia->ia_iot, pioh, ia->ia_io[0].ir_size);
124} 124}
125 125
126static u_char tr_isa_id[] = { 126static u_char tr_isa_id[] = {
127 5, 0, 4, 9, 4, 3, 4, 15, 3, 6, 3, 1, 3, 1, 3, 0, 3, 9, 3, 9, 3, 0, 2, 0 127 5, 0, 4, 9, 4, 3, 4, 15, 3, 6, 3, 1, 3, 1, 3, 0, 3, 9, 3, 9, 3, 0, 2, 0
128}; 128};
129 129
130/* 130/*
131 * XXX handle multiple IBM TR cards (sram mapping !!) 131 * XXX handle multiple IBM TR cards (sram mapping !!)
132 */ 132 */
133 133
134int 134int
135tr_isa_probe(parent, match, aux) 135tr_isa_probe(parent, match, aux)
136 struct device *parent; 136 struct device *parent;
137 struct cfdata *match; 137 struct cfdata *match;
138 void *aux; 138 void *aux;
139{ 139{
140 struct isa_attach_args *ia = aux; 140 struct isa_attach_args *ia = aux;
141 int i; 141 int i;
142 bus_size_t tr_id; 142 bus_size_t tr_id;
143 bus_space_handle_t sramh, pioh, mmioh; 143 bus_space_handle_t sramh, pioh, mmioh;
144 int probecode; 144 int probecode;
145 int matched = 0; 145 int matched = 0;
146 146
147 if (ia->ia_nio < 1) 147 if (ia->ia_nio < 1)
148 return (0); 148 return (0);
149 if (ia->ia_niomem < 1) 149 if (ia->ia_niomem < 1)
150 return (0); 150 return (0);
151 if (ia->ia_nirq < 1) 151 if (ia->ia_nirq < 1)
152 return (0); 152 return (0);
153 153
154 if (ISA_DIRECT_CONFIG(ia)) 154 if (ISA_DIRECT_CONFIG(ia))
155 return (0); 155 return (0);
156 156
157 for (i = 0; tr_isa_probe_list[i] != 0; i++) { 157 for (i = 0; tr_isa_probe_list[i] != 0; i++) {
158 probecode = tr_isa_probe_list[i](parent, match, aux); 158 probecode = tr_isa_probe_list[i](parent, match, aux);
159 if (probecode < 0) 159 if (probecode < 0)
160 return 0; /* Fail instantly. */ 160 return 0; /* Fail instantly. */
161 if (probecode > 0) 161 if (probecode > 0)
162 break; /* We have a match. */ 162 break; /* We have a match. */
163 } 163 }
164 if (tr_isa_probe_list[i] == 0) 164 if (tr_isa_probe_list[i] == 0)
165 return 0; /* Nothing matched. */ 165 return 0; /* Nothing matched. */
166 if (tr_isa_map_io(ia, &pioh, &mmioh)) 166 if (tr_isa_map_io(ia, &pioh, &mmioh))
167 return 0; 167 return 0;
168 tr_id = TR_ID_OFFSET; 168 tr_id = TR_ID_OFFSET;
169 matched = 1; 169 matched = 1;
170 for (i = 0; i < sizeof(tr_isa_id); i++) { 170 for (i = 0; i < sizeof(tr_isa_id); i++) {
171 if (bus_space_read_1(ia->ia_memt, mmioh, tr_id) != 171 if (bus_space_read_1(ia->ia_memt, mmioh, tr_id) !=
172 tr_isa_id[i]) 172 tr_isa_id[i])
173 matched = 0; 173 matched = 0;
174 tr_id += 2; 174 tr_id += 2;
175 } 175 }
176#ifdef TRISADEBUG 176#ifdef TRISADEBUG
177 tr_isa_dumpaip(ia->ia_memt, mmioh); 177 tr_isa_dumpaip(ia->ia_memt, mmioh);
178#endif 178#endif
179 tr_isa_unmap_io(ia, pioh, mmioh); 179 tr_isa_unmap_io(ia, pioh, mmioh);
180 if (!matched) { 180 if (!matched) {
181 return 0; 181 return 0;
182 } 182 }
183 if (bus_space_map(ia->ia_memt, ia->ia_iomem[0].ir_addr, 183 if (bus_space_map(ia->ia_memt, ia->ia_iomem[0].ir_addr,
184 ia->ia_iomem[0].ir_size, 0, &sramh)) { 184 ia->ia_iomem[0].ir_size, 0, &sramh)) {
185 printf("tr_isa_probe: can't map shared ram\n"); 185 printf("tr_isa_probe: can't map shared ram\n");
186 return 0; 186 return 0;
187 } 187 }
188 bus_space_unmap(ia->ia_memt, sramh, ia->ia_iomem[0].ir_size); 188 bus_space_unmap(ia->ia_memt, sramh, ia->ia_iomem[0].ir_size);
189 189
190 ia->ia_nio = 1; 190 ia->ia_nio = 1;
191 ia->ia_niomem = 1; 191 ia->ia_niomem = 1;
192 ia->ia_nirq = 1; 192 ia->ia_nirq = 1;
193 193
194 ia->ia_ndrq = 0; 194 ia->ia_ndrq = 0;
195 195
196 return 1; 196 return 1;
197} 197}
198 198
199int trtcm_setspeed(struct tr_softc *, int); 199int trtcm_setspeed(struct tr_softc *, int);
200 200
201void 201void
202tr_isa_attach(struct device *parent, struct device *self, void *aux) 202tr_isa_attach(struct device *parent, struct device *self, void *aux)
203{ 203{
204 struct tr_softc *sc = (void *) self; 204 struct tr_softc *sc = (void *) self;
205 struct isa_attach_args *ia = aux; 205 struct isa_attach_args *ia = aux;
206 206
207 printf("\n"); 207 printf("\n");
208 208
209 sc->sc_piot = ia->ia_iot; 209 sc->sc_piot = ia->ia_iot;
210 sc->sc_memt = ia->ia_memt; 210 sc->sc_memt = ia->ia_memt;
211 if (tr_isa_map_io(ia, &sc->sc_pioh, &sc->sc_mmioh)) { 211 if (tr_isa_map_io(ia, &sc->sc_pioh, &sc->sc_mmioh)) {
212 printf("tr_isa_attach: IO space vanished\n"); 212 printf("tr_isa_attach: IO space vanished\n");
213 return; 213 return;
214 } 214 }
215 if (bus_space_map(sc->sc_memt, ia->ia_iomem[0].ir_addr, 215 if (bus_space_map(sc->sc_memt, ia->ia_iomem[0].ir_addr,
216 ia->ia_iomem[0].ir_size, 0, &sc->sc_sramh)) { 216 ia->ia_iomem[0].ir_size, 0, &sc->sc_sramh)) {
217 printf("tr_isa_attach: shared ram space vanished\n"); 217 printf("tr_isa_attach: shared ram space vanished\n");
218 return; 218 return;
219 } 219 }
220 /* set ACA offset */ 220 /* set ACA offset */
221 sc->sc_aca = TR_ACA_OFFSET; 221 sc->sc_aca = TR_ACA_OFFSET;
222 sc->sc_memwinsz = ia->ia_iomem[0].ir_size; 222 sc->sc_memwinsz = ia->ia_iomem[0].ir_size;
223 sc->sc_maddr = ia->ia_iomem[0].ir_addr; 223 sc->sc_maddr = ia->ia_iomem[0].ir_addr;
224 /* 224 /*
225 * Determine total RAM on adapter and decide how much to use. 225 * Determine total RAM on adapter and decide how much to use.
226 * XXX Since we don't use RAM paging, use sc_memwinsz for now. 226 * XXX Since we don't use RAM paging, use sc_memwinsz for now.
227 */ 227 */
228 sc->sc_memsize = sc->sc_memwinsz; 228 sc->sc_memsize = sc->sc_memwinsz;
229 sc->sc_memreserved = 0; 229 sc->sc_memreserved = 0;
230 230
231 if (tr_reset(sc) != 0) 231 if (tr_reset(sc) != 0)
232 return; 232 return;
233 233
234 if (ia->ia_aux != NULL) { 234 if (ia->ia_aux != NULL) {
235 sc->sc_mediastatus = trtcm_isa_mediastatus; 235 sc->sc_mediastatus = trtcm_isa_mediastatus;
236 sc->sc_mediachange = trtcm_isa_mediachange; 236 sc->sc_mediachange = trtcm_isa_mediachange;
237 } 237 }
238 else { 238 else {
239 sc->sc_mediastatus = NULL; 239 sc->sc_mediastatus = NULL;
240 sc->sc_mediachange = NULL; 240 sc->sc_mediachange = NULL;
241 } 241 }
242 242
243 if (tr_attach(sc) != 0) 243 if (tr_attach(sc) != 0)
244 return; 244 return;
245 245
246/* 246/*
247 * XXX 3Com 619 can use LEVEL intr 247 * XXX 3Com 619 can use LEVEL intr
248 */ 248 */
249 sc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq[0].ir_irq, 249 sc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq[0].ir_irq,
250 IST_EDGE, IPL_NET, tr_intr, sc); 250 IST_EDGE, IPL_NET, tr_intr, sc);
251} 251}
252 252
253#ifdef TRISADEBUG 253#ifdef TRISADEBUG
254/* 254/*
255 * Dump the adapters AIP 255 * Dump the adapters AIP
256 */ 256 */
257void 257void
258tr_isa_dumpaip(memt, mmioh) 258tr_isa_dumpaip(memt, mmioh)
259 bus_space_tag_t memt; 259 bus_space_tag_t memt;
260 bus_space_handle_t mmioh; 260 bus_space_handle_t mmioh;
261{ 261{
262 unsigned int off, val; 262 unsigned int off, val;
263 printf("AIP contents:"); 263 printf("AIP contents:");
264 for (off=0; off < 256; off++) { 264 for (off=0; off < 256; off++) {
265 val = bus_space_read_1(memt, mmioh, TR_MAC_OFFSET + off); 265 val = bus_space_read_1(memt, mmioh, TR_MAC_OFFSET + off);
266 if ((off % 16) == 0) 266 if ((off % 16) == 0)
267 printf("\n"); 267 printf("\n");
268 printf("%02x ", val); 268 printf("%02x ", val);
269 } 269 }
270 printf("\n"); 270 printf("\n");
271} 271}
272#endif 272#endif