Module Name: src Committed By: mrg Date: Sun Jul 17 23:18:23 UTC 2011
Modified Files: src/sys/arch/sparc/dev: fd.c power.c src/sys/arch/sparc/sparc: autoconf.c auxreg.c cpu.c cpuunit.c iommu.c memecc.c timer.c timer_msiiep.c timer_sun4.c timer_sun4m.c timervar.h Log Message: 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. To generate a diff of this commit: cvs rdiff -u -r1.149 -r1.150 src/sys/arch/sparc/dev/fd.c cvs rdiff -u -r1.17 -r1.18 src/sys/arch/sparc/dev/power.c cvs rdiff -u -r1.241 -r1.242 src/sys/arch/sparc/sparc/autoconf.c cvs rdiff -u -r1.38 -r1.39 src/sys/arch/sparc/sparc/auxreg.c cvs rdiff -u -r1.232 -r1.233 src/sys/arch/sparc/sparc/cpu.c cvs rdiff -u -r1.14 -r1.15 src/sys/arch/sparc/sparc/cpuunit.c cvs rdiff -u -r1.93 -r1.94 src/sys/arch/sparc/sparc/iommu.c cvs rdiff -u -r1.12 -r1.13 src/sys/arch/sparc/sparc/memecc.c cvs rdiff -u -r1.28 -r1.29 src/sys/arch/sparc/sparc/timer.c cvs rdiff -u -r1.25 -r1.26 src/sys/arch/sparc/sparc/timer_msiiep.c cvs rdiff -u -r1.18 -r1.19 src/sys/arch/sparc/sparc/timer_sun4.c cvs rdiff -u -r1.26 -r1.27 src/sys/arch/sparc/sparc/timer_sun4m.c cvs rdiff -u -r1.9 -r1.10 src/sys/arch/sparc/sparc/timervar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/sparc/dev/fd.c diff -u src/sys/arch/sparc/dev/fd.c:1.149 src/sys/arch/sparc/dev/fd.c:1.150 --- src/sys/arch/sparc/dev/fd.c:1.149 Wed Feb 24 22:37:55 2010 +++ src/sys/arch/sparc/dev/fd.c Sun Jul 17 23:18:23 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: fd.c,v 1.149 2010/02/24 22:37:55 dyoung Exp $ */ +/* $NetBSD: fd.c,v 1.150 2011/07/17 23:18:23 mrg Exp $ */ /*- * Copyright (c) 2000 The NetBSD Foundation, Inc. @@ -101,7 +101,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: fd.c,v 1.149 2010/02/24 22:37:55 dyoung Exp $"); +__KERNEL_RCSID(0, "$NetBSD: fd.c,v 1.150 2011/07/17 23:18:23 mrg Exp $"); #include "opt_ddb.h" #include "opt_md.h" @@ -174,7 +174,7 @@ /* software state, per controller */ struct fdc_softc { - struct device sc_dev; /* boilerplate */ + struct device *sc_dev; bus_space_tag_t sc_bustag; struct callout sc_timo_ch; /* timeout callout */ @@ -212,17 +212,17 @@ extern struct fdcio *fdciop; /* I/O descriptor used in fdintr.s */ /* controller driver configuration */ -int fdcmatch_mainbus(struct device *, struct cfdata *, void *); -int fdcmatch_obio(struct device *, struct cfdata *, void *); -void fdcattach_mainbus(struct device *, struct device *, void *); -void fdcattach_obio(struct device *, struct device *, void *); +int fdcmatch_mainbus(device_t, cfdata_t, void *); +int fdcmatch_obio(device_t, cfdata_t, void *); +void fdcattach_mainbus(device_t, device_t, void *); +void fdcattach_obio(device_t, device_t, void *); int fdcattach(struct fdc_softc *, int); -CFATTACH_DECL(fdc_mainbus, sizeof(struct fdc_softc), +CFATTACH_DECL_NEW(fdc_mainbus, sizeof(struct fdc_softc), fdcmatch_mainbus, fdcattach_mainbus, NULL, NULL); -CFATTACH_DECL(fdc_obio, sizeof(struct fdc_softc), +CFATTACH_DECL_NEW(fdc_obio, sizeof(struct fdc_softc), fdcmatch_obio, fdcattach_obio, NULL, NULL); inline struct fd_type *fd_dev_to_type(struct fd_softc *, dev_t); @@ -259,7 +259,7 @@ /* software state, per disk (with up to 4 disks per ctlr) */ struct fd_softc { - struct device sc_dv; /* generic device info */ + struct device *sc_dv; /* generic device info */ struct disk sc_dk; /* generic disk info */ struct fd_type *sc_deftype; /* default type descriptor */ @@ -289,12 +289,12 @@ }; /* floppy driver configuration */ -int fdmatch(struct device *, struct cfdata *, void *); -void fdattach(struct device *, struct device *, void *); +int fdmatch(device_t, cfdata_t, void *); +void fdattach(device_t, device_t, void *); bool fdshutdown(device_t, int); bool fdsuspend(device_t, const pmf_qual_t *); -CFATTACH_DECL(fd, sizeof(struct fd_softc), +CFATTACH_DECL_NEW(fd, sizeof(struct fd_softc), fdmatch, fdattach, NULL, NULL); extern struct cfdriver fd_cd; @@ -358,7 +358,7 @@ #define OBP_FDNAME (CPU_ISSUN4M ? "SUNW,fdtwo" : "fd") int -fdcmatch_mainbus(struct device *parent, struct cfdata *match, void *aux) +fdcmatch_mainbus(device_t parent, cfdata_t match, void *aux) { struct mainbus_attach_args *ma = aux; @@ -381,7 +381,7 @@ } int -fdcmatch_obio(struct device *parent, struct cfdata *match, void *aux) +fdcmatch_obio(device_t parent, cfdata_t match, void *aux) { union obio_attach_args *uoba = aux; struct sbus_attach_args *sa; @@ -533,11 +533,12 @@ } void -fdcattach_mainbus(struct device *parent, struct device *self, void *aux) +fdcattach_mainbus(device_t parent, device_t self, void *aux) { struct fdc_softc *fdc = device_private(self); struct mainbus_attach_args *ma = aux; + fdc->sc_dev = self; fdc->sc_bustag = ma->ma_bustag; if (bus_space_map( @@ -561,7 +562,7 @@ } void -fdcattach_obio(struct device *parent, struct device *self, void *aux) +fdcattach_obio(device_t parent, device_t self, void *aux) { struct fdc_softc *fdc = device_private(self); union obio_attach_args *uoba = aux; @@ -572,6 +573,7 @@ return; } + fdc->sc_dev = self; fdc->sc_bustag = sa->sa_bustag; if (sbus_bus_map(sa->sa_bustag, @@ -647,27 +649,27 @@ #endif ) == NULL) { printf("\n%s: cannot register interrupt handler\n", - fdc->sc_dev.dv_xname); + device_xname(fdc->sc_dev)); return (-1); } fdc->sc_sicookie = softint_establish(SOFTINT_BIO, fdcswintr, fdc); if (fdc->sc_sicookie == NULL) { printf("\n%s: cannot register soft interrupt handler\n", - fdc->sc_dev.dv_xname); + device_xname(fdc->sc_dev)); return (-1); } printf(" softpri %d: chip 8207%c\n", IPL_SOFTFDC, code); evcnt_attach_dynamic(&fdc->sc_intrcnt, EVCNT_TYPE_INTR, NULL, - fdc->sc_dev.dv_xname, "intr"); + device_xname(fdc->sc_dev), "intr"); /* physical limit: four drives per controller. */ drive_attached = 0; for (fa.fa_drive = 0; fa.fa_drive < 4; fa.fa_drive++) { fa.fa_deftype = NULL; /* unknown */ fa.fa_deftype = &fd_types[0]; /* XXX */ - if (config_found(&fdc->sc_dev, (void *)&fa, fdprint) != NULL) + if (config_found(fdc->sc_dev, (void *)&fa, fdprint) != NULL) drive_attached = 1; } @@ -680,7 +682,7 @@ } int -fdmatch(struct device *parent, struct cfdata *match, void *aux) +fdmatch(device_t parent, cfdata_t match, void *aux) { struct fdc_softc *fdc = device_private(parent); bus_space_tag_t t = fdc->sc_bustag; @@ -754,7 +756,7 @@ * Controller is working, and drive responded. Attach it. */ void -fdattach(struct device *parent, struct device *self, void *aux) +fdattach(device_t parent, device_t self, void *aux) { struct fdc_softc *fdc = device_private(parent); struct fd_softc *fd = device_private(self); @@ -762,6 +764,8 @@ struct fd_type *type = fa->fa_deftype; int drive = fa->fa_drive; + fd->sc_dv = self; + callout_init(&fd->sc_motoron_ch, 0); callout_init(&fd->sc_motoroff_ch, 0); @@ -787,14 +791,14 @@ /* * Initialize and attach the disk structure. */ - disk_init(&fd->sc_dk, fd->sc_dv.dv_xname, &fddkdriver); + disk_init(&fd->sc_dk, device_xname(fd->sc_dv), &fddkdriver); disk_attach(&fd->sc_dk); /* * Establish a mountroot_hook anyway in case we booted * with RB_ASKNAME and get selected as the boot device. */ - mountroothook_establish(fd_mountroot_hook, &fd->sc_dv); + mountroothook_establish(fd_mountroot_hook, fd->sc_dv); /* Make sure the drive motor gets turned off at shutdown time. */ if (!pmf_device_register1(self, fdsuspend, NULL, fdshutdown)) @@ -886,7 +890,7 @@ fdstart(fd); #ifdef DIAGNOSTIC else { - struct fdc_softc *fdc = (void *)device_parent(&fd->sc_dv); + struct fdc_softc *fdc = (void *)device_parent(fd->sc_dv); if (fdc->sc_state == DEVIDLE) { printf("fdstrategy: controller inactive\n"); fdcstart(fdc); @@ -904,7 +908,7 @@ void fdstart(struct fd_softc *fd) { - struct fdc_softc *fdc = device_private(device_parent(&fd->sc_dv)); + struct fdc_softc *fdc = device_private(device_parent(fd->sc_dv)); int active = fdc->sc_drives.tqh_first != 0; /* Link into controller queue. */ @@ -919,7 +923,7 @@ void fdfinish(struct fd_softc *fd, struct buf *bp) { - struct fdc_softc *fdc = device_private(device_parent(&fd->sc_dv)); + struct fdc_softc *fdc = device_private(device_parent(fd->sc_dv)); /* * Move this drive to the end of the queue to give others a `fair' @@ -1008,7 +1012,7 @@ s = splbio(); fd->sc_flags &= ~(FD_MOTOR | FD_MOTOR_WAIT); - fd_set_motor((struct fdc_softc *)device_parent(&fd->sc_dv)); + fd_set_motor((struct fdc_softc *)device_parent(fd->sc_dv)); splx(s); } @@ -1016,7 +1020,7 @@ fd_motor_on(void *arg) { struct fd_softc *fd = arg; - struct fdc_softc *fdc = device_private(device_parent(&fd->sc_dv)); + struct fdc_softc *fdc = device_private(device_parent(fd->sc_dv)); int s; s = splbio(); @@ -1248,7 +1252,7 @@ #endif printf("%s: %s: state %d", - fd ? fd->sc_dv.dv_xname : "fdc", s, fdc->sc_state); + fd ? device_xname(fd->sc_dv) : "fdc", s, fdc->sc_state); fdcpstatus(n, fdc); } @@ -1264,7 +1268,7 @@ fd = fdc->sc_drives.tqh_first; if (fd == NULL) { printf("%s: timeout but no I/O pending: state %d, istatus=%d\n", - fdc->sc_dev.dv_xname, + device_xname(fdc->sc_dev), fdc->sc_state, fdc->sc_istatus); fdc->sc_state = DEVIDLE; goto out; @@ -1553,7 +1557,7 @@ if (fdc_diskchange(fdc)) { printf("%s: cannot clear disk change status\n", - fdc->sc_dev.dv_xname); + device_xname(fdc->sc_dev)); fdc->sc_state = DORESET; } goto loop; @@ -1867,7 +1871,8 @@ if (fdc->sc_nstat == 7 && (fdc->sc_status[0] & 0xd8) == 0x40 && (fdc->sc_status[1] & 0x2) == 0x2) { - printf("%s: read-only medium\n", fd->sc_dv.dv_xname); + printf("%s: read-only medium\n", + device_xname(fd->sc_dv)); error = EROFS; goto failsilent; } @@ -1892,7 +1897,8 @@ * are zero. Assume this condition is the * result of no disk loaded into the drive. */ - printf("%s: no medium?\n", fd->sc_dv.dv_xname); + printf("%s: no medium?\n", + device_xname(fd->sc_dv)); error = ENODEV; goto failsilent; } @@ -1936,7 +1942,7 @@ return (ENXIO); fd = device_lookup_private(&fd_cd, FDUNIT(dev)); - fdc = device_private(device_parent(&fd->sc_dv)); + fdc = device_private(device_parent(fd->sc_dv)); switch (cmd) { case DIOCGDINFO: @@ -2277,7 +2283,7 @@ void fd_do_eject(struct fd_softc *fd) { - struct fdc_softc *fdc = device_private(device_parent(&fd->sc_dv)); + struct fdc_softc *fdc = device_private(device_parent(fd->sc_dv)); if (CPU_ISSUN4C) { auxregbisc(AUXIO4C_FDS, AUXIO4C_FEJ); Index: src/sys/arch/sparc/dev/power.c diff -u src/sys/arch/sparc/dev/power.c:1.17 src/sys/arch/sparc/dev/power.c:1.18 --- src/sys/arch/sparc/dev/power.c:1.17 Wed Nov 16 00:49:03 2005 +++ src/sys/arch/sparc/dev/power.c Sun Jul 17 23:18:23 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: power.c,v 1.17 2005/11/16 00:49:03 uwe Exp $ */ +/* $NetBSD: power.c,v 1.18 2011/07/17 23:18:23 mrg Exp $ */ /* * Copyright (c) 1996 @@ -40,7 +40,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: power.c,v 1.17 2005/11/16 00:49:03 uwe Exp $"); +__KERNEL_RCSID(0, "$NetBSD: power.c,v 1.18 2011/07/17 23:18:23 mrg Exp $"); #include <sys/param.h> #include <sys/device.h> @@ -51,11 +51,10 @@ #include <sparc/dev/power.h> -static int powermatch(struct device *, struct cfdata *, void *); -static void powerattach(struct device *, struct device *, void *); +static int powermatch(device_t, cfdata_t, void *); +static void powerattach(device_t, device_t, void *); -CFATTACH_DECL(power, sizeof(struct device), - powermatch, powerattach, NULL, NULL); +CFATTACH_DECL_NEW(power, 0, powermatch, powerattach, NULL, NULL); /* * This is the driver for the "power" register available on some Sun4m @@ -64,7 +63,7 @@ */ static int -powermatch(struct device *parent, struct cfdata *cf, void *aux) +powermatch(device_t parent, cfdata_t cf, void *aux) { union obio_attach_args *uoba = aux; struct sbus_attach_args *sa = &uoba->uoba_sbus; @@ -77,7 +76,7 @@ /* ARGSUSED */ static void -powerattach(struct device *parent, struct device *self, void *aux) +powerattach(device_t parent, device_t self, void *aux) { union obio_attach_args *uoba = aux; struct sbus_attach_args *sa = &uoba->uoba_sbus; @@ -87,7 +86,7 @@ if (sbus_bus_map(sa->sa_bustag, sa->sa_slot, sa->sa_offset, sizeof(uint8_t), BUS_SPACE_MAP_LINEAR, &bh) != 0) { - printf("%s: cannot map register\n", self->dv_xname); + printf("%s: cannot map register\n", device_xname(self)); return; } power_reg = (volatile uint8_t *)bh; Index: src/sys/arch/sparc/sparc/autoconf.c diff -u src/sys/arch/sparc/sparc/autoconf.c:1.241 src/sys/arch/sparc/sparc/autoconf.c:1.242 --- src/sys/arch/sparc/sparc/autoconf.c:1.241 Wed Jul 6 20:47:05 2011 +++ src/sys/arch/sparc/sparc/autoconf.c Sun Jul 17 23:18:23 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: autoconf.c,v 1.241 2011/07/06 20:47:05 dyoung Exp $ */ +/* $NetBSD: autoconf.c,v 1.242 2011/07/17 23:18:23 mrg Exp $ */ /* * Copyright (c) 1996 @@ -48,7 +48,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.241 2011/07/06 20:47:05 dyoung Exp $"); +__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.242 2011/07/17 23:18:23 mrg Exp $"); #include "opt_ddb.h" #include "opt_kgdb.h" @@ -131,8 +131,8 @@ int st_crazymap(int); int sd_crazymap(int); void sync_crash(void); -int mainbus_match(struct device *, struct cfdata *, void *); -static void mainbus_attach(struct device *, struct device *, void *); +int mainbus_match(device_t, cfdata_t, void *); +static void mainbus_attach(device_t, device_t, void *); struct bootpath bootpath[8]; int nbootpath; @@ -1044,7 +1044,7 @@ } int -mainbus_match(struct device *parent, struct cfdata *cf, void *aux) +mainbus_match(device_t parent, cfdata_t cf, void *aux) { return (1); @@ -1069,7 +1069,7 @@ * We also record the `node id' of the default frame buffer, if any. */ static void -mainbus_attach(struct device *parent, struct device *dev, void *aux) +mainbus_attach(device_t parent, device_t dev, void *aux) { extern struct sparc_bus_dma_tag mainbus_dma_tag; extern struct sparc_bus_space_tag mainbus_space_tag; @@ -1365,8 +1365,7 @@ #endif /* SUN4C || SUN4M || SUN4D */ } -CFATTACH_DECL(mainbus, sizeof(struct device), - mainbus_match, mainbus_attach, NULL, NULL); +CFATTACH_DECL_NEW(mainbus, 0, mainbus_match, mainbus_attach, NULL, NULL); #if defined(SUN4C) || defined(SUN4M) || defined(SUN4D) Index: src/sys/arch/sparc/sparc/auxreg.c diff -u src/sys/arch/sparc/sparc/auxreg.c:1.38 src/sys/arch/sparc/sparc/auxreg.c:1.39 --- src/sys/arch/sparc/sparc/auxreg.c:1.38 Wed Oct 17 19:57:14 2007 +++ src/sys/arch/sparc/sparc/auxreg.c Sun Jul 17 23:18:23 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: auxreg.c,v 1.38 2007/10/17 19:57:14 garbled Exp $ */ +/* $NetBSD: auxreg.c,v 1.39 2011/07/17 23:18:23 mrg Exp $ */ /* * Copyright (c) 1992, 1993 @@ -41,7 +41,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: auxreg.c,v 1.38 2007/10/17 19:57:14 garbled Exp $"); +__KERNEL_RCSID(0, "$NetBSD: auxreg.c,v 1.39 2011/07/17 23:18:23 mrg Exp $"); #include "opt_blink.h" @@ -56,17 +56,17 @@ #include <sparc/sparc/vaddrs.h> #include <sparc/sparc/auxreg.h> -static int auxregmatch_mainbus(struct device *, struct cfdata *, void *); -static int auxregmatch_obio(struct device *, struct cfdata *, void *); -static void auxregattach_mainbus(struct device *, struct device *, void *); -static void auxregattach_obio(struct device *, struct device *, void *); +static int auxregmatch_mainbus(device_t, cfdata_t, void *); +static int auxregmatch_obio(device_t, cfdata_t, void *); +static void auxregattach_mainbus(device_t, device_t, void *); +static void auxregattach_obio(device_t, device_t, void *); -static void auxregattach(struct device *); +static void auxregattach(void); -CFATTACH_DECL(auxreg_mainbus, sizeof(struct device), +CFATTACH_DECL_NEW(auxreg_mainbus, 0, auxregmatch_mainbus, auxregattach_mainbus, NULL, NULL); -CFATTACH_DECL(auxreg_obio, sizeof(struct device), +CFATTACH_DECL_NEW(auxreg_obio, 0, auxregmatch_obio, auxregattach_obio, NULL, NULL); #ifdef BLINK @@ -98,7 +98,7 @@ * The OPENPROM calls this "auxiliary-io" (sun4c) or "auxio" (sun4m). */ static int -auxregmatch_mainbus(struct device *parent, struct cfdata *cf, void *aux) +auxregmatch_mainbus(device_t parent, cfdata_t cf, void *aux) { struct mainbus_attach_args *ma = aux; @@ -106,7 +106,7 @@ } static int -auxregmatch_obio(struct device *parent, struct cfdata *cf, void *aux) +auxregmatch_obio(device_t parent, cfdata_t cf, void *aux) { union obio_attach_args *uoba = aux; @@ -118,7 +118,7 @@ /* ARGSUSED */ static void -auxregattach_mainbus(struct device *parent, struct device *self, void *aux) +auxregattach_mainbus(device_t parent, device_t self, void *aux) { struct mainbus_attach_args *ma = aux; bus_space_handle_t bh; @@ -135,11 +135,11 @@ auxio_reg = AUXIO4C_REG; auxio_regval = *AUXIO4C_REG | AUXIO4C_FEJ | AUXIO4C_MB1; - auxregattach(self); + auxregattach(); } static void -auxregattach_obio(struct device *parent, struct device *self, void *aux) +auxregattach_obio(device_t parent, device_t self, void *aux) { union obio_attach_args *uoba = aux; struct sbus_attach_args *sa = &uoba->uoba_sbus; @@ -156,11 +156,11 @@ auxio_reg = AUXIO4M_REG; auxio_regval = *AUXIO4M_REG | AUXIO4M_MB1; - auxregattach(self); + auxregattach(); } static void -auxregattach(struct device *self) +auxregattach(void) { printf("\n"); Index: src/sys/arch/sparc/sparc/cpu.c diff -u src/sys/arch/sparc/sparc/cpu.c:1.232 src/sys/arch/sparc/sparc/cpu.c:1.233 --- src/sys/arch/sparc/sparc/cpu.c:1.232 Sun Feb 20 11:41:20 2011 +++ src/sys/arch/sparc/sparc/cpu.c Sun Jul 17 23:18:23 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu.c,v 1.232 2011/02/20 11:41:20 mrg Exp $ */ +/* $NetBSD: cpu.c,v 1.233 2011/07/17 23:18:23 mrg Exp $ */ /* * Copyright (c) 1996 @@ -52,7 +52,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.232 2011/02/20 11:41:20 mrg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.233 2011/07/17 23:18:23 mrg Exp $"); #include "opt_multiprocessor.h" #include "opt_lockdebug.h" @@ -93,7 +93,7 @@ #endif struct cpu_softc { - struct device sc_dev; /* generic device info */ + device_t sc_dev; struct cpu_info *sc_cpuinfo; }; @@ -108,17 +108,17 @@ struct cpu_info *cpus[_MAXNCPU+1]; /* we only support 4 CPUs. */ /* The CPU configuration driver. */ -static void cpu_mainbus_attach(struct device *, struct device *, void *); -int cpu_mainbus_match(struct device *, struct cfdata *, void *); +static void cpu_mainbus_attach(device_t, device_t, void *); +int cpu_mainbus_match(device_t, cfdata_t, void *); -CFATTACH_DECL(cpu_mainbus, sizeof(struct cpu_softc), +CFATTACH_DECL_NEW(cpu_mainbus, sizeof(struct cpu_softc), cpu_mainbus_match, cpu_mainbus_attach, NULL, NULL); #if defined(SUN4D) -static int cpu_cpuunit_match(struct device *, struct cfdata *, void *); -static void cpu_cpuunit_attach(struct device *, struct device *, void *); +static int cpu_cpuunit_match(device_t, cfdata_t, void *); +static void cpu_cpuunit_attach(device_t, device_t, void *); -CFATTACH_DECL(cpu_cpuunit, sizeof(struct cpu_softc), +CFATTACH_DECL_NEW(cpu_cpuunit, sizeof(struct cpu_softc), cpu_cpuunit_match, cpu_cpuunit_attach, NULL, NULL); #endif /* SUN4D */ @@ -193,7 +193,7 @@ */ int -cpu_mainbus_match(struct device *parent, struct cfdata *cf, void *aux) +cpu_mainbus_match(device_t parent, cfdata_t cf, void *aux) { struct mainbus_attach_args *ma = aux; @@ -201,20 +201,23 @@ } static void -cpu_mainbus_attach(struct device *parent, struct device *self, void *aux) +cpu_mainbus_attach(device_t parent, device_t self, void *aux) { struct mainbus_attach_args *ma = aux; struct { uint32_t va; uint32_t size; } *mbprop = NULL; struct openprom_addr *rrp = NULL; struct cpu_info *cpi; + struct cpu_softc *sc; int mid, node; int error, n; node = ma->ma_node; mid = (node != 0) ? prom_getpropint(node, "mid", 0) : 0; - cpu_attach((struct cpu_softc *)self, node, mid); + sc = device_private(self); + sc->sc_dev = self; + cpu_attach(sc, node, mid); - cpi = ((struct cpu_softc *)self)->sc_cpuinfo; + cpi = sc->sc_cpuinfo; if (cpi == NULL) return; @@ -280,7 +283,7 @@ #if defined(SUN4D) static int -cpu_cpuunit_match(struct device *parent, struct cfdata *cf, void *aux) +cpu_cpuunit_match(device_t parent, cfdata_t cf, void *aux) { struct cpuunit_attach_args *cpua = aux; @@ -288,12 +291,13 @@ } static void -cpu_cpuunit_attach(struct device *parent, struct device *self, void *aux) +cpu_cpuunit_attach(device_t parent, device_t self, void *aux) { struct cpuunit_attach_args *cpua = aux; + struct cpu_softc *sc = device_private(self); - cpu_attach((struct cpu_softc *)self, cpua->cpua_node, - cpua->cpua_device_id); + sc->sc_dev = self; + cpu_attach(sc, cpua->cpua_node, cpua->cpua_device_id); } #endif /* SUN4D */ @@ -490,7 +494,7 @@ if (error != 0) { aprint_normal("\n"); aprint_error("%s: mi_cpu_attach failed with %d\n", - sc->sc_dev.dv_xname, error); + device_xname(sc->sc_dev), error); return; } @@ -939,9 +943,9 @@ if (sc->sc_cpuinfo->flags & CPUFLG_SUN4CACHEBUG) printf("%s: cache chip bug; trap page uncached\n", - sc->sc_dev.dv_xname); + device_xname(sc->sc_dev)); - printf("%s: ", sc->sc_dev.dv_xname); + printf("%s: ", device_xname(sc->sc_dev)); if (ci->c_totalsize == 0) { printf("no cache\n"); Index: src/sys/arch/sparc/sparc/cpuunit.c diff -u src/sys/arch/sparc/sparc/cpuunit.c:1.14 src/sys/arch/sparc/sparc/cpuunit.c:1.15 --- src/sys/arch/sparc/sparc/cpuunit.c:1.14 Fri Jul 1 18:51:51 2011 +++ src/sys/arch/sparc/sparc/cpuunit.c Sun Jul 17 23:18:23 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: cpuunit.c,v 1.14 2011/07/01 18:51:51 dyoung Exp $ */ +/* $NetBSD: cpuunit.c,v 1.15 2011/07/17 23:18:23 mrg Exp $ */ /*- * Copyright (c) 2002 The NetBSD Foundation, Inc. @@ -34,7 +34,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: cpuunit.c,v 1.14 2011/07/01 18:51:51 dyoung Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cpuunit.c,v 1.15 2011/07/17 23:18:23 mrg Exp $"); #include <sys/param.h> #include <sys/malloc.h> @@ -47,7 +47,6 @@ #include <sparc/sparc/cpuunitvar.h> struct cpuunit_softc { - struct device sc_dev; int sc_node; /* our OBP node */ bus_space_tag_t sc_st; /* ours */ @@ -57,10 +56,10 @@ int sc_board; /* board number */ }; -static int cpuunit_match(struct device *, struct cfdata *, void *); -static void cpuunit_attach(struct device *, struct device *, void *); +static int cpuunit_match(device_t, cfdata_t, void *); +static void cpuunit_attach(device_t, device_t, void *); -CFATTACH_DECL(cpuunit, sizeof(struct cpuunit_softc), +CFATTACH_DECL_NEW(cpuunit, sizeof(struct cpuunit_softc), cpuunit_match, cpuunit_attach, NULL, NULL); static int cpuunit_print(void *, const char *); @@ -70,7 +69,7 @@ static void cpuunit_destroy_attach_args(struct cpuunit_attach_args *); static int -cpuunit_match(struct device *parent, struct cfdata *cf, void *aux) +cpuunit_match(device_t parent, cfdata_t cf, void *aux) { struct mainbus_attach_args *ma = aux; @@ -81,9 +80,9 @@ } static void -cpuunit_attach(struct device *parent, struct device *self, void *aux) +cpuunit_attach(device_t parent, device_t self, void *aux) { - struct cpuunit_softc *sc = (void *) self; + struct cpuunit_softc *sc = device_private(self); struct mainbus_attach_args *ma = aux; int node, error; bus_space_tag_t sbt; @@ -113,7 +112,7 @@ sizeof(struct openprom_range), &sbt->nranges, &sbt->ranges); if (error) { printf("%s: error %d getting \"ranges\" property\n", - sc->sc_dev.dv_xname, error); + device_xname(self), error); panic("cpuunit_attach"); } @@ -125,7 +124,7 @@ if (cpuunit_setup_attach_args(sc, sbt, node, &cpua)) panic("cpuunit_attach: failed to set up attach args"); - (void) config_found(&sc->sc_dev, &cpua, cpuunit_print); + (void) config_found(self, &cpua, cpuunit_print); cpuunit_destroy_attach_args(&cpua); } Index: src/sys/arch/sparc/sparc/iommu.c diff -u src/sys/arch/sparc/sparc/iommu.c:1.93 src/sys/arch/sparc/sparc/iommu.c:1.94 --- src/sys/arch/sparc/sparc/iommu.c:1.93 Fri Jul 1 18:51:51 2011 +++ src/sys/arch/sparc/sparc/iommu.c Sun Jul 17 23:18:23 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: iommu.c,v 1.93 2011/07/01 18:51:51 dyoung Exp $ */ +/* $NetBSD: iommu.c,v 1.94 2011/07/17 23:18:23 mrg Exp $ */ /* * Copyright (c) 1996 @@ -37,7 +37,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: iommu.c,v 1.93 2011/07/01 18:51:51 dyoung Exp $"); +__KERNEL_RCSID(0, "$NetBSD: iommu.c,v 1.94 2011/07/17 23:18:23 mrg Exp $"); #include "opt_sparc_arch.h" @@ -62,7 +62,6 @@ #include <sparc/sparc/iommuvar.h> struct iommu_softc { - struct device sc_dev; /* base device */ struct iommureg *sc_reg; u_int sc_pagesize; u_int sc_range; @@ -80,14 +79,14 @@ /* autoconfiguration driver */ int iommu_print(void *, const char *); -void iommu_attach(struct device *, struct device *, void *); -int iommu_match(struct device *, struct cfdata *, void *); +void iommu_attach(device_t, device_t, void *); +int iommu_match(device_t, cfdata_t, void *); #if defined(SUN4M) static void iommu_copy_prom_entries(struct iommu_softc *); #endif -CFATTACH_DECL(iommu, sizeof(struct iommu_softc), +CFATTACH_DECL_NEW(iommu, sizeof(struct iommu_softc), iommu_match, iommu_attach, NULL, NULL); /* IOMMU DMA map functions */ @@ -130,7 +129,7 @@ } int -iommu_match(struct device *parent, struct cfdata *cf, void *aux) +iommu_match(device_t parent, cfdata_t cf, void *aux) { struct mainbus_attach_args *ma = aux; @@ -143,10 +142,10 @@ * Attach the iommu. */ void -iommu_attach(struct device *parent, struct device *self, void *aux) +iommu_attach(device_t parent, device_t self, void *aux) { #if defined(SUN4M) - struct iommu_softc *sc = (struct iommu_softc *)self; + struct iommu_softc *sc = device_private(self); struct mainbus_attach_args *ma = aux; struct sparc_bus_dma_tag *dmat = &sc->sc_dmatag; bus_space_handle_t bh; @@ -301,7 +300,7 @@ ia.iom_reg = &sbus_iommu_reg; ia.iom_nreg = 1; - (void) config_found(&sc->sc_dev, (void *)&ia, iommu_print); + (void) config_found(self, (void *)&ia, iommu_print); return; } @@ -324,7 +323,7 @@ prom_getprop(node, "reg", sizeof(struct openprom_addr), &ia.iom_nreg, &ia.iom_reg); - (void) config_found(&sc->sc_dev, (void *)&ia, iommu_print); + (void) config_found(self, (void *)&ia, iommu_print); if (ia.iom_reg != NULL) free(ia.iom_reg, M_DEVBUF); } Index: src/sys/arch/sparc/sparc/memecc.c diff -u src/sys/arch/sparc/sparc/memecc.c:1.12 src/sys/arch/sparc/sparc/memecc.c:1.13 --- src/sys/arch/sparc/sparc/memecc.c:1.12 Fri Jul 1 18:51:51 2011 +++ src/sys/arch/sparc/sparc/memecc.c Sun Jul 17 23:18:23 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: memecc.c,v 1.12 2011/07/01 18:51:51 dyoung Exp $ */ +/* $NetBSD: memecc.c,v 1.13 2011/07/17 23:18:23 mrg Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -34,7 +34,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: memecc.c,v 1.12 2011/07/01 18:51:51 dyoung Exp $"); +__KERNEL_RCSID(0, "$NetBSD: memecc.c,v 1.13 2011/07/17 23:18:23 mrg Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -45,7 +45,6 @@ #include <sparc/sparc/memeccreg.h> struct memecc_softc { - struct device sc_dev; /* base device */ bus_space_tag_t sc_bt; bus_space_handle_t sc_bh; }; @@ -53,17 +52,17 @@ struct memecc_softc *memecc_sc; /* autoconfiguration driver */ -static void memecc_attach(struct device *, struct device *, void *); -static int memecc_match(struct device *, struct cfdata *, void *); +static void memecc_attach(device_t, device_t, void *); +static int memecc_match(device_t, cfdata_t, void *); static int memecc_error(void); int (*memerr_handler)(void); -CFATTACH_DECL(eccmemctl, sizeof(struct memecc_softc), +CFATTACH_DECL_NEW(eccmemctl, sizeof(struct memecc_softc), memecc_match, memecc_attach, NULL, NULL); int -memecc_match(struct device *parent, struct cfdata *cf, void *aux) +memecc_match(device_t parent, cfdata_t cf, void *aux) { struct mainbus_attach_args *ma = aux; @@ -74,13 +73,18 @@ * Attach the device. */ void -memecc_attach(struct device *parent, struct device *self, void *aux) +memecc_attach(device_t parent, device_t self, void *aux) { struct memecc_softc *sc = (struct memecc_softc *)self; struct mainbus_attach_args *ma = aux; int node; uint32_t reg; + if (memerr_handler) { + printf("%s: already attached\n", __func__); + return; + } + sc->sc_bt = ma->ma_bustag; node = ma->ma_node; Index: src/sys/arch/sparc/sparc/timer.c diff -u src/sys/arch/sparc/sparc/timer.c:1.28 src/sys/arch/sparc/sparc/timer.c:1.29 --- src/sys/arch/sparc/sparc/timer.c:1.28 Fri Jul 1 18:51:51 2011 +++ src/sys/arch/sparc/sparc/timer.c Sun Jul 17 23:18:23 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: timer.c,v 1.28 2011/07/01 18:51:51 dyoung Exp $ */ +/* $NetBSD: timer.c,v 1.29 2011/07/17 23:18:23 mrg Exp $ */ /* * Copyright (c) 1992, 1993 @@ -60,7 +60,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: timer.c,v 1.28 2011/07/01 18:51:51 dyoung Exp $"); +__KERNEL_RCSID(0, "$NetBSD: timer.c,v 1.29 2011/07/17 23:18:23 mrg Exp $"); #include <sys/param.h> #include <sys/kernel.h> @@ -240,7 +240,7 @@ * The sun4 timer must be probed. */ static int -timermatch_obio(struct device *parent, struct cfdata *cf, void *aux) +timermatch_obio(device_t parent, cfdata_t cf, void *aux) { #if defined(SUN4) || defined(SUN4M) union obio_attach_args *uoba = aux; @@ -277,7 +277,7 @@ } static void -timerattach_obio(struct device *parent, struct device *self, void *aux) +timerattach_obio(device_t parent, device_t self, void *aux) { union obio_attach_args *uoba = aux; @@ -297,14 +297,14 @@ } } -CFATTACH_DECL(timer_obio, sizeof(struct device), +CFATTACH_DECL_NEW(timer_obio, 0, timermatch_obio, timerattach_obio, NULL, NULL); /* * Only sun4c attaches a timer at mainbus */ static int -timermatch_mainbus(struct device *parent, struct cfdata *cf, void *aux) +timermatch_mainbus(device_t parent, cfdata_t cf, void *aux) { #if defined(SUN4C) struct mainbus_attach_args *ma = aux; @@ -316,7 +316,7 @@ } static void -timerattach_mainbus(struct device *parent, struct device *self, void *aux) +timerattach_mainbus(device_t parent, device_t self, void *aux) { #if defined(SUN4C) @@ -324,5 +324,5 @@ #endif /* SUN4C */ } -CFATTACH_DECL(timer_mainbus, sizeof(struct device), +CFATTACH_DECL_NEW(timer_mainbus, 0, timermatch_mainbus, timerattach_mainbus, NULL, NULL); Index: src/sys/arch/sparc/sparc/timer_msiiep.c diff -u src/sys/arch/sparc/sparc/timer_msiiep.c:1.25 src/sys/arch/sparc/sparc/timer_msiiep.c:1.26 --- src/sys/arch/sparc/sparc/timer_msiiep.c:1.25 Mon Jan 4 03:54:42 2010 +++ src/sys/arch/sparc/sparc/timer_msiiep.c Sun Jul 17 23:18:23 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: timer_msiiep.c,v 1.25 2010/01/04 03:54:42 mrg Exp $ */ +/* $NetBSD: timer_msiiep.c,v 1.26 2011/07/17 23:18:23 mrg Exp $ */ /* * Copyright (c) 1992, 1993 @@ -58,7 +58,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: timer_msiiep.c,v 1.25 2010/01/04 03:54:42 mrg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: timer_msiiep.c,v 1.26 2011/07/17 23:18:23 mrg Exp $"); #include <sys/param.h> #include <sys/kernel.h> @@ -74,10 +74,10 @@ #include <sparc/sparc/timervar.h> -static int timermatch_msiiep(struct device *, struct cfdata *, void *); -static void timerattach_msiiep(struct device *, struct device *, void *); +static int timermatch_msiiep(device_t, cfdata_t, void *); +static void timerattach_msiiep(device_t, device_t, void *); -CFATTACH_DECL(timer_msiiep, sizeof(struct device), +CFATTACH_DECL_NEW(timer_msiiep, 0, timermatch_msiiep, timerattach_msiiep, NULL, NULL); @@ -120,7 +120,7 @@ static int -timermatch_msiiep(struct device *parent, struct cfdata *cf, void *aux) +timermatch_msiiep(device_t parent, cfdata_t cf, void *aux) { struct msiiep_attach_args *msa = aux; @@ -134,7 +134,7 @@ * node for them. */ static void -timerattach_msiiep(struct device *parent, struct device *self, void *aux) +timerattach_msiiep(device_t parent, device_t self, void *aux) { /* Put processor counter in "counter" mode */ Index: src/sys/arch/sparc/sparc/timer_sun4.c diff -u src/sys/arch/sparc/sparc/timer_sun4.c:1.18 src/sys/arch/sparc/sparc/timer_sun4.c:1.19 --- src/sys/arch/sparc/sparc/timer_sun4.c:1.18 Fri Jul 1 18:51:51 2011 +++ src/sys/arch/sparc/sparc/timer_sun4.c Sun Jul 17 23:18:23 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: timer_sun4.c,v 1.18 2011/07/01 18:51:51 dyoung Exp $ */ +/* $NetBSD: timer_sun4.c,v 1.19 2011/07/17 23:18:23 mrg Exp $ */ /* * Copyright (c) 1992, 1993 @@ -58,7 +58,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: timer_sun4.c,v 1.18 2011/07/01 18:51:51 dyoung Exp $"); +__KERNEL_RCSID(0, "$NetBSD: timer_sun4.c,v 1.19 2011/07/17 23:18:23 mrg Exp $"); #include <sys/param.h> #include <sys/kernel.h> @@ -153,7 +153,7 @@ #if defined(SUN4) void -timerattach_obio_4(struct device *parent, struct device *self, void *aux) +timerattach_obio_4(device_t parent, device_t self, void *aux) { union obio_attach_args *uoba = aux; struct obio4_attach_args *oba = &uoba->uoba_oba4; @@ -175,7 +175,7 @@ #if defined(SUN4C) void -timerattach_mainbus_4c(struct device *parent, struct device *self, void *aux) +timerattach_mainbus_4c(device_t parent, device_t self, void *aux) { struct mainbus_attach_args *ma = aux; bus_space_handle_t bh; Index: src/sys/arch/sparc/sparc/timer_sun4m.c diff -u src/sys/arch/sparc/sparc/timer_sun4m.c:1.26 src/sys/arch/sparc/sparc/timer_sun4m.c:1.27 --- src/sys/arch/sparc/sparc/timer_sun4m.c:1.26 Fri Jul 1 18:51:52 2011 +++ src/sys/arch/sparc/sparc/timer_sun4m.c Sun Jul 17 23:18:23 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: timer_sun4m.c,v 1.26 2011/07/01 18:51:52 dyoung Exp $ */ +/* $NetBSD: timer_sun4m.c,v 1.27 2011/07/17 23:18:23 mrg Exp $ */ /* * Copyright (c) 1992, 1993 @@ -58,7 +58,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: timer_sun4m.c,v 1.26 2011/07/01 18:51:52 dyoung Exp $"); +__KERNEL_RCSID(0, "$NetBSD: timer_sun4m.c,v 1.27 2011/07/17 23:18:23 mrg Exp $"); #include <sys/param.h> #include <sys/kernel.h> @@ -206,7 +206,7 @@ } void -timerattach_obio_4m(struct device *parent, struct device *self, void *aux) +timerattach_obio_4m(device_t parent, device_t self, void *aux) { union obio_attach_args *uoba = aux; struct sbus_attach_args *sa = &uoba->uoba_sbus; Index: src/sys/arch/sparc/sparc/timervar.h diff -u src/sys/arch/sparc/sparc/timervar.h:1.9 src/sys/arch/sparc/sparc/timervar.h:1.10 --- src/sys/arch/sparc/sparc/timervar.h:1.9 Mon Jan 4 04:21:35 2010 +++ src/sys/arch/sparc/sparc/timervar.h Sun Jul 17 23:18:23 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: timervar.h,v 1.9 2010/01/04 04:21:35 mrg Exp $ */ +/* $NetBSD: timervar.h,v 1.10 2011/07/17 23:18:23 mrg Exp $ */ /* * Copyright (c) 1992, 1993 @@ -45,8 +45,8 @@ int statintr_4(void *); void timer_init_4(void); -void timerattach_obio_4(struct device *, struct device *, void *); -void timerattach_mainbus_4c(struct device *, struct device *, void *); +void timerattach_obio_4(device_t, device_t, void *); +void timerattach_mainbus_4c(device_t, device_t, void *); #endif /* SUN4 || SUN4C */ #if defined(SUN4M) @@ -55,7 +55,7 @@ int statintr_4m(void *); void timer_init_4m(void); -void timerattach_obio_4m(struct device *, struct device *, void *); +void timerattach_obio_4m(device_t, device_t, void *); #endif /* SUN4M */ /* Imported from clock.c: */