split auxio, ebus, psycho, sab.

This commit is contained in:
christos 2011-06-02 00:24:23 +00:00
parent 4418f77599
commit d92ab1d44a
7 changed files with 81 additions and 74 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: auxio.c,v 1.21 2011/03/12 11:43:38 nakayama Exp $ */
/* $NetBSD: auxio.c,v 1.22 2011/06/02 00:24:23 christos Exp $ */
/*
* Copyright (c) 2000, 2001 Matthew R. Green
@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: auxio.c,v 1.21 2011/03/12 11:43:38 nakayama Exp $");
__KERNEL_RCSID(0, "$NetBSD: auxio.c,v 1.22 2011/06/02 00:24:23 christos Exp $");
#include "opt_auxio.h"
@ -60,7 +60,7 @@ __KERNEL_RCSID(0, "$NetBSD: auxio.c,v 1.21 2011/03/12 11:43:38 nakayama Exp $");
*/
struct auxio_softc {
struct device sc_dev;
device_t sc_dev;
/* parent's tag */
bus_space_tag_t sc_tag;
@ -81,15 +81,15 @@ struct auxio_softc {
#define AUXIO_ROM_NAME "auxio"
void auxio_attach_common(struct auxio_softc *);
int auxio_ebus_match(struct device *, struct cfdata *, void *);
void auxio_ebus_attach(struct device *, struct device *, void *);
int auxio_sbus_match(struct device *, struct cfdata *, void *);
void auxio_sbus_attach(struct device *, struct device *, void *);
int auxio_ebus_match(device_t, cfdata_t, void *);
void auxio_ebus_attach(device_t, device_t, void *);
int auxio_sbus_match(device_t, cfdata_t, void *);
void auxio_sbus_attach(device_t, device_t, void *);
CFATTACH_DECL(auxio_ebus, sizeof(struct auxio_softc),
CFATTACH_DECL_NEW(auxio_ebus, sizeof(struct auxio_softc),
auxio_ebus_match, auxio_ebus_attach, NULL, NULL);
CFATTACH_DECL(auxio_sbus, sizeof(struct auxio_softc),
CFATTACH_DECL_NEW(auxio_sbus, sizeof(struct auxio_softc),
auxio_sbus_match, auxio_sbus_attach, NULL, NULL);
extern struct cfdriver auxio_cd;
@ -153,7 +153,7 @@ auxio_attach_common(struct auxio_softc *sc)
}
int
auxio_ebus_match(struct device *parent, struct cfdata *cf, void *aux)
auxio_ebus_match(device_t parent, cfdata_t cf, void *aux)
{
struct ebus_attach_args *ea = aux;
@ -161,11 +161,12 @@ auxio_ebus_match(struct device *parent, struct cfdata *cf, void *aux)
}
void
auxio_ebus_attach(struct device *parent, struct device *self, void *aux)
auxio_ebus_attach(device_t parent, device_t self, void *aux)
{
struct auxio_softc *sc = (struct auxio_softc *)self;
struct auxio_softc *sc = device_private(self);
struct ebus_attach_args *ea = aux;
sc->sc_dev = self;
sc->sc_tag = ea->ea_bustag;
if (ea->ea_nreg < 1) {
@ -212,19 +213,20 @@ auxio_ebus_attach(struct device *parent, struct device *self, void *aux)
}
int
auxio_sbus_match(struct device *parent, struct cfdata *cf, void *aux)
auxio_sbus_match(device_t parent, cfdata_t cf, void *aux)
{
struct sbus_attach_args *sa = aux;
return (strcmp(AUXIO_ROM_NAME, sa->sa_name) == 0);
return strcmp(AUXIO_ROM_NAME, sa->sa_name) == 0;
}
void
auxio_sbus_attach(struct device *parent, struct device *self, void *aux)
auxio_sbus_attach(device_t parent, device_t self, void *aux)
{
struct auxio_softc *sc = (struct auxio_softc *)self;
struct auxio_softc *sc = device_private(self);
struct sbus_attach_args *sa = aux;
sc->sc_dev = self;
sc->sc_tag = sa->sa_bustag;
if (sa->sa_nreg < 1) {

View File

@ -1,4 +1,4 @@
/* $NetBSD: ebus.c,v 1.56 2011/03/18 09:52:54 mrg Exp $ */
/* $NetBSD: ebus.c,v 1.57 2011/06/02 00:24:23 christos Exp $ */
/*
* Copyright (c) 1999, 2000, 2001 Matthew R. Green
@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ebus.c,v 1.56 2011/03/18 09:52:54 mrg Exp $");
__KERNEL_RCSID(0, "$NetBSD: ebus.c,v 1.57 2011/06/02 00:24:23 christos Exp $");
#include "opt_ddb.h"
@ -76,10 +76,10 @@ int ebus_debug = 0x0;
#include <dev/ebus/ebusvar.h>
#include <sparc64/dev/ebusvar.h>
int ebus_match(struct device *, struct cfdata *, void *);
void ebus_attach(struct device *, struct device *, void *);
int ebus_match(device_t, cfdata_t, void *);
void ebus_attach(device_t, device_t, void *);
CFATTACH_DECL(ebus, sizeof(struct ebus_softc),
CFATTACH_DECL_NEW(ebus, sizeof(struct ebus_softc),
ebus_match, ebus_attach, NULL, NULL);
/*
@ -91,7 +91,7 @@ static void *ebus_intr_establish(bus_space_tag_t, int, int, int (*)(void *),
void *, void(*)(void));
int
ebus_match(struct device *parent, struct cfdata *match, void *aux)
ebus_match(device_t parent, cfdata_t match, void *aux)
{
struct pci_attach_args *pa = aux;
char *name;
@ -131,15 +131,17 @@ ebus_match(struct device *parent, struct cfdata *match, void *aux)
* after the sbus code which does similar things.
*/
void
ebus_attach(struct device *parent, struct device *self, void *aux)
ebus_attach(device_t parent, device_t self, void *aux)
{
struct ebus_softc *sc = (struct ebus_softc *)self;
struct ebus_softc *sc = device_private(self);
struct pci_attach_args *pa = aux;
struct ebus_attach_args eba;
struct ebus_interrupt_map_mask *immp;
int node, nmapmask, error;
char devinfo[256];
sc->sc_dev = self;
aprint_normal("\n");
aprint_naive("\n");

View File

@ -1,4 +1,4 @@
/* $NetBSD: ebus_mainbus.c,v 1.3 2011/03/16 04:00:42 mrg Exp $ */
/* $NetBSD: ebus_mainbus.c,v 1.4 2011/06/02 00:24:23 christos Exp $ */
/* $OpenBSD: ebus_mainbus.c,v 1.7 2010/11/11 17:58:23 miod Exp $ */
/*
@ -53,10 +53,10 @@ extern int ebus_debug;
#include <dev/ebus/ebusvar.h>
#include <sparc64/dev/ebusvar.h>
int ebus_mainbus_match(struct device *, struct cfdata *, void *);
void ebus_mainbus_attach(struct device *, struct device *, void *);
int ebus_mainbus_match(device_t, cfdata_t, void *);
void ebus_mainbus_attach(device_t, device_t, void *);
CFATTACH_DECL(ebus_mainbus, sizeof(struct ebus_softc),
CFATTACH_DECL_NEW(ebus_mainbus, sizeof(struct ebus_softc),
ebus_mainbus_match, ebus_mainbus_attach, NULL, NULL);
int ebus_mainbus_bus_map(bus_space_tag_t, bus_addr_t, bus_size_t, int,
@ -67,7 +67,7 @@ bus_space_tag_t ebus_mainbus_alloc_bus_tag(struct ebus_softc *, bus_space_tag_t,
void ebus_mainbus_intr_ack(struct intrhand *);
int
ebus_mainbus_match(struct device *parent, struct cfdata *match, void *aux)
ebus_mainbus_match(struct device *parent, cfdata_t cf, void *aux)
{
struct mainbus_attach_args *ma = aux;
@ -79,7 +79,7 @@ ebus_mainbus_match(struct device *parent, struct cfdata *match, void *aux)
void
ebus_mainbus_attach(struct device *parent, struct device *self, void *aux)
{
struct ebus_softc *sc = (struct ebus_softc *)self;
struct ebus_softc *sc = device_private(self);
struct mainbus_attach_args *ma = aux;
struct ebus_attach_args eba;
struct ebus_interrupt_map_mask *immp;
@ -87,6 +87,7 @@ ebus_mainbus_attach(struct device *parent, struct device *self, void *aux)
struct pyro_softc *psc;
int i;
sc->sc_dev = self;
sc->sc_node = node = ma->ma_node;
sc->sc_ign = INTIGN((ma->ma_upaid) << INTMAP_IGN_SHIFT);

View File

@ -1,4 +1,4 @@
/* $NetBSD: ebusvar.h,v 1.9 2011/03/18 09:52:54 mrg Exp $ */
/* $NetBSD: ebusvar.h,v 1.10 2011/06/02 00:24:23 christos Exp $ */
/*
* Copyright (c) 1999, 2000, 2001 Matthew R. Green
@ -46,7 +46,7 @@
#include <dev/ebus/ebusvar.h>
struct ebus_softc {
struct device sc_dev;
device_t sc_dev;
int sc_node;

View File

@ -1,4 +1,4 @@
/* $NetBSD: psycho.c,v 1.106 2011/05/17 17:34:53 dyoung Exp $ */
/* $NetBSD: psycho.c,v 1.107 2011/06/02 00:24:23 christos Exp $ */
/*
* Copyright (c) 1999, 2000 Matthew R. Green
@ -55,7 +55,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: psycho.c,v 1.106 2011/05/17 17:34:53 dyoung Exp $");
__KERNEL_RCSID(0, "$NetBSD: psycho.c,v 1.107 2011/06/02 00:24:23 christos Exp $");
#include "opt_ddb.h"
@ -161,11 +161,11 @@ static void psycho_power_button_pressed(void *arg);
/*
* autoconfiguration
*/
static int psycho_match(struct device *, struct cfdata *, void *);
static void psycho_attach(struct device *, struct device *, void *);
static int psycho_match(device_t, cfdata_t, void *);
static void psycho_attach(device_t, device_t, void *);
static int psycho_print(void *aux, const char *p);
CFATTACH_DECL(psycho, sizeof(struct psycho_softc),
CFATTACH_DECL_NEW(psycho, sizeof(struct psycho_softc),
psycho_match, psycho_attach, NULL, NULL);
/*
@ -221,7 +221,7 @@ struct psycho_names {
};
static int
psycho_match(struct device *parent, struct cfdata *match, void *aux)
psycho_match(device_t parent, cfdata_t match, void *aux)
{
struct mainbus_attach_args *ma = aux;
char *model = prom_getpropstring(ma->ma_node, "model");
@ -285,9 +285,9 @@ psycho_dump_intmap(struct psycho_softc *sc)
* just copy it's tags and addresses.
*/
static void
psycho_attach(struct device *parent, struct device *self, void *aux)
psycho_attach(device_t parent, device_t self, void *aux)
{
struct psycho_softc *sc = (struct psycho_softc *)self;
struct psycho_softc *sc = device_private(self);
struct psycho_softc *osc = NULL;
struct psycho_pbm *pp;
struct pcibus_attach_args pba;
@ -303,6 +303,7 @@ psycho_attach(struct device *parent, struct device *self, void *aux)
aprint_normal("\n");
sc->sc_dev = self;
sc->sc_node = ma->ma_node;
sc->sc_bustag = ma->ma_bustag;
sc->sc_dmatag = ma->ma_dmatag;
@ -718,14 +719,14 @@ psycho_register_power_button(struct psycho_softc *sc)
sc->sc_powerpressed = 0;
sc->sc_smcontext = malloc(sizeof(struct sysmon_pswitch), M_DEVBUF, 0);
if (!sc->sc_smcontext) {
aprint_error_dev(&sc->sc_dev, "could not allocate power button context\n");
aprint_error_dev(sc->sc_dev, "could not allocate power button context\n");
return;
}
memset(sc->sc_smcontext, 0, sizeof(struct sysmon_pswitch));
sc->sc_smcontext->smpsw_name = device_xname(&sc->sc_dev);
sc->sc_smcontext->smpsw_name = device_xname(sc->sc_dev);
sc->sc_smcontext->smpsw_type = PSWITCH_TYPE_POWER;
if (sysmon_pswitch_register(sc->sc_smcontext) != 0)
aprint_error_dev(&sc->sc_dev, "unable to register power button with sysmon\n");
aprint_error_dev(sc->sc_dev, "unable to register power button with sysmon\n");
}
static void
@ -885,12 +886,12 @@ psycho_ue(void *arg)
* It's uncorrectable. Dump the regs and panic.
*/
snprintb(bits, sizeof(bits), PSYCHO_UE_AFSR_BITS, afsr);
aprint_error_dev(&sc->sc_dev,
aprint_error_dev(sc->sc_dev,
"uncorrectable DMA error AFAR %" PRIx64 " AFSR %s\n", afar, bits);
/* Sometimes the AFAR points to an IOTSB entry */
if (afar >= is->is_ptsb && afar < is->is_ptsb + size) {
aprint_error_dev(&sc->sc_dev,
aprint_error_dev(sc->sc_dev,
"IOVA %" PRIx64 " IOTTE %" PRIx64 "\n",
(afar - is->is_ptsb) / sizeof(is->is_tsb[0]) * PAGE_SIZE
+ is->is_dvmabase, ldxa(afar, ASI_PHYS_CACHED));
@ -912,7 +913,7 @@ psycho_ce(void *arg)
/*
* It's correctable. Dump the regs and continue.
*/
aprint_error_dev(&sc->sc_dev,
aprint_error_dev(sc->sc_dev,
"correctable DMA error AFAR %" PRIx64 " AFSR %" PRIx64 "\n",
regs->psy_ce_afar, regs->psy_ce_afsr);
return (1);
@ -929,7 +930,7 @@ psycho_bus_a(void *arg)
*/
panic("%s: PCI bus A error AFAR %" PRIx64 " AFSR %" PRIx64,
device_xname(&sc->sc_dev),
device_xname(sc->sc_dev),
regs->psy_pcictl[0].pci_afar, regs->psy_pcictl[0].pci_afsr);
return (1);
}
@ -945,7 +946,7 @@ psycho_bus_b(void *arg)
*/
panic("%s: PCI bus B error AFAR %" PRIx64 " AFSR %" PRIx64,
device_xname(&sc->sc_dev),
device_xname(sc->sc_dev),
regs->psy_pcictl[0].pci_afar, regs->psy_pcictl[0].pci_afsr);
return (1);
}
@ -975,7 +976,7 @@ int psycho_wakeup(void *arg)
* Gee, we don't really have a framework to deal with this
* properly.
*/
aprint_error_dev(&sc->sc_dev, "power management wakeup\n");
aprint_error_dev(sc->sc_dev, "power management wakeup\n");
return (1);
}
@ -1027,7 +1028,7 @@ psycho_iommu_init(struct psycho_softc *sc, int tsbsize)
name = (char *)malloc(32, M_DEVBUF, M_NOWAIT);
if (name == 0)
panic("couldn't malloc iommu name");
snprintf(name, 32, "%s dvma", device_xname(&sc->sc_dev));
snprintf(name, 32, "%s dvma", device_xname(sc->sc_dev));
iommu_init(name, is, tsbsize, iobase);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: psychovar.h,v 1.17 2008/12/09 13:14:38 nakayama Exp $ */
/* $NetBSD: psychovar.h,v 1.18 2011/06/02 00:24:23 christos Exp $ */
/*
* Copyright (c) 1999, 2000 Matthew R. Green
@ -83,7 +83,7 @@ struct psycho_pbm {
* per pair of psycho's.
*/
struct psycho_softc {
struct device sc_dev;
device_t sc_dev;
/*
* one sabre has two simba's. psycho's are separately attached,

View File

@ -1,4 +1,4 @@
/* $NetBSD: sab.c,v 1.47 2011/05/24 01:17:36 mrg Exp $ */
/* $NetBSD: sab.c,v 1.48 2011/06/02 00:24:23 christos Exp $ */
/* $OpenBSD: sab.c,v 1.7 2002/04/08 17:49:42 jason Exp $ */
/*
@ -42,7 +42,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: sab.c,v 1.47 2011/05/24 01:17:36 mrg Exp $");
__KERNEL_RCSID(0, "$NetBSD: sab.c,v 1.48 2011/06/02 00:24:23 christos Exp $");
#include "opt_kgdb.h"
#include <sys/types.h>
@ -77,7 +77,7 @@ __KERNEL_RCSID(0, "$NetBSD: sab.c,v 1.47 2011/05/24 01:17:36 mrg Exp $");
#define SABTTY_RBUF_SIZE 1024 /* must be divisible by 2 */
struct sab_softc {
struct device sc_dv;
device_t sc_dev;
struct intrhand * sc_ih;
bus_space_tag_t sc_bt;
bus_space_handle_t sc_bh;
@ -92,7 +92,7 @@ struct sabtty_attach_args {
};
struct sabtty_softc {
struct device sc_dv;
device_t sc_dev;
struct sab_softc * sc_parent;
bus_space_tag_t sc_bt;
bus_space_handle_t sc_bh;
@ -128,8 +128,8 @@ struct sabtty_softc *sabtty_cons_output;
#define SAB_WRITE_BLOCK(sc,r,p,c) \
bus_space_write_region_1((sc)->sc_bt, (sc)->sc_bh, (r), (p), (c))
int sab_match(struct device *, struct cfdata *, void *);
void sab_attach(struct device *, struct device *, void *);
int sab_match(device_t, cfdata_t, void *);
void sab_attach(device_t, device_t, void *);
int sab_print(void *, const char *);
int sab_intr(void *);
@ -138,8 +138,8 @@ void sab_cnputc(dev_t, int);
int sab_cngetc(dev_t);
void sab_cnpollc(dev_t, int);
int sabtty_match(struct device *, struct cfdata *, void *);
void sabtty_attach(struct device *, struct device *, void *);
int sabtty_match(device_t, cfdata_t, void *);
void sabtty_attach(device_t, device_t, void *);
void sabtty_start(struct tty *);
int sabtty_param(struct tty *, struct termios *);
int sabtty_intr(struct sabtty_softc *, int *);
@ -163,12 +163,12 @@ void sab_kgdb_init(struct sabtty_softc *);
void sabtty_cnputc(struct sabtty_softc *, int);
int sabtty_cngetc(struct sabtty_softc *);
CFATTACH_DECL(sab, sizeof(struct sab_softc),
CFATTACH_DECL_NEW(sab, sizeof(struct sab_softc),
sab_match, sab_attach, NULL, NULL);
extern struct cfdriver sab_cd;
CFATTACH_DECL(sabtty, sizeof(struct sabtty_softc),
CFATTACH_DECL_NEW(sabtty, sizeof(struct sabtty_softc),
sabtty_match, sabtty_attach, NULL, NULL);
extern struct cfdriver sabtty_cd;
@ -222,7 +222,7 @@ struct sabtty_rate sabtty_baudtable[] = {
};
int
sab_match(struct device *parent, struct cfdata *match, void *aux)
sab_match(device_t parent, cfdata_t match, void *aux)
{
struct ebus_attach_args *ea = aux;
char *compat;
@ -239,14 +239,15 @@ sab_match(struct device *parent, struct cfdata *match, void *aux)
}
void
sab_attach(struct device *parent, struct device *self, void *aux)
sab_attach(device_t parent, device_t self, void *aux)
{
struct sab_softc *sc = (struct sab_softc *)self;
struct sab_softc *sc = device_private(self);
struct ebus_attach_args *ea = aux;
uint8_t r;
u_int i;
int locs[SABCF_NLOCS];
sc->sc_dev = self;
sc->sc_bt = ea->ea_bustag;
sc->sc_node = ea->ea_node;
@ -309,9 +310,8 @@ sab_attach(struct device *parent, struct device *self, void *aux)
locs[SABCF_CHANNEL] = i;
sc->sc_child[i] =
(struct sabtty_softc *)config_found_sm_loc(self,
"sab", locs, &stax, sab_print, config_stdsubmatch);
sc->sc_child[i] = device_private(config_found_sm_loc(self,
"sab", locs, &stax, sab_print, config_stdsubmatch));
if (sc->sc_child[i] != NULL)
sc->sc_nchild++;
}
@ -365,21 +365,22 @@ sab_softintr(void *vsc)
}
int
sabtty_match(struct device *parent, struct cfdata *match, void *aux)
sabtty_match(device_t parent, cfdata_t match, void *aux)
{
return (1);
}
void
sabtty_attach(struct device *parent, struct device *self, void *aux)
sabtty_attach(device_t parent, device_t self, void *aux)
{
struct sabtty_softc *sc = (struct sabtty_softc *)self;
struct sabtty_softc *sc = device_private(self);
struct sabtty_attach_args *sa = aux;
int r;
int maj;
int is_kgdb = 0;
sc->sc_dev = self;
#ifdef KGDB
is_kgdb = sab_kgdb_check(sc);
#endif
@ -395,7 +396,7 @@ sabtty_attach(struct device *parent, struct device *self, void *aux)
sc->sc_tty->t_param = sabtty_param;
}
sc->sc_parent = (struct sab_softc *)parent;
sc->sc_parent = device_private(parent);
sc->sc_bt = sc->sc_parent->sc_bt;
sc->sc_portno = sa->sbt_portno;
sc->sc_rend = sc->sc_rbuf + SABTTY_RBUF_SIZE;
@ -647,7 +648,7 @@ sabtty_softintr(struct sabtty_softc *sc)
if (flags & SABTTYF_RINGOVERFLOW)
log(LOG_WARNING, "%s: ring overflow\n",
device_xname(&sc->sc_dv));
device_xname(sc->sc_dev));
if (flags & SABTTYF_DONE) {
ndflush(&tp->t_outq, sc->sc_txp - tp->t_outq.c_cf);
@ -1349,7 +1350,7 @@ sab_kgdb_putc(void *arg, int c)
int
sab_kgdb_check(struct sabtty_softc *sc)
{
return strcmp(device_xname(&sc->sc_dv), KGDB_DEVNAME) == 0;
return strcmp(device_xname(sc->sc_dev), KGDB_DEVNAME) == 0;
}
void