Remove the namespace scopes.

These are neither used nor useful beyond the parser and interpreter.

ok jmcneill@, joerg@
This commit is contained in:
jruoho 2010-03-09 18:15:21 +00:00
parent 2c0a7fd6bd
commit 320e1e3fb8
4 changed files with 117 additions and 163 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: acpi.c,v 1.156 2010/03/05 21:01:44 jruoho Exp $ */
/* $NetBSD: acpi.c,v 1.157 2010/03/09 18:15:21 jruoho Exp $ */
/*-
* Copyright (c) 2003, 2007 The NetBSD Foundation, Inc.
@ -70,7 +70,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: acpi.c,v 1.156 2010/03/05 21:01:44 jruoho Exp $");
__KERNEL_RCSID(0, "$NetBSD: acpi.c,v 1.157 2010/03/09 18:15:21 jruoho Exp $");
#include "opt_acpi.h"
#include "opt_pcifixup.h"
@ -402,17 +402,15 @@ static void
acpi_childdet(device_t self, device_t child)
{
struct acpi_softc *sc = device_private(self);
struct acpi_scope *as;
struct acpi_devnode *ad;
if (sc->sc_apmbus == child)
sc->sc_apmbus = NULL;
TAILQ_FOREACH(as, &sc->sc_scopes, as_list) {
TAILQ_FOREACH(ad, &as->as_devnodes, ad_list) {
if (ad->ad_device == child)
ad->ad_device = NULL;
}
SIMPLEQ_FOREACH(ad, &sc->sc_devnodes, ad_list) {
if (ad->ad_device == child)
ad->ad_device = NULL;
}
}
@ -450,6 +448,7 @@ acpi_attach(device_t parent, device_t self, void *aux)
rsdt->AslCompilerId, rsdt->AslCompilerRevision);
} else
aprint_error_dev(self, "X/RSDT: Not found\n");
acpi_unmap_rsdt(rsdt);
sc->sc_dev = self;
@ -461,6 +460,8 @@ acpi_attach(device_t parent, device_t self, void *aux)
sc->sc_pciflags = aa->aa_pciflags;
sc->sc_ic = aa->aa_ic;
SIMPLEQ_INIT(&sc->sc_devnodes);
acpi_softc = sc;
/*
@ -661,11 +662,6 @@ acpi_disable(struct acpi_softc *sc)
}
#endif
struct acpi_make_devnode_state {
struct acpi_softc *softc;
struct acpi_scope *scope;
};
/*
* acpi_build_tree:
*
@ -676,46 +672,27 @@ static void
acpi_build_tree(struct acpi_softc *sc)
{
static const char *scopes[] = {
"\\_PR_", /* ACPI 1.0 processor namespace */
"\\_SB_", /* system bus namespace */
"\\_SI_", /* system indicator namespace */
"\\_TZ_", /* ACPI 1.0 thermal zone namespace */
NULL,
"\\_PR_", "\\_SB_", "\\_SI_", "\\_TZ_", NULL
};
struct acpi_make_devnode_state state;
struct acpi_scope *as;
ACPI_HANDLE parent;
ACPI_STATUS rv;
int i;
TAILQ_INIT(&sc->sc_scopes);
state.softc = sc;
/*
* Scan the namespace and build our tree.
* Scan the namespace and build our device tree.
*/
for (i = 0; scopes[i] != NULL; i++) {
as = malloc(sizeof(*as), M_ACPI, M_WAITOK);
as->as_name = scopes[i];
TAILQ_INIT(&as->as_devnodes);
TAILQ_INSERT_TAIL(&sc->sc_scopes, as, as_list);
rv = AcpiGetHandle(ACPI_ROOT_OBJECT, scopes[i], &parent);
state.scope = as;
rv = AcpiGetHandle(ACPI_ROOT_OBJECT, scopes[i],
&parent);
if (ACPI_SUCCESS(rv)) {
AcpiWalkNamespace(ACPI_TYPE_ANY, parent, 100,
acpi_make_devnode, &state, NULL);
}
if (ACPI_SUCCESS(rv))
(void)AcpiWalkNamespace(ACPI_TYPE_ANY, parent, 100,
acpi_make_devnode, sc, NULL);
}
acpi_rescan1(sc, NULL, NULL);
acpi_wakedev_scan(sc);
acpi_pcidev_scan(sc);
}
@ -743,73 +720,68 @@ acpi_rescan1(struct acpi_softc *sc, const char *ifattr, const int *locators)
static void
acpi_rescan_nodes(struct acpi_softc *sc)
{
struct acpi_scope *as;
struct acpi_attach_args aa;
struct acpi_devnode *ad;
TAILQ_FOREACH(as, &sc->sc_scopes, as_list) {
struct acpi_devnode *ad;
SIMPLEQ_FOREACH(ad, &sc->sc_devnodes, ad_list) {
/* Now, for this namespace, try to attach the devices. */
TAILQ_FOREACH(ad, &as->as_devnodes, ad_list) {
struct acpi_attach_args aa;
if (ad->ad_device != NULL)
continue;
if (ad->ad_device != NULL)
continue;
aa.aa_node = ad;
aa.aa_iot = sc->sc_iot;
aa.aa_memt = sc->sc_memt;
aa.aa_pc = sc->sc_pc;
aa.aa_pciflags = sc->sc_pciflags;
aa.aa_ic = sc->sc_ic;
if (ad->ad_devinfo->Type == ACPI_TYPE_DEVICE) {
/*
* XXX We only attach devices which are:
*
* - present
* - enabled
* - functioning properly
*
* However, if enabled, it's decoding resources,
* so we should claim them, if possible.
* Requires changes to bus_space(9).
*/
if ((ad->ad_devinfo->Valid & ACPI_VALID_STA) ==
ACPI_VALID_STA &&
(ad->ad_devinfo->CurrentStatus &
(ACPI_STA_DEV_PRESENT|ACPI_STA_DEV_ENABLED|
ACPI_STA_DEV_OK)) !=
(ACPI_STA_DEV_PRESENT|ACPI_STA_DEV_ENABLED|
ACPI_STA_DEV_OK))
continue;
}
aa.aa_node = ad;
aa.aa_iot = sc->sc_iot;
aa.aa_memt = sc->sc_memt;
aa.aa_pc = sc->sc_pc;
aa.aa_pciflags = sc->sc_pciflags;
aa.aa_ic = sc->sc_ic;
if (ad->ad_devinfo->Type == ACPI_TYPE_DEVICE) {
/*
* XXX Same problem as above...
* XXX We only attach devices which are:
*
* Do this check only for devices, as e.g.
* a Thermal Zone doesn't have a HID.
* - present
* - enabled
* - functioning properly
*
* However, if enabled, it's decoding resources,
* so we should claim them, if possible.
* Requires changes to bus_space(9).
*/
if (ad->ad_devinfo->Type == ACPI_TYPE_DEVICE &&
(ad->ad_devinfo->Valid & ACPI_VALID_HID) == 0)
if ((ad->ad_devinfo->Valid & ACPI_VALID_STA) ==
ACPI_VALID_STA &&
(ad->ad_devinfo->CurrentStatus &
(ACPI_STA_DEV_PRESENT|ACPI_STA_DEV_ENABLED|
ACPI_STA_DEV_OK)) !=
(ACPI_STA_DEV_PRESENT|ACPI_STA_DEV_ENABLED|
ACPI_STA_DEV_OK))
continue;
/*
* Handled internally
*/
if (ad->ad_devinfo->Type == ACPI_TYPE_PROCESSOR ||
ad->ad_devinfo->Type == ACPI_TYPE_POWER)
continue;
/*
* Skip ignored HIDs
*/
if (acpi_match_hid(ad->ad_devinfo, acpi_ignored_ids))
continue;
ad->ad_device = config_found_ia(sc->sc_dev,
"acpinodebus", &aa, acpi_print);
}
/*
* XXX Same problem as above...
*
* Do this check only for devices, as e.g.
* a Thermal Zone doesn't have a HID.
*/
if (ad->ad_devinfo->Type == ACPI_TYPE_DEVICE &&
(ad->ad_devinfo->Valid & ACPI_VALID_HID) == 0)
continue;
/*
* Handled internally.
*/
if (ad->ad_devinfo->Type == ACPI_TYPE_PROCESSOR ||
ad->ad_devinfo->Type == ACPI_TYPE_POWER)
continue;
/*
* Skip ignored HIDs.
*/
if (acpi_match_hid(ad->ad_devinfo, acpi_ignored_ids))
continue;
ad->ad_device = config_found_ia(sc->sc_dev,
"acpinodebus", &aa, acpi_print);
}
}
@ -854,9 +826,7 @@ static ACPI_STATUS
acpi_make_devnode(ACPI_HANDLE handle, uint32_t level,
void *context, void **status)
{
struct acpi_make_devnode_state *state = context;
struct acpi_softc *sc = state->softc;
struct acpi_scope *as = state->scope;
struct acpi_softc *sc = context;
struct acpi_devnode *ad;
ACPI_DEVICE_INFO *devinfo;
ACPI_OBJECT_TYPE type;
@ -901,10 +871,9 @@ acpi_make_devnode(ACPI_HANDLE handle, uint32_t level,
if (ad == NULL)
return AE_NO_MEMORY;
ad->ad_parent = sc->sc_dev;
ad->ad_devinfo = devinfo;
ad->ad_handle = handle;
ad->ad_level = level;
ad->ad_scope = as;
ad->ad_type = type;
anu = (ACPI_NAME_UNION *)&devinfo->Name;
@ -923,7 +892,7 @@ acpi_make_devnode(ACPI_HANDLE handle, uint32_t level,
if (ad->ad_name[0] == '\0')
ad->ad_name[0] = '_';
TAILQ_INSERT_TAIL(&as->as_devnodes, ad, ad_list);
SIMPLEQ_INSERT_TAIL(&sc->sc_devnodes, ad, ad_list);
if (type != ACPI_TYPE_DEVICE)
return AE_OK;
@ -932,10 +901,8 @@ acpi_make_devnode(ACPI_HANDLE handle, uint32_t level,
return AE_OK;
#ifdef ACPIVERBOSE
aprint_normal_dev(sc->sc_dev,
"HID %s found in scope %s level %d\n",
ad->ad_devinfo->HardwareId.String,
as->as_name, ad->ad_level);
aprint_normal(" HID %s\n",
ad->ad_devinfo->HardwareId.String);
if (ad->ad_devinfo->Valid & ACPI_VALID_UID)
aprint_normal(" UID %s\n",

View File

@ -1,4 +1,4 @@
/* $NetBSD: acpi_pci.c,v 1.3 2010/03/05 14:00:17 jruoho Exp $ */
/* $NetBSD: acpi_pci.c,v 1.4 2010/03/09 18:15:22 jruoho Exp $ */
/*
* Copyright (c) 2009 The NetBSD Foundation, Inc.
@ -33,7 +33,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: acpi_pci.c,v 1.3 2010/03/05 14:00:17 jruoho Exp $");
__KERNEL_RCSID(0, "$NetBSD: acpi_pci.c,v 1.4 2010/03/09 18:15:22 jruoho Exp $");
#include <sys/param.h>
#include <sys/device.h>
@ -139,7 +139,6 @@ acpi_pcidev_print(struct acpi_pcidev *ap)
int
acpi_pcidev_scan(struct acpi_softc *sc)
{
struct acpi_scope *as;
struct acpi_devnode *ad;
struct acpi_pcidev *ap;
ACPI_DEVICE_INFO *di;
@ -148,18 +147,20 @@ acpi_pcidev_scan(struct acpi_softc *sc)
#define ACPI_STA_DEV_VALID \
(ACPI_STA_DEV_PRESENT|ACPI_STA_DEV_ENABLED|ACPI_STA_DEV_OK)
TAILQ_FOREACH(as, &sc->sc_scopes, as_list) {
TAILQ_FOREACH(ad, &as->as_devnodes, ad_list) {
di = ad->ad_devinfo;
if (di->Type != ACPI_TYPE_DEVICE)
continue;
if ((di->Valid & ACPI_VALID_STA) != 0 &&
(di->CurrentStatus & ACPI_STA_DEV_VALID) !=
ACPI_STA_DEV_VALID)
continue;
if (acpi_pcidev_add(sc, ad) == true)
++count;
}
SIMPLEQ_FOREACH(ad, &sc->sc_devnodes, ad_list) {
di = ad->ad_devinfo;
if (di->Type != ACPI_TYPE_DEVICE)
continue;
if ((di->Valid & ACPI_VALID_STA) != 0 &&
(di->CurrentStatus & ACPI_STA_DEV_VALID) !=
ACPI_STA_DEV_VALID)
continue;
if (acpi_pcidev_add(sc, ad) == true)
++count;
}
#undef ACPI_STA_DEV_VALID

View File

@ -1,4 +1,4 @@
/* $NetBSD: acpi_wakedev.c,v 1.5 2010/03/05 22:00:11 jruoho Exp $ */
/* $NetBSD: acpi_wakedev.c,v 1.6 2010/03/09 18:15:22 jruoho Exp $ */
/*-
* Copyright (c) 2009 Jared D. McNeill <jmcneill@invisible.ca>
@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: acpi_wakedev.c,v 1.5 2010/03/05 22:00:11 jruoho Exp $");
__KERNEL_RCSID(0, "$NetBSD: acpi_wakedev.c,v 1.6 2010/03/09 18:15:22 jruoho Exp $");
#include <sys/param.h>
#include <sys/device.h>
@ -145,7 +145,6 @@ acpi_wakedev_print(struct acpi_wakedev *aw)
int
acpi_wakedev_scan(struct acpi_softc *sc)
{
struct acpi_scope *as;
struct acpi_devnode *ad;
struct acpi_wakedev *aw;
ACPI_DEVICE_INFO *di;
@ -154,18 +153,21 @@ acpi_wakedev_scan(struct acpi_softc *sc)
#define ACPI_STA_DEV_VALID \
(ACPI_STA_DEV_PRESENT|ACPI_STA_DEV_ENABLED|ACPI_STA_DEV_OK)
TAILQ_FOREACH(as, &sc->sc_scopes, as_list)
TAILQ_FOREACH(ad, &as->as_devnodes, ad_list) {
di = ad->ad_devinfo;
if (di->Type != ACPI_TYPE_DEVICE)
continue;
if ((di->Valid & ACPI_VALID_STA) != 0 &&
(di->CurrentStatus & ACPI_STA_DEV_VALID) !=
ACPI_STA_DEV_VALID)
continue;
if (acpi_wakedev_add(sc, ad) == true)
++count;
}
SIMPLEQ_FOREACH(ad, &sc->sc_devnodes, ad_list) {
di = ad->ad_devinfo;
if (di->Type != ACPI_TYPE_DEVICE)
continue;
if ((di->Valid & ACPI_VALID_STA) != 0 &&
(di->CurrentStatus & ACPI_STA_DEV_VALID) !=
ACPI_STA_DEV_VALID)
continue;
if (acpi_wakedev_add(sc, ad) == true)
++count;
}
#undef ACPI_STA_DEV_VALID

View File

@ -1,4 +1,4 @@
/* $NetBSD: acpivar.h,v 1.41 2010/03/05 08:30:48 jruoho Exp $ */
/* $NetBSD: acpivar.h,v 1.42 2010/03/09 18:15:22 jruoho Exp $ */
/*
* Copyright 2001 Wasabi Systems, Inc.
@ -79,28 +79,14 @@ struct acpibus_attach_args {
* An ACPI device node.
*/
struct acpi_devnode {
TAILQ_ENTRY(acpi_devnode) ad_list;
ACPI_HANDLE ad_handle; /* our ACPI handle */
uint32_t ad_level; /* ACPI level */
uint32_t ad_type; /* ACPI object type */
ACPI_DEVICE_INFO *ad_devinfo; /* our ACPI device info */
struct acpi_scope *ad_scope; /* backpointer to scope */
device_t ad_device; /* pointer to configured device */
char ad_name[5]; /* Human-readable device name */
};
device_t ad_device; /* Device */
device_t ad_parent; /* Backpointer to the parent */
ACPI_DEVICE_INFO *ad_devinfo; /* Device info */
ACPI_HANDLE ad_handle; /* Device handle */
char ad_name[5]; /* Device name */
uint32_t ad_type; /* Device type */
/*
* acpi_scope:
*
* Description of an ACPI scope.
*/
struct acpi_scope {
TAILQ_ENTRY(acpi_scope) as_list;
const char *as_name; /* scope name */
/*
* Device nodes we manage.
*/
TAILQ_HEAD(, acpi_devnode) as_devnodes;
SIMPLEQ_ENTRY(acpi_devnode) ad_list;
};
/*
@ -135,11 +121,9 @@ struct acpi_softc {
int sc_quirks;
/*
* Scopes we manage.
*/
TAILQ_HEAD(, acpi_scope) sc_scopes;
device_t sc_apmbus;
SIMPLEQ_HEAD(, acpi_devnode) sc_devnodes; /* devices */
};
/*