convert all the sparc drivers that attach on my ss20 to use device_t, cfdata_t and CFATTACH_DECL_NEW(). fd/fdc could use better testing, but i'm pretty sure i got it right.diff -r1.149 -r1.150 src/sys/arch/sparc/dev/fd.c
(mrg)
--- src/sys/arch/sparc/dev/fd.c 2010/02/24 22:37:55 1.149
+++ src/sys/arch/sparc/dev/fd.c 2011/07/17 23:18:23 1.150
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: fd.c,v 1.149 2010/02/24 22:37:55 dyoung Exp $ */ | 1 | /* $NetBSD: fd.c,v 1.150 2011/07/17 23:18:23 mrg Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2000 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2000 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Paul Kranenburg. | 8 | * by Paul Kranenburg. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -91,27 +91,27 @@ | @@ -91,27 +91,27 @@ | |||
91 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | 91 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
92 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 92 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
93 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 93 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
94 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 94 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
95 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 95 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
96 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 96 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
97 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 97 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
98 | * SUCH DAMAGE. | 98 | * SUCH DAMAGE. | |
99 | * | 99 | * | |
100 | * @(#)fd.c 7.4 (Berkeley) 5/25/91 | 100 | * @(#)fd.c 7.4 (Berkeley) 5/25/91 | |
101 | */ | 101 | */ | |
102 | 102 | |||
103 | #include <sys/cdefs.h> | 103 | #include <sys/cdefs.h> | |
104 | __KERNEL_RCSID(0, "$NetBSD: fd.c,v 1.149 2010/02/24 22:37:55 dyoung Exp $"); | 104 | __KERNEL_RCSID(0, "$NetBSD: fd.c,v 1.150 2011/07/17 23:18:23 mrg Exp $"); | |
105 | 105 | |||
106 | #include "opt_ddb.h" | 106 | #include "opt_ddb.h" | |
107 | #include "opt_md.h" | 107 | #include "opt_md.h" | |
108 | 108 | |||
109 | #include <sys/param.h> | 109 | #include <sys/param.h> | |
110 | #include <sys/systm.h> | 110 | #include <sys/systm.h> | |
111 | #include <sys/callout.h> | 111 | #include <sys/callout.h> | |
112 | #include <sys/kernel.h> | 112 | #include <sys/kernel.h> | |
113 | #include <sys/file.h> | 113 | #include <sys/file.h> | |
114 | #include <sys/ioctl.h> | 114 | #include <sys/ioctl.h> | |
115 | #include <sys/device.h> | 115 | #include <sys/device.h> | |
116 | #include <sys/disklabel.h> | 116 | #include <sys/disklabel.h> | |
117 | #include <sys/disk.h> | 117 | #include <sys/disk.h> | |
@@ -164,27 +164,27 @@ enum fdc_state { | @@ -164,27 +164,27 @@ enum fdc_state { | |||
164 | RESETCOMPLETE, /* 12 */ | 164 | RESETCOMPLETE, /* 12 */ | |
165 | RESETTIMEDOUT, /* 13 */ | 165 | RESETTIMEDOUT, /* 13 */ | |
166 | DORECAL, /* 14 */ | 166 | DORECAL, /* 14 */ | |
167 | RECALWAIT, /* 15 */ | 167 | RECALWAIT, /* 15 */ | |
168 | RECALTIMEDOUT, /* 16 */ | 168 | RECALTIMEDOUT, /* 16 */ | |
169 | RECALCOMPLETE, /* 17 */ | 169 | RECALCOMPLETE, /* 17 */ | |
170 | DODSKCHG, /* 18 */ | 170 | DODSKCHG, /* 18 */ | |
171 | DSKCHGWAIT, /* 19 */ | 171 | DSKCHGWAIT, /* 19 */ | |
172 | DSKCHGTIMEDOUT, /* 20 */ | 172 | DSKCHGTIMEDOUT, /* 20 */ | |
173 | }; | 173 | }; | |
174 | 174 | |||
175 | /* software state, per controller */ | 175 | /* software state, per controller */ | |
176 | struct fdc_softc { | 176 | struct fdc_softc { | |
177 | struct device sc_dev; /* boilerplate */ | 177 | struct device *sc_dev; | |
178 | bus_space_tag_t sc_bustag; | 178 | bus_space_tag_t sc_bustag; | |
179 | 179 | |||
180 | struct callout sc_timo_ch; /* timeout callout */ | 180 | struct callout sc_timo_ch; /* timeout callout */ | |
181 | struct callout sc_intr_ch; /* pseudo-intr callout */ | 181 | struct callout sc_intr_ch; /* pseudo-intr callout */ | |
182 | 182 | |||
183 | struct fd_softc *sc_fd[4]; /* pointers to children */ | 183 | struct fd_softc *sc_fd[4]; /* pointers to children */ | |
184 | TAILQ_HEAD(drivehead, fd_softc) sc_drives; | 184 | TAILQ_HEAD(drivehead, fd_softc) sc_drives; | |
185 | enum fdc_state sc_state; | 185 | enum fdc_state sc_state; | |
186 | int sc_flags; | 186 | int sc_flags; | |
187 | #define FDC_82077 0x01 | 187 | #define FDC_82077 0x01 | |
188 | #define FDC_NEEDHEADSETTLE 0x02 | 188 | #define FDC_NEEDHEADSETTLE 0x02 | |
189 | #define FDC_EIS 0x04 | 189 | #define FDC_EIS 0x04 | |
190 | #define FDC_NEEDMOTORWAIT 0x08 | 190 | #define FDC_NEEDMOTORWAIT 0x08 | |
@@ -202,37 +202,37 @@ struct fdc_softc { | @@ -202,37 +202,37 @@ struct fdc_softc { | |||
202 | #define sc_istatus sc_io.fdcio_istatus | 202 | #define sc_istatus sc_io.fdcio_istatus | |
203 | #define sc_data sc_io.fdcio_data | 203 | #define sc_data sc_io.fdcio_data | |
204 | #define sc_tc sc_io.fdcio_tc | 204 | #define sc_tc sc_io.fdcio_tc | |
205 | #define sc_nstat sc_io.fdcio_nstat | 205 | #define sc_nstat sc_io.fdcio_nstat | |
206 | #define sc_status sc_io.fdcio_status | 206 | #define sc_status sc_io.fdcio_status | |
207 | #define sc_intrcnt sc_io.fdcio_intrcnt | 207 | #define sc_intrcnt sc_io.fdcio_intrcnt | |
208 | 208 | |||
209 | void *sc_sicookie; /* softintr(9) cookie */ | 209 | void *sc_sicookie; /* softintr(9) cookie */ | |
210 | }; | 210 | }; | |
211 | 211 | |||
212 | extern struct fdcio *fdciop; /* I/O descriptor used in fdintr.s */ | 212 | extern struct fdcio *fdciop; /* I/O descriptor used in fdintr.s */ | |
213 | 213 | |||
214 | /* controller driver configuration */ | 214 | /* controller driver configuration */ | |
215 | int fdcmatch_mainbus(struct device *, struct cfdata *, void *); | 215 | int fdcmatch_mainbus(device_t, cfdata_t, void *); | |
216 | int fdcmatch_obio(struct device *, struct cfdata *, void *); | 216 | int fdcmatch_obio(device_t, cfdata_t, void *); | |
217 | void fdcattach_mainbus(struct device *, struct device *, void *); | 217 | void fdcattach_mainbus(device_t, device_t, void *); | |
218 | void fdcattach_obio(struct device *, struct device *, void *); | 218 | void fdcattach_obio(device_t, device_t, void *); | |
219 | 219 | |||
220 | int fdcattach(struct fdc_softc *, int); | 220 | int fdcattach(struct fdc_softc *, int); | |
221 | 221 | |||
222 | CFATTACH_DECL(fdc_mainbus, sizeof(struct fdc_softc), | 222 | CFATTACH_DECL_NEW(fdc_mainbus, sizeof(struct fdc_softc), | |
223 | fdcmatch_mainbus, fdcattach_mainbus, NULL, NULL); | 223 | fdcmatch_mainbus, fdcattach_mainbus, NULL, NULL); | |
224 | 224 | |||
225 | CFATTACH_DECL(fdc_obio, sizeof(struct fdc_softc), | 225 | CFATTACH_DECL_NEW(fdc_obio, sizeof(struct fdc_softc), | |
226 | fdcmatch_obio, fdcattach_obio, NULL, NULL); | 226 | fdcmatch_obio, fdcattach_obio, NULL, NULL); | |
227 | 227 | |||
228 | inline struct fd_type *fd_dev_to_type(struct fd_softc *, dev_t); | 228 | inline struct fd_type *fd_dev_to_type(struct fd_softc *, dev_t); | |
229 | 229 | |||
230 | /* | 230 | /* | |
231 | * Floppies come in various flavors, e.g., 1.2MB vs 1.44MB; here is how | 231 | * Floppies come in various flavors, e.g., 1.2MB vs 1.44MB; here is how | |
232 | * we tell them apart. | 232 | * we tell them apart. | |
233 | */ | 233 | */ | |
234 | struct fd_type { | 234 | struct fd_type { | |
235 | int sectrac; /* sectors per track */ | 235 | int sectrac; /* sectors per track */ | |
236 | int heads; /* number of heads */ | 236 | int heads; /* number of heads */ | |
237 | int seccyl; /* sectors per cylinder */ | 237 | int seccyl; /* sectors per cylinder */ | |
238 | int secsize; /* size code for sectors */ | 238 | int secsize; /* size code for sectors */ | |
@@ -249,27 +249,27 @@ struct fd_type { | @@ -249,27 +249,27 @@ struct fd_type { | |||
249 | const char *name; | 249 | const char *name; | |
250 | }; | 250 | }; | |
251 | 251 | |||
252 | /* The order of entries in the following table is important -- BEWARE! */ | 252 | /* The order of entries in the following table is important -- BEWARE! */ | |
253 | struct fd_type fd_types[] = { | 253 | struct fd_type fd_types[] = { | |
254 | { 18,2,36,2,0xff,0xcf,0x1b,0x54,80,2880,1,FDC_500KBPS,0xf6,1, "1.44MB" }, /* 1.44MB diskette */ | 254 | { 18,2,36,2,0xff,0xcf,0x1b,0x54,80,2880,1,FDC_500KBPS,0xf6,1, "1.44MB" }, /* 1.44MB diskette */ | |
255 | { 9,2,18,2,0xff,0xdf,0x2a,0x50,80,1440,1,FDC_250KBPS,0xf6,1, "720KB" }, /* 3.5" 720kB diskette */ | 255 | { 9,2,18,2,0xff,0xdf,0x2a,0x50,80,1440,1,FDC_250KBPS,0xf6,1, "720KB" }, /* 3.5" 720kB diskette */ | |
256 | { 9,2,18,2,0xff,0xdf,0x2a,0x50,40, 720,2,FDC_250KBPS,0xf6,1, "360KB/x" }, /* 360kB in 720kB drive */ | 256 | { 9,2,18,2,0xff,0xdf,0x2a,0x50,40, 720,2,FDC_250KBPS,0xf6,1, "360KB/x" }, /* 360kB in 720kB drive */ | |
257 | { 8,2,16,3,0xff,0xdf,0x35,0x74,77,1232,1,FDC_500KBPS,0xf6,1, "1.2MB/NEC" } /* 1.2 MB japanese format */ | 257 | { 8,2,16,3,0xff,0xdf,0x35,0x74,77,1232,1,FDC_500KBPS,0xf6,1, "1.2MB/NEC" } /* 1.2 MB japanese format */ | |
258 | }; | 258 | }; | |
259 | 259 | |||
260 | /* software state, per disk (with up to 4 disks per ctlr) */ | 260 | /* software state, per disk (with up to 4 disks per ctlr) */ | |
261 | struct fd_softc { | 261 | struct fd_softc { | |
262 | struct device sc_dv; /* generic device info */ | 262 | struct device *sc_dv; /* generic device info */ | |
263 | struct disk sc_dk; /* generic disk info */ | 263 | struct disk sc_dk; /* generic disk info */ | |
264 | 264 | |||
265 | struct fd_type *sc_deftype; /* default type descriptor */ | 265 | struct fd_type *sc_deftype; /* default type descriptor */ | |
266 | struct fd_type *sc_type; /* current type descriptor */ | 266 | struct fd_type *sc_type; /* current type descriptor */ | |
267 | 267 | |||
268 | struct callout sc_motoron_ch; | 268 | struct callout sc_motoron_ch; | |
269 | struct callout sc_motoroff_ch; | 269 | struct callout sc_motoroff_ch; | |
270 | 270 | |||
271 | daddr_t sc_blkno; /* starting block number */ | 271 | daddr_t sc_blkno; /* starting block number */ | |
272 | int sc_bcount; /* byte count left */ | 272 | int sc_bcount; /* byte count left */ | |
273 | int sc_skip; /* bytes already transferred */ | 273 | int sc_skip; /* bytes already transferred */ | |
274 | int sc_nblks; /* number of blocks currently transferring */ | 274 | int sc_nblks; /* number of blocks currently transferring */ | |
275 | int sc_nbytes; /* number of bytes currently transferring */ | 275 | int sc_nbytes; /* number of bytes currently transferring */ | |
@@ -279,32 +279,32 @@ struct fd_softc { | @@ -279,32 +279,32 @@ struct fd_softc { | |||
279 | #define FD_OPEN 0x01 /* it's open */ | 279 | #define FD_OPEN 0x01 /* it's open */ | |
280 | #define FD_MOTOR 0x02 /* motor should be on */ | 280 | #define FD_MOTOR 0x02 /* motor should be on */ | |
281 | #define FD_MOTOR_WAIT 0x04 /* motor coming up */ | 281 | #define FD_MOTOR_WAIT 0x04 /* motor coming up */ | |
282 | int sc_cylin; /* where we think the head is */ | 282 | int sc_cylin; /* where we think the head is */ | |
283 | int sc_opts; /* user-set options */ | 283 | int sc_opts; /* user-set options */ | |
284 | 284 | |||
285 | TAILQ_ENTRY(fd_softc) sc_drivechain; | 285 | TAILQ_ENTRY(fd_softc) sc_drivechain; | |
286 | int sc_ops; /* I/O ops since last switch */ | 286 | int sc_ops; /* I/O ops since last switch */ | |
287 | struct bufq_state *sc_q;/* pending I/O requests */ | 287 | struct bufq_state *sc_q;/* pending I/O requests */ | |
288 | int sc_active; /* number of active I/O requests */ | 288 | int sc_active; /* number of active I/O requests */ | |
289 | }; | 289 | }; | |
290 | 290 | |||
291 | /* floppy driver configuration */ | 291 | /* floppy driver configuration */ | |
292 | int fdmatch(struct device *, struct cfdata *, void *); | 292 | int fdmatch(device_t, cfdata_t, void *); | |
293 | void fdattach(struct device *, struct device *, void *); | 293 | void fdattach(device_t, device_t, void *); | |
294 | bool fdshutdown(device_t, int); | 294 | bool fdshutdown(device_t, int); | |
295 | bool fdsuspend(device_t, const pmf_qual_t *); | 295 | bool fdsuspend(device_t, const pmf_qual_t *); | |
296 | 296 | |||
297 | CFATTACH_DECL(fd, sizeof(struct fd_softc), | 297 | CFATTACH_DECL_NEW(fd, sizeof(struct fd_softc), | |
298 | fdmatch, fdattach, NULL, NULL); | 298 | fdmatch, fdattach, NULL, NULL); | |
299 | 299 | |||
300 | extern struct cfdriver fd_cd; | 300 | extern struct cfdriver fd_cd; | |
301 | 301 | |||
302 | dev_type_open(fdopen); | 302 | dev_type_open(fdopen); | |
303 | dev_type_close(fdclose); | 303 | dev_type_close(fdclose); | |
304 | dev_type_read(fdread); | 304 | dev_type_read(fdread); | |
305 | dev_type_write(fdwrite); | 305 | dev_type_write(fdwrite); | |
306 | dev_type_ioctl(fdioctl); | 306 | dev_type_ioctl(fdioctl); | |
307 | dev_type_strategy(fdstrategy); | 307 | dev_type_strategy(fdstrategy); | |
308 | 308 | |||
309 | const struct bdevsw fd_bdevsw = { | 309 | const struct bdevsw fd_bdevsw = { | |
310 | fdopen, fdclose, fdstrategy, fdioctl, nodump, nosize, D_DISK | 310 | fdopen, fdclose, fdstrategy, fdioctl, nodump, nosize, D_DISK | |
@@ -348,50 +348,50 @@ static void establish_chip_type( | @@ -348,50 +348,50 @@ static void establish_chip_type( | |||
348 | struct fdc_softc *, | 348 | struct fdc_softc *, | |
349 | bus_space_tag_t, | 349 | bus_space_tag_t, | |
350 | bus_addr_t, | 350 | bus_addr_t, | |
351 | bus_size_t, | 351 | bus_size_t, | |
352 | bus_space_handle_t); | 352 | bus_space_handle_t); | |
353 | 353 | |||
354 | #ifdef MEMORY_DISK_HOOKS | 354 | #ifdef MEMORY_DISK_HOOKS | |
355 | int fd_read_md_image(size_t *, void **); | 355 | int fd_read_md_image(size_t *, void **); | |
356 | #endif | 356 | #endif | |
357 | 357 | |||
358 | #define OBP_FDNAME (CPU_ISSUN4M ? "SUNW,fdtwo" : "fd") | 358 | #define OBP_FDNAME (CPU_ISSUN4M ? "SUNW,fdtwo" : "fd") | |
359 | 359 | |||
360 | int | 360 | int | |
361 | fdcmatch_mainbus(struct device *parent, struct cfdata *match, void *aux) | 361 | fdcmatch_mainbus(device_t parent, cfdata_t match, void *aux) | |
362 | { | 362 | { | |
363 | struct mainbus_attach_args *ma = aux; | 363 | struct mainbus_attach_args *ma = aux; | |
364 | 364 | |||
365 | /* | 365 | /* | |
366 | * Floppy controller is on mainbus on sun4c. | 366 | * Floppy controller is on mainbus on sun4c. | |
367 | */ | 367 | */ | |
368 | if (!CPU_ISSUN4C) | 368 | if (!CPU_ISSUN4C) | |
369 | return (0); | 369 | return (0); | |
370 | 370 | |||
371 | /* sun4c PROMs call the controller "fd" */ | 371 | /* sun4c PROMs call the controller "fd" */ | |
372 | if (strcmp("fd", ma->ma_name) != 0) | 372 | if (strcmp("fd", ma->ma_name) != 0) | |
373 | return (0); | 373 | return (0); | |
374 | 374 | |||
375 | return (bus_space_probe(ma->ma_bustag, | 375 | return (bus_space_probe(ma->ma_bustag, | |
376 | ma->ma_paddr, | 376 | ma->ma_paddr, | |
377 | 1, /* probe size */ | 377 | 1, /* probe size */ | |
378 | 0, /* offset */ | 378 | 0, /* offset */ | |
379 | 0, /* flags */ | 379 | 0, /* flags */ | |
380 | NULL, NULL)); | 380 | NULL, NULL)); | |
381 | } | 381 | } | |
382 | 382 | |||
383 | int | 383 | int | |
384 | fdcmatch_obio(struct device *parent, struct cfdata *match, void *aux) | 384 | fdcmatch_obio(device_t parent, cfdata_t match, void *aux) | |
385 | { | 385 | { | |
386 | union obio_attach_args *uoba = aux; | 386 | union obio_attach_args *uoba = aux; | |
387 | struct sbus_attach_args *sa; | 387 | struct sbus_attach_args *sa; | |
388 | 388 | |||
389 | /* | 389 | /* | |
390 | * Floppy controller is on obio on sun4m. | 390 | * Floppy controller is on obio on sun4m. | |
391 | */ | 391 | */ | |
392 | if (uoba->uoba_isobio4 != 0) | 392 | if (uoba->uoba_isobio4 != 0) | |
393 | return (0); | 393 | return (0); | |
394 | 394 | |||
395 | sa = &uoba->uoba_sbus; | 395 | sa = &uoba->uoba_sbus; | |
396 | 396 | |||
397 | /* sun4m PROMs call the controller "SUNW,fdtwo" */ | 397 | /* sun4m PROMs call the controller "SUNW,fdtwo" */ | |
@@ -523,65 +523,67 @@ fdconf(struct fdc_softc *fdc) | @@ -523,65 +523,67 @@ fdconf(struct fdc_softc *fdc) | |||
523 | } | 523 | } | |
524 | 524 | |||
525 | return (0); | 525 | return (0); | |
526 | #if 0 | 526 | #if 0 | |
527 | if (fdc_wrfifo(fdc, NE7CMD_VERSION) == 0 && | 527 | if (fdc_wrfifo(fdc, NE7CMD_VERSION) == 0 && | |
528 | fdcresult(fdc) == 1 && fdc->sc_status[0] == 0x90) { | 528 | fdcresult(fdc) == 1 && fdc->sc_status[0] == 0x90) { | |
529 | if (fdc_debug) | 529 | if (fdc_debug) | |
530 | printf("[version cmd]"); | 530 | printf("[version cmd]"); | |
531 | } | 531 | } | |
532 | #endif | 532 | #endif | |
533 | } | 533 | } | |
534 | 534 | |||
535 | void | 535 | void | |
536 | fdcattach_mainbus(struct device *parent, struct device *self, void *aux) | 536 | fdcattach_mainbus(device_t parent, device_t self, void *aux) | |
537 | { | 537 | { | |
538 | struct fdc_softc *fdc = device_private(self); | 538 | struct fdc_softc *fdc = device_private(self); | |
539 | struct mainbus_attach_args *ma = aux; | 539 | struct mainbus_attach_args *ma = aux; | |
540 | 540 | |||
541 | fdc->sc_dev = self; | |||
541 | fdc->sc_bustag = ma->ma_bustag; | 542 | fdc->sc_bustag = ma->ma_bustag; | |
542 | 543 | |||
543 | if (bus_space_map( | 544 | if (bus_space_map( | |
544 | ma->ma_bustag, | 545 | ma->ma_bustag, | |
545 | ma->ma_paddr, | 546 | ma->ma_paddr, | |
546 | ma->ma_size, | 547 | ma->ma_size, | |
547 | BUS_SPACE_MAP_LINEAR, | 548 | BUS_SPACE_MAP_LINEAR, | |
548 | &fdc->sc_handle) != 0) { | 549 | &fdc->sc_handle) != 0) { | |
549 | printf("%s: cannot map registers\n", self->dv_xname); | 550 | printf("%s: cannot map registers\n", self->dv_xname); | |
550 | return; | 551 | return; | |
551 | } | 552 | } | |
552 | 553 | |||
553 | establish_chip_type(fdc, | 554 | establish_chip_type(fdc, | |
554 | ma->ma_bustag, | 555 | ma->ma_bustag, | |
555 | ma->ma_paddr, | 556 | ma->ma_paddr, | |
556 | ma->ma_size, | 557 | ma->ma_size, | |
557 | fdc->sc_handle); | 558 | fdc->sc_handle); | |
558 | 559 | |||
559 | if (fdcattach(fdc, ma->ma_pri) != 0) | 560 | if (fdcattach(fdc, ma->ma_pri) != 0) | |
560 | bus_space_unmap(ma->ma_bustag, fdc->sc_handle, ma->ma_size); | 561 | bus_space_unmap(ma->ma_bustag, fdc->sc_handle, ma->ma_size); | |
561 | } | 562 | } | |
562 | 563 | |||
563 | void | 564 | void | |
564 | fdcattach_obio(struct device *parent, struct device *self, void *aux) | 565 | fdcattach_obio(device_t parent, device_t self, void *aux) | |
565 | { | 566 | { | |
566 | struct fdc_softc *fdc = device_private(self); | 567 | struct fdc_softc *fdc = device_private(self); | |
567 | union obio_attach_args *uoba = aux; | 568 | union obio_attach_args *uoba = aux; | |
568 | struct sbus_attach_args *sa = &uoba->uoba_sbus; | 569 | struct sbus_attach_args *sa = &uoba->uoba_sbus; | |
569 | 570 | |||
570 | if (sa->sa_nintr == 0) { | 571 | if (sa->sa_nintr == 0) { | |
571 | printf(": no interrupt line configured\n"); | 572 | printf(": no interrupt line configured\n"); | |
572 | return; | 573 | return; | |
573 | } | 574 | } | |
574 | 575 | |||
576 | fdc->sc_dev = self; | |||
575 | fdc->sc_bustag = sa->sa_bustag; | 577 | fdc->sc_bustag = sa->sa_bustag; | |
576 | 578 | |||
577 | if (sbus_bus_map(sa->sa_bustag, | 579 | if (sbus_bus_map(sa->sa_bustag, | |
578 | sa->sa_slot, sa->sa_offset, sa->sa_size, | 580 | sa->sa_slot, sa->sa_offset, sa->sa_size, | |
579 | BUS_SPACE_MAP_LINEAR, &fdc->sc_handle) != 0) { | 581 | BUS_SPACE_MAP_LINEAR, &fdc->sc_handle) != 0) { | |
580 | printf("%s: cannot map control registers\n", | 582 | printf("%s: cannot map control registers\n", | |
581 | self->dv_xname); | 583 | self->dv_xname); | |
582 | return; | 584 | return; | |
583 | } | 585 | } | |
584 | 586 | |||
585 | establish_chip_type(fdc, | 587 | establish_chip_type(fdc, | |
586 | sa->sa_bustag, | 588 | sa->sa_bustag, | |
587 | sbus_bus_addr(sa->sa_bustag, sa->sa_slot, sa->sa_offset), | 589 | sbus_bus_addr(sa->sa_bustag, sa->sa_slot, sa->sa_offset), | |
@@ -637,60 +639,60 @@ fdcattach(struct fdc_softc *fdc, int pri | @@ -637,60 +639,60 @@ fdcattach(struct fdc_softc *fdc, int pri | |||
637 | return (-1); | 639 | return (-1); | |
638 | } | 640 | } | |
639 | 641 | |||
640 | fdciop = &fdc->sc_io; | 642 | fdciop = &fdc->sc_io; | |
641 | if (bus_intr_establish2(fdc->sc_bustag, pri, 0, | 643 | if (bus_intr_establish2(fdc->sc_bustag, pri, 0, | |
642 | fdc_c_hwintr, fdc, | 644 | fdc_c_hwintr, fdc, | |
643 | #ifdef notyet /* XXX bsd_fdintr.s needs to be fixed for MI softint(9) */ | 645 | #ifdef notyet /* XXX bsd_fdintr.s needs to be fixed for MI softint(9) */ | |
644 | fdchwintr | 646 | fdchwintr | |
645 | #else | 647 | #else | |
646 | NULL | 648 | NULL | |
647 | #endif | 649 | #endif | |
648 | ) == NULL) { | 650 | ) == NULL) { | |
649 | printf("\n%s: cannot register interrupt handler\n", | 651 | printf("\n%s: cannot register interrupt handler\n", | |
650 | fdc->sc_dev.dv_xname); | 652 | device_xname(fdc->sc_dev)); | |
651 | return (-1); | 653 | return (-1); | |
652 | } | 654 | } | |
653 | 655 | |||
654 | fdc->sc_sicookie = softint_establish(SOFTINT_BIO, fdcswintr, fdc); | 656 | fdc->sc_sicookie = softint_establish(SOFTINT_BIO, fdcswintr, fdc); | |
655 | if (fdc->sc_sicookie == NULL) { | 657 | if (fdc->sc_sicookie == NULL) { | |
656 | printf("\n%s: cannot register soft interrupt handler\n", | 658 | printf("\n%s: cannot register soft interrupt handler\n", | |
657 | fdc->sc_dev.dv_xname); | 659 | device_xname(fdc->sc_dev)); | |
658 | return (-1); | 660 | return (-1); | |
659 | } | 661 | } | |
660 | printf(" softpri %d: chip 8207%c\n", IPL_SOFTFDC, code); | 662 | printf(" softpri %d: chip 8207%c\n", IPL_SOFTFDC, code); | |
661 | 663 | |||
662 | evcnt_attach_dynamic(&fdc->sc_intrcnt, EVCNT_TYPE_INTR, NULL, | 664 | evcnt_attach_dynamic(&fdc->sc_intrcnt, EVCNT_TYPE_INTR, NULL, | |
663 | fdc->sc_dev.dv_xname, "intr"); | 665 | device_xname(fdc->sc_dev), "intr"); | |
664 | 666 | |||
665 | /* physical limit: four drives per controller. */ | 667 | /* physical limit: four drives per controller. */ | |
666 | drive_attached = 0; | 668 | drive_attached = 0; | |
667 | for (fa.fa_drive = 0; fa.fa_drive < 4; fa.fa_drive++) { | 669 | for (fa.fa_drive = 0; fa.fa_drive < 4; fa.fa_drive++) { | |
668 | fa.fa_deftype = NULL; /* unknown */ | 670 | fa.fa_deftype = NULL; /* unknown */ | |
669 | fa.fa_deftype = &fd_types[0]; /* XXX */ | 671 | fa.fa_deftype = &fd_types[0]; /* XXX */ | |
670 | if (config_found(&fdc->sc_dev, (void *)&fa, fdprint) != NULL) | 672 | if (config_found(fdc->sc_dev, (void *)&fa, fdprint) != NULL) | |
671 | drive_attached = 1; | 673 | drive_attached = 1; | |
672 | } | 674 | } | |
673 | 675 | |||
674 | if (drive_attached == 0) { | 676 | if (drive_attached == 0) { | |
675 | /* XXX - dis-establish interrupts here */ | 677 | /* XXX - dis-establish interrupts here */ | |
676 | /* return (-1); */ | 678 | /* return (-1); */ | |
677 | } | 679 | } | |
678 | 680 | |||
679 | return (0); | 681 | return (0); | |
680 | } | 682 | } | |
681 | 683 | |||
682 | int | 684 | int | |
683 | fdmatch(struct device *parent, struct cfdata *match, void *aux) | 685 | fdmatch(device_t parent, cfdata_t match, void *aux) | |
684 | { | 686 | { | |
685 | struct fdc_softc *fdc = device_private(parent); | 687 | struct fdc_softc *fdc = device_private(parent); | |
686 | bus_space_tag_t t = fdc->sc_bustag; | 688 | bus_space_tag_t t = fdc->sc_bustag; | |
687 | bus_space_handle_t h = fdc->sc_handle; | 689 | bus_space_handle_t h = fdc->sc_handle; | |
688 | struct fdc_attach_args *fa = aux; | 690 | struct fdc_attach_args *fa = aux; | |
689 | int drive = fa->fa_drive; | 691 | int drive = fa->fa_drive; | |
690 | int n, ok; | 692 | int n, ok; | |
691 | 693 | |||
692 | if (drive > 0) | 694 | if (drive > 0) | |
693 | /* XXX - for now, punt on more than one drive */ | 695 | /* XXX - for now, punt on more than one drive */ | |
694 | return (0); | 696 | return (0); | |
695 | 697 | |||
696 | if ((fdc->sc_flags & FDC_82077) != 0) { | 698 | if ((fdc->sc_flags & FDC_82077) != 0) { | |
@@ -744,67 +746,69 @@ fdmatch(struct device *parent, struct cf | @@ -744,67 +746,69 @@ fdmatch(struct device *parent, struct cf | |||
744 | /* deselect drive and turn motor off */ | 746 | /* deselect drive and turn motor off */ | |
745 | bus_space_write_1(t, h, fdc->sc_reg_dor, FDO_FRST | FDO_DS); | 747 | bus_space_write_1(t, h, fdc->sc_reg_dor, FDO_FRST | FDO_DS); | |
746 | } else { | 748 | } else { | |
747 | auxregbisc(0, AUXIO4C_FDS); | 749 | auxregbisc(0, AUXIO4C_FDS); | |
748 | } | 750 | } | |
749 | 751 | |||
750 | return (ok); | 752 | return (ok); | |
751 | } | 753 | } | |
752 | 754 | |||
753 | /* | 755 | /* | |
754 | * Controller is working, and drive responded. Attach it. | 756 | * Controller is working, and drive responded. Attach it. | |
755 | */ | 757 | */ | |
756 | void | 758 | void | |
757 | fdattach(struct device *parent, struct device *self, void *aux) | 759 | fdattach(device_t parent, device_t self, void *aux) | |
758 | { | 760 | { | |
759 | struct fdc_softc *fdc = device_private(parent); | 761 | struct fdc_softc *fdc = device_private(parent); | |
760 | struct fd_softc *fd = device_private(self); | 762 | struct fd_softc *fd = device_private(self); | |
761 | struct fdc_attach_args *fa = aux; | 763 | struct fdc_attach_args *fa = aux; | |
762 | struct fd_type *type = fa->fa_deftype; | 764 | struct fd_type *type = fa->fa_deftype; | |
763 | int drive = fa->fa_drive; | 765 | int drive = fa->fa_drive; | |
764 | 766 | |||
767 | fd->sc_dv = self; | |||
768 | ||||
765 | callout_init(&fd->sc_motoron_ch, 0); | 769 | callout_init(&fd->sc_motoron_ch, 0); | |
766 | callout_init(&fd->sc_motoroff_ch, 0); | 770 | callout_init(&fd->sc_motoroff_ch, 0); | |
767 | 771 | |||
768 | /* XXX Allow `flags' to override device type? */ | 772 | /* XXX Allow `flags' to override device type? */ | |
769 | 773 | |||
770 | if (type) | 774 | if (type) | |
771 | printf(": %s %d cyl, %d head, %d sec\n", type->name, | 775 | printf(": %s %d cyl, %d head, %d sec\n", type->name, | |
772 | type->cylinders, type->heads, type->sectrac); | 776 | type->cylinders, type->heads, type->sectrac); | |
773 | else | 777 | else | |
774 | printf(": density unknown\n"); | 778 | printf(": density unknown\n"); | |
775 | 779 | |||
776 | bufq_alloc(&fd->sc_q, "disksort", BUFQ_SORT_CYLINDER); | 780 | bufq_alloc(&fd->sc_q, "disksort", BUFQ_SORT_CYLINDER); | |
777 | fd->sc_cylin = -1; | 781 | fd->sc_cylin = -1; | |
778 | fd->sc_drive = drive; | 782 | fd->sc_drive = drive; | |
779 | fd->sc_deftype = type; | 783 | fd->sc_deftype = type; | |
780 | fdc->sc_fd[drive] = fd; | 784 | fdc->sc_fd[drive] = fd; | |
781 | 785 | |||
782 | fdc_wrfifo(fdc, NE7CMD_SPECIFY); | 786 | fdc_wrfifo(fdc, NE7CMD_SPECIFY); | |
783 | fdc_wrfifo(fdc, type->steprate); | 787 | fdc_wrfifo(fdc, type->steprate); | |
784 | /* XXX head load time == 6ms */ | 788 | /* XXX head load time == 6ms */ | |
785 | fdc_wrfifo(fdc, 6 | NE7_SPECIFY_NODMA); | 789 | fdc_wrfifo(fdc, 6 | NE7_SPECIFY_NODMA); | |
786 | 790 | |||
787 | /* | 791 | /* | |
788 | * Initialize and attach the disk structure. | 792 | * Initialize and attach the disk structure. | |
789 | */ | 793 | */ | |
790 | disk_init(&fd->sc_dk, fd->sc_dv.dv_xname, &fddkdriver); | 794 | disk_init(&fd->sc_dk, device_xname(fd->sc_dv), &fddkdriver); | |
791 | disk_attach(&fd->sc_dk); | 795 | disk_attach(&fd->sc_dk); | |
792 | 796 | |||
793 | /* | 797 | /* | |
794 | * Establish a mountroot_hook anyway in case we booted | 798 | * Establish a mountroot_hook anyway in case we booted | |
795 | * with RB_ASKNAME and get selected as the boot device. | 799 | * with RB_ASKNAME and get selected as the boot device. | |
796 | */ | 800 | */ | |
797 | mountroothook_establish(fd_mountroot_hook, &fd->sc_dv); | 801 | mountroothook_establish(fd_mountroot_hook, fd->sc_dv); | |
798 | 802 | |||
799 | /* Make sure the drive motor gets turned off at shutdown time. */ | 803 | /* Make sure the drive motor gets turned off at shutdown time. */ | |
800 | if (!pmf_device_register1(self, fdsuspend, NULL, fdshutdown)) | 804 | if (!pmf_device_register1(self, fdsuspend, NULL, fdshutdown)) | |
801 | aprint_error_dev(self, "couldn't establish power handler\n"); | 805 | aprint_error_dev(self, "couldn't establish power handler\n"); | |
802 | } | 806 | } | |
803 | 807 | |||
804 | bool fdshutdown(device_t self, int how) | 808 | bool fdshutdown(device_t self, int how) | |
805 | { | 809 | { | |
806 | struct fd_softc *fd = device_private(self); | 810 | struct fd_softc *fd = device_private(self); | |
807 | 811 | |||
808 | fd_motor_off(fd); | 812 | fd_motor_off(fd); | |
809 | return true; | 813 | return true; | |
810 | } | 814 | } | |
@@ -876,60 +880,60 @@ fdstrategy(struct buf *bp) | @@ -876,60 +880,60 @@ fdstrategy(struct buf *bp) | |||
876 | printf("fdstrategy: b_blkno %lld b_bcount %d blkno %lld cylin %d\n", | 880 | printf("fdstrategy: b_blkno %lld b_bcount %d blkno %lld cylin %d\n", | |
877 | (long long)bp->b_blkno, bp->b_bcount, | 881 | (long long)bp->b_blkno, bp->b_bcount, | |
878 | (long long)fd->sc_blkno, bp->b_cylinder); | 882 | (long long)fd->sc_blkno, bp->b_cylinder); | |
879 | #endif | 883 | #endif | |
880 | 884 | |||
881 | /* Queue transfer on drive, activate drive and controller if idle. */ | 885 | /* Queue transfer on drive, activate drive and controller if idle. */ | |
882 | s = splbio(); | 886 | s = splbio(); | |
883 | bufq_put(fd->sc_q, bp); | 887 | bufq_put(fd->sc_q, bp); | |
884 | callout_stop(&fd->sc_motoroff_ch); /* a good idea */ | 888 | callout_stop(&fd->sc_motoroff_ch); /* a good idea */ | |
885 | if (fd->sc_active == 0) | 889 | if (fd->sc_active == 0) | |
886 | fdstart(fd); | 890 | fdstart(fd); | |
887 | #ifdef DIAGNOSTIC | 891 | #ifdef DIAGNOSTIC | |
888 | else { | 892 | else { | |
889 | struct fdc_softc *fdc = (void *)device_parent(&fd->sc_dv); | 893 | struct fdc_softc *fdc = (void *)device_parent(fd->sc_dv); | |
890 | if (fdc->sc_state == DEVIDLE) { | 894 | if (fdc->sc_state == DEVIDLE) { | |
891 | printf("fdstrategy: controller inactive\n"); | 895 | printf("fdstrategy: controller inactive\n"); | |
892 | fdcstart(fdc); | 896 | fdcstart(fdc); | |
893 | } | 897 | } | |
894 | } | 898 | } | |
895 | #endif | 899 | #endif | |
896 | splx(s); | 900 | splx(s); | |
897 | return; | 901 | return; | |
898 | 902 | |||
899 | done: | 903 | done: | |
900 | /* Toss transfer; we're done early. */ | 904 | /* Toss transfer; we're done early. */ | |
901 | biodone(bp); | 905 | biodone(bp); | |
902 | } | 906 | } | |
903 | 907 | |||
904 | void | 908 | void | |
905 | fdstart(struct fd_softc *fd) | 909 | fdstart(struct fd_softc *fd) | |
906 | { | 910 | { | |
907 | struct fdc_softc *fdc = device_private(device_parent(&fd->sc_dv)); | 911 | struct fdc_softc *fdc = device_private(device_parent(fd->sc_dv)); | |
908 | int active = fdc->sc_drives.tqh_first != 0; | 912 | int active = fdc->sc_drives.tqh_first != 0; | |
909 | 913 | |||
910 | /* Link into controller queue. */ | 914 | /* Link into controller queue. */ | |
911 | fd->sc_active = 1; | 915 | fd->sc_active = 1; | |
912 | TAILQ_INSERT_TAIL(&fdc->sc_drives, fd, sc_drivechain); | 916 | TAILQ_INSERT_TAIL(&fdc->sc_drives, fd, sc_drivechain); | |
913 | 917 | |||
914 | /* If controller not already active, start it. */ | 918 | /* If controller not already active, start it. */ | |
915 | if (!active) | 919 | if (!active) | |
916 | fdcstart(fdc); | 920 | fdcstart(fdc); | |
917 | } | 921 | } | |
918 | 922 | |||
919 | void | 923 | void | |
920 | fdfinish(struct fd_softc *fd, struct buf *bp) | 924 | fdfinish(struct fd_softc *fd, struct buf *bp) | |
921 | { | 925 | { | |
922 | struct fdc_softc *fdc = device_private(device_parent(&fd->sc_dv)); | 926 | struct fdc_softc *fdc = device_private(device_parent(fd->sc_dv)); | |
923 | 927 | |||
924 | /* | 928 | /* | |
925 | * Move this drive to the end of the queue to give others a `fair' | 929 | * Move this drive to the end of the queue to give others a `fair' | |
926 | * chance. We only force a switch if N operations are completed while | 930 | * chance. We only force a switch if N operations are completed while | |
927 | * another drive is waiting to be serviced, since there is a long motor | 931 | * another drive is waiting to be serviced, since there is a long motor | |
928 | * startup delay whenever we switch. | 932 | * startup delay whenever we switch. | |
929 | */ | 933 | */ | |
930 | (void)bufq_get(fd->sc_q); | 934 | (void)bufq_get(fd->sc_q); | |
931 | if (fd->sc_drivechain.tqe_next && ++fd->sc_ops >= 8) { | 935 | if (fd->sc_drivechain.tqe_next && ++fd->sc_ops >= 8) { | |
932 | fd->sc_ops = 0; | 936 | fd->sc_ops = 0; | |
933 | TAILQ_REMOVE(&fdc->sc_drives, fd, sc_drivechain); | 937 | TAILQ_REMOVE(&fdc->sc_drives, fd, sc_drivechain); | |
934 | if (bufq_peek(fd->sc_q) != NULL) { | 938 | if (bufq_peek(fd->sc_q) != NULL) { | |
935 | TAILQ_INSERT_TAIL(&fdc->sc_drives, fd, sc_drivechain); | 939 | TAILQ_INSERT_TAIL(&fdc->sc_drives, fd, sc_drivechain); | |
@@ -998,35 +1002,35 @@ fd_set_motor(struct fdc_softc *fdc) | @@ -998,35 +1002,35 @@ fd_set_motor(struct fdc_softc *fdc) | |||
998 | } | 1002 | } | |
999 | auxregbisc(0, AUXIO4C_FDS); | 1003 | auxregbisc(0, AUXIO4C_FDS); | |
1000 | } | 1004 | } | |
1001 | } | 1005 | } | |
1002 | 1006 | |||
1003 | void | 1007 | void | |
1004 | fd_motor_off(void *arg) | 1008 | fd_motor_off(void *arg) | |
1005 | { | 1009 | { | |
1006 | struct fd_softc *fd = arg; | 1010 | struct fd_softc *fd = arg; | |
1007 | int s; | 1011 | int s; | |
1008 | 1012 | |||
1009 | s = splbio(); | 1013 | s = splbio(); | |
1010 | fd->sc_flags &= ~(FD_MOTOR | FD_MOTOR_WAIT); | 1014 | fd->sc_flags &= ~(FD_MOTOR | FD_MOTOR_WAIT); | |
1011 | fd_set_motor((struct fdc_softc *)device_parent(&fd->sc_dv)); | 1015 | fd_set_motor((struct fdc_softc *)device_parent(fd->sc_dv)); | |
1012 | splx(s); | 1016 | splx(s); | |
1013 | } | 1017 | } | |
1014 | 1018 | |||
1015 | void | 1019 | void | |
1016 | fd_motor_on(void *arg) | 1020 | fd_motor_on(void *arg) | |
1017 | { | 1021 | { | |
1018 | struct fd_softc *fd = arg; | 1022 | struct fd_softc *fd = arg; | |
1019 | struct fdc_softc *fdc = device_private(device_parent(&fd->sc_dv)); | 1023 | struct fdc_softc *fdc = device_private(device_parent(fd->sc_dv)); | |
1020 | int s; | 1024 | int s; | |
1021 | 1025 | |||
1022 | s = splbio(); | 1026 | s = splbio(); | |
1023 | fd->sc_flags &= ~FD_MOTOR_WAIT; | 1027 | fd->sc_flags &= ~FD_MOTOR_WAIT; | |
1024 | if ((fdc->sc_drives.tqh_first == fd) && (fdc->sc_state == MOTORWAIT)) | 1028 | if ((fdc->sc_drives.tqh_first == fd) && (fdc->sc_state == MOTORWAIT)) | |
1025 | (void) fdcstate(fdc); | 1029 | (void) fdcstate(fdc); | |
1026 | splx(s); | 1030 | splx(s); | |
1027 | } | 1031 | } | |
1028 | 1032 | |||
1029 | /* | 1033 | /* | |
1030 | * Get status bytes off the FDC after a command has finished | 1034 | * Get status bytes off the FDC after a command has finished | |
1031 | * Returns the number of status bytes read; -1 on error. | 1035 | * Returns the number of status bytes read; -1 on error. | |
1032 | * The return value is also stored in `sc_nstat'. | 1036 | * The return value is also stored in `sc_nstat'. | |
@@ -1238,43 +1242,43 @@ fdcstatus(struct fdc_softc *fdc, const c | @@ -1238,43 +1242,43 @@ fdcstatus(struct fdc_softc *fdc, const c | |||
1238 | #if 0 | 1242 | #if 0 | |
1239 | /* | 1243 | /* | |
1240 | * A 82072 seems to return <invalid command> on | 1244 | * A 82072 seems to return <invalid command> on | |
1241 | * gratuitous Sense Interrupt commands. | 1245 | * gratuitous Sense Interrupt commands. | |
1242 | */ | 1246 | */ | |
1243 | if (n == 0 && (fdc->sc_flags & FDC_82077) != 0) { | 1247 | if (n == 0 && (fdc->sc_flags & FDC_82077) != 0) { | |
1244 | fdc_wrfifo(fdc, NE7CMD_SENSEI); | 1248 | fdc_wrfifo(fdc, NE7CMD_SENSEI); | |
1245 | (void) fdcresult(fdc); | 1249 | (void) fdcresult(fdc); | |
1246 | n = 2; | 1250 | n = 2; | |
1247 | } | 1251 | } | |
1248 | #endif | 1252 | #endif | |
1249 | 1253 | |||
1250 | printf("%s: %s: state %d", | 1254 | printf("%s: %s: state %d", | |
1251 | fd ? fd->sc_dv.dv_xname : "fdc", s, fdc->sc_state); | 1255 | fd ? device_xname(fd->sc_dv) : "fdc", s, fdc->sc_state); | |
1252 | 1256 | |||
1253 | fdcpstatus(n, fdc); | 1257 | fdcpstatus(n, fdc); | |
1254 | } | 1258 | } | |
1255 | 1259 | |||
1256 | void | 1260 | void | |
1257 | fdctimeout(void *arg) | 1261 | fdctimeout(void *arg) | |
1258 | { | 1262 | { | |
1259 | struct fdc_softc *fdc = arg; | 1263 | struct fdc_softc *fdc = arg; | |
1260 | struct fd_softc *fd; | 1264 | struct fd_softc *fd; | |
1261 | int s; | 1265 | int s; | |
1262 | 1266 | |||
1263 | s = splbio(); | 1267 | s = splbio(); | |
1264 | fd = fdc->sc_drives.tqh_first; | 1268 | fd = fdc->sc_drives.tqh_first; | |
1265 | if (fd == NULL) { | 1269 | if (fd == NULL) { | |
1266 | printf("%s: timeout but no I/O pending: state %d, istatus=%d\n", | 1270 | printf("%s: timeout but no I/O pending: state %d, istatus=%d\n", | |
1267 | fdc->sc_dev.dv_xname, | 1271 | device_xname(fdc->sc_dev), | |
1268 | fdc->sc_state, fdc->sc_istatus); | 1272 | fdc->sc_state, fdc->sc_istatus); | |
1269 | fdc->sc_state = DEVIDLE; | 1273 | fdc->sc_state = DEVIDLE; | |
1270 | goto out; | 1274 | goto out; | |
1271 | } | 1275 | } | |
1272 | 1276 | |||
1273 | if (bufq_peek(fd->sc_q) != NULL) | 1277 | if (bufq_peek(fd->sc_q) != NULL) | |
1274 | fdc->sc_state++; | 1278 | fdc->sc_state++; | |
1275 | else | 1279 | else | |
1276 | fdc->sc_state = DEVIDLE; | 1280 | fdc->sc_state = DEVIDLE; | |
1277 | 1281 | |||
1278 | (void) fdcstate(fdc); | 1282 | (void) fdcstate(fdc); | |
1279 | out: | 1283 | out: | |
1280 | splx(s); | 1284 | splx(s); | |
@@ -1543,27 +1547,27 @@ loop: | @@ -1543,27 +1547,27 @@ loop: | |||
1543 | 1547 | |||
1544 | case DSKCHGWAIT: | 1548 | case DSKCHGWAIT: | |
1545 | callout_stop(&fdc->sc_timo_ch); | 1549 | callout_stop(&fdc->sc_timo_ch); | |
1546 | disk_unbusy(&fd->sc_dk, 0, 0); | 1550 | disk_unbusy(&fd->sc_dk, 0, 0); | |
1547 | if (fdc->sc_nstat != 2 || (st0 & 0xf8) != 0x20 || | 1551 | if (fdc->sc_nstat != 2 || (st0 & 0xf8) != 0x20 || | |
1548 | cyl != 1 * fd->sc_type->step) { | 1552 | cyl != 1 * fd->sc_type->step) { | |
1549 | fdcstatus(fdc, "dskchg seek failed"); | 1553 | fdcstatus(fdc, "dskchg seek failed"); | |
1550 | fdc->sc_state = DORESET; | 1554 | fdc->sc_state = DORESET; | |
1551 | } else | 1555 | } else | |
1552 | fdc->sc_state = DORECAL; | 1556 | fdc->sc_state = DORECAL; | |
1553 | 1557 | |||
1554 | if (fdc_diskchange(fdc)) { | 1558 | if (fdc_diskchange(fdc)) { | |
1555 | printf("%s: cannot clear disk change status\n", | 1559 | printf("%s: cannot clear disk change status\n", | |
1556 | fdc->sc_dev.dv_xname); | 1560 | device_xname(fdc->sc_dev)); | |
1557 | fdc->sc_state = DORESET; | 1561 | fdc->sc_state = DORESET; | |
1558 | } | 1562 | } | |
1559 | goto loop; | 1563 | goto loop; | |
1560 | 1564 | |||
1561 | case DOIO: | 1565 | case DOIO: | |
1562 | doio: | 1566 | doio: | |
1563 | if (finfo != NULL) | 1567 | if (finfo != NULL) | |
1564 | fd->sc_skip = (char *)&(finfo->fd_formb_cylno(0)) - | 1568 | fd->sc_skip = (char *)&(finfo->fd_formb_cylno(0)) - | |
1565 | (char *)finfo; | 1569 | (char *)finfo; | |
1566 | type = fd->sc_type; | 1570 | type = fd->sc_type; | |
1567 | sec = fd->sc_blkno % type->seccyl; | 1571 | sec = fd->sc_blkno % type->seccyl; | |
1568 | nblks = type->seccyl - sec; | 1572 | nblks = type->seccyl - sec; | |
1569 | nblks = min(nblks, fd->sc_bcount / FD_BSIZE(fd)); | 1573 | nblks = min(nblks, fd->sc_bcount / FD_BSIZE(fd)); | |
@@ -1857,52 +1861,54 @@ fdcretry(struct fdc_softc *fdc) | @@ -1857,52 +1861,54 @@ fdcretry(struct fdc_softc *fdc) | |||
1857 | 1861 | |||
1858 | fd = fdc->sc_drives.tqh_first; | 1862 | fd = fdc->sc_drives.tqh_first; | |
1859 | bp = bufq_peek(fd->sc_q); | 1863 | bp = bufq_peek(fd->sc_q); | |
1860 | 1864 | |||
1861 | fdc->sc_overruns = 0; | 1865 | fdc->sc_overruns = 0; | |
1862 | if (fd->sc_opts & FDOPT_NORETRY) | 1866 | if (fd->sc_opts & FDOPT_NORETRY) | |
1863 | goto fail; | 1867 | goto fail; | |
1864 | 1868 | |||
1865 | switch (fdc->sc_errors) { | 1869 | switch (fdc->sc_errors) { | |
1866 | case 0: | 1870 | case 0: | |
1867 | if (fdc->sc_nstat == 7 && | 1871 | if (fdc->sc_nstat == 7 && | |
1868 | (fdc->sc_status[0] & 0xd8) == 0x40 && | 1872 | (fdc->sc_status[0] & 0xd8) == 0x40 && | |
1869 | (fdc->sc_status[1] & 0x2) == 0x2) { | 1873 | (fdc->sc_status[1] & 0x2) == 0x2) { | |
1870 | printf("%s: read-only medium\n", fd->sc_dv.dv_xname); | 1874 | printf("%s: read-only medium\n", | |
1875 | device_xname(fd->sc_dv)); | |||
1871 | error = EROFS; | 1876 | error = EROFS; | |
1872 | goto failsilent; | 1877 | goto failsilent; | |
1873 | } | 1878 | } | |
1874 | /* try again */ | 1879 | /* try again */ | |
1875 | fdc->sc_state = | 1880 | fdc->sc_state = | |
1876 | (fdc->sc_flags & FDC_EIS) ? DOIO : DOSEEK; | 1881 | (fdc->sc_flags & FDC_EIS) ? DOIO : DOSEEK; | |
1877 | break; | 1882 | break; | |
1878 | 1883 | |||
1879 | case 1: case 2: case 3: | 1884 | case 1: case 2: case 3: | |
1880 | /* didn't work; try recalibrating */ | 1885 | /* didn't work; try recalibrating */ | |
1881 | fdc->sc_state = DORECAL; | 1886 | fdc->sc_state = DORECAL; | |
1882 | break; | 1887 | break; | |
1883 | 1888 | |||
1884 | case 4: | 1889 | case 4: | |
1885 | if (fdc->sc_nstat == 7 && | 1890 | if (fdc->sc_nstat == 7 && | |
1886 | fdc->sc_status[0] == 0 && | 1891 | fdc->sc_status[0] == 0 && | |
1887 | fdc->sc_status[1] == 0 && | 1892 | fdc->sc_status[1] == 0 && | |
1888 | fdc->sc_status[2] == 0) { | 1893 | fdc->sc_status[2] == 0) { | |
1889 | /* | 1894 | /* | |
1890 | * We've retried a few times and we've got | 1895 | * We've retried a few times and we've got | |
1891 | * valid status and all three status bytes | 1896 | * valid status and all three status bytes | |
1892 | * are zero. Assume this condition is the | 1897 | * are zero. Assume this condition is the | |
1893 | * result of no disk loaded into the drive. | 1898 | * result of no disk loaded into the drive. | |
1894 | */ | 1899 | */ | |
1895 | printf("%s: no medium?\n", fd->sc_dv.dv_xname); | 1900 | printf("%s: no medium?\n", | |
1901 | device_xname(fd->sc_dv)); | |||
1896 | error = ENODEV; | 1902 | error = ENODEV; | |
1897 | goto failsilent; | 1903 | goto failsilent; | |
1898 | } | 1904 | } | |
1899 | 1905 | |||
1900 | /* still no go; reset the bastard */ | 1906 | /* still no go; reset the bastard */ | |
1901 | fdc->sc_state = DORESET; | 1907 | fdc->sc_state = DORESET; | |
1902 | break; | 1908 | break; | |
1903 | 1909 | |||
1904 | default: | 1910 | default: | |
1905 | fail: | 1911 | fail: | |
1906 | if ((fd->sc_opts & FDOPT_SILENT) == 0) { | 1912 | if ((fd->sc_opts & FDOPT_SILENT) == 0) { | |
1907 | diskerr(bp, "fd", "hard error", LOG_PRINTF, | 1913 | diskerr(bp, "fd", "hard error", LOG_PRINTF, | |
1908 | fd->sc_skip / FD_BSIZE(fd), | 1914 | fd->sc_skip / FD_BSIZE(fd), | |
@@ -1926,27 +1932,27 @@ fdioctl(dev_t dev, u_long cmd, void *add | @@ -1926,27 +1932,27 @@ fdioctl(dev_t dev, u_long cmd, void *add | |||
1926 | struct fdformat_parms *form_parms; | 1932 | struct fdformat_parms *form_parms; | |
1927 | struct fdformat_cmd *form_cmd; | 1933 | struct fdformat_cmd *form_cmd; | |
1928 | struct ne7_fd_formb *fd_formb; | 1934 | struct ne7_fd_formb *fd_formb; | |
1929 | int il[FD_MAX_NSEC + 1]; | 1935 | int il[FD_MAX_NSEC + 1]; | |
1930 | int unit; | 1936 | int unit; | |
1931 | int i, j; | 1937 | int i, j; | |
1932 | int error; | 1938 | int error; | |
1933 | 1939 | |||
1934 | unit = FDUNIT(dev); | 1940 | unit = FDUNIT(dev); | |
1935 | if (unit >= fd_cd.cd_ndevs) | 1941 | if (unit >= fd_cd.cd_ndevs) | |
1936 | return (ENXIO); | 1942 | return (ENXIO); | |
1937 | 1943 | |||
1938 | fd = device_lookup_private(&fd_cd, FDUNIT(dev)); | 1944 | fd = device_lookup_private(&fd_cd, FDUNIT(dev)); | |
1939 | fdc = device_private(device_parent(&fd->sc_dv)); | 1945 | fdc = device_private(device_parent(fd->sc_dv)); | |
1940 | 1946 | |||
1941 | switch (cmd) { | 1947 | switch (cmd) { | |
1942 | case DIOCGDINFO: | 1948 | case DIOCGDINFO: | |
1943 | *(struct disklabel *)addr = *(fd->sc_dk.dk_label); | 1949 | *(struct disklabel *)addr = *(fd->sc_dk.dk_label); | |
1944 | return 0; | 1950 | return 0; | |
1945 | 1951 | |||
1946 | case DIOCWLABEL: | 1952 | case DIOCWLABEL: | |
1947 | if ((flag & FWRITE) == 0) | 1953 | if ((flag & FWRITE) == 0) | |
1948 | return EBADF; | 1954 | return EBADF; | |
1949 | /* XXX do something */ | 1955 | /* XXX do something */ | |
1950 | return (0); | 1956 | return (0); | |
1951 | 1957 | |||
1952 | case DIOCWDINFO: | 1958 | case DIOCWDINFO: | |
@@ -2267,27 +2273,27 @@ fdgetdisklabel(dev_t dev) | @@ -2267,27 +2273,27 @@ fdgetdisklabel(dev_t dev) | |||
2267 | lp->d_partitions[i].p_fstype = FS_BSDFFS; | 2273 | lp->d_partitions[i].p_fstype = FS_BSDFFS; | |
2268 | } else { | 2274 | } else { | |
2269 | lp->d_partitions[i].p_size = 0; | 2275 | lp->d_partitions[i].p_size = 0; | |
2270 | lp->d_partitions[i].p_fstype = FS_UNUSED; | 2276 | lp->d_partitions[i].p_fstype = FS_UNUSED; | |
2271 | } | 2277 | } | |
2272 | } | 2278 | } | |
2273 | lp->d_npartitions = RAW_PART + 1; | 2279 | lp->d_npartitions = RAW_PART + 1; | |
2274 | } | 2280 | } | |
2275 | } | 2281 | } | |
2276 | 2282 | |||
2277 | void | 2283 | void | |
2278 | fd_do_eject(struct fd_softc *fd) | 2284 | fd_do_eject(struct fd_softc *fd) | |
2279 | { | 2285 | { | |
2280 | struct fdc_softc *fdc = device_private(device_parent(&fd->sc_dv)); | 2286 | struct fdc_softc *fdc = device_private(device_parent(fd->sc_dv)); | |
2281 | 2287 | |||
2282 | if (CPU_ISSUN4C) { | 2288 | if (CPU_ISSUN4C) { | |
2283 | auxregbisc(AUXIO4C_FDS, AUXIO4C_FEJ); | 2289 | auxregbisc(AUXIO4C_FDS, AUXIO4C_FEJ); | |
2284 | delay(10); | 2290 | delay(10); | |
2285 | auxregbisc(AUXIO4C_FEJ, AUXIO4C_FDS); | 2291 | auxregbisc(AUXIO4C_FEJ, AUXIO4C_FDS); | |
2286 | return; | 2292 | return; | |
2287 | } | 2293 | } | |
2288 | if (CPU_ISSUN4M && (fdc->sc_flags & FDC_82077) != 0) { | 2294 | if (CPU_ISSUN4M && (fdc->sc_flags & FDC_82077) != 0) { | |
2289 | bus_space_tag_t t = fdc->sc_bustag; | 2295 | bus_space_tag_t t = fdc->sc_bustag; | |
2290 | bus_space_handle_t h = fdc->sc_handle; | 2296 | bus_space_handle_t h = fdc->sc_handle; | |
2291 | uint8_t dor = FDO_FRST | FDO_FDMAEN | FDO_MOEN(0); | 2297 | uint8_t dor = FDO_FRST | FDO_FDMAEN | FDO_MOEN(0); | |
2292 | 2298 | |||
2293 | bus_space_write_1(t, h, fdc->sc_reg_dor, dor | FDO_EJ); | 2299 | bus_space_write_1(t, h, fdc->sc_reg_dor, dor | FDO_EJ); |
--- src/sys/arch/sparc/dev/power.c 2005/11/16 00:49:03 1.17
+++ src/sys/arch/sparc/dev/power.c 2011/07/17 23:18:23 1.18
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: power.c,v 1.17 2005/11/16 00:49:03 uwe Exp $ */ | 1 | /* $NetBSD: power.c,v 1.18 2011/07/17 23:18:23 mrg Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 1996 | 4 | * Copyright (c) 1996 | |
5 | * The President and Fellows of Harvard College. All rights reserved. | 5 | * The President and Fellows of Harvard College. All rights reserved. | |
6 | * | 6 | * | |
7 | * All advertising materials mentioning features or use of this software | 7 | * All advertising materials mentioning features or use of this software | |
8 | * must display the following acknowledgement: | 8 | * must display the following acknowledgement: | |
9 | * This product includes software developed by Aaron Brown and | 9 | * This product includes software developed by Aaron Brown and | |
10 | * Harvard University. | 10 | * Harvard University. | |
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: | |
@@ -30,74 +30,73 @@ | @@ -30,74 +30,73 @@ | |||
30 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 30 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
31 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 31 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
32 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | 32 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
33 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 33 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
34 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 34 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
35 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 35 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
36 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 36 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
37 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 37 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
38 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 38 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
39 | * SUCH DAMAGE. | 39 | * SUCH DAMAGE. | |
40 | */ | 40 | */ | |
41 | 41 | |||
42 | #include <sys/cdefs.h> | 42 | #include <sys/cdefs.h> | |
43 | __KERNEL_RCSID(0, "$NetBSD: power.c,v 1.17 2005/11/16 00:49:03 uwe Exp $"); | 43 | __KERNEL_RCSID(0, "$NetBSD: power.c,v 1.18 2011/07/17 23:18:23 mrg Exp $"); | |
44 | 44 | |||
45 | #include <sys/param.h> | 45 | #include <sys/param.h> | |
46 | #include <sys/device.h> | 46 | #include <sys/device.h> | |
47 | #include <sys/kernel.h> | 47 | #include <sys/kernel.h> | |
48 | #include <sys/systm.h> | 48 | #include <sys/systm.h> | |
49 | 49 | |||
50 | #include <machine/autoconf.h> | 50 | #include <machine/autoconf.h> | |
51 | 51 | |||
52 | #include <sparc/dev/power.h> | 52 | #include <sparc/dev/power.h> | |
53 | 53 | |||
54 | static int powermatch(struct device *, struct cfdata *, void *); | 54 | static int powermatch(device_t, cfdata_t, void *); | |
55 | static void powerattach(struct device *, struct device *, void *); | 55 | static void powerattach(device_t, device_t, void *); | |
56 | 56 | |||
57 | CFATTACH_DECL(power, sizeof(struct device), | 57 | CFATTACH_DECL_NEW(power, 0, powermatch, powerattach, NULL, NULL); | |
58 | powermatch, powerattach, NULL, NULL); | |||
59 | 58 | |||
60 | /* | 59 | /* | |
61 | * This is the driver for the "power" register available on some Sun4m | 60 | * This is the driver for the "power" register available on some Sun4m | |
62 | * machines. This allows the machine to remove power automatically when | 61 | * machines. This allows the machine to remove power automatically when | |
63 | * shutdown or halted or whatever. | 62 | * shutdown or halted or whatever. | |
64 | */ | 63 | */ | |
65 | 64 | |||
66 | static int | 65 | static int | |
67 | powermatch(struct device *parent, struct cfdata *cf, void *aux) | 66 | powermatch(device_t parent, cfdata_t cf, void *aux) | |
68 | { | 67 | { | |
69 | union obio_attach_args *uoba = aux; | 68 | union obio_attach_args *uoba = aux; | |
70 | struct sbus_attach_args *sa = &uoba->uoba_sbus; | 69 | struct sbus_attach_args *sa = &uoba->uoba_sbus; | |
71 | 70 | |||
72 | if (uoba->uoba_isobio4 != 0) | 71 | if (uoba->uoba_isobio4 != 0) | |
73 | return (0); | 72 | return (0); | |
74 | 73 | |||
75 | return (strcmp("power", sa->sa_name) == 0); | 74 | return (strcmp("power", sa->sa_name) == 0); | |
76 | } | 75 | } | |
77 | 76 | |||
78 | /* ARGSUSED */ | 77 | /* ARGSUSED */ | |
79 | static void | 78 | static void | |
80 | powerattach(struct device *parent, struct device *self, void *aux) | 79 | powerattach(device_t parent, device_t self, void *aux) | |
81 | { | 80 | { | |
82 | union obio_attach_args *uoba = aux; | 81 | union obio_attach_args *uoba = aux; | |
83 | struct sbus_attach_args *sa = &uoba->uoba_sbus; | 82 | struct sbus_attach_args *sa = &uoba->uoba_sbus; | |
84 | bus_space_handle_t bh; | 83 | bus_space_handle_t bh; | |
85 | 84 | |||
86 | /* Map the power configuration register. */ | 85 | /* Map the power configuration register. */ | |
87 | if (sbus_bus_map(sa->sa_bustag, | 86 | if (sbus_bus_map(sa->sa_bustag, | |
88 | sa->sa_slot, sa->sa_offset, sizeof(uint8_t), | 87 | sa->sa_slot, sa->sa_offset, sizeof(uint8_t), | |
89 | BUS_SPACE_MAP_LINEAR, &bh) != 0) { | 88 | BUS_SPACE_MAP_LINEAR, &bh) != 0) { | |
90 | printf("%s: cannot map register\n", self->dv_xname); | 89 | printf("%s: cannot map register\n", device_xname(self)); | |
91 | return; | 90 | return; | |
92 | } | 91 | } | |
93 | power_reg = (volatile uint8_t *)bh; | 92 | power_reg = (volatile uint8_t *)bh; | |
94 | 93 | |||
95 | printf("\n"); | 94 | printf("\n"); | |
96 | } | 95 | } | |
97 | 96 | |||
98 | void | 97 | void | |
99 | powerdown(void) | 98 | powerdown(void) | |
100 | { | 99 | { | |
101 | /* Only try if the power node was attached. */ | 100 | /* Only try if the power node was attached. */ | |
102 | if (power_reg != NULL) | 101 | if (power_reg != NULL) | |
103 | *POWER_REG |= POWER_OFF; | 102 | *POWER_REG |= POWER_OFF; |
--- src/sys/arch/sparc/sparc/autoconf.c 2011/07/06 20:47:05 1.241
+++ src/sys/arch/sparc/sparc/autoconf.c 2011/07/17 23:18:23 1.242
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: autoconf.c,v 1.241 2011/07/06 20:47:05 dyoung Exp $ */ | 1 | /* $NetBSD: autoconf.c,v 1.242 2011/07/17 23:18:23 mrg Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 1996 | 4 | * Copyright (c) 1996 | |
5 | * The President and Fellows of Harvard College. All rights reserved. | 5 | * The President and Fellows of Harvard College. All rights reserved. | |
6 | * Copyright (c) 1992, 1993 | 6 | * Copyright (c) 1992, 1993 | |
7 | * The Regents of the University of California. All rights reserved. | 7 | * The Regents of the University of California. All rights reserved. | |
8 | * | 8 | * | |
9 | * This software was developed by the Computer Systems Engineering group | 9 | * This software was developed by the Computer Systems Engineering group | |
10 | * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and | 10 | * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and | |
11 | * contributed to Berkeley. | 11 | * contributed to Berkeley. | |
12 | * | 12 | * | |
13 | * All advertising materials mentioning features or use of this software | 13 | * All advertising materials mentioning features or use of this software | |
14 | * must display the following acknowledgement: | 14 | * must display the following acknowledgement: | |
@@ -38,27 +38,27 @@ | @@ -38,27 +38,27 @@ | |||
38 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | 38 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
39 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 39 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
40 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 40 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
41 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 41 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
42 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 42 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
43 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 43 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
44 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 44 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
45 | * SUCH DAMAGE. | 45 | * SUCH DAMAGE. | |
46 | * | 46 | * | |
47 | * @(#)autoconf.c 8.4 (Berkeley) 10/1/93 | 47 | * @(#)autoconf.c 8.4 (Berkeley) 10/1/93 | |
48 | */ | 48 | */ | |
49 | 49 | |||
50 | #include <sys/cdefs.h> | 50 | #include <sys/cdefs.h> | |
51 | __KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.241 2011/07/06 20:47:05 dyoung Exp $"); | 51 | __KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.242 2011/07/17 23:18:23 mrg Exp $"); | |
52 | 52 | |||
53 | #include "opt_ddb.h" | 53 | #include "opt_ddb.h" | |
54 | #include "opt_kgdb.h" | 54 | #include "opt_kgdb.h" | |
55 | #include "opt_modular.h" | 55 | #include "opt_modular.h" | |
56 | #include "opt_multiprocessor.h" | 56 | #include "opt_multiprocessor.h" | |
57 | #include "opt_sparc_arch.h" | 57 | #include "opt_sparc_arch.h" | |
58 | 58 | |||
59 | #include "scsibus.h" | 59 | #include "scsibus.h" | |
60 | 60 | |||
61 | #include <sys/param.h> | 61 | #include <sys/param.h> | |
62 | #include <sys/kernel.h> | 62 | #include <sys/kernel.h> | |
63 | #include <sys/systm.h> | 63 | #include <sys/systm.h> | |
64 | #include <sys/endian.h> | 64 | #include <sys/endian.h> | |
@@ -121,28 +121,28 @@ extern int kgdb_debug_panic; | @@ -121,28 +121,28 @@ extern int kgdb_debug_panic; | |||
121 | #endif | 121 | #endif | |
122 | extern void *bootinfo; | 122 | extern void *bootinfo; | |
123 | 123 | |||
124 | #if !NKSYMS && !defined(DDB) && !defined(MODULAR) | 124 | #if !NKSYMS && !defined(DDB) && !defined(MODULAR) | |
125 | void bootinfo_relocate(void *); | 125 | void bootinfo_relocate(void *); | |
126 | #endif | 126 | #endif | |
127 | 127 | |||
128 | static const char *str2hex(const char *, int *); | 128 | static const char *str2hex(const char *, int *); | |
129 | static int mbprint(void *, const char *); | 129 | static int mbprint(void *, const char *); | |
130 | static void crazymap(const char *, int *); | 130 | static void crazymap(const char *, int *); | |
131 | int st_crazymap(int); | 131 | int st_crazymap(int); | |
132 | int sd_crazymap(int); | 132 | int sd_crazymap(int); | |
133 | void sync_crash(void); | 133 | void sync_crash(void); | |
134 | int mainbus_match(struct device *, struct cfdata *, void *); | 134 | int mainbus_match(device_t, cfdata_t, void *); | |
135 | static void mainbus_attach(struct device *, struct device *, void *); | 135 | static void mainbus_attach(device_t, device_t, void *); | |
136 | 136 | |||
137 | struct bootpath bootpath[8]; | 137 | struct bootpath bootpath[8]; | |
138 | int nbootpath; | 138 | int nbootpath; | |
139 | static void bootpath_build(void); | 139 | static void bootpath_build(void); | |
140 | static void bootpath_fake(struct bootpath *, const char *); | 140 | static void bootpath_fake(struct bootpath *, const char *); | |
141 | static void bootpath_print(struct bootpath *); | 141 | static void bootpath_print(struct bootpath *); | |
142 | static struct bootpath *bootpath_store(int, struct bootpath *); | 142 | static struct bootpath *bootpath_store(int, struct bootpath *); | |
143 | int find_cpus(void); | 143 | int find_cpus(void); | |
144 | char machine_model[100]; | 144 | char machine_model[100]; | |
145 | 145 | |||
146 | #ifdef DEBUG | 146 | #ifdef DEBUG | |
147 | #define ACDB_BOOTDEV 0x1 | 147 | #define ACDB_BOOTDEV 0x1 | |
148 | #define ACDB_PROBE 0x2 | 148 | #define ACDB_PROBE 0x2 | |
@@ -1034,52 +1034,52 @@ mbprint(void *aux, const char *name) | @@ -1034,52 +1034,52 @@ mbprint(void *aux, const char *name) | |||
1034 | 1034 | |||
1035 | if (name) | 1035 | if (name) | |
1036 | aprint_normal("%s at %s", ma->ma_name, name); | 1036 | aprint_normal("%s at %s", ma->ma_name, name); | |
1037 | if (ma->ma_paddr) | 1037 | if (ma->ma_paddr) | |
1038 | aprint_normal(" %saddr 0x%lx", | 1038 | aprint_normal(" %saddr 0x%lx", | |
1039 | BUS_ADDR_IOSPACE(ma->ma_paddr) ? "io" : "", | 1039 | BUS_ADDR_IOSPACE(ma->ma_paddr) ? "io" : "", | |
1040 | (u_long)BUS_ADDR_PADDR(ma->ma_paddr)); | 1040 | (u_long)BUS_ADDR_PADDR(ma->ma_paddr)); | |
1041 | if (ma->ma_pri) | 1041 | if (ma->ma_pri) | |
1042 | aprint_normal(" ipl %d", ma->ma_pri); | 1042 | aprint_normal(" ipl %d", ma->ma_pri); | |
1043 | return (UNCONF); | 1043 | return (UNCONF); | |
1044 | } | 1044 | } | |
1045 | 1045 | |||
1046 | int | 1046 | int | |
1047 | mainbus_match(struct device *parent, struct cfdata *cf, void *aux) | 1047 | mainbus_match(device_t parent, cfdata_t cf, void *aux) | |
1048 | { | 1048 | { | |
1049 | 1049 | |||
1050 | return (1); | 1050 | return (1); | |
1051 | } | 1051 | } | |
1052 | 1052 | |||
1053 | /* | 1053 | /* | |
1054 | * Helper routines to get some of the more common properties. These | 1054 | * Helper routines to get some of the more common properties. These | |
1055 | * only get the first item in case the property value is an array. | 1055 | * only get the first item in case the property value is an array. | |
1056 | * Drivers that "need to know it all" can call prom_getprop() directly. | 1056 | * Drivers that "need to know it all" can call prom_getprop() directly. | |
1057 | */ | 1057 | */ | |
1058 | #if defined(SUN4C) || defined(SUN4M) || defined(SUN4D) | 1058 | #if defined(SUN4C) || defined(SUN4M) || defined(SUN4D) | |
1059 | static int prom_getprop_reg1(int, struct openprom_addr *); | 1059 | static int prom_getprop_reg1(int, struct openprom_addr *); | |
1060 | static int prom_getprop_intr1(int, int *); | 1060 | static int prom_getprop_intr1(int, int *); | |
1061 | static int prom_getprop_address1(int, void **); | 1061 | static int prom_getprop_address1(int, void **); | |
1062 | #endif | 1062 | #endif | |
1063 | 1063 | |||
1064 | /* | 1064 | /* | |
1065 | * Attach the mainbus. | 1065 | * Attach the mainbus. | |
1066 | * | 1066 | * | |
1067 | * Our main job is to attach the CPU (the root node we got in configure()) | 1067 | * Our main job is to attach the CPU (the root node we got in configure()) | |
1068 | * and iterate down the list of `mainbus devices' (children of that node). | 1068 | * and iterate down the list of `mainbus devices' (children of that node). | |
1069 | * We also record the `node id' of the default frame buffer, if any. | 1069 | * We also record the `node id' of the default frame buffer, if any. | |
1070 | */ | 1070 | */ | |
1071 | static void | 1071 | static void | |
1072 | mainbus_attach(struct device *parent, struct device *dev, void *aux) | 1072 | mainbus_attach(device_t parent, device_t dev, void *aux) | |
1073 | { | 1073 | { | |
1074 | extern struct sparc_bus_dma_tag mainbus_dma_tag; | 1074 | extern struct sparc_bus_dma_tag mainbus_dma_tag; | |
1075 | extern struct sparc_bus_space_tag mainbus_space_tag; | 1075 | extern struct sparc_bus_space_tag mainbus_space_tag; | |
1076 | 1076 | |||
1077 | struct mainbus_attach_args ma; | 1077 | struct mainbus_attach_args ma; | |
1078 | char namebuf[32]; | 1078 | char namebuf[32]; | |
1079 | #if defined(SUN4C) || defined(SUN4M) || defined(SUN4D) | 1079 | #if defined(SUN4C) || defined(SUN4M) || defined(SUN4D) | |
1080 | const char *const *ssp, *sp = NULL; | 1080 | const char *const *ssp, *sp = NULL; | |
1081 | int node0, node; | 1081 | int node0, node; | |
1082 | const char *const *openboot_special; | 1082 | const char *const *openboot_special; | |
1083 | #endif | 1083 | #endif | |
1084 | 1084 | |||
1085 | #if defined(SUN4C) | 1085 | #if defined(SUN4C) | |
@@ -1355,28 +1355,27 @@ extern struct sparc_bus_space_tag mainbu | @@ -1355,28 +1355,27 @@ extern struct sparc_bus_space_tag mainbu | |||
1355 | ma.ma_size = romreg.oa_size; | 1355 | ma.ma_size = romreg.oa_size; | |
1356 | 1356 | |||
1357 | if (prom_getprop_intr1(node, &ma.ma_pri) != 0) | 1357 | if (prom_getprop_intr1(node, &ma.ma_pri) != 0) | |
1358 | continue; | 1358 | continue; | |
1359 | 1359 | |||
1360 | if (prom_getprop_address1(node, &ma.ma_promvaddr) != 0) | 1360 | if (prom_getprop_address1(node, &ma.ma_promvaddr) != 0) | |
1361 | continue; | 1361 | continue; | |
1362 | 1362 | |||
1363 | (void) config_found(dev, (void *)&ma, mbprint); | 1363 | (void) config_found(dev, (void *)&ma, mbprint); | |
1364 | } | 1364 | } | |
1365 | #endif /* SUN4C || SUN4M || SUN4D */ | 1365 | #endif /* SUN4C || SUN4M || SUN4D */ | |
1366 | } | 1366 | } | |
1367 | 1367 | |||
1368 | CFATTACH_DECL(mainbus, sizeof(struct device), | 1368 | CFATTACH_DECL_NEW(mainbus, 0, mainbus_match, mainbus_attach, NULL, NULL); | |
1369 | mainbus_match, mainbus_attach, NULL, NULL); | |||
1370 | 1369 | |||
1371 | 1370 | |||
1372 | #if defined(SUN4C) || defined(SUN4M) || defined(SUN4D) | 1371 | #if defined(SUN4C) || defined(SUN4M) || defined(SUN4D) | |
1373 | int | 1372 | int | |
1374 | prom_getprop_reg1(int node, struct openprom_addr *rrp) | 1373 | prom_getprop_reg1(int node, struct openprom_addr *rrp) | |
1375 | { | 1374 | { | |
1376 | int error, n; | 1375 | int error, n; | |
1377 | struct openprom_addr *rrp0 = NULL; | 1376 | struct openprom_addr *rrp0 = NULL; | |
1378 | char buf[32]; | 1377 | char buf[32]; | |
1379 | 1378 | |||
1380 | error = prom_getprop(node, "reg", sizeof(struct openprom_addr), | 1379 | error = prom_getprop(node, "reg", sizeof(struct openprom_addr), | |
1381 | &n, &rrp0); | 1380 | &n, &rrp0); | |
1382 | if (error != 0) { | 1381 | if (error != 0) { |
--- src/sys/arch/sparc/sparc/auxreg.c 2007/10/17 19:57:14 1.38
+++ src/sys/arch/sparc/sparc/auxreg.c 2011/07/17 23:18:23 1.39
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: auxreg.c,v 1.38 2007/10/17 19:57:14 garbled Exp $ */ | 1 | /* $NetBSD: auxreg.c,v 1.39 2011/07/17 23:18:23 mrg Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 1992, 1993 | 4 | * Copyright (c) 1992, 1993 | |
5 | * The Regents of the University of California. All rights reserved. | 5 | * The Regents of the University of California. All rights reserved. | |
6 | * | 6 | * | |
7 | * This software was developed by the Computer Systems Engineering group | 7 | * This software was developed by the Computer Systems Engineering group | |
8 | * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and | 8 | * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and | |
9 | * contributed to Berkeley. | 9 | * contributed to Berkeley. | |
10 | * | 10 | * | |
11 | * All advertising materials mentioning features or use of this software | 11 | * All advertising materials mentioning features or use of this software | |
12 | * must display the following acknowledgement: | 12 | * must display the following acknowledgement: | |
13 | * This product includes software developed by the University of | 13 | * This product includes software developed by the University of | |
14 | * California, Lawrence Berkeley Laboratory. | 14 | * California, Lawrence Berkeley Laboratory. | |
@@ -31,52 +31,52 @@ | @@ -31,52 +31,52 @@ | |||
31 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | 31 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
32 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 32 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
36 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 36 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
37 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 37 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
38 | * SUCH DAMAGE. | 38 | * SUCH DAMAGE. | |
39 | * | 39 | * | |
40 | * @(#)auxreg.c 8.1 (Berkeley) 6/11/93 | 40 | * @(#)auxreg.c 8.1 (Berkeley) 6/11/93 | |
41 | */ | 41 | */ | |
42 | 42 | |||
43 | #include <sys/cdefs.h> | 43 | #include <sys/cdefs.h> | |
44 | __KERNEL_RCSID(0, "$NetBSD: auxreg.c,v 1.38 2007/10/17 19:57:14 garbled Exp $"); | 44 | __KERNEL_RCSID(0, "$NetBSD: auxreg.c,v 1.39 2011/07/17 23:18:23 mrg Exp $"); | |
45 | 45 | |||
46 | #include "opt_blink.h" | 46 | #include "opt_blink.h" | |
47 | 47 | |||
48 | #include <sys/param.h> | 48 | #include <sys/param.h> | |
49 | #include <sys/systm.h> | 49 | #include <sys/systm.h> | |
50 | #include <sys/callout.h> | 50 | #include <sys/callout.h> | |
51 | #include <sys/device.h> | 51 | #include <sys/device.h> | |
52 | #include <sys/kernel.h> | 52 | #include <sys/kernel.h> | |
53 | 53 | |||
54 | #include <machine/autoconf.h> | 54 | #include <machine/autoconf.h> | |
55 | 55 | |||
56 | #include <sparc/sparc/vaddrs.h> | 56 | #include <sparc/sparc/vaddrs.h> | |
57 | #include <sparc/sparc/auxreg.h> | 57 | #include <sparc/sparc/auxreg.h> | |
58 | 58 | |||
59 | static int auxregmatch_mainbus(struct device *, struct cfdata *, void *); | 59 | static int auxregmatch_mainbus(device_t, cfdata_t, void *); | |
60 | static int auxregmatch_obio(struct device *, struct cfdata *, void *); | 60 | static int auxregmatch_obio(device_t, cfdata_t, void *); | |
61 | static void auxregattach_mainbus(struct device *, struct device *, void *); | 61 | static void auxregattach_mainbus(device_t, device_t, void *); | |
62 | static void auxregattach_obio(struct device *, struct device *, void *); | 62 | static void auxregattach_obio(device_t, device_t, void *); | |
63 | 63 | |||
64 | static void auxregattach(struct device *); | 64 | static void auxregattach(void); | |
65 | 65 | |||
66 | CFATTACH_DECL(auxreg_mainbus, sizeof(struct device), | 66 | CFATTACH_DECL_NEW(auxreg_mainbus, 0, | |
67 | auxregmatch_mainbus, auxregattach_mainbus, NULL, NULL); | 67 | auxregmatch_mainbus, auxregattach_mainbus, NULL, NULL); | |
68 | 68 | |||
69 | CFATTACH_DECL(auxreg_obio, sizeof(struct device), | 69 | CFATTACH_DECL_NEW(auxreg_obio, 0, | |
70 | auxregmatch_obio, auxregattach_obio, NULL, NULL); | 70 | auxregmatch_obio, auxregattach_obio, NULL, NULL); | |
71 | 71 | |||
72 | #ifdef BLINK | 72 | #ifdef BLINK | |
73 | static callout_t blink_ch; | 73 | static callout_t blink_ch; | |
74 | 74 | |||
75 | static void blink(void *); | 75 | static void blink(void *); | |
76 | 76 | |||
77 | static void | 77 | static void | |
78 | blink(void *zero) | 78 | blink(void *zero) | |
79 | { | 79 | { | |
80 | register int s; | 80 | register int s; | |
81 | 81 | |||
82 | s = splhigh(); | 82 | s = splhigh(); | |
@@ -88,89 +88,89 @@ blink(void *zero) | @@ -88,89 +88,89 @@ blink(void *zero) | |||
88 | * full cycle every 2 seconds if loadav = 1 | 88 | * full cycle every 2 seconds if loadav = 1 | |
89 | * full cycle every 3 seconds if loadav = 2 | 89 | * full cycle every 3 seconds if loadav = 2 | |
90 | * etc. | 90 | * etc. | |
91 | */ | 91 | */ | |
92 | s = (((averunnable.ldavg[0] + FSCALE) * hz) >> (FSHIFT + 1)); | 92 | s = (((averunnable.ldavg[0] + FSCALE) * hz) >> (FSHIFT + 1)); | |
93 | callout_reset(&blink_ch, s, blink, NULL); | 93 | callout_reset(&blink_ch, s, blink, NULL); | |
94 | } | 94 | } | |
95 | #endif | 95 | #endif | |
96 | 96 | |||
97 | /* | 97 | /* | |
98 | * The OPENPROM calls this "auxiliary-io" (sun4c) or "auxio" (sun4m). | 98 | * The OPENPROM calls this "auxiliary-io" (sun4c) or "auxio" (sun4m). | |
99 | */ | 99 | */ | |
100 | static int | 100 | static int | |
101 | auxregmatch_mainbus(struct device *parent, struct cfdata *cf, void *aux) | 101 | auxregmatch_mainbus(device_t parent, cfdata_t cf, void *aux) | |
102 | { | 102 | { | |
103 | struct mainbus_attach_args *ma = aux; | 103 | struct mainbus_attach_args *ma = aux; | |
104 | 104 | |||
105 | return (strcmp("auxiliary-io", ma->ma_name) == 0); | 105 | return (strcmp("auxiliary-io", ma->ma_name) == 0); | |
106 | } | 106 | } | |
107 | 107 | |||
108 | static int | 108 | static int | |
109 | auxregmatch_obio(struct device *parent, struct cfdata *cf, void *aux) | 109 | auxregmatch_obio(device_t parent, cfdata_t cf, void *aux) | |
110 | { | 110 | { | |
111 | union obio_attach_args *uoba = aux; | 111 | union obio_attach_args *uoba = aux; | |
112 | 112 | |||
113 | if (uoba->uoba_isobio4 != 0) | 113 | if (uoba->uoba_isobio4 != 0) | |
114 | return (0); | 114 | return (0); | |
115 | 115 | |||
116 | return (strcmp("auxio", uoba->uoba_sbus.sa_name) == 0); | 116 | return (strcmp("auxio", uoba->uoba_sbus.sa_name) == 0); | |
117 | } | 117 | } | |
118 | 118 | |||
119 | /* ARGSUSED */ | 119 | /* ARGSUSED */ | |
120 | static void | 120 | static void | |
121 | auxregattach_mainbus(struct device *parent, struct device *self, void *aux) | 121 | auxregattach_mainbus(device_t parent, device_t self, void *aux) | |
122 | { | 122 | { | |
123 | struct mainbus_attach_args *ma = aux; | 123 | struct mainbus_attach_args *ma = aux; | |
124 | bus_space_handle_t bh; | 124 | bus_space_handle_t bh; | |
125 | 125 | |||
126 | if (bus_space_map2(ma->ma_bustag, | 126 | if (bus_space_map2(ma->ma_bustag, | |
127 | (bus_addr_t)ma->ma_paddr, | 127 | (bus_addr_t)ma->ma_paddr, | |
128 | sizeof(long), | 128 | sizeof(long), | |
129 | BUS_SPACE_MAP_LINEAR, | 129 | BUS_SPACE_MAP_LINEAR, | |
130 | AUXREG_VA, | 130 | AUXREG_VA, | |
131 | &bh) != 0) { | 131 | &bh) != 0) { | |
132 | printf("auxregattach_mainbus: can't map register\n"); | 132 | printf("auxregattach_mainbus: can't map register\n"); | |
133 | return; | 133 | return; | |
134 | } | 134 | } | |
135 | 135 | |||
136 | auxio_reg = AUXIO4C_REG; | 136 | auxio_reg = AUXIO4C_REG; | |
137 | auxio_regval = *AUXIO4C_REG | AUXIO4C_FEJ | AUXIO4C_MB1; | 137 | auxio_regval = *AUXIO4C_REG | AUXIO4C_FEJ | AUXIO4C_MB1; | |
138 | auxregattach(self); | 138 | auxregattach(); | |
139 | } | 139 | } | |
140 | 140 | |||
141 | static void | 141 | static void | |
142 | auxregattach_obio(struct device *parent, struct device *self, void *aux) | 142 | auxregattach_obio(device_t parent, device_t self, void *aux) | |
143 | { | 143 | { | |
144 | union obio_attach_args *uoba = aux; | 144 | union obio_attach_args *uoba = aux; | |
145 | struct sbus_attach_args *sa = &uoba->uoba_sbus; | 145 | struct sbus_attach_args *sa = &uoba->uoba_sbus; | |
146 | bus_space_handle_t bh; | 146 | bus_space_handle_t bh; | |
147 | 147 | |||
148 | if (bus_space_map2(sa->sa_bustag, | 148 | if (bus_space_map2(sa->sa_bustag, | |
149 | BUS_ADDR(sa->sa_slot, sa->sa_offset), | 149 | BUS_ADDR(sa->sa_slot, sa->sa_offset), | |
150 | sizeof(long), | 150 | sizeof(long), | |
151 | BUS_SPACE_MAP_LINEAR, | 151 | BUS_SPACE_MAP_LINEAR, | |
152 | AUXREG_VA, &bh) != 0) { | 152 | AUXREG_VA, &bh) != 0) { | |
153 | printf("auxregattach_obio: can't map register\n"); | 153 | printf("auxregattach_obio: can't map register\n"); | |
154 | return; | 154 | return; | |
155 | } | 155 | } | |
156 | 156 | |||
157 | auxio_reg = AUXIO4M_REG; | 157 | auxio_reg = AUXIO4M_REG; | |
158 | auxio_regval = *AUXIO4M_REG | AUXIO4M_MB1; | 158 | auxio_regval = *AUXIO4M_REG | AUXIO4M_MB1; | |
159 | auxregattach(self); | 159 | auxregattach(); | |
160 | } | 160 | } | |
161 | 161 | |||
162 | static void | 162 | static void | |
163 | auxregattach(struct device *self) | 163 | auxregattach(void) | |
164 | { | 164 | { | |
165 | 165 | |||
166 | printf("\n"); | 166 | printf("\n"); | |
167 | #ifdef BLINK | 167 | #ifdef BLINK | |
168 | callout_init(&blink_ch, 0); | 168 | callout_init(&blink_ch, 0); | |
169 | blink((void *)0); | 169 | blink((void *)0); | |
170 | #else | 170 | #else | |
171 | LED_ON; | 171 | LED_ON; | |
172 | #endif | 172 | #endif | |
173 | } | 173 | } | |
174 | 174 | |||
175 | unsigned int | 175 | unsigned int | |
176 | auxregbisc(int bis, int bic) | 176 | auxregbisc(int bis, int bic) |
--- src/sys/arch/sparc/sparc/cpu.c 2011/02/20 11:41:20 1.232
+++ src/sys/arch/sparc/sparc/cpu.c 2011/07/17 23:18:23 1.233
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: cpu.c,v 1.232 2011/02/20 11:41:20 mrg Exp $ */ | 1 | /* $NetBSD: cpu.c,v 1.233 2011/07/17 23:18:23 mrg Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 1996 | 4 | * Copyright (c) 1996 | |
5 | * The President and Fellows of Harvard College. All rights reserved. | 5 | * The President and Fellows of Harvard College. All rights reserved. | |
6 | * Copyright (c) 1992, 1993 | 6 | * Copyright (c) 1992, 1993 | |
7 | * The Regents of the University of California. All rights reserved. | 7 | * The Regents of the University of California. All rights reserved. | |
8 | * | 8 | * | |
9 | * This software was developed by the Computer Systems Engineering group | 9 | * This software was developed by the Computer Systems Engineering group | |
10 | * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and | 10 | * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and | |
11 | * contributed to Berkeley. | 11 | * contributed to Berkeley. | |
12 | * | 12 | * | |
13 | * All advertising materials mentioning features or use of this software | 13 | * All advertising materials mentioning features or use of this software | |
14 | * must display the following acknowledgement: | 14 | * must display the following acknowledgement: | |
@@ -42,27 +42,27 @@ | @@ -42,27 +42,27 @@ | |||
42 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 42 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
43 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 43 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
44 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 44 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
45 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 45 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
46 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 46 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
47 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 47 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
48 | * SUCH DAMAGE. | 48 | * SUCH DAMAGE. | |
49 | * | 49 | * | |
50 | * @(#)cpu.c 8.5 (Berkeley) 11/23/93 | 50 | * @(#)cpu.c 8.5 (Berkeley) 11/23/93 | |
51 | * | 51 | * | |
52 | */ | 52 | */ | |
53 | 53 | |||
54 | #include <sys/cdefs.h> | 54 | #include <sys/cdefs.h> | |
55 | __KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.232 2011/02/20 11:41:20 mrg Exp $"); | 55 | __KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.233 2011/07/17 23:18:23 mrg Exp $"); | |
56 | 56 | |||
57 | #include "opt_multiprocessor.h" | 57 | #include "opt_multiprocessor.h" | |
58 | #include "opt_lockdebug.h" | 58 | #include "opt_lockdebug.h" | |
59 | #include "opt_ddb.h" | 59 | #include "opt_ddb.h" | |
60 | #include "opt_sparc_arch.h" | 60 | #include "opt_sparc_arch.h" | |
61 | 61 | |||
62 | #include <sys/param.h> | 62 | #include <sys/param.h> | |
63 | #include <sys/systm.h> | 63 | #include <sys/systm.h> | |
64 | #include <sys/device.h> | 64 | #include <sys/device.h> | |
65 | #include <sys/malloc.h> | 65 | #include <sys/malloc.h> | |
66 | #include <sys/kernel.h> | 66 | #include <sys/kernel.h> | |
67 | #include <sys/evcnt.h> | 67 | #include <sys/evcnt.h> | |
68 | #include <sys/xcall.h> | 68 | #include <sys/xcall.h> | |
@@ -83,52 +83,52 @@ __KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.23 | @@ -83,52 +83,52 @@ __KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.23 | |||
83 | #include <ddb/db_output.h> | 83 | #include <ddb/db_output.h> | |
84 | #include <machine/db_machdep.h> | 84 | #include <machine/db_machdep.h> | |
85 | #endif | 85 | #endif | |
86 | 86 | |||
87 | #include <sparc/sparc/cache.h> | 87 | #include <sparc/sparc/cache.h> | |
88 | #include <sparc/sparc/asm.h> | 88 | #include <sparc/sparc/asm.h> | |
89 | #include <sparc/sparc/cpuvar.h> | 89 | #include <sparc/sparc/cpuvar.h> | |
90 | #include <sparc/sparc/memreg.h> | 90 | #include <sparc/sparc/memreg.h> | |
91 | #if defined(SUN4D) | 91 | #if defined(SUN4D) | |
92 | #include <sparc/sparc/cpuunitvar.h> | 92 | #include <sparc/sparc/cpuunitvar.h> | |
93 | #endif | 93 | #endif | |
94 | 94 | |||
95 | struct cpu_softc { | 95 | struct cpu_softc { | |
96 | struct device sc_dev; /* generic device info */ | 96 | device_t sc_dev; | |
97 | struct cpu_info *sc_cpuinfo; | 97 | struct cpu_info *sc_cpuinfo; | |
98 | }; | 98 | }; | |
99 | 99 | |||
100 | /* The following are used externally (sysctl_hw). */ | 100 | /* The following are used externally (sysctl_hw). */ | |
101 | char machine[] = MACHINE; /* from <machine/param.h> */ | 101 | char machine[] = MACHINE; /* from <machine/param.h> */ | |
102 | char machine_arch[] = MACHINE_ARCH; /* from <machine/param.h> */ | 102 | char machine_arch[] = MACHINE_ARCH; /* from <machine/param.h> */ | |
103 | int cpu_arch; /* sparc architecture version */ | 103 | int cpu_arch; /* sparc architecture version */ | |
104 | char cpu_model[100]; /* machine model (primary CPU) */ | 104 | char cpu_model[100]; /* machine model (primary CPU) */ | |
105 | extern char machine_model[]; | 105 | extern char machine_model[]; | |
106 | 106 | |||
107 | int sparc_ncpus; /* # of CPUs detected by PROM */ | 107 | int sparc_ncpus; /* # of CPUs detected by PROM */ | |
108 | struct cpu_info *cpus[_MAXNCPU+1]; /* we only support 4 CPUs. */ | 108 | struct cpu_info *cpus[_MAXNCPU+1]; /* we only support 4 CPUs. */ | |
109 | 109 | |||
110 | /* The CPU configuration driver. */ | 110 | /* The CPU configuration driver. */ | |
111 | static void cpu_mainbus_attach(struct device *, struct device *, void *); | 111 | static void cpu_mainbus_attach(device_t, device_t, void *); | |
112 | int cpu_mainbus_match(struct device *, struct cfdata *, void *); | 112 | int cpu_mainbus_match(device_t, cfdata_t, void *); | |
113 | 113 | |||
114 | CFATTACH_DECL(cpu_mainbus, sizeof(struct cpu_softc), | 114 | CFATTACH_DECL_NEW(cpu_mainbus, sizeof(struct cpu_softc), | |
115 | cpu_mainbus_match, cpu_mainbus_attach, NULL, NULL); | 115 | cpu_mainbus_match, cpu_mainbus_attach, NULL, NULL); | |
116 | 116 | |||
117 | #if defined(SUN4D) | 117 | #if defined(SUN4D) | |
118 | static int cpu_cpuunit_match(struct device *, struct cfdata *, void *); | 118 | static int cpu_cpuunit_match(device_t, cfdata_t, void *); | |
119 | static void cpu_cpuunit_attach(struct device *, struct device *, void *); | 119 | static void cpu_cpuunit_attach(device_t, device_t, void *); | |
120 | 120 | |||
121 | CFATTACH_DECL(cpu_cpuunit, sizeof(struct cpu_softc), | 121 | CFATTACH_DECL_NEW(cpu_cpuunit, sizeof(struct cpu_softc), | |
122 | cpu_cpuunit_match, cpu_cpuunit_attach, NULL, NULL); | 122 | cpu_cpuunit_match, cpu_cpuunit_attach, NULL, NULL); | |
123 | #endif /* SUN4D */ | 123 | #endif /* SUN4D */ | |
124 | 124 | |||
125 | static void cpu_init_evcnt(struct cpu_info *cpi); | 125 | static void cpu_init_evcnt(struct cpu_info *cpi); | |
126 | static void cpu_attach(struct cpu_softc *, int, int); | 126 | static void cpu_attach(struct cpu_softc *, int, int); | |
127 | 127 | |||
128 | static const char *fsrtoname(int, int, int); | 128 | static const char *fsrtoname(int, int, int); | |
129 | void cache_print(struct cpu_softc *); | 129 | void cache_print(struct cpu_softc *); | |
130 | void cpu_setup(void); | 130 | void cpu_setup(void); | |
131 | void fpu_init(struct cpu_info *); | 131 | void fpu_init(struct cpu_info *); | |
132 | 132 | |||
133 | #define IU_IMPL(psr) ((u_int)(psr) >> 28) | 133 | #define IU_IMPL(psr) ((u_int)(psr) >> 28) | |
134 | #define IU_VERS(psr) (((psr) >> 24) & 0xf) | 134 | #define IU_VERS(psr) (((psr) >> 24) & 0xf) | |
@@ -183,48 +183,51 @@ static kmutex_t xpmsg_mutex; | @@ -183,48 +183,51 @@ static kmutex_t xpmsg_mutex; | |||
183 | * this confuses autoconf. for example, if you try and map | 183 | * this confuses autoconf. for example, if you try and map | |
184 | * 0xfe000000 in obio space on a 4/110 it actually maps 0x0e000000. | 184 | * 0xfe000000 in obio space on a 4/110 it actually maps 0x0e000000. | |
185 | * this is easy to verify with the PROM. this causes problems | 185 | * this is easy to verify with the PROM. this causes problems | |
186 | * with devices like "esp0 at obio0 addr 0xfa000000" because the | 186 | * with devices like "esp0 at obio0 addr 0xfa000000" because the | |
187 | * 4/110 treats it as esp0 at obio0 addr 0x0a000000" which is the | 187 | * 4/110 treats it as esp0 at obio0 addr 0x0a000000" which is the | |
188 | * address of the 4/110's "sw0" scsi chip. the same thing happens | 188 | * address of the 4/110's "sw0" scsi chip. the same thing happens | |
189 | * between zs1 and zs2. since the sun4 line is "closed" and | 189 | * between zs1 and zs2. since the sun4 line is "closed" and | |
190 | * we know all the "obio" devices that will ever be on it we just | 190 | * we know all the "obio" devices that will ever be on it we just | |
191 | * put in some special case "if"'s in the match routines of esp, | 191 | * put in some special case "if"'s in the match routines of esp, | |
192 | * dma, and zs. | 192 | * dma, and zs. | |
193 | */ | 193 | */ | |
194 | 194 | |||
195 | int | 195 | int | |
196 | cpu_mainbus_match(struct device *parent, struct cfdata *cf, void *aux) | 196 | cpu_mainbus_match(device_t parent, cfdata_t cf, void *aux) | |
197 | { | 197 | { | |
198 | struct mainbus_attach_args *ma = aux; | 198 | struct mainbus_attach_args *ma = aux; | |
199 | 199 | |||
200 | return (strcmp(cf->cf_name, ma->ma_name) == 0); | 200 | return (strcmp(cf->cf_name, ma->ma_name) == 0); | |
201 | } | 201 | } | |
202 | 202 | |||
203 | static void | 203 | static void | |
204 | cpu_mainbus_attach(struct device *parent, struct device *self, void *aux) | 204 | cpu_mainbus_attach(device_t parent, device_t self, void *aux) | |
205 | { | 205 | { | |
206 | struct mainbus_attach_args *ma = aux; | 206 | struct mainbus_attach_args *ma = aux; | |
207 | struct { uint32_t va; uint32_t size; } *mbprop = NULL; | 207 | struct { uint32_t va; uint32_t size; } *mbprop = NULL; | |
208 | struct openprom_addr *rrp = NULL; | 208 | struct openprom_addr *rrp = NULL; | |
209 | struct cpu_info *cpi; | 209 | struct cpu_info *cpi; | |
210 | struct cpu_softc *sc; | |||
210 | int mid, node; | 211 | int mid, node; | |
211 | int error, n; | 212 | int error, n; | |
212 | 213 | |||
213 | node = ma->ma_node; | 214 | node = ma->ma_node; | |
214 | mid = (node != 0) ? prom_getpropint(node, "mid", 0) : 0; | 215 | mid = (node != 0) ? prom_getpropint(node, "mid", 0) : 0; | |
215 | cpu_attach((struct cpu_softc *)self, node, mid); | 216 | sc = device_private(self); | |
217 | sc->sc_dev = self; | |||
218 | cpu_attach(sc, node, mid); | |||
216 | 219 | |||
217 | cpi = ((struct cpu_softc *)self)->sc_cpuinfo; | 220 | cpi = sc->sc_cpuinfo; | |
218 | if (cpi == NULL) | 221 | if (cpi == NULL) | |
219 | return; | 222 | return; | |
220 | 223 | |||
221 | /* | 224 | /* | |
222 | * Map CPU mailbox if available | 225 | * Map CPU mailbox if available | |
223 | */ | 226 | */ | |
224 | if (node != 0 && (error = prom_getprop(node, "mailbox-virtual", | 227 | if (node != 0 && (error = prom_getprop(node, "mailbox-virtual", | |
225 | sizeof(*mbprop), | 228 | sizeof(*mbprop), | |
226 | &n, &mbprop)) == 0) { | 229 | &n, &mbprop)) == 0) { | |
227 | cpi->mailbox = mbprop->va; | 230 | cpi->mailbox = mbprop->va; | |
228 | free(mbprop, M_DEVBUF); | 231 | free(mbprop, M_DEVBUF); | |
229 | } else if (node != 0 && (error = prom_getprop(node, "mailbox", | 232 | } else if (node != 0 && (error = prom_getprop(node, "mailbox", | |
230 | sizeof(struct openprom_addr), | 233 | sizeof(struct openprom_addr), | |
@@ -270,40 +273,41 @@ cpu_mainbus_attach(struct device *parent | @@ -270,40 +273,41 @@ cpu_mainbus_attach(struct device *parent | |||
270 | BUS_ADDR(rrp[1].oa_space, rrp[1].oa_base), | 273 | BUS_ADDR(rrp[1].oa_space, rrp[1].oa_base), | |
271 | rrp[1].oa_size, | 274 | rrp[1].oa_size, | |
272 | BUS_SPACE_MAP_LINEAR, | 275 | BUS_SPACE_MAP_LINEAR, | |
273 | &cpi->ci_mxccregs) != 0) { | 276 | &cpi->ci_mxccregs) != 0) { | |
274 | panic("%s: can't map CPU regs", self->dv_xname); | 277 | panic("%s: can't map CPU regs", self->dv_xname); | |
275 | } | 278 | } | |
276 | /* register sets #3 and #4 are E$ cache data and tags */ | 279 | /* register sets #3 and #4 are E$ cache data and tags */ | |
277 | 280 | |||
278 | free(rrp, M_DEVBUF); | 281 | free(rrp, M_DEVBUF); | |
279 | } | 282 | } | |
280 | 283 | |||
281 | #if defined(SUN4D) | 284 | #if defined(SUN4D) | |
282 | static int | 285 | static int | |
283 | cpu_cpuunit_match(struct device *parent, struct cfdata *cf, void *aux) | 286 | cpu_cpuunit_match(device_t parent, cfdata_t cf, void *aux) | |
284 | { | 287 | { | |
285 | struct cpuunit_attach_args *cpua = aux; | 288 | struct cpuunit_attach_args *cpua = aux; | |
286 | 289 | |||
287 | return (strcmp(cf->cf_name, cpua->cpua_type) == 0); | 290 | return (strcmp(cf->cf_name, cpua->cpua_type) == 0); | |
288 | } | 291 | } | |
289 | 292 | |||
290 | static void | 293 | static void | |
291 | cpu_cpuunit_attach(struct device *parent, struct device *self, void *aux) | 294 | cpu_cpuunit_attach(device_t parent, device_t self, void *aux) | |
292 | { | 295 | { | |
293 | struct cpuunit_attach_args *cpua = aux; | 296 | struct cpuunit_attach_args *cpua = aux; | |
297 | struct cpu_softc *sc = device_private(self); | |||
294 | 298 | |||
295 | cpu_attach((struct cpu_softc *)self, cpua->cpua_node, | 299 | sc->sc_dev = self; | |
296 | cpua->cpua_device_id); | 300 | cpu_attach(sc, cpua->cpua_node, cpua->cpua_device_id); | |
297 | } | 301 | } | |
298 | #endif /* SUN4D */ | 302 | #endif /* SUN4D */ | |
299 | 303 | |||
300 | static const char * const hard_intr_names[] = { | 304 | static const char * const hard_intr_names[] = { | |
301 | "spur hard", | 305 | "spur hard", | |
302 | "lev1 hard", | 306 | "lev1 hard", | |
303 | "lev2 hard", | 307 | "lev2 hard", | |
304 | "lev3 hard", | 308 | "lev3 hard", | |
305 | "lev4 hard", | 309 | "lev4 hard", | |
306 | "lev5 hard", | 310 | "lev5 hard", | |
307 | "lev6 hard", | 311 | "lev6 hard", | |
308 | "lev7 hard", | 312 | "lev7 hard", | |
309 | "lev8 hard", | 313 | "lev8 hard", | |
@@ -480,27 +484,27 @@ cpu_attach_non_boot(struct cpu_softc *sc | @@ -480,27 +484,27 @@ cpu_attach_non_boot(struct cpu_softc *sc | |||
480 | if (va == 0) | 484 | if (va == 0) | |
481 | panic("%s: no virtual space", __func__); | 485 | panic("%s: no virtual space", __func__); | |
482 | 486 | |||
483 | cpi->vpage[0] = (void *)(va + 0); | 487 | cpi->vpage[0] = (void *)(va + 0); | |
484 | cpi->vpage[1] = (void *)(va + PAGE_SIZE); | 488 | cpi->vpage[1] = (void *)(va + PAGE_SIZE); | |
485 | 489 | |||
486 | /* | 490 | /* | |
487 | * Call the MI attach which creates an idle LWP for us. | 491 | * Call the MI attach which creates an idle LWP for us. | |
488 | */ | 492 | */ | |
489 | error = mi_cpu_attach(cpi); | 493 | error = mi_cpu_attach(cpi); | |
490 | if (error != 0) { | 494 | if (error != 0) { | |
491 | aprint_normal("\n"); | 495 | aprint_normal("\n"); | |
492 | aprint_error("%s: mi_cpu_attach failed with %d\n", | 496 | aprint_error("%s: mi_cpu_attach failed with %d\n", | |
493 | sc->sc_dev.dv_xname, error); | 497 | device_xname(sc->sc_dev), error); | |
494 | return; | 498 | return; | |
495 | } | 499 | } | |
496 | 500 | |||
497 | /* | 501 | /* | |
498 | * Note: `eintstack' is set in cpu_attach_non_boot() above. | 502 | * Note: `eintstack' is set in cpu_attach_non_boot() above. | |
499 | * The %wim register will be initialized in cpu_hatch(). | 503 | * The %wim register will be initialized in cpu_hatch(). | |
500 | */ | 504 | */ | |
501 | cpi->ci_curlwp = cpi->ci_data.cpu_idlelwp; | 505 | cpi->ci_curlwp = cpi->ci_data.cpu_idlelwp; | |
502 | cpi->curpcb = lwp_getpcb(cpi->ci_curlwp); | 506 | cpi->curpcb = lwp_getpcb(cpi->ci_curlwp); | |
503 | cpi->curpcb->pcb_wim = 1; | 507 | cpi->curpcb->pcb_wim = 1; | |
504 | 508 | |||
505 | /* for now use the fixed virtual addresses setup in autoconf.c */ | 509 | /* for now use the fixed virtual addresses setup in autoconf.c */ | |
506 | cpi->intreg_4m = (struct icr_pi *) | 510 | cpi->intreg_4m = (struct icr_pi *) | |
@@ -929,29 +933,29 @@ fpu_init(struct cpu_info *sc) | @@ -929,29 +933,29 @@ fpu_init(struct cpu_info *sc) | |||
929 | if (sc->fpu_name == NULL) { | 933 | if (sc->fpu_name == NULL) { | |
930 | sprintf(sc->fpu_namebuf, "version 0x%x", fpuvers); | 934 | sprintf(sc->fpu_namebuf, "version 0x%x", fpuvers); | |
931 | sc->fpu_name = sc->fpu_namebuf; | 935 | sc->fpu_name = sc->fpu_namebuf; | |
932 | } | 936 | } | |
933 | } | 937 | } | |
934 | 938 | |||
935 | void | 939 | void | |
936 | cache_print(struct cpu_softc *sc) | 940 | cache_print(struct cpu_softc *sc) | |
937 | { | 941 | { | |
938 | struct cacheinfo *ci = &sc->sc_cpuinfo->cacheinfo; | 942 | struct cacheinfo *ci = &sc->sc_cpuinfo->cacheinfo; | |
939 | 943 | |||
940 | if (sc->sc_cpuinfo->flags & CPUFLG_SUN4CACHEBUG) | 944 | if (sc->sc_cpuinfo->flags & CPUFLG_SUN4CACHEBUG) | |
941 | printf("%s: cache chip bug; trap page uncached\n", | 945 | printf("%s: cache chip bug; trap page uncached\n", | |
942 | sc->sc_dev.dv_xname); | 946 | device_xname(sc->sc_dev)); | |
943 | 947 | |||
944 | printf("%s: ", sc->sc_dev.dv_xname); | 948 | printf("%s: ", device_xname(sc->sc_dev)); | |
945 | 949 | |||
946 | if (ci->c_totalsize == 0) { | 950 | if (ci->c_totalsize == 0) { | |
947 | printf("no cache\n"); | 951 | printf("no cache\n"); | |
948 | return; | 952 | return; | |
949 | } | 953 | } | |
950 | 954 | |||
951 | if (ci->c_split) { | 955 | if (ci->c_split) { | |
952 | const char *sep = ""; | 956 | const char *sep = ""; | |
953 | 957 | |||
954 | printf("%s", (ci->c_physical ? "physical " : "")); | 958 | printf("%s", (ci->c_physical ? "physical " : "")); | |
955 | if (ci->ic_totalsize > 0) { | 959 | if (ci->ic_totalsize > 0) { | |
956 | printf("%s%dK instruction (%d b/l)", sep, | 960 | printf("%s%dK instruction (%d b/l)", sep, | |
957 | ci->ic_totalsize/1024, ci->ic_linesize); | 961 | ci->ic_totalsize/1024, ci->ic_linesize); |
--- src/sys/arch/sparc/sparc/cpuunit.c 2011/07/01 18:51:51 1.14
+++ src/sys/arch/sparc/sparc/cpuunit.c 2011/07/17 23:18:23 1.15
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: cpuunit.c,v 1.14 2011/07/01 18:51:51 dyoung Exp $ */ | 1 | /* $NetBSD: cpuunit.c,v 1.15 2011/07/17 23:18:23 mrg Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2002 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2002 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Jason R. Thorpe. | 8 | * by Jason R. Thorpe. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -24,76 +24,75 @@ | @@ -24,76 +24,75 @@ | |||
24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
29 | * POSSIBILITY OF SUCH DAMAGE. | 29 | * POSSIBILITY OF SUCH DAMAGE. | |
30 | */ | 30 | */ | |
31 | 31 | |||
32 | /* | 32 | /* | |
33 | * Autoconfiguration support for Sun4d "cpu units". | 33 | * Autoconfiguration support for Sun4d "cpu units". | |
34 | */ | 34 | */ | |
35 | 35 | |||
36 | #include <sys/cdefs.h> | 36 | #include <sys/cdefs.h> | |
37 | __KERNEL_RCSID(0, "$NetBSD: cpuunit.c,v 1.14 2011/07/01 18:51:51 dyoung Exp $"); | 37 | __KERNEL_RCSID(0, "$NetBSD: cpuunit.c,v 1.15 2011/07/17 23:18:23 mrg Exp $"); | |
38 | 38 | |||
39 | #include <sys/param.h> | 39 | #include <sys/param.h> | |
40 | #include <sys/malloc.h> | 40 | #include <sys/malloc.h> | |
41 | #include <sys/systm.h> | 41 | #include <sys/systm.h> | |
42 | #include <sys/device.h> | 42 | #include <sys/device.h> | |
43 | 43 | |||
44 | #include <machine/autoconf.h> | 44 | #include <machine/autoconf.h> | |
45 | #include <sys/bus.h> | 45 | #include <sys/bus.h> | |
46 | 46 | |||
47 | #include <sparc/sparc/cpuunitvar.h> | 47 | #include <sparc/sparc/cpuunitvar.h> | |
48 | 48 | |||
49 | struct cpuunit_softc { | 49 | struct cpuunit_softc { | |
50 | struct device sc_dev; | |||
51 | int sc_node; /* our OBP node */ | 50 | int sc_node; /* our OBP node */ | |
52 | 51 | |||
53 | bus_space_tag_t sc_st; /* ours */ | 52 | bus_space_tag_t sc_st; /* ours */ | |
54 | bus_space_tag_t sc_bustag; /* passed on to children */ | 53 | bus_space_tag_t sc_bustag; /* passed on to children */ | |
55 | 54 | |||
56 | int sc_device_id; /* device-id */ | 55 | int sc_device_id; /* device-id */ | |
57 | int sc_board; /* board number */ | 56 | int sc_board; /* board number */ | |
58 | }; | 57 | }; | |
59 | 58 | |||
60 | static int cpuunit_match(struct device *, struct cfdata *, void *); | 59 | static int cpuunit_match(device_t, cfdata_t, void *); | |
61 | static void cpuunit_attach(struct device *, struct device *, void *); | 60 | static void cpuunit_attach(device_t, device_t, void *); | |
62 | 61 | |||
63 | CFATTACH_DECL(cpuunit, sizeof(struct cpuunit_softc), | 62 | CFATTACH_DECL_NEW(cpuunit, sizeof(struct cpuunit_softc), | |
64 | cpuunit_match, cpuunit_attach, NULL, NULL); | 63 | cpuunit_match, cpuunit_attach, NULL, NULL); | |
65 | 64 | |||
66 | static int cpuunit_print(void *, const char *); | 65 | static int cpuunit_print(void *, const char *); | |
67 | 66 | |||
68 | static int cpuunit_setup_attach_args(struct cpuunit_softc *, bus_space_tag_t, | 67 | static int cpuunit_setup_attach_args(struct cpuunit_softc *, bus_space_tag_t, | |
69 | int, struct cpuunit_attach_args *); | 68 | int, struct cpuunit_attach_args *); | |
70 | static void cpuunit_destroy_attach_args(struct cpuunit_attach_args *); | 69 | static void cpuunit_destroy_attach_args(struct cpuunit_attach_args *); | |
71 | 70 | |||
72 | static int | 71 | static int | |
73 | cpuunit_match(struct device *parent, struct cfdata *cf, void *aux) | 72 | cpuunit_match(device_t parent, cfdata_t cf, void *aux) | |
74 | { | 73 | { | |
75 | struct mainbus_attach_args *ma = aux; | 74 | struct mainbus_attach_args *ma = aux; | |
76 | 75 | |||
77 | if (strcmp(ma->ma_name, "cpu-unit") == 0) | 76 | if (strcmp(ma->ma_name, "cpu-unit") == 0) | |
78 | return (1); | 77 | return (1); | |
79 | 78 | |||
80 | return (0); | 79 | return (0); | |
81 | } | 80 | } | |
82 | 81 | |||
83 | static void | 82 | static void | |
84 | cpuunit_attach(struct device *parent, struct device *self, void *aux) | 83 | cpuunit_attach(device_t parent, device_t self, void *aux) | |
85 | { | 84 | { | |
86 | struct cpuunit_softc *sc = (void *) self; | 85 | struct cpuunit_softc *sc = device_private(self); | |
87 | struct mainbus_attach_args *ma = aux; | 86 | struct mainbus_attach_args *ma = aux; | |
88 | int node, error; | 87 | int node, error; | |
89 | bus_space_tag_t sbt; | 88 | bus_space_tag_t sbt; | |
90 | 89 | |||
91 | sc->sc_node = ma->ma_node; | 90 | sc->sc_node = ma->ma_node; | |
92 | sc->sc_st = ma->ma_bustag; | 91 | sc->sc_st = ma->ma_bustag; | |
93 | 92 | |||
94 | sc->sc_device_id = prom_getpropint(sc->sc_node, "device-id", -1); | 93 | sc->sc_device_id = prom_getpropint(sc->sc_node, "device-id", -1); | |
95 | sc->sc_board = prom_getpropint(sc->sc_node, "board#", -1); | 94 | sc->sc_board = prom_getpropint(sc->sc_node, "board#", -1); | |
96 | 95 | |||
97 | printf(": board #%d, ID %d\n", sc->sc_board, sc->sc_device_id); | 96 | printf(": board #%d, ID %d\n", sc->sc_board, sc->sc_device_id); | |
98 | 97 | |||
99 | /* | 98 | /* | |
@@ -103,39 +102,39 @@ cpuunit_attach(struct device *parent, st | @@ -103,39 +102,39 @@ cpuunit_attach(struct device *parent, st | |||
103 | memcpy(sbt, sc->sc_st, sizeof(*sbt)); | 102 | memcpy(sbt, sc->sc_st, sizeof(*sbt)); | |
104 | sbt->cookie = sc; | 103 | sbt->cookie = sc; | |
105 | sbt->parent = sc->sc_st; | 104 | sbt->parent = sc->sc_st; | |
106 | sbt->nranges = 0; | 105 | sbt->nranges = 0; | |
107 | sbt->ranges = NULL; | 106 | sbt->ranges = NULL; | |
108 | 107 | |||
109 | /* | 108 | /* | |
110 | * Collect address translations from the OBP. | 109 | * Collect address translations from the OBP. | |
111 | */ | 110 | */ | |
112 | error = prom_getprop(sc->sc_node, "ranges", | 111 | error = prom_getprop(sc->sc_node, "ranges", | |
113 | sizeof(struct openprom_range), &sbt->nranges, &sbt->ranges); | 112 | sizeof(struct openprom_range), &sbt->nranges, &sbt->ranges); | |
114 | if (error) { | 113 | if (error) { | |
115 | printf("%s: error %d getting \"ranges\" property\n", | 114 | printf("%s: error %d getting \"ranges\" property\n", | |
116 | sc->sc_dev.dv_xname, error); | 115 | device_xname(self), error); | |
117 | panic("cpuunit_attach"); | 116 | panic("cpuunit_attach"); | |
118 | } | 117 | } | |
119 | 118 | |||
120 | /* Attach the CPU (and possibly bootbus) child nodes. */ | 119 | /* Attach the CPU (and possibly bootbus) child nodes. */ | |
121 | for (node = firstchild(sc->sc_node); node != 0; | 120 | for (node = firstchild(sc->sc_node); node != 0; | |
122 | node = nextsibling(node)) { | 121 | node = nextsibling(node)) { | |
123 | struct cpuunit_attach_args cpua; | 122 | struct cpuunit_attach_args cpua; | |
124 | 123 | |||
125 | if (cpuunit_setup_attach_args(sc, sbt, node, &cpua)) | 124 | if (cpuunit_setup_attach_args(sc, sbt, node, &cpua)) | |
126 | panic("cpuunit_attach: failed to set up attach args"); | 125 | panic("cpuunit_attach: failed to set up attach args"); | |
127 | 126 | |||
128 | (void) config_found(&sc->sc_dev, &cpua, cpuunit_print); | 127 | (void) config_found(self, &cpua, cpuunit_print); | |
129 | 128 | |||
130 | cpuunit_destroy_attach_args(&cpua); | 129 | cpuunit_destroy_attach_args(&cpua); | |
131 | } | 130 | } | |
132 | } | 131 | } | |
133 | 132 | |||
134 | static int | 133 | static int | |
135 | cpuunit_print(void *aux, const char *pnp) | 134 | cpuunit_print(void *aux, const char *pnp) | |
136 | { | 135 | { | |
137 | struct cpuunit_attach_args *cpua = aux; | 136 | struct cpuunit_attach_args *cpua = aux; | |
138 | 137 | |||
139 | if (pnp) | 138 | if (pnp) | |
140 | aprint_normal("%s at %s", cpua->cpua_name, pnp); | 139 | aprint_normal("%s at %s", cpua->cpua_name, pnp); | |
141 | 140 |
--- src/sys/arch/sparc/sparc/iommu.c 2011/07/01 18:51:51 1.93
+++ src/sys/arch/sparc/sparc/iommu.c 2011/07/17 23:18:23 1.94
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: iommu.c,v 1.93 2011/07/01 18:51:51 dyoung Exp $ */ | 1 | /* $NetBSD: iommu.c,v 1.94 2011/07/17 23:18:23 mrg Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 1996 | 4 | * Copyright (c) 1996 | |
5 | * The President and Fellows of Harvard College. All rights reserved. | 5 | * The President and Fellows of Harvard College. All rights reserved. | |
6 | * Copyright (c) 1995 Paul Kranenburg | 6 | * Copyright (c) 1995 Paul Kranenburg | |
7 | * | 7 | * | |
8 | * Redistribution and use in source and binary forms, with or without | 8 | * Redistribution and use in source and binary forms, with or without | |
9 | * modification, are permitted provided that the following conditions | 9 | * modification, are permitted provided that the following conditions | |
10 | * are met: | 10 | * are met: | |
11 | * 1. Redistributions of source code must retain the above copyright | 11 | * 1. Redistributions of source code must retain the above copyright | |
12 | * notice, this list of conditions and the following disclaimer. | 12 | * notice, this list of conditions and the following disclaimer. | |
13 | * 2. Redistributions in binary form must reproduce the above copyright | 13 | * 2. Redistributions in binary form must reproduce the above copyright | |
14 | * notice, this list of conditions and the following disclaimer in the | 14 | * notice, this list of conditions and the following disclaimer in the | |
@@ -27,77 +27,76 @@ | @@ -27,77 +27,76 @@ | |||
27 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 27 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
28 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | 28 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
29 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 29 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
30 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 30 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
31 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 31 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
32 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 32 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
34 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 34 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
35 | * SUCH DAMAGE. | 35 | * SUCH DAMAGE. | |
36 | * | 36 | * | |
37 | */ | 37 | */ | |
38 | 38 | |||
39 | #include <sys/cdefs.h> | 39 | #include <sys/cdefs.h> | |
40 | __KERNEL_RCSID(0, "$NetBSD: iommu.c,v 1.93 2011/07/01 18:51:51 dyoung Exp $"); | 40 | __KERNEL_RCSID(0, "$NetBSD: iommu.c,v 1.94 2011/07/17 23:18:23 mrg Exp $"); | |
41 | 41 | |||
42 | #include "opt_sparc_arch.h" | 42 | #include "opt_sparc_arch.h" | |
43 | 43 | |||
44 | #include <sys/param.h> | 44 | #include <sys/param.h> | |
45 | #include <sys/extent.h> | 45 | #include <sys/extent.h> | |
46 | #include <sys/malloc.h> | 46 | #include <sys/malloc.h> | |
47 | #include <sys/queue.h> | 47 | #include <sys/queue.h> | |
48 | #include <sys/systm.h> | 48 | #include <sys/systm.h> | |
49 | #include <sys/device.h> | 49 | #include <sys/device.h> | |
50 | #include <sys/proc.h> | 50 | #include <sys/proc.h> | |
51 | 51 | |||
52 | #include <uvm/uvm.h> | 52 | #include <uvm/uvm.h> | |
53 | 53 | |||
54 | #define _SPARC_BUS_DMA_PRIVATE | 54 | #define _SPARC_BUS_DMA_PRIVATE | |
55 | #include <sys/bus.h> | 55 | #include <sys/bus.h> | |
56 | #include <machine/autoconf.h> | 56 | #include <machine/autoconf.h> | |
57 | #include <machine/ctlreg.h> | 57 | #include <machine/ctlreg.h> | |
58 | #include <sparc/sparc/asm.h> | 58 | #include <sparc/sparc/asm.h> | |
59 | #include <sparc/sparc/vaddrs.h> | 59 | #include <sparc/sparc/vaddrs.h> | |
60 | #include <sparc/sparc/cpuvar.h> | 60 | #include <sparc/sparc/cpuvar.h> | |
61 | #include <sparc/sparc/iommureg.h> | 61 | #include <sparc/sparc/iommureg.h> | |
62 | #include <sparc/sparc/iommuvar.h> | 62 | #include <sparc/sparc/iommuvar.h> | |
63 | 63 | |||
64 | struct iommu_softc { | 64 | struct iommu_softc { | |
65 | struct device sc_dev; /* base device */ | |||
66 | struct iommureg *sc_reg; | 65 | struct iommureg *sc_reg; | |
67 | u_int sc_pagesize; | 66 | u_int sc_pagesize; | |
68 | u_int sc_range; | 67 | u_int sc_range; | |
69 | bus_addr_t sc_dvmabase; | 68 | bus_addr_t sc_dvmabase; | |
70 | iopte_t *sc_ptes; | 69 | iopte_t *sc_ptes; | |
71 | int sc_cachecoherent; | 70 | int sc_cachecoherent; | |
72 | /* | 71 | /* | |
73 | * Note: operations on the extent map are being protected with | 72 | * Note: operations on the extent map are being protected with | |
74 | * splhigh(), since we cannot predict at which interrupt priority | 73 | * splhigh(), since we cannot predict at which interrupt priority | |
75 | * our clients will run. | 74 | * our clients will run. | |
76 | */ | 75 | */ | |
77 | struct sparc_bus_dma_tag sc_dmatag; | 76 | struct sparc_bus_dma_tag sc_dmatag; | |
78 | struct extent *sc_dvmamap; | 77 | struct extent *sc_dvmamap; | |
79 | }; | 78 | }; | |
80 | 79 | |||
81 | /* autoconfiguration driver */ | 80 | /* autoconfiguration driver */ | |
82 | int iommu_print(void *, const char *); | 81 | int iommu_print(void *, const char *); | |
83 | void iommu_attach(struct device *, struct device *, void *); | 82 | void iommu_attach(device_t, device_t, void *); | |
84 | int iommu_match(struct device *, struct cfdata *, void *); | 83 | int iommu_match(device_t, cfdata_t, void *); | |
85 | 84 | |||
86 | #if defined(SUN4M) | 85 | #if defined(SUN4M) | |
87 | static void iommu_copy_prom_entries(struct iommu_softc *); | 86 | static void iommu_copy_prom_entries(struct iommu_softc *); | |
88 | #endif | 87 | #endif | |
89 | 88 | |||
90 | CFATTACH_DECL(iommu, sizeof(struct iommu_softc), | 89 | CFATTACH_DECL_NEW(iommu, sizeof(struct iommu_softc), | |
91 | iommu_match, iommu_attach, NULL, NULL); | 90 | iommu_match, iommu_attach, NULL, NULL); | |
92 | 91 | |||
93 | /* IOMMU DMA map functions */ | 92 | /* IOMMU DMA map functions */ | |
94 | int iommu_dmamap_create(bus_dma_tag_t, bus_size_t, int, bus_size_t, | 93 | int iommu_dmamap_create(bus_dma_tag_t, bus_size_t, int, bus_size_t, | |
95 | bus_size_t, int, bus_dmamap_t *); | 94 | bus_size_t, int, bus_dmamap_t *); | |
96 | int iommu_dmamap_load(bus_dma_tag_t, bus_dmamap_t, void *, | 95 | int iommu_dmamap_load(bus_dma_tag_t, bus_dmamap_t, void *, | |
97 | bus_size_t, struct proc *, int); | 96 | bus_size_t, struct proc *, int); | |
98 | int iommu_dmamap_load_mbuf(bus_dma_tag_t, bus_dmamap_t, | 97 | int iommu_dmamap_load_mbuf(bus_dma_tag_t, bus_dmamap_t, | |
99 | struct mbuf *, int); | 98 | struct mbuf *, int); | |
100 | int iommu_dmamap_load_uio(bus_dma_tag_t, bus_dmamap_t, | 99 | int iommu_dmamap_load_uio(bus_dma_tag_t, bus_dmamap_t, | |
101 | struct uio *, int); | 100 | struct uio *, int); | |
102 | int iommu_dmamap_load_raw(bus_dma_tag_t, bus_dmamap_t, | 101 | int iommu_dmamap_load_raw(bus_dma_tag_t, bus_dmamap_t, | |
103 | bus_dma_segment_t *, int, bus_size_t, int); | 102 | bus_dma_segment_t *, int, bus_size_t, int); | |
@@ -120,43 +119,43 @@ int iommu_dvma_alloc(struct iommu_softc | @@ -120,43 +119,43 @@ int iommu_dvma_alloc(struct iommu_softc | |||
120 | * Return UNCONF (config_find ignores this if the device was configured). | 119 | * Return UNCONF (config_find ignores this if the device was configured). | |
121 | */ | 120 | */ | |
122 | int | 121 | int | |
123 | iommu_print(void *args, const char *iommu) | 122 | iommu_print(void *args, const char *iommu) | |
124 | { | 123 | { | |
125 | struct iommu_attach_args *ia = args; | 124 | struct iommu_attach_args *ia = args; | |
126 | 125 | |||
127 | if (iommu) | 126 | if (iommu) | |
128 | aprint_normal("%s at %s", ia->iom_name, iommu); | 127 | aprint_normal("%s at %s", ia->iom_name, iommu); | |
129 | return (UNCONF); | 128 | return (UNCONF); | |
130 | } | 129 | } | |
131 | 130 | |||
132 | int | 131 | int | |
133 | iommu_match(struct device *parent, struct cfdata *cf, void *aux) | 132 | iommu_match(device_t parent, cfdata_t cf, void *aux) | |
134 | { | 133 | { | |
135 | struct mainbus_attach_args *ma = aux; | 134 | struct mainbus_attach_args *ma = aux; | |
136 | 135 | |||
137 | if (CPU_ISSUN4 || CPU_ISSUN4C) | 136 | if (CPU_ISSUN4 || CPU_ISSUN4C) | |
138 | return (0); | 137 | return (0); | |
139 | return (strcmp(cf->cf_name, ma->ma_name) == 0); | 138 | return (strcmp(cf->cf_name, ma->ma_name) == 0); | |
140 | } | 139 | } | |
141 | 140 | |||
142 | /* | 141 | /* | |
143 | * Attach the iommu. | 142 | * Attach the iommu. | |
144 | */ | 143 | */ | |
145 | void | 144 | void | |
146 | iommu_attach(struct device *parent, struct device *self, void *aux) | 145 | iommu_attach(device_t parent, device_t self, void *aux) | |
147 | { | 146 | { | |
148 | #if defined(SUN4M) | 147 | #if defined(SUN4M) | |
149 | struct iommu_softc *sc = (struct iommu_softc *)self; | 148 | struct iommu_softc *sc = device_private(self); | |
150 | struct mainbus_attach_args *ma = aux; | 149 | struct mainbus_attach_args *ma = aux; | |
151 | struct sparc_bus_dma_tag *dmat = &sc->sc_dmatag; | 150 | struct sparc_bus_dma_tag *dmat = &sc->sc_dmatag; | |
152 | bus_space_handle_t bh; | 151 | bus_space_handle_t bh; | |
153 | int node; | 152 | int node; | |
154 | int js1_implicit_iommu; | 153 | int js1_implicit_iommu; | |
155 | int i, s; | 154 | int i, s; | |
156 | u_int iopte_table_pa; | 155 | u_int iopte_table_pa; | |
157 | struct pglist mlist; | 156 | struct pglist mlist; | |
158 | u_int size; | 157 | u_int size; | |
159 | struct vm_page *m; | 158 | struct vm_page *m; | |
160 | vaddr_t va; | 159 | vaddr_t va; | |
161 | 160 | |||
162 | dmat->_cookie = sc; | 161 | dmat->_cookie = sc; | |
@@ -291,50 +290,50 @@ iommu_attach(struct device *parent, stru | @@ -291,50 +290,50 @@ iommu_attach(struct device *parent, stru | |||
291 | struct openprom_addr sbus_iommu_reg = { 0, 0x10001000, 0x28 }; | 290 | struct openprom_addr sbus_iommu_reg = { 0, 0x10001000, 0x28 }; | |
292 | 291 | |||
293 | memset(&ia, 0, sizeof ia); | 292 | memset(&ia, 0, sizeof ia); | |
294 | 293 | |||
295 | /* Propagate BUS & DMA tags */ | 294 | /* Propagate BUS & DMA tags */ | |
296 | ia.iom_bustag = ma->ma_bustag; | 295 | ia.iom_bustag = ma->ma_bustag; | |
297 | ia.iom_dmatag = &sc->sc_dmatag; | 296 | ia.iom_dmatag = &sc->sc_dmatag; | |
298 | 297 | |||
299 | ia.iom_name = "sbus"; | 298 | ia.iom_name = "sbus"; | |
300 | ia.iom_node = node; | 299 | ia.iom_node = node; | |
301 | ia.iom_reg = &sbus_iommu_reg; | 300 | ia.iom_reg = &sbus_iommu_reg; | |
302 | ia.iom_nreg = 1; | 301 | ia.iom_nreg = 1; | |
303 | 302 | |||
304 | (void) config_found(&sc->sc_dev, (void *)&ia, iommu_print); | 303 | (void) config_found(self, (void *)&ia, iommu_print); | |
305 | return; | 304 | return; | |
306 | } | 305 | } | |
307 | 306 | |||
308 | /* | 307 | /* | |
309 | * Loop through ROM children (expect Sbus among them). | 308 | * Loop through ROM children (expect Sbus among them). | |
310 | */ | 309 | */ | |
311 | for (node = firstchild(node); node; node = nextsibling(node)) { | 310 | for (node = firstchild(node); node; node = nextsibling(node)) { | |
312 | struct iommu_attach_args ia; | 311 | struct iommu_attach_args ia; | |
313 | 312 | |||
314 | memset(&ia, 0, sizeof ia); | 313 | memset(&ia, 0, sizeof ia); | |
315 | ia.iom_name = prom_getpropstring(node, "name"); | 314 | ia.iom_name = prom_getpropstring(node, "name"); | |
316 | 315 | |||
317 | /* Propagate BUS & DMA tags */ | 316 | /* Propagate BUS & DMA tags */ | |
318 | ia.iom_bustag = ma->ma_bustag; | 317 | ia.iom_bustag = ma->ma_bustag; | |
319 | ia.iom_dmatag = &sc->sc_dmatag; | 318 | ia.iom_dmatag = &sc->sc_dmatag; | |
320 | 319 | |||
321 | ia.iom_node = node; | 320 | ia.iom_node = node; | |
322 | 321 | |||
323 | ia.iom_reg = NULL; | 322 | ia.iom_reg = NULL; | |
324 | prom_getprop(node, "reg", sizeof(struct openprom_addr), | 323 | prom_getprop(node, "reg", sizeof(struct openprom_addr), | |
325 | &ia.iom_nreg, &ia.iom_reg); | 324 | &ia.iom_nreg, &ia.iom_reg); | |
326 | 325 | |||
327 | (void) config_found(&sc->sc_dev, (void *)&ia, iommu_print); | 326 | (void) config_found(self, (void *)&ia, iommu_print); | |
328 | if (ia.iom_reg != NULL) | 327 | if (ia.iom_reg != NULL) | |
329 | free(ia.iom_reg, M_DEVBUF); | 328 | free(ia.iom_reg, M_DEVBUF); | |
330 | } | 329 | } | |
331 | #endif | 330 | #endif | |
332 | } | 331 | } | |
333 | 332 | |||
334 | #if defined(SUN4M) | 333 | #if defined(SUN4M) | |
335 | static void | 334 | static void | |
336 | iommu_copy_prom_entries(struct iommu_softc *sc) | 335 | iommu_copy_prom_entries(struct iommu_softc *sc) | |
337 | { | 336 | { | |
338 | u_int pbase, pa; | 337 | u_int pbase, pa; | |
339 | u_int range; | 338 | u_int range; | |
340 | iopte_t *tpte_p; | 339 | iopte_t *tpte_p; |
--- src/sys/arch/sparc/sparc/memecc.c 2011/07/01 18:51:51 1.12
+++ src/sys/arch/sparc/sparc/memecc.c 2011/07/17 23:18:23 1.13
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: memecc.c,v 1.12 2011/07/01 18:51:51 dyoung Exp $ */ | 1 | /* $NetBSD: memecc.c,v 1.13 2011/07/17 23:18:23 mrg Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 1998 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 1998 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Paul Kranenburg. | 8 | * by Paul Kranenburg. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -24,73 +24,77 @@ | @@ -24,73 +24,77 @@ | |||
24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
29 | * POSSIBILITY OF SUCH DAMAGE. | 29 | * POSSIBILITY OF SUCH DAMAGE. | |
30 | */ | 30 | */ | |
31 | 31 | |||
32 | /* | 32 | /* | |
33 | * ECC memory control. | 33 | * ECC memory control. | |
34 | */ | 34 | */ | |
35 | 35 | |||
36 | #include <sys/cdefs.h> | 36 | #include <sys/cdefs.h> | |
37 | __KERNEL_RCSID(0, "$NetBSD: memecc.c,v 1.12 2011/07/01 18:51:51 dyoung Exp $"); | 37 | __KERNEL_RCSID(0, "$NetBSD: memecc.c,v 1.13 2011/07/17 23:18:23 mrg Exp $"); | |
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/device.h> | 41 | #include <sys/device.h> | |
42 | 42 | |||
43 | #include <sys/bus.h> | 43 | #include <sys/bus.h> | |
44 | #include <machine/autoconf.h> | 44 | #include <machine/autoconf.h> | |
45 | #include <sparc/sparc/memeccreg.h> | 45 | #include <sparc/sparc/memeccreg.h> | |
46 | 46 | |||
47 | struct memecc_softc { | 47 | struct memecc_softc { | |
48 | struct device sc_dev; /* base device */ | |||
49 | bus_space_tag_t sc_bt; | 48 | bus_space_tag_t sc_bt; | |
50 | bus_space_handle_t sc_bh; | 49 | bus_space_handle_t sc_bh; | |
51 | }; | 50 | }; | |
52 | 51 | |||
53 | struct memecc_softc *memecc_sc; | 52 | struct memecc_softc *memecc_sc; | |
54 | 53 | |||
55 | /* autoconfiguration driver */ | 54 | /* autoconfiguration driver */ | |
56 | static void memecc_attach(struct device *, struct device *, void *); | 55 | static void memecc_attach(device_t, device_t, void *); | |
57 | static int memecc_match(struct device *, struct cfdata *, void *); | 56 | static int memecc_match(device_t, cfdata_t, void *); | |
58 | static int memecc_error(void); | 57 | static int memecc_error(void); | |
59 | 58 | |||
60 | int (*memerr_handler)(void); | 59 | int (*memerr_handler)(void); | |
61 | 60 | |||
62 | CFATTACH_DECL(eccmemctl, sizeof(struct memecc_softc), | 61 | CFATTACH_DECL_NEW(eccmemctl, sizeof(struct memecc_softc), | |
63 | memecc_match, memecc_attach, NULL, NULL); | 62 | memecc_match, memecc_attach, NULL, NULL); | |
64 | 63 | |||
65 | int | 64 | int | |
66 | memecc_match(struct device *parent, struct cfdata *cf, void *aux) | 65 | memecc_match(device_t parent, cfdata_t cf, void *aux) | |
67 | { | 66 | { | |
68 | struct mainbus_attach_args *ma = aux; | 67 | struct mainbus_attach_args *ma = aux; | |
69 | 68 | |||
70 | return (strcmp("eccmemctl", ma->ma_name) == 0); | 69 | return (strcmp("eccmemctl", ma->ma_name) == 0); | |
71 | } | 70 | } | |
72 | 71 | |||
73 | /* | 72 | /* | |
74 | * Attach the device. | 73 | * Attach the device. | |
75 | */ | 74 | */ | |
76 | void | 75 | void | |
77 | memecc_attach(struct device *parent, struct device *self, void *aux) | 76 | memecc_attach(device_t parent, device_t self, void *aux) | |
78 | { | 77 | { | |
79 | struct memecc_softc *sc = (struct memecc_softc *)self; | 78 | struct memecc_softc *sc = (struct memecc_softc *)self; | |
80 | struct mainbus_attach_args *ma = aux; | 79 | struct mainbus_attach_args *ma = aux; | |
81 | int node; | 80 | int node; | |
82 | uint32_t reg; | 81 | uint32_t reg; | |
83 | 82 | |||
83 | if (memerr_handler) { | |||
84 | printf("%s: already attached\n", __func__); | |||
85 | return; | |||
86 | } | |||
87 | ||||
84 | sc->sc_bt = ma->ma_bustag; | 88 | sc->sc_bt = ma->ma_bustag; | |
85 | node = ma->ma_node; | 89 | node = ma->ma_node; | |
86 | 90 | |||
87 | /* | 91 | /* | |
88 | * Map registers | 92 | * Map registers | |
89 | */ | 93 | */ | |
90 | if (bus_space_map( | 94 | if (bus_space_map( | |
91 | ma->ma_bustag, | 95 | ma->ma_bustag, | |
92 | ma->ma_paddr, | 96 | ma->ma_paddr, | |
93 | ma->ma_size, | 97 | ma->ma_size, | |
94 | 0, | 98 | 0, | |
95 | &sc->sc_bh) != 0) { | 99 | &sc->sc_bh) != 0) { | |
96 | printf("memecc_attach: cannot map registers\n"); | 100 | printf("memecc_attach: cannot map registers\n"); |
--- src/sys/arch/sparc/sparc/timer.c 2011/07/01 18:51:51 1.28
+++ src/sys/arch/sparc/sparc/timer.c 2011/07/17 23:18:23 1.29
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: timer.c,v 1.28 2011/07/01 18:51:51 dyoung Exp $ */ | 1 | /* $NetBSD: timer.c,v 1.29 2011/07/17 23:18:23 mrg Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 1992, 1993 | 4 | * Copyright (c) 1992, 1993 | |
5 | * The Regents of the University of California. All rights reserved. | 5 | * The Regents of the University of California. All rights reserved. | |
6 | * Copyright (c) 1994 Gordon W. Ross | 6 | * Copyright (c) 1994 Gordon W. Ross | |
7 | * Copyright (c) 1993 Adam Glass | 7 | * Copyright (c) 1993 Adam Glass | |
8 | * Copyright (c) 1996 Paul Kranenburg | 8 | * Copyright (c) 1996 Paul Kranenburg | |
9 | * Copyright (c) 1996 | 9 | * Copyright (c) 1996 | |
10 | * The President and Fellows of Harvard College. All rights reserved. | 10 | * The President and Fellows of Harvard College. All rights reserved. | |
11 | * | 11 | * | |
12 | * This software was developed by the Computer Systems Engineering group | 12 | * This software was developed by the Computer Systems Engineering group | |
13 | * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and | 13 | * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and | |
14 | * contributed to Berkeley. | 14 | * contributed to Berkeley. | |
@@ -50,27 +50,27 @@ | @@ -50,27 +50,27 @@ | |||
50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
51 | * SUCH DAMAGE. | 51 | * SUCH DAMAGE. | |
52 | * | 52 | * | |
53 | * @(#)clock.c 8.1 (Berkeley) 6/11/93 | 53 | * @(#)clock.c 8.1 (Berkeley) 6/11/93 | |
54 | */ | 54 | */ | |
55 | 55 | |||
56 | /* | 56 | /* | |
57 | * Kernel clocks provided by "timer" device. The hardclock is provided by | 57 | * Kernel clocks provided by "timer" device. The hardclock is provided by | |
58 | * the timer register (aka system counter). The statclock is provided by | 58 | * the timer register (aka system counter). The statclock is provided by | |
59 | * per CPU counter register(s) (aka processor counter(s)). | 59 | * per CPU counter register(s) (aka processor counter(s)). | |
60 | */ | 60 | */ | |
61 | 61 | |||
62 | #include <sys/cdefs.h> | 62 | #include <sys/cdefs.h> | |
63 | __KERNEL_RCSID(0, "$NetBSD: timer.c,v 1.28 2011/07/01 18:51:51 dyoung Exp $"); | 63 | __KERNEL_RCSID(0, "$NetBSD: timer.c,v 1.29 2011/07/17 23:18:23 mrg Exp $"); | |
64 | 64 | |||
65 | #include <sys/param.h> | 65 | #include <sys/param.h> | |
66 | #include <sys/kernel.h> | 66 | #include <sys/kernel.h> | |
67 | #include <sys/device.h> | 67 | #include <sys/device.h> | |
68 | #include <sys/systm.h> | 68 | #include <sys/systm.h> | |
69 | #include <sys/timetc.h> | 69 | #include <sys/timetc.h> | |
70 | 70 | |||
71 | #include <machine/autoconf.h> | 71 | #include <machine/autoconf.h> | |
72 | #include <sys/bus.h> | 72 | #include <sys/bus.h> | |
73 | 73 | |||
74 | #include <sparc/sparc/timerreg.h> | 74 | #include <sparc/sparc/timerreg.h> | |
75 | #include <sparc/sparc/timervar.h> | 75 | #include <sparc/sparc/timervar.h> | |
76 | 76 | |||
@@ -230,27 +230,27 @@ timerattach(volatile int *cntreg, volati | @@ -230,27 +230,27 @@ timerattach(volatile int *cntreg, volati | |||
230 | 230 | |||
231 | cntr.cntreg = cntreg; | 231 | cntr.cntreg = cntreg; | |
232 | cntr.limit >>= cntr.shift; | 232 | cntr.limit >>= cntr.shift; | |
233 | 233 | |||
234 | tc_init(&counter_timecounter); | 234 | tc_init(&counter_timecounter); | |
235 | } | 235 | } | |
236 | 236 | |||
237 | /* | 237 | /* | |
238 | * Both sun4 and sun4m can attach a timer on obio. | 238 | * Both sun4 and sun4m can attach a timer on obio. | |
239 | * The sun4m OPENPROM calls the timer the "counter". | 239 | * The sun4m OPENPROM calls the timer the "counter". | |
240 | * The sun4 timer must be probed. | 240 | * The sun4 timer must be probed. | |
241 | */ | 241 | */ | |
242 | static int | 242 | static int | |
243 | timermatch_obio(struct device *parent, struct cfdata *cf, void *aux) | 243 | timermatch_obio(device_t parent, cfdata_t cf, void *aux) | |
244 | { | 244 | { | |
245 | #if defined(SUN4) || defined(SUN4M) | 245 | #if defined(SUN4) || defined(SUN4M) | |
246 | union obio_attach_args *uoba = aux; | 246 | union obio_attach_args *uoba = aux; | |
247 | #endif | 247 | #endif | |
248 | #if defined(SUN4) | 248 | #if defined(SUN4) | |
249 | struct obio4_attach_args *oba; | 249 | struct obio4_attach_args *oba; | |
250 | #endif | 250 | #endif | |
251 | 251 | |||
252 | #if defined(SUN4M) | 252 | #if defined(SUN4M) | |
253 | if (uoba->uoba_isobio4 == 0) | 253 | if (uoba->uoba_isobio4 == 0) | |
254 | return (strcmp("counter", uoba->uoba_sbus.sa_name) == 0); | 254 | return (strcmp("counter", uoba->uoba_sbus.sa_name) == 0); | |
255 | #endif /* SUN4M */ | 255 | #endif /* SUN4M */ | |
256 | 256 | |||
@@ -267,62 +267,62 @@ timermatch_obio(struct device *parent, s | @@ -267,62 +267,62 @@ timermatch_obio(struct device *parent, s | |||
267 | 267 | |||
268 | /* Make sure there is something there */ | 268 | /* Make sure there is something there */ | |
269 | oba = &uoba->uoba_oba4; | 269 | oba = &uoba->uoba_oba4; | |
270 | return (bus_space_probe(oba->oba_bustag, oba->oba_paddr, | 270 | return (bus_space_probe(oba->oba_bustag, oba->oba_paddr, | |
271 | 4, /* probe size */ | 271 | 4, /* probe size */ | |
272 | 0, /* offset */ | 272 | 0, /* offset */ | |
273 | 0, /* flags */ | 273 | 0, /* flags */ | |
274 | NULL, NULL)); | 274 | NULL, NULL)); | |
275 | #endif /* SUN4 */ | 275 | #endif /* SUN4 */ | |
276 | panic("timermatch_obio: impossible"); | 276 | panic("timermatch_obio: impossible"); | |
277 | } | 277 | } | |
278 | 278 | |||
279 | static void | 279 | static void | |
280 | timerattach_obio(struct device *parent, struct device *self, void *aux) | 280 | timerattach_obio(device_t parent, device_t self, void *aux) | |
281 | { | 281 | { | |
282 | union obio_attach_args *uoba = aux; | 282 | union obio_attach_args *uoba = aux; | |
283 | 283 | |||
284 | if (uoba->uoba_isobio4 == 0) { | 284 | if (uoba->uoba_isobio4 == 0) { | |
285 | #if defined(SUN4M) | 285 | #if defined(SUN4M) | |
286 | /* sun4m timer at obio */ | 286 | /* sun4m timer at obio */ | |
287 | timerattach_obio_4m(parent, self, aux); | 287 | timerattach_obio_4m(parent, self, aux); | |
288 | #endif /* SUN4M */ | 288 | #endif /* SUN4M */ | |
289 | return; | 289 | return; | |
290 | } | 290 | } | |
291 | 291 | |||
292 | if (uoba->uoba_isobio4 != 0) { | 292 | if (uoba->uoba_isobio4 != 0) { | |
293 | #if defined(SUN4) | 293 | #if defined(SUN4) | |
294 | /* sun4 timer at obio */ | 294 | /* sun4 timer at obio */ | |
295 | timerattach_obio_4(parent, self, aux); | 295 | timerattach_obio_4(parent, self, aux); | |
296 | #endif /* SUN4 */ | 296 | #endif /* SUN4 */ | |
297 | } | 297 | } | |
298 | } | 298 | } | |
299 | 299 | |||
300 | CFATTACH_DECL(timer_obio, sizeof(struct device), | 300 | CFATTACH_DECL_NEW(timer_obio, 0, | |
301 | timermatch_obio, timerattach_obio, NULL, NULL); | 301 | timermatch_obio, timerattach_obio, NULL, NULL); | |
302 | 302 | |||
303 | /* | 303 | /* | |
304 | * Only sun4c attaches a timer at mainbus | 304 | * Only sun4c attaches a timer at mainbus | |
305 | */ | 305 | */ | |
306 | static int | 306 | static int | |
307 | timermatch_mainbus(struct device *parent, struct cfdata *cf, void *aux) | 307 | timermatch_mainbus(device_t parent, cfdata_t cf, void *aux) | |
308 | { | 308 | { | |
309 | #if defined(SUN4C) | 309 | #if defined(SUN4C) | |
310 | struct mainbus_attach_args *ma = aux; | 310 | struct mainbus_attach_args *ma = aux; | |
311 | 311 | |||
312 | return (strcmp("counter-timer", ma->ma_name) == 0); | 312 | return (strcmp("counter-timer", ma->ma_name) == 0); | |
313 | #else | 313 | #else | |
314 | return (0); | 314 | return (0); | |
315 | #endif | 315 | #endif | |
316 | } | 316 | } | |
317 | 317 | |||
318 | static void | 318 | static void | |
319 | timerattach_mainbus(struct device *parent, struct device *self, void *aux) | 319 | timerattach_mainbus(device_t parent, device_t self, void *aux) | |
320 | { | 320 | { | |
321 | 321 | |||
322 | #if defined(SUN4C) | 322 | #if defined(SUN4C) | |
323 | timerattach_mainbus_4c(parent, self, aux); | 323 | timerattach_mainbus_4c(parent, self, aux); | |
324 | #endif /* SUN4C */ | 324 | #endif /* SUN4C */ | |
325 | } | 325 | } | |
326 | 326 | |||
327 | CFATTACH_DECL(timer_mainbus, sizeof(struct device), | 327 | CFATTACH_DECL_NEW(timer_mainbus, 0, | |
328 | timermatch_mainbus, timerattach_mainbus, NULL, NULL); | 328 | timermatch_mainbus, timerattach_mainbus, NULL, NULL); |
--- src/sys/arch/sparc/sparc/timer_msiiep.c 2010/01/04 03:54:42 1.25
+++ src/sys/arch/sparc/sparc/timer_msiiep.c 2011/07/17 23:18:23 1.26
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: timer_msiiep.c,v 1.25 2010/01/04 03:54:42 mrg Exp $ */ | 1 | /* $NetBSD: timer_msiiep.c,v 1.26 2011/07/17 23:18:23 mrg Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 1992, 1993 | 4 | * Copyright (c) 1992, 1993 | |
5 | * The Regents of the University of California. All rights reserved. | 5 | * The Regents of the University of California. All rights reserved. | |
6 | * Copyright (c) 1994 Gordon W. Ross | 6 | * Copyright (c) 1994 Gordon W. Ross | |
7 | * Copyright (c) 1993 Adam Glass | 7 | * Copyright (c) 1993 Adam Glass | |
8 | * Copyright (c) 1996 Paul Kranenburg | 8 | * Copyright (c) 1996 Paul Kranenburg | |
9 | * Copyright (c) 1996 | 9 | * Copyright (c) 1996 | |
10 | * The President and Fellows of Harvard College. All rights reserved. | 10 | * The President and Fellows of Harvard College. All rights reserved. | |
11 | * | 11 | * | |
12 | * This software was developed by the Computer Systems Engineering group | 12 | * This software was developed by the Computer Systems Engineering group | |
13 | * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and | 13 | * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and | |
14 | * contributed to Berkeley. | 14 | * contributed to Berkeley. | |
@@ -48,46 +48,46 @@ | @@ -48,46 +48,46 @@ | |||
48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
51 | * SUCH DAMAGE. | 51 | * SUCH DAMAGE. | |
52 | * | 52 | * | |
53 | * @(#)clock.c 8.1 (Berkeley) 6/11/93 | 53 | * @(#)clock.c 8.1 (Berkeley) 6/11/93 | |
54 | */ | 54 | */ | |
55 | 55 | |||
56 | /* | 56 | /* | |
57 | * MicroSPARC-IIep timer support. | 57 | * MicroSPARC-IIep timer support. | |
58 | */ | 58 | */ | |
59 | 59 | |||
60 | #include <sys/cdefs.h> | 60 | #include <sys/cdefs.h> | |
61 | __KERNEL_RCSID(0, "$NetBSD: timer_msiiep.c,v 1.25 2010/01/04 03:54:42 mrg Exp $"); | 61 | __KERNEL_RCSID(0, "$NetBSD: timer_msiiep.c,v 1.26 2011/07/17 23:18:23 mrg Exp $"); | |
62 | 62 | |||
63 | #include <sys/param.h> | 63 | #include <sys/param.h> | |
64 | #include <sys/kernel.h> | 64 | #include <sys/kernel.h> | |
65 | #include <sys/device.h> | 65 | #include <sys/device.h> | |
66 | #include <sys/systm.h> | 66 | #include <sys/systm.h> | |
67 | #include <sys/timetc.h> | 67 | #include <sys/timetc.h> | |
68 | #include <sys/bus.h> | 68 | #include <sys/bus.h> | |
69 | #include <sys/intr.h> | 69 | #include <sys/intr.h> | |
70 | 70 | |||
71 | #include <sparc/sparc/msiiepreg.h> | 71 | #include <sparc/sparc/msiiepreg.h> | |
72 | #include <sparc/sparc/msiiepvar.h> | 72 | #include <sparc/sparc/msiiepvar.h> | |
73 | 73 | |||
74 | #include <sparc/sparc/timervar.h> | 74 | #include <sparc/sparc/timervar.h> | |
75 | 75 | |||
76 | 76 | |||
77 | static int timermatch_msiiep(struct device *, struct cfdata *, void *); | 77 | static int timermatch_msiiep(device_t, cfdata_t, void *); | |
78 | static void timerattach_msiiep(struct device *, struct device *, void *); | 78 | static void timerattach_msiiep(device_t, device_t, void *); | |
79 | 79 | |||
80 | CFATTACH_DECL(timer_msiiep, sizeof(struct device), | 80 | CFATTACH_DECL_NEW(timer_msiiep, 0, | |
81 | timermatch_msiiep, timerattach_msiiep, NULL, NULL); | 81 | timermatch_msiiep, timerattach_msiiep, NULL, NULL); | |
82 | 82 | |||
83 | 83 | |||
84 | static void timer_init_msiiep(void); | 84 | static void timer_init_msiiep(void); | |
85 | static int clockintr_msiiep(void *); | 85 | static int clockintr_msiiep(void *); | |
86 | static int statintr_msiiep(void *); | 86 | static int statintr_msiiep(void *); | |
87 | static u_int timer_get_timecount(struct timecounter *); | 87 | static u_int timer_get_timecount(struct timecounter *); | |
88 | 88 | |||
89 | 89 | |||
90 | static struct intrhand level10 = { .ih_fun = clockintr_msiiep }; | 90 | static struct intrhand level10 = { .ih_fun = clockintr_msiiep }; | |
91 | static struct intrhand level14 = { .ih_fun = statintr_msiiep }; | 91 | static struct intrhand level14 = { .ih_fun = statintr_msiiep }; | |
92 | 92 | |||
93 | /* | 93 | /* | |
@@ -110,41 +110,41 @@ static struct timecounter counter_timeco | @@ -110,41 +110,41 @@ static struct timecounter counter_timeco | |||
110 | .tc_quality = 100, | 110 | .tc_quality = 100, | |
111 | .tc_priv = &cntr, | 111 | .tc_priv = &cntr, | |
112 | }; | 112 | }; | |
113 | 113 | |||
114 | 114 | |||
115 | /* | 115 | /* | |
116 | * ms-IIep counters tick every 4 CPU clocks @100MHz. | 116 | * ms-IIep counters tick every 4 CPU clocks @100MHz. | |
117 | * counter is reset to 1 when new limit is written. | 117 | * counter is reset to 1 when new limit is written. | |
118 | */ | 118 | */ | |
119 | #define tmr_ustolimIIep(n) ((n) * 25 + 1) | 119 | #define tmr_ustolimIIep(n) ((n) * 25 + 1) | |
120 | 120 | |||
121 | 121 | |||
122 | static int | 122 | static int | |
123 | timermatch_msiiep(struct device *parent, struct cfdata *cf, void *aux) | 123 | timermatch_msiiep(device_t parent, cfdata_t cf, void *aux) | |
124 | { | 124 | { | |
125 | struct msiiep_attach_args *msa = aux; | 125 | struct msiiep_attach_args *msa = aux; | |
126 | 126 | |||
127 | return (strcmp(msa->msa_name, "timer") == 0); | 127 | return (strcmp(msa->msa_name, "timer") == 0); | |
128 | } | 128 | } | |
129 | 129 | |||
130 | 130 | |||
131 | /* | 131 | /* | |
132 | * Attach system and processor counters (kernel hard and stat clocks) | 132 | * Attach system and processor counters (kernel hard and stat clocks) | |
133 | * for ms-IIep. Counters are part of the PCIC and there's no PROM | 133 | * for ms-IIep. Counters are part of the PCIC and there's no PROM | |
134 | * node for them. | 134 | * node for them. | |
135 | */ | 135 | */ | |
136 | static void | 136 | static void | |
137 | timerattach_msiiep(struct device *parent, struct device *self, void *aux) | 137 | timerattach_msiiep(device_t parent, device_t self, void *aux) | |
138 | { | 138 | { | |
139 | 139 | |||
140 | /* Put processor counter in "counter" mode */ | 140 | /* Put processor counter in "counter" mode */ | |
141 | mspcic_write_1(pcic_pc_ctl, 0); /* stop user timer (just in case) */ | 141 | mspcic_write_1(pcic_pc_ctl, 0); /* stop user timer (just in case) */ | |
142 | mspcic_write_1(pcic_pc_cfg, 0); /* timer mode disabled */ | 142 | mspcic_write_1(pcic_pc_cfg, 0); /* timer mode disabled */ | |
143 | 143 | |||
144 | /* | 144 | /* | |
145 | * Calibrate delay() by tweaking the magic constant until | 145 | * Calibrate delay() by tweaking the magic constant until | |
146 | * delay(100) actually reads (at least) 100 us on the clock. | 146 | * delay(100) actually reads (at least) 100 us on the clock. | |
147 | */ | 147 | */ | |
148 | for (timerblurb = 1; ; ++timerblurb) { | 148 | for (timerblurb = 1; ; ++timerblurb) { | |
149 | int t; | 149 | int t; | |
150 | volatile uint32_t junk; | 150 | volatile uint32_t junk; |
--- src/sys/arch/sparc/sparc/timer_sun4.c 2011/07/01 18:51:51 1.18
+++ src/sys/arch/sparc/sparc/timer_sun4.c 2011/07/17 23:18:23 1.19
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: timer_sun4.c,v 1.18 2011/07/01 18:51:51 dyoung Exp $ */ | 1 | /* $NetBSD: timer_sun4.c,v 1.19 2011/07/17 23:18:23 mrg Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 1992, 1993 | 4 | * Copyright (c) 1992, 1993 | |
5 | * The Regents of the University of California. All rights reserved. | 5 | * The Regents of the University of California. All rights reserved. | |
6 | * Copyright (c) 1994 Gordon W. Ross | 6 | * Copyright (c) 1994 Gordon W. Ross | |
7 | * Copyright (c) 1993 Adam Glass | 7 | * Copyright (c) 1993 Adam Glass | |
8 | * Copyright (c) 1996 Paul Kranenburg | 8 | * Copyright (c) 1996 Paul Kranenburg | |
9 | * Copyright (c) 1996 | 9 | * Copyright (c) 1996 | |
10 | * The President and Fellows of Harvard College. All rights reserved. | 10 | * The President and Fellows of Harvard College. All rights reserved. | |
11 | * | 11 | * | |
12 | * This software was developed by the Computer Systems Engineering group | 12 | * This software was developed by the Computer Systems Engineering group | |
13 | * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and | 13 | * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and | |
14 | * contributed to Berkeley. | 14 | * contributed to Berkeley. | |
@@ -48,27 +48,27 @@ | @@ -48,27 +48,27 @@ | |||
48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
51 | * SUCH DAMAGE. | 51 | * SUCH DAMAGE. | |
52 | * | 52 | * | |
53 | * @(#)clock.c 8.1 (Berkeley) 6/11/93 | 53 | * @(#)clock.c 8.1 (Berkeley) 6/11/93 | |
54 | */ | 54 | */ | |
55 | 55 | |||
56 | /* | 56 | /* | |
57 | * Sun4/Sun4c timer support. | 57 | * Sun4/Sun4c timer support. | |
58 | */ | 58 | */ | |
59 | 59 | |||
60 | #include <sys/cdefs.h> | 60 | #include <sys/cdefs.h> | |
61 | __KERNEL_RCSID(0, "$NetBSD: timer_sun4.c,v 1.18 2011/07/01 18:51:51 dyoung Exp $"); | 61 | __KERNEL_RCSID(0, "$NetBSD: timer_sun4.c,v 1.19 2011/07/17 23:18:23 mrg Exp $"); | |
62 | 62 | |||
63 | #include <sys/param.h> | 63 | #include <sys/param.h> | |
64 | #include <sys/kernel.h> | 64 | #include <sys/kernel.h> | |
65 | #include <sys/device.h> | 65 | #include <sys/device.h> | |
66 | #include <sys/systm.h> | 66 | #include <sys/systm.h> | |
67 | 67 | |||
68 | #include <machine/autoconf.h> | 68 | #include <machine/autoconf.h> | |
69 | #include <sys/bus.h> | 69 | #include <sys/bus.h> | |
70 | 70 | |||
71 | #include <sparc/sparc/vaddrs.h> | 71 | #include <sparc/sparc/vaddrs.h> | |
72 | #include <sparc/sparc/timerreg.h> | 72 | #include <sparc/sparc/timerreg.h> | |
73 | #include <sparc/sparc/timervar.h> | 73 | #include <sparc/sparc/timervar.h> | |
74 | 74 | |||
@@ -143,49 +143,49 @@ statintr_4(void *cap) | @@ -143,49 +143,49 @@ statintr_4(void *cap) | |||
143 | /* | 143 | /* | |
144 | * We're interrupting a thread that may have the | 144 | * We're interrupting a thread that may have the | |
145 | * scheduler lock; run schedintr() later. | 145 | * scheduler lock; run schedintr() later. | |
146 | */ | 146 | */ | |
147 | sparc_softintr_schedule(sched_cookie); | 147 | sparc_softintr_schedule(sched_cookie); | |
148 | } | 148 | } | |
149 | } | 149 | } | |
150 | 150 | |||
151 | return (1); | 151 | return (1); | |
152 | } | 152 | } | |
153 | 153 | |||
154 | #if defined(SUN4) | 154 | #if defined(SUN4) | |
155 | void | 155 | void | |
156 | timerattach_obio_4(struct device *parent, struct device *self, void *aux) | 156 | timerattach_obio_4(device_t parent, device_t self, void *aux) | |
157 | { | 157 | { | |
158 | union obio_attach_args *uoba = aux; | 158 | union obio_attach_args *uoba = aux; | |
159 | struct obio4_attach_args *oba = &uoba->uoba_oba4; | 159 | struct obio4_attach_args *oba = &uoba->uoba_oba4; | |
160 | bus_space_handle_t bh; | 160 | bus_space_handle_t bh; | |
161 | 161 | |||
162 | if (bus_space_map2(oba->oba_bustag, | 162 | if (bus_space_map2(oba->oba_bustag, | |
163 | oba->oba_paddr, | 163 | oba->oba_paddr, | |
164 | sizeof(struct timerreg_4), | 164 | sizeof(struct timerreg_4), | |
165 | BUS_SPACE_MAP_LINEAR, | 165 | BUS_SPACE_MAP_LINEAR, | |
166 | TIMERREG_VA, | 166 | TIMERREG_VA, | |
167 | &bh) != 0) { | 167 | &bh) != 0) { | |
168 | printf(": can't map registers\n"); | 168 | printf(": can't map registers\n"); | |
169 | return; | 169 | return; | |
170 | } | 170 | } | |
171 | 171 | |||
172 | timerattach(&timerreg4->t_c10.t_counter, &timerreg4->t_c10.t_limit); | 172 | timerattach(&timerreg4->t_c10.t_counter, &timerreg4->t_c10.t_limit); | |
173 | } | 173 | } | |
174 | #endif /* SUN4 */ | 174 | #endif /* SUN4 */ | |
175 | 175 | |||
176 | #if defined(SUN4C) | 176 | #if defined(SUN4C) | |
177 | void | 177 | void | |
178 | timerattach_mainbus_4c(struct device *parent, struct device *self, void *aux) | 178 | timerattach_mainbus_4c(device_t parent, device_t self, void *aux) | |
179 | { | 179 | { | |
180 | struct mainbus_attach_args *ma = aux; | 180 | struct mainbus_attach_args *ma = aux; | |
181 | bus_space_handle_t bh; | 181 | bus_space_handle_t bh; | |
182 | 182 | |||
183 | /* | 183 | /* | |
184 | * This time we ignore any existing virtual address because | 184 | * This time we ignore any existing virtual address because | |
185 | * we have a fixed virtual address for the timer, to make | 185 | * we have a fixed virtual address for the timer, to make | |
186 | * microtime() faster. | 186 | * microtime() faster. | |
187 | */ | 187 | */ | |
188 | if (bus_space_map2(ma->ma_bustag, | 188 | if (bus_space_map2(ma->ma_bustag, | |
189 | ma->ma_paddr, | 189 | ma->ma_paddr, | |
190 | sizeof(struct timerreg_4), | 190 | sizeof(struct timerreg_4), | |
191 | BUS_SPACE_MAP_LINEAR, | 191 | BUS_SPACE_MAP_LINEAR, |
--- src/sys/arch/sparc/sparc/timer_sun4m.c 2011/07/01 18:51:52 1.26
+++ src/sys/arch/sparc/sparc/timer_sun4m.c 2011/07/17 23:18:23 1.27
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: timer_sun4m.c,v 1.26 2011/07/01 18:51:52 dyoung Exp $ */ | 1 | /* $NetBSD: timer_sun4m.c,v 1.27 2011/07/17 23:18:23 mrg Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 1992, 1993 | 4 | * Copyright (c) 1992, 1993 | |
5 | * The Regents of the University of California. All rights reserved. | 5 | * The Regents of the University of California. All rights reserved. | |
6 | * Copyright (c) 1994 Gordon W. Ross | 6 | * Copyright (c) 1994 Gordon W. Ross | |
7 | * Copyright (c) 1993 Adam Glass | 7 | * Copyright (c) 1993 Adam Glass | |
8 | * Copyright (c) 1996 Paul Kranenburg | 8 | * Copyright (c) 1996 Paul Kranenburg | |
9 | * Copyright (c) 1996 | 9 | * Copyright (c) 1996 | |
10 | * The President and Fellows of Harvard College. All rights reserved. | 10 | * The President and Fellows of Harvard College. All rights reserved. | |
11 | * | 11 | * | |
12 | * This software was developed by the Computer Systems Engineering group | 12 | * This software was developed by the Computer Systems Engineering group | |
13 | * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and | 13 | * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and | |
14 | * contributed to Berkeley. | 14 | * contributed to Berkeley. | |
@@ -48,27 +48,27 @@ | @@ -48,27 +48,27 @@ | |||
48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
51 | * SUCH DAMAGE. | 51 | * SUCH DAMAGE. | |
52 | * | 52 | * | |
53 | * @(#)clock.c 8.1 (Berkeley) 6/11/93 | 53 | * @(#)clock.c 8.1 (Berkeley) 6/11/93 | |
54 | */ | 54 | */ | |
55 | 55 | |||
56 | /* | 56 | /* | |
57 | * Sun4m timer support. | 57 | * Sun4m timer support. | |
58 | */ | 58 | */ | |
59 | 59 | |||
60 | #include <sys/cdefs.h> | 60 | #include <sys/cdefs.h> | |
61 | __KERNEL_RCSID(0, "$NetBSD: timer_sun4m.c,v 1.26 2011/07/01 18:51:52 dyoung Exp $"); | 61 | __KERNEL_RCSID(0, "$NetBSD: timer_sun4m.c,v 1.27 2011/07/17 23:18:23 mrg Exp $"); | |
62 | 62 | |||
63 | #include <sys/param.h> | 63 | #include <sys/param.h> | |
64 | #include <sys/kernel.h> | 64 | #include <sys/kernel.h> | |
65 | #include <sys/device.h> | 65 | #include <sys/device.h> | |
66 | #include <sys/systm.h> | 66 | #include <sys/systm.h> | |
67 | #include <sys/cpu.h> | 67 | #include <sys/cpu.h> | |
68 | 68 | |||
69 | #include <machine/autoconf.h> | 69 | #include <machine/autoconf.h> | |
70 | #include <sys/bus.h> | 70 | #include <sys/bus.h> | |
71 | 71 | |||
72 | #include <sparc/sparc/vaddrs.h> | 72 | #include <sparc/sparc/vaddrs.h> | |
73 | #include <sparc/sparc/cpuvar.h> | 73 | #include <sparc/sparc/cpuvar.h> | |
74 | #include <sparc/sparc/timerreg.h> | 74 | #include <sparc/sparc/timerreg.h> | |
@@ -196,27 +196,27 @@ statintr_4m(void *cap) | @@ -196,27 +196,27 @@ statintr_4m(void *cap) | |||
196 | * scheduler lock; run schedintr_4m() on this CPU later. | 196 | * scheduler lock; run schedintr_4m() on this CPU later. | |
197 | */ | 197 | */ | |
198 | raise_ipi(&cpuinfo, IPL_SCHED); /* sched_cookie->pil */ | 198 | raise_ipi(&cpuinfo, IPL_SCHED); /* sched_cookie->pil */ | |
199 | } | 199 | } | |
200 | #if !defined(MULTIPROCESSOR) | 200 | #if !defined(MULTIPROCESSOR) | |
201 | } | 201 | } | |
202 | #endif | 202 | #endif | |
203 | kpreempt_enable(); | 203 | kpreempt_enable(); | |
204 | 204 | |||
205 | return (1); | 205 | return (1); | |
206 | } | 206 | } | |
207 | 207 | |||
208 | void | 208 | void | |
209 | timerattach_obio_4m(struct device *parent, struct device *self, void *aux) | 209 | timerattach_obio_4m(device_t parent, device_t self, void *aux) | |
210 | { | 210 | { | |
211 | union obio_attach_args *uoba = aux; | 211 | union obio_attach_args *uoba = aux; | |
212 | struct sbus_attach_args *sa = &uoba->uoba_sbus; | 212 | struct sbus_attach_args *sa = &uoba->uoba_sbus; | |
213 | struct cpu_info *cpi; | 213 | struct cpu_info *cpi; | |
214 | bus_space_handle_t bh; | 214 | bus_space_handle_t bh; | |
215 | int i, n; | 215 | int i, n; | |
216 | 216 | |||
217 | if (sa->sa_nreg < 2) { | 217 | if (sa->sa_nreg < 2) { | |
218 | printf(": only %d register sets\n", sa->sa_nreg); | 218 | printf(": only %d register sets\n", sa->sa_nreg); | |
219 | return; | 219 | return; | |
220 | } | 220 | } | |
221 | 221 | |||
222 | /* Map the system timer */ | 222 | /* Map the system timer */ |
--- src/sys/arch/sparc/sparc/timervar.h 2010/01/04 04:21:35 1.9
+++ src/sys/arch/sparc/sparc/timervar.h 2011/07/17 23:18:23 1.10
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: timervar.h,v 1.9 2010/01/04 04:21:35 mrg Exp $ */ | 1 | /* $NetBSD: timervar.h,v 1.10 2011/07/17 23:18:23 mrg Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 1992, 1993 | 4 | * Copyright (c) 1992, 1993 | |
5 | * The Regents of the University of California. All rights reserved. | 5 | * The Regents of the University of California. All rights reserved. | |
6 | * | 6 | * | |
7 | * This software was developed by the Computer Systems Engineering group | 7 | * This software was developed by the Computer Systems Engineering group | |
8 | * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and | 8 | * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and | |
9 | * contributed to Berkeley. | 9 | * contributed to Berkeley. | |
10 | * | 10 | * | |
11 | * All advertising materials mentioning features or use of this software | 11 | * All advertising materials mentioning features or use of this software | |
12 | * must display the following acknowledgement: | 12 | * must display the following acknowledgement: | |
13 | * This product includes software developed by the University of | 13 | * This product includes software developed by the University of | |
14 | * California, Lawrence Berkeley Laboratory. | 14 | * California, Lawrence Berkeley Laboratory. | |
@@ -35,37 +35,37 @@ | @@ -35,37 +35,37 @@ | |||
35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
36 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 36 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
37 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 37 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
38 | * SUCH DAMAGE. | 38 | * SUCH DAMAGE. | |
39 | */ | 39 | */ | |
40 | 40 | |||
41 | #include "opt_sparc_arch.h" | 41 | #include "opt_sparc_arch.h" | |
42 | 42 | |||
43 | #if defined(SUN4) || defined(SUN4C) | 43 | #if defined(SUN4) || defined(SUN4C) | |
44 | int clockintr_4(void *); | 44 | int clockintr_4(void *); | |
45 | int statintr_4(void *); | 45 | int statintr_4(void *); | |
46 | void timer_init_4(void); | 46 | void timer_init_4(void); | |
47 | 47 | |||
48 | void timerattach_obio_4(struct device *, struct device *, void *); | 48 | void timerattach_obio_4(device_t, device_t, void *); | |
49 | void timerattach_mainbus_4c(struct device *, struct device *, void *); | 49 | void timerattach_mainbus_4c(device_t, device_t, void *); | |
50 | #endif /* SUN4 || SUN4C */ | 50 | #endif /* SUN4 || SUN4C */ | |
51 | 51 | |||
52 | #if defined(SUN4M) | 52 | #if defined(SUN4M) | |
53 | void schedintr_4m(void *); | 53 | void schedintr_4m(void *); | |
54 | int clockintr_4m(void *); | 54 | int clockintr_4m(void *); | |
55 | int statintr_4m(void *); | 55 | int statintr_4m(void *); | |
56 | void timer_init_4m(void); | 56 | void timer_init_4m(void); | |
57 | 57 | |||
58 | void timerattach_obio_4m(struct device *, struct device *, void *); | 58 | void timerattach_obio_4m(device_t, device_t, void *); | |
59 | #endif /* SUN4M */ | 59 | #endif /* SUN4M */ | |
60 | 60 | |||
61 | /* Imported from clock.c: */ | 61 | /* Imported from clock.c: */ | |
62 | extern int statvar, statmin, statint; | 62 | extern int statvar, statmin, statint; | |
63 | extern int timerblurb; | 63 | extern int timerblurb; | |
64 | extern void (*timer_init)(void); | 64 | extern void (*timer_init)(void); | |
65 | extern void tickle_tc(void); | 65 | extern void tickle_tc(void); | |
66 | 66 | |||
67 | /* Common timer attach routine in timer.c: */ | 67 | /* Common timer attach routine in timer.c: */ | |
68 | void timerattach(volatile int *, volatile int *); | 68 | void timerattach(volatile int *, volatile int *); | |
69 | void *sched_cookie; /* for schedclock() interrupts */ | 69 | void *sched_cookie; /* for schedclock() interrupts */ | |
70 | 70 | |||
71 | static inline u_long __attribute__((__unused__)) | 71 | static inline u_long __attribute__((__unused__)) |