-/* $OpenBSD: acpi.c,v 1.413 2022/02/17 00:21:40 jsg Exp $ */
+/* $OpenBSD: acpi.c,v 1.414 2022/08/10 16:58:16 patrick Exp $ */
/*
* Copyright (c) 2005 Thorsten Lockert <tholo@sigmasoft.com>
* Copyright (c) 2005 Jordan Hargrave <jordan@openbsd.org>
struct acpi_softc *acpi_softc;
-/* XXX move this into dsdt softc at some point */
extern struct aml_node aml_root;
struct cfdriver acpi_cd = {
rw_init(&sc->sc_lck, "acpilk");
acpi_softc = sc;
+ sc->sc_root = &aml_root;
if (acpi_map(base, sizeof(struct acpi_rsdp), &handle)) {
printf(": can't map memory\n");
}
/* initialize runtime environment */
- aml_find_node(&aml_root, "_INI", acpi_inidev, sc);
+ aml_find_node(sc->sc_root, "_INI", acpi_inidev, sc);
/* Get PCI mapping */
- aml_walknodes(&aml_root, AML_WALK_PRE, acpi_getpci, sc);
+ aml_walknodes(sc->sc_root, AML_WALK_PRE, acpi_getpci, sc);
#if defined (__amd64__) || defined(__i386__)
/* attach pci interrupt routing tables */
- aml_find_node(&aml_root, "_PRT", acpi_foundprt, sc);
+ aml_find_node(sc->sc_root, "_PRT", acpi_foundprt, sc);
#endif
- aml_find_node(&aml_root, "_HID", acpi_foundec, sc);
+ aml_find_node(sc->sc_root, "_HID", acpi_foundec, sc);
/* check if we're running on a sony */
- aml_find_node(&aml_root, "GBRT", acpi_foundsony, sc);
+ aml_find_node(sc->sc_root, "GBRT", acpi_foundsony, sc);
#ifndef SMALL_KERNEL
/* try to find smart battery first */
- aml_find_node(&aml_root, "_HID", acpi_foundsbs, sc);
+ aml_find_node(sc->sc_root, "_HID", acpi_foundsbs, sc);
#endif /* SMALL_KERNEL */
/* attach battery, power supply and button devices */
- aml_find_node(&aml_root, "_HID", acpi_foundhid, sc);
+ aml_find_node(sc->sc_root, "_HID", acpi_foundhid, sc);
- aml_walknodes(&aml_root, AML_WALK_PRE, acpi_add_device, sc);
+ aml_walknodes(sc->sc_root, AML_WALK_PRE, acpi_add_device, sc);
#ifndef SMALL_KERNEL
#if NWD > 0
/* Attach IDE bay */
- aml_walknodes(&aml_root, AML_WALK_PRE, acpi_foundide, sc);
+ aml_walknodes(sc->sc_root, AML_WALK_PRE, acpi_foundide, sc);
#endif
/* attach docks */
- aml_find_node(&aml_root, "_DCK", acpi_founddock, sc);
+ aml_find_node(sc->sc_root, "_DCK", acpi_founddock, sc);
/* attach video */
- aml_find_node(&aml_root, "_DOS", acpi_foundvideo, sc);
+ aml_find_node(sc->sc_root, "_DOS", acpi_foundvideo, sc);
/* create list of devices we want to query when APM comes in */
SLIST_INIT(&sc->sc_ac);
for (idx = 0; idx < sc->sc_lastgpe; idx++) {
/* Search Level-sensitive GPES */
snprintf(name, sizeof(name), "\\_GPE._L%.2X", idx);
- gpe = aml_searchname(&aml_root, name);
+ gpe = aml_searchname(sc->sc_root, name);
if (gpe != NULL)
acpi_set_gpehandler(sc, idx, acpi_gpe, gpe, GPE_LEVEL);
if (gpe == NULL) {
/* Search Edge-sensitive GPES */
snprintf(name, sizeof(name), "\\_GPE._E%.2X", idx);
- gpe = aml_searchname(&aml_root, name);
+ gpe = aml_searchname(sc->sc_root, name);
if (gpe != NULL)
acpi_set_gpehandler(sc, idx, acpi_gpe, gpe,
GPE_EDGE);
}
}
- aml_find_node(&aml_root, "_PRW", acpi_foundprw, sc);
+ aml_find_node(sc->sc_root, "_PRW", acpi_foundprw, sc);
}
void
acpi_init_pm(struct acpi_softc *sc)
{
- sc->sc_tts = aml_searchname(&aml_root, "_TTS");
- sc->sc_pts = aml_searchname(&aml_root, "_PTS");
- sc->sc_wak = aml_searchname(&aml_root, "_WAK");
- sc->sc_bfs = aml_searchname(&aml_root, "_BFS");
- sc->sc_gts = aml_searchname(&aml_root, "_GTS");
- sc->sc_sst = aml_searchname(&aml_root, "_SI_._SST");
+ sc->sc_tts = aml_searchname(sc->sc_root, "_TTS");
+ sc->sc_pts = aml_searchname(sc->sc_root, "_PTS");
+ sc->sc_wak = aml_searchname(sc->sc_root, "_WAK");
+ sc->sc_bfs = aml_searchname(sc->sc_root, "_BFS");
+ sc->sc_gts = aml_searchname(sc->sc_root, "_GTS");
+ sc->sc_sst = aml_searchname(sc->sc_root, "_SI_._SST");
}
#ifndef SMALL_KERNEL
snprintf(name, sizeof(name), "_S%d_", i);
sc->sc_sleeptype[i].slp_typa = -1;
sc->sc_sleeptype[i].slp_typb = -1;
- if (aml_evalname(sc, &aml_root, name, 0, NULL, &res) == 0) {
+ if (aml_evalname(sc, sc->sc_root, name, 0, NULL, &res) == 0) {
if (res.type == AML_OBJTYPE_PACKAGE) {
sc->sc_sleeptype[i].slp_typa =
aml_val2int(res.v_package[0]);
-/* $OpenBSD: acpidock.c,v 1.45 2022/04/06 18:59:27 naddy Exp $ */
+/* $OpenBSD: acpidock.c,v 1.46 2022/08/10 16:58:16 patrick Exp $ */
/*
* Copyright (c) 2006,2007 Michael Knudsen <mk@openbsd.org>
*
{
struct acpidock_softc *sc = (struct acpidock_softc *)self;
struct acpi_attach_args *aa = aux;
- extern struct aml_node aml_root;
sc->sc_acpi = (struct acpi_softc *)parent;
sc->sc_devnode = aa->aaa_node;
sensordev_install(&sc->sc_sensdev);
TAILQ_INIT(&sc->sc_deps_h);
- aml_find_node(&aml_root, "_EJD", acpidock_foundejd, sc);
+ aml_find_node(sc->sc_acpi->sc_root, "_EJD", acpidock_foundejd, sc);
aml_register_notify(sc->sc_devnode, aa->aaa_dev,
acpidock_notify, sc, ACPIDEV_NOPOLL);
struct acpidock_softc *sc = (struct acpidock_softc *)arg;
struct aml_value res;
struct aml_node *dock;
- extern struct aml_node aml_root;
dnprintf(15, "%s: %s", DEVNAME(sc), node->name);
if (aml_evalnode(sc->sc_acpi, node, 0, NULL, &res) == -1)
printf(": error\n");
else {
- dock = aml_searchname(&aml_root, res.v_string);
+ dock = aml_searchname(sc->sc_acpi->sc_root, res.v_string);
if (dock == sc->sc_devnode)
/* Add all children devices of Device containing _EJD */
-/* $OpenBSD: acpipwrres.c,v 1.11 2022/04/06 18:59:27 naddy Exp $ */
+/* $OpenBSD: acpipwrres.c,v 1.12 2022/08/10 16:58:16 patrick Exp $ */
/*
* Copyright (c) 2013 Martin Pieuchot <mpi@openbsd.org>
struct aml_value res;
struct acpipwrres_consumer *cons;
- extern struct aml_node aml_root;
-
sc->sc_acpi = (struct acpi_softc *)parent;
sc->sc_devnode = aaa->aaa_node;
memset(&res, 0, sizeof res);
/* Get the list of consumers */
SIMPLEQ_INIT(&sc->sc_cons);
#if notyet
- aml_find_node(&aml_root, "_PRW", acpipwrres_foundcons, sc);
+ aml_find_node(sc->sc_acpi->sc_root, "_PRW", acpipwrres_foundcons, sc);
#endif
- aml_find_node(&aml_root, "_PR0", acpipwrres_foundcons, sc);
- aml_find_node(&aml_root, "_PR1", acpipwrres_foundcons, sc);
- aml_find_node(&aml_root, "_PR2", acpipwrres_foundcons, sc);
- aml_find_node(&aml_root, "_PR3", acpipwrres_foundcons, sc);
+ aml_find_node(sc->sc_acpi->sc_root, "_PR0", acpipwrres_foundcons, sc);
+ aml_find_node(sc->sc_acpi->sc_root, "_PR1", acpipwrres_foundcons, sc);
+ aml_find_node(sc->sc_acpi->sc_root, "_PR2", acpipwrres_foundcons, sc);
+ aml_find_node(sc->sc_acpi->sc_root, "_PR3", acpipwrres_foundcons, sc);
DPRINTF(("%s", DEVNAME(sc)));
if (!SIMPLEQ_EMPTY(&sc->sc_cons)) {
struct aml_value res, *ref;
int i = 0;
- extern struct aml_node aml_root;
-
memset(&res, 0, sizeof(res));
if (aml_evalnode(sc->sc_acpi, node, 0, NULL, &res) == -1) {
if (ref->type == AML_OBJTYPE_NAMEREF) {
struct aml_node *pnode;
- pnode = aml_searchrel(&aml_root,
+ pnode = aml_searchrel(sc->sc_acpi->sc_root,
aml_getname(ref->v_nameref));
if (pnode == NULL) {
DPRINTF(("%s: device %s not found\n",