Split device_t and softc for npx(4).
This commit is contained in:
parent
50698ab6af
commit
0e763ef11c
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: npx_acpi.c,v 1.16 2006/11/16 01:32:38 christos Exp $ */
|
||||
/* $NetBSD: npx_acpi.c,v 1.17 2008/03/04 14:53:38 cube Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2002 Jared D. McNeill <jmcneill@invisible.ca>
|
||||
|
@ -26,7 +26,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: npx_acpi.c,v 1.16 2006/11/16 01:32:38 christos Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: npx_acpi.c,v 1.17 2008/03/04 14:53:38 cube Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
|
@ -46,10 +46,10 @@ __KERNEL_RCSID(0, "$NetBSD: npx_acpi.c,v 1.16 2006/11/16 01:32:38 christos Exp $
|
|||
|
||||
#include <i386/isa/npxvar.h>
|
||||
|
||||
static int npx_acpi_match(struct device *, struct cfdata *, void *);
|
||||
static void npx_acpi_attach(struct device *, struct device *, void *);
|
||||
static int npx_acpi_match(device_t, cfdata_t, void *);
|
||||
static void npx_acpi_attach(device_t, device_t, void *);
|
||||
|
||||
CFATTACH_DECL(npx_acpi, sizeof(struct npx_softc), npx_acpi_match,
|
||||
CFATTACH_DECL_NEW(npx_acpi, sizeof(struct npx_softc), npx_acpi_match,
|
||||
npx_acpi_attach, NULL, NULL);
|
||||
|
||||
/*
|
||||
|
@ -65,8 +65,7 @@ static const char * const npx_acpi_ids[] = {
|
|||
* npx_acpi_match: autoconf(9) match routine
|
||||
*/
|
||||
static int
|
||||
npx_acpi_match(struct device *parent, struct cfdata *match,
|
||||
void *aux)
|
||||
npx_acpi_match(device_t parent, cfdata_t match, void *aux)
|
||||
{
|
||||
struct acpi_attach_args *aa = aux;
|
||||
|
||||
|
@ -80,9 +79,9 @@ npx_acpi_match(struct device *parent, struct cfdata *match,
|
|||
* npx_acpi_attach: autoconf(9) attach routine
|
||||
*/
|
||||
static void
|
||||
npx_acpi_attach(struct device *parent, struct device *self, void *aux)
|
||||
npx_acpi_attach(device_t parent, device_t self, void *aux)
|
||||
{
|
||||
struct npx_softc *sc = (struct npx_softc *)self;
|
||||
struct npx_softc *sc = device_private(self);
|
||||
struct acpi_attach_args *aa = aux;
|
||||
struct acpi_resources res;
|
||||
struct acpi_io *io;
|
||||
|
@ -92,8 +91,10 @@ npx_acpi_attach(struct device *parent, struct device *self, void *aux)
|
|||
aprint_naive("\n");
|
||||
aprint_normal("\n");
|
||||
|
||||
sc->sc_dev = self;
|
||||
|
||||
/* parse resources */
|
||||
rv = acpi_resource_parse(&sc->sc_dev, aa->aa_node->ad_handle, "_CRS",
|
||||
rv = acpi_resource_parse(sc->sc_dev, aa->aa_node->ad_handle, "_CRS",
|
||||
&res, &acpi_resource_parse_ops_default);
|
||||
if (ACPI_FAILURE(rv))
|
||||
return;
|
||||
|
@ -101,23 +102,22 @@ npx_acpi_attach(struct device *parent, struct device *self, void *aux)
|
|||
/* find our i/o registers */
|
||||
io = acpi_res_io(&res, 0);
|
||||
if (io == NULL) {
|
||||
aprint_error("%s: unable to find i/o register resource\n",
|
||||
sc->sc_dev.dv_xname);
|
||||
aprint_error_dev(self,
|
||||
"unable to find i/o register resource\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* find our IRQ */
|
||||
irq = acpi_res_irq(&res, 0);
|
||||
if (irq == NULL) {
|
||||
aprint_error("%s: unable to find irq resource\n",
|
||||
sc->sc_dev.dv_xname);
|
||||
aprint_error_dev(self, "unable to find irq resource\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
sc->sc_iot = aa->aa_iot;
|
||||
if (bus_space_map(sc->sc_iot, io->ar_base, io->ar_length,
|
||||
0, &sc->sc_ioh)) {
|
||||
aprint_error("%s: can't map i/o space\n", sc->sc_dev.dv_xname);
|
||||
aprint_error_dev(self, "can't map i/o space\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
@ -133,14 +133,12 @@ npx_acpi_attach(struct device *parent, struct device *self, void *aux)
|
|||
case NPX_EXCEPTION:
|
||||
/*FALLTHROUGH*/
|
||||
case NPX_CPUID:
|
||||
aprint_verbose("%s:%s using exception 16\n",
|
||||
sc->sc_dev.dv_xname,
|
||||
sc->sc_type == NPX_CPUID ? " reported by CPUID;" : "");
|
||||
aprint_verbose_dev(self, "%susing exception 16\n",
|
||||
sc->sc_type == NPX_CPUID ? "reported by CPUID; " : "");
|
||||
sc->sc_type = NPX_EXCEPTION;
|
||||
break;
|
||||
case NPX_BROKEN:
|
||||
aprint_error("%s: error reporting broken; not using\n",
|
||||
sc->sc_dev.dv_xname);
|
||||
aprint_error_dev(self, "error reporting broken; not using\n");
|
||||
sc->sc_type = NPX_NONE;
|
||||
goto out;
|
||||
case NPX_NONE:
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: npx.c,v 1.126 2008/02/08 18:10:40 christos Exp $ */
|
||||
/* $NetBSD: npx.c,v 1.127 2008/03/04 14:53:38 cube Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1991 The Regents of the University of California.
|
||||
|
@ -67,7 +67,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: npx.c,v 1.126 2008/02/08 18:10:40 christos Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: npx.c,v 1.127 2008/03/04 14:53:38 cube Exp $");
|
||||
|
||||
#if 0
|
||||
#define IPRINTF(x) printf x
|
||||
|
@ -287,8 +287,8 @@ void npxinit(struct cpu_info *ci)
|
|||
fninit();
|
||||
if (npx586bug1(4195835, 3145727) != 0) {
|
||||
i386_fpu_fdivbug = 1;
|
||||
aprint_normal("%s: WARNING: Pentium FDIV bug detected!\n",
|
||||
ci->ci_dev->dv_xname);
|
||||
aprint_normal_dev(ci->ci_dev,
|
||||
"WARNING: Pentium FDIV bug detected!\n");
|
||||
}
|
||||
lcr0(rcr0() | (CR0_TS));
|
||||
}
|
||||
|
@ -314,8 +314,8 @@ npxattach(struct npx_softc *sc)
|
|||
else
|
||||
npxdna_func = npxdna_s87;
|
||||
|
||||
if (!pmf_device_register(&sc->sc_dev, NULL, NULL))
|
||||
aprint_error_dev(&sc->sc_dev, "couldn't establish power handler\n");
|
||||
if (!pmf_device_register(sc->sc_dev, NULL, NULL))
|
||||
aprint_error_dev(sc->sc_dev, "couldn't establish power handler\n");
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -358,7 +358,7 @@ npxintr(void *arg, struct intrframe *frame)
|
|||
sc = npx_softc;
|
||||
|
||||
uvmexp.traps++;
|
||||
IPRINTF(("%s: fp intr\n", ci->ci_dev->dv_xname));
|
||||
IPRINTF(("%s: fp intr\n", device_xname(ci->ci_dev)));
|
||||
|
||||
#ifndef XEN
|
||||
/*
|
||||
|
@ -622,7 +622,7 @@ npxdna_s87(struct cpu_info *ci)
|
|||
s = splhigh(); /* lock out IPI's while we clean house.. */
|
||||
l = ci->ci_curlwp;
|
||||
|
||||
IPRINTF(("%s: dna for lwp %p\n", ci->ci_dev->dv_xname, l));
|
||||
IPRINTF(("%s: dna for lwp %p\n", device_xname(ci->ci_dev), l));
|
||||
/*
|
||||
* If someone else was using our FPU, save their state (which does an
|
||||
* implicit initialization); otherwise, initialize the FPU state to
|
||||
|
@ -632,14 +632,14 @@ npxdna_s87(struct cpu_info *ci)
|
|||
npxsave_cpu(true);
|
||||
else {
|
||||
clts();
|
||||
IPRINTF(("%s: fp init\n", ci->ci_dev->dv_xname));
|
||||
IPRINTF(("%s: fp init\n", device_xname(ci->ci_dev)));
|
||||
fninit();
|
||||
fwait();
|
||||
stts();
|
||||
}
|
||||
splx(s);
|
||||
|
||||
IPRINTF(("%s: done saving\n", ci->ci_dev->dv_xname));
|
||||
IPRINTF(("%s: done saving\n", device_xname(ci->ci_dev)));
|
||||
KDASSERT(ci->ci_fpcurlwp == NULL);
|
||||
if (l->l_addr->u_pcb.pcb_fpcpu != NULL)
|
||||
npxsave_lwp(l, true);
|
||||
|
@ -688,7 +688,7 @@ npxsave_cpu(bool save)
|
|||
if (l == NULL)
|
||||
return;
|
||||
|
||||
IPRINTF(("%s: fp CPU %s lwp %p\n", ci->ci_dev->dv_xname,
|
||||
IPRINTF(("%s: fp CPU %s lwp %p\n", device_xname(ci->ci_dev),
|
||||
save? "save" : "flush", l));
|
||||
|
||||
if (save) {
|
||||
|
@ -756,7 +756,7 @@ npxsave_lwp(struct lwp *l, bool save)
|
|||
return;
|
||||
}
|
||||
|
||||
IPRINTF(("%s: fp %s lwp %p\n", ci->ci_dev->dv_xname,
|
||||
IPRINTF(("%s: fp %s lwp %p\n", device_xname(ci->ci_dev),
|
||||
save? "save" : "flush", l));
|
||||
|
||||
#if defined(MULTIPROCESSOR)
|
||||
|
@ -770,8 +770,8 @@ npxsave_lwp(struct lwp *l, bool save)
|
|||
#endif
|
||||
|
||||
IPRINTF(("%s: fp ipi to %s %s lwp %p\n",
|
||||
ci->ci_dev->dv_xname,
|
||||
oci->ci_dev->dv_xname,
|
||||
device_xname(ci->ci_dev),
|
||||
device_xname(oci->ci_dev),
|
||||
save? "save" : "flush", l));
|
||||
|
||||
x86_send_ipi(oci,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: npx_isa.c,v 1.17 2008/01/20 21:49:57 dyoung Exp $ */
|
||||
/* $NetBSD: npx_isa.c,v 1.18 2008/03/04 14:53:38 cube Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1991 The Regents of the University of California.
|
||||
|
@ -67,7 +67,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: npx_isa.c,v 1.17 2008/01/20 21:49:57 dyoung Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: npx_isa.c,v 1.18 2008/03/04 14:53:38 cube Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
|
@ -86,7 +86,7 @@ __KERNEL_RCSID(0, "$NetBSD: npx_isa.c,v 1.17 2008/01/20 21:49:57 dyoung Exp $");
|
|||
int npx_isa_probe(device_t, struct cfdata *, void *);
|
||||
void npx_isa_attach(device_t, device_t, void *);
|
||||
|
||||
CFATTACH_DECL(npx_isa, sizeof(struct npx_softc),
|
||||
CFATTACH_DECL_NEW(npx_isa, sizeof(struct npx_softc),
|
||||
npx_isa_probe, npx_isa_attach, npxdetach, NULL);
|
||||
|
||||
int
|
||||
|
@ -144,6 +144,7 @@ npx_isa_attach(device_t parent, device_t self, void *aux)
|
|||
aprint_naive("\n");
|
||||
aprint_normal("\n");
|
||||
|
||||
sc->sc_dev = self;
|
||||
sc->sc_type = (u_long) ia->ia_aux;
|
||||
|
||||
switch (sc->sc_type) {
|
||||
|
@ -158,12 +159,12 @@ npx_isa_attach(device_t parent, device_t self, void *aux)
|
|||
case NPX_EXCEPTION:
|
||||
/*FALLTHROUGH*/
|
||||
case NPX_CPUID:
|
||||
aprint_verbose_dev(&sc->sc_dev, "%s using exception 16\n",
|
||||
aprint_verbose_dev(sc->sc_dev, "%s using exception 16\n",
|
||||
sc->sc_type == NPX_CPUID ? " reported by CPUID;" : "");
|
||||
sc->sc_type = NPX_EXCEPTION;
|
||||
break;
|
||||
case NPX_BROKEN:
|
||||
aprint_error_dev(&sc->sc_dev,
|
||||
aprint_error_dev(sc->sc_dev,
|
||||
"error reporting broken; not using\n");
|
||||
sc->sc_type = NPX_NONE;
|
||||
return;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: npxvar.h,v 1.7 2008/01/20 21:49:57 dyoung Exp $ */
|
||||
/* $NetBSD: npxvar.h,v 1.8 2008/03/04 14:53:38 cube Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1991 The Regents of the University of California.
|
||||
|
@ -75,7 +75,7 @@ enum npx_type {
|
|||
};
|
||||
|
||||
struct npx_softc {
|
||||
struct device sc_dev;
|
||||
device_t sc_dev;
|
||||
|
||||
bus_space_tag_t sc_iot;
|
||||
bus_space_handle_t sc_ioh;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: npx_pnpbios.c,v 1.10 2006/11/16 01:32:39 christos Exp $ */
|
||||
/* $NetBSD: npx_pnpbios.c,v 1.11 2008/03/04 14:53:38 cube Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2000 The NetBSD Foundation, Inc.
|
||||
|
@ -37,7 +37,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: npx_pnpbios.c,v 1.10 2006/11/16 01:32:39 christos Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: npx_pnpbios.c,v 1.11 2008/03/04 14:53:38 cube Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
|
@ -55,15 +55,14 @@ __KERNEL_RCSID(0, "$NetBSD: npx_pnpbios.c,v 1.10 2006/11/16 01:32:39 christos Ex
|
|||
|
||||
#include <i386/isa/npxvar.h>
|
||||
|
||||
int npx_pnpbios_match(struct device *, struct cfdata *, void *);
|
||||
void npx_pnpbios_attach(struct device *, struct device *, void *);
|
||||
int npx_pnpbios_match(device_t, cfdata_t, void *);
|
||||
void npx_pnpbios_attach(device_t, device_t, void *);
|
||||
|
||||
CFATTACH_DECL(npx_pnpbios, sizeof(struct npx_softc),
|
||||
CFATTACH_DECL_NEW(npx_pnpbios, sizeof(struct npx_softc),
|
||||
npx_pnpbios_match, npx_pnpbios_attach, NULL, NULL);
|
||||
|
||||
int
|
||||
npx_pnpbios_match(struct device *parent, struct cfdata *match,
|
||||
void *aux)
|
||||
npx_pnpbios_match(device_t parent, cfdata_t match, void *aux)
|
||||
{
|
||||
struct pnpbiosdev_attach_args *aa = aux;
|
||||
|
||||
|
@ -74,14 +73,15 @@ npx_pnpbios_match(struct device *parent, struct cfdata *match,
|
|||
}
|
||||
|
||||
void
|
||||
npx_pnpbios_attach(struct device *parent, struct device *self,
|
||||
void *aux)
|
||||
npx_pnpbios_attach(device_t parent, device_t self, void *aux)
|
||||
{
|
||||
struct npx_softc *sc = (void *)self;
|
||||
struct npx_softc *sc = device_private(self);
|
||||
struct pnpbiosdev_attach_args *aa = aux;
|
||||
int irq, ist;
|
||||
|
||||
if (pnpbios_io_map(aa->pbt, aa->resc, 0, &sc->sc_iot, &sc->sc_ioh)) {
|
||||
sc->sc_dev = self;
|
||||
|
||||
if (pnpbios_io_map(aa->pbt, aa->resc, 0, &sc->sc_iot, &sc->sc_ioh)) {
|
||||
aprint_error(": can't map i/o space\n");
|
||||
return;
|
||||
}
|
||||
|
@ -91,8 +91,7 @@ npx_pnpbios_attach(struct device *parent, struct device *self,
|
|||
pnpbios_print_devres(self, aa);
|
||||
|
||||
if (pnpbios_getirqnum(aa->pbt, aa->resc, 0, &irq, &ist) != 0) {
|
||||
aprint_error("%s: unable to get IRQ number or type\n",
|
||||
sc->sc_dev.dv_xname);
|
||||
aprint_error_dev(self, "unable to get IRQ number or type\n");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -100,8 +99,7 @@ npx_pnpbios_attach(struct device *parent, struct device *self,
|
|||
|
||||
switch (sc->sc_type) {
|
||||
case NPX_INTERRUPT:
|
||||
aprint_normal("%s: interrupting at irq %d\n",
|
||||
sc->sc_dev.dv_xname, irq);
|
||||
aprint_normal_dev(self, "interrupting at irq %d\n", irq);
|
||||
lcr0(rcr0() & ~CR0_NE);
|
||||
sc->sc_ih = isa_intr_establish(0/*XXX*/, irq, ist, IPL_NONE,
|
||||
(int (*)(void *))npxintr, NULL);
|
||||
|
@ -109,14 +107,12 @@ npx_pnpbios_attach(struct device *parent, struct device *self,
|
|||
case NPX_EXCEPTION:
|
||||
/*FALLTHROUGH*/
|
||||
case NPX_CPUID:
|
||||
aprint_verbose("%s:%s using exception 16\n",
|
||||
sc->sc_dev.dv_xname,
|
||||
sc->sc_type == NPX_CPUID ? " reported by CPUID;" : "");
|
||||
aprint_verbose_dev(self, "%susing exception 16\n",
|
||||
sc->sc_type == NPX_CPUID ? "reported by CPUID; " : "");
|
||||
sc->sc_type = NPX_EXCEPTION;
|
||||
break;
|
||||
case NPX_BROKEN:
|
||||
aprint_error("%s: error reporting broken; not using\n",
|
||||
sc->sc_dev.dv_xname);
|
||||
aprint_error_dev(self, "error reporting broken; not using\n");
|
||||
sc->sc_type = NPX_NONE;
|
||||
return;
|
||||
case NPX_NONE:
|
||||
|
|
Loading…
Reference in New Issue