From ace9f0e4af0eabf83c9158d5ca2c9729eee224ce Mon Sep 17 00:00:00 2001 From: mrg Date: Sun, 17 Jul 2011 23:18:23 +0000 Subject: [PATCH] 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. --- sys/arch/sparc/dev/fd.c | 80 ++++++++++++++++------------- sys/arch/sparc/dev/power.c | 17 +++--- sys/arch/sparc/sparc/autoconf.c | 15 +++--- sys/arch/sparc/sparc/auxreg.c | 32 ++++++------ sys/arch/sparc/sparc/cpu.c | 44 ++++++++-------- sys/arch/sparc/sparc/cpuunit.c | 21 ++++---- sys/arch/sparc/sparc/iommu.c | 21 ++++---- sys/arch/sparc/sparc/memecc.c | 20 +++++--- sys/arch/sparc/sparc/timer.c | 16 +++--- sys/arch/sparc/sparc/timer_msiiep.c | 14 ++--- sys/arch/sparc/sparc/timer_sun4.c | 8 +-- sys/arch/sparc/sparc/timer_sun4m.c | 6 +-- sys/arch/sparc/sparc/timervar.h | 8 +-- 13 files changed, 156 insertions(+), 146 deletions(-) diff --git a/sys/arch/sparc/dev/fd.c b/sys/arch/sparc/dev/fd.c index 32d0fedc5644..64b452836f2b 100644 --- a/sys/arch/sparc/dev/fd.c +++ b/sys/arch/sparc/dev/fd.c @@ -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 -__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 @@ enum fdc_state { /* 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 @@ struct fdc_softc { 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 @@ struct fd_type fd_types[] = { /* 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 @@ struct fd_softc { }; /* 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 @@ int fd_read_md_image(size_t *, void **); #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 @@ fdcmatch_mainbus(struct device *parent, struct cfdata *match, void *aux) } 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 @@ fdconf(struct fdc_softc *fdc) } 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 @@ fdcattach_mainbus(struct device *parent, struct device *self, void *aux) } 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 @@ fdcattach_obio(struct device *parent, struct device *self, void *aux) return; } + fdc->sc_dev = self; fdc->sc_bustag = sa->sa_bustag; if (sbus_bus_map(sa->sa_bustag, @@ -647,27 +649,27 @@ fdcattach(struct fdc_softc *fdc, int pri) #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 @@ fdcattach(struct fdc_softc *fdc, int pri) } 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 @@ fdmatch(struct device *parent, struct cfdata *match, void *aux) * 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 @@ fdattach(struct device *parent, struct device *self, void *aux) 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 @@ fdattach(struct device *parent, struct device *self, void *aux) /* * 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 @@ fdstrategy(struct buf *bp) 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 @@ done: 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 @@ fdstart(struct fd_softc *fd) 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 @@ fd_motor_off(void *arg) 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 @@ void 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 @@ fdcstatus(struct fdc_softc *fdc, const char *s) #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 @@ fdctimeout(void *arg) 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 @@ loop: 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 @@ fdcretry(struct fdc_softc *fdc) 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 @@ fdcretry(struct fdc_softc *fdc) * 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 @@ fdioctl(dev_t dev, u_long cmd, void *addr, int flag, struct lwp *l) 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 @@ fdgetdisklabel(dev_t dev) 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); diff --git a/sys/arch/sparc/dev/power.c b/sys/arch/sparc/dev/power.c index b05c04cc9df8..005e77be6026 100644 --- a/sys/arch/sparc/dev/power.c +++ b/sys/arch/sparc/dev/power.c @@ -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 -__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 #include @@ -51,11 +51,10 @@ __KERNEL_RCSID(0, "$NetBSD: power.c,v 1.17 2005/11/16 00:49:03 uwe Exp $"); #include -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 @@ CFATTACH_DECL(power, sizeof(struct device), */ 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 @@ powermatch(struct device *parent, struct cfdata *cf, void *aux) /* 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 @@ powerattach(struct device *parent, struct device *self, void *aux) 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; diff --git a/sys/arch/sparc/sparc/autoconf.c b/sys/arch/sparc/sparc/autoconf.c index 0ad71a1f7879..feaa2041526c 100644 --- a/sys/arch/sparc/sparc/autoconf.c +++ b/sys/arch/sparc/sparc/autoconf.c @@ -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 -__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 @@ static void crazymap(const char *, int *); 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 @@ mbprint(void *aux, const char *name) } 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 @@ static int prom_getprop_address1(int, void **); * 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 @@ extern struct sparc_bus_space_tag mainbus_space_tag; #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) diff --git a/sys/arch/sparc/sparc/auxreg.c b/sys/arch/sparc/sparc/auxreg.c index 6cdbb5410638..55ee19f93e08 100644 --- a/sys/arch/sparc/sparc/auxreg.c +++ b/sys/arch/sparc/sparc/auxreg.c @@ -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 -__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 @@ __KERNEL_RCSID(0, "$NetBSD: auxreg.c,v 1.38 2007/10/17 19:57:14 garbled Exp $"); #include #include -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 @@ blink(void *zero) * 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 @@ auxregmatch_mainbus(struct device *parent, struct cfdata *cf, void *aux) } 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 @@ auxregmatch_obio(struct device *parent, struct cfdata *cf, void *aux) /* 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 @@ auxregattach_mainbus(struct device *parent, struct device *self, void *aux) 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 @@ auxregattach_obio(struct device *parent, struct device *self, void *aux) auxio_reg = AUXIO4M_REG; auxio_regval = *AUXIO4M_REG | AUXIO4M_MB1; - auxregattach(self); + auxregattach(); } static void -auxregattach(struct device *self) +auxregattach(void) { printf("\n"); diff --git a/sys/arch/sparc/sparc/cpu.c b/sys/arch/sparc/sparc/cpu.c index 9a2c58002573..08732739a1f1 100644 --- a/sys/arch/sparc/sparc/cpu.c +++ b/sys/arch/sparc/sparc/cpu.c @@ -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 -__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 @@ __KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.232 2011/02/20 11:41:20 mrg Exp $"); #endif struct cpu_softc { - struct device sc_dev; /* generic device info */ + device_t sc_dev; struct cpu_info *sc_cpuinfo; }; @@ -108,17 +108,17 @@ int sparc_ncpus; /* # of CPUs detected by PROM */ 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 @@ static kmutex_t xpmsg_mutex; */ 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 @@ cpu_mainbus_match(struct device *parent, struct cfdata *cf, void *aux) } 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 @@ cpu_mainbus_attach(struct device *parent, struct device *self, void *aux) #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 @@ cpu_cpuunit_match(struct device *parent, struct cfdata *cf, void *aux) } 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 @@ cpu_attach_non_boot(struct cpu_softc *sc, struct cpu_info *cpi, int node) 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 @@ cache_print(struct cpu_softc *sc) 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"); diff --git a/sys/arch/sparc/sparc/cpuunit.c b/sys/arch/sparc/sparc/cpuunit.c index 5426198ea453..b59d3e1c0c6d 100644 --- a/sys/arch/sparc/sparc/cpuunit.c +++ b/sys/arch/sparc/sparc/cpuunit.c @@ -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 -__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 #include @@ -47,7 +47,6 @@ __KERNEL_RCSID(0, "$NetBSD: cpuunit.c,v 1.14 2011/07/01 18:51:51 dyoung Exp $"); #include struct cpuunit_softc { - struct device sc_dev; int sc_node; /* our OBP node */ bus_space_tag_t sc_st; /* ours */ @@ -57,10 +56,10 @@ struct cpuunit_softc { 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 int cpuunit_setup_attach_args(struct cpuunit_softc *, bus_space_tag_t, 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 @@ cpuunit_match(struct device *parent, struct cfdata *cf, void *aux) } 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 @@ cpuunit_attach(struct device *parent, struct device *self, void *aux) 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 @@ cpuunit_attach(struct device *parent, struct device *self, void *aux) 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); } diff --git a/sys/arch/sparc/sparc/iommu.c b/sys/arch/sparc/sparc/iommu.c index e119fcb646b7..3bfc734e4dfc 100644 --- a/sys/arch/sparc/sparc/iommu.c +++ b/sys/arch/sparc/sparc/iommu.c @@ -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 -__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 @@ __KERNEL_RCSID(0, "$NetBSD: iommu.c,v 1.93 2011/07/01 18:51:51 dyoung Exp $"); #include 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 @@ struct iommu_softc { /* 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 @@ iommu_print(void *args, const char *iommu) } 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 @@ iommu_match(struct device *parent, struct cfdata *cf, void *aux) * 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 @@ iommu_attach(struct device *parent, struct device *self, void *aux) 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 @@ iommu_attach(struct device *parent, struct device *self, void *aux) 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); } diff --git a/sys/arch/sparc/sparc/memecc.c b/sys/arch/sparc/sparc/memecc.c index 1e3919c8ea8a..e9e455f3c02d 100644 --- a/sys/arch/sparc/sparc/memecc.c +++ b/sys/arch/sparc/sparc/memecc.c @@ -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 -__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 #include @@ -45,7 +45,6 @@ __KERNEL_RCSID(0, "$NetBSD: memecc.c,v 1.12 2011/07/01 18:51:51 dyoung Exp $"); #include 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 { 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 @@ memecc_match(struct device *parent, struct cfdata *cf, void *aux) * 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; diff --git a/sys/arch/sparc/sparc/timer.c b/sys/arch/sparc/sparc/timer.c index 388df972eb85..588634a2b83d 100644 --- a/sys/arch/sparc/sparc/timer.c +++ b/sys/arch/sparc/sparc/timer.c @@ -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 -__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 #include @@ -240,7 +240,7 @@ timerattach(volatile int *cntreg, volatile int *limreg) * 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 @@ timermatch_obio(struct device *parent, struct cfdata *cf, void *aux) } 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 @@ timerattach_obio(struct device *parent, struct device *self, void *aux) } } -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 @@ timermatch_mainbus(struct device *parent, struct cfdata *cf, void *aux) } 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 @@ timerattach_mainbus(struct device *parent, struct device *self, void *aux) #endif /* SUN4C */ } -CFATTACH_DECL(timer_mainbus, sizeof(struct device), +CFATTACH_DECL_NEW(timer_mainbus, 0, timermatch_mainbus, timerattach_mainbus, NULL, NULL); diff --git a/sys/arch/sparc/sparc/timer_msiiep.c b/sys/arch/sparc/sparc/timer_msiiep.c index 91f2a8f9754b..18d8e9a4d02b 100644 --- a/sys/arch/sparc/sparc/timer_msiiep.c +++ b/sys/arch/sparc/sparc/timer_msiiep.c @@ -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 -__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 #include @@ -74,10 +74,10 @@ __KERNEL_RCSID(0, "$NetBSD: timer_msiiep.c,v 1.25 2010/01/04 03:54:42 mrg Exp $" #include -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 struct timecounter counter_timecounter = { 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 @@ timermatch_msiiep(struct device *parent, struct cfdata *cf, void *aux) * 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 */ diff --git a/sys/arch/sparc/sparc/timer_sun4.c b/sys/arch/sparc/sparc/timer_sun4.c index a48c95b7bad1..c33d6f3864c6 100644 --- a/sys/arch/sparc/sparc/timer_sun4.c +++ b/sys/arch/sparc/sparc/timer_sun4.c @@ -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 -__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 #include @@ -153,7 +153,7 @@ statintr_4(void *cap) #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 @@ timerattach_obio_4(struct device *parent, struct device *self, void *aux) #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; diff --git a/sys/arch/sparc/sparc/timer_sun4m.c b/sys/arch/sparc/sparc/timer_sun4m.c index 7070338ad37f..68cfcd4913f0 100644 --- a/sys/arch/sparc/sparc/timer_sun4m.c +++ b/sys/arch/sparc/sparc/timer_sun4m.c @@ -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 -__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 #include @@ -206,7 +206,7 @@ statintr_4m(void *cap) } 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; diff --git a/sys/arch/sparc/sparc/timervar.h b/sys/arch/sparc/sparc/timervar.h index 79e84e066349..b93eb469cdf9 100644 --- a/sys/arch/sparc/sparc/timervar.h +++ b/sys/arch/sparc/sparc/timervar.h @@ -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 clockintr_4(void *); 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 clockintr_4m(void *); 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: */