-/* $OpenBSD: dsdt.c,v 1.166 2010/07/13 21:01:05 deraadt Exp $ */
+/* $OpenBSD: dsdt.c,v 1.167 2010/07/19 16:57:27 deraadt Exp $ */
/*
* Copyright (c) 2005 Jordan Hargrave <jordan@openbsd.org>
*
int aml_intlen = 64;
struct aml_node aml_root;
struct aml_value *aml_global_lock;
-struct acpi_softc *dsdt_softc;
/* Perfect Hash key */
#define HASH_OFF 6904
else {
if (to <= 0)
to = 1;
- while (tsleep(dsdt_softc, PWAIT, "asleep", to) !=
+ while (tsleep(acpi_softc, PWAIT, "asleep", to) !=
EWOULDBLOCK);
}
}
void
acpi_poll(void *arg)
{
- dsdt_softc->sc_poll = 1;
- dsdt_softc->sc_threadwaiting = 0;
- wakeup(dsdt_softc);
+ acpi_softc->sc_poll = 1;
+ acpi_softc->sc_threadwaiting = 0;
+ wakeup(acpi_softc);
- timeout_add_sec(&dsdt_softc->sc_dev_timeout, 10);
+ timeout_add_sec(&acpi_softc->sc_dev_timeout, 10);
}
void
SLIST_INSERT_HEAD(&aml_notify_list, pdata, link);
if (poll && !acpi_poll_enabled)
- timeout_add_sec(&dsdt_softc->sc_dev_timeout, 10);
+ timeout_add_sec(&acpi_softc->sc_dev_timeout, 10);
}
void
/* Spin to acquire lock */
while (!st) {
- st = acpi_acquire_global_lock(&dsdt_softc->sc_facs->global_lock);
+ st = acpi_acquire_global_lock(&acpi_softc->sc_facs->global_lock);
/* XXX - yield/delay? */
}
return;
/* Release lock */
- st = acpi_release_global_lock(&dsdt_softc->sc_facs->global_lock);
+ st = acpi_release_global_lock(&acpi_softc->sc_facs->global_lock);
if (!st)
return;
/* Signal others if someone waiting */
- x = acpi_read_pmreg(dsdt_softc, ACPIREG_PM1_CNT, 0);
+ x = acpi_read_pmreg(acpi_softc, ACPIREG_PM1_CNT, 0);
x |= ACPI_PM1_GBL_RLS;
- acpi_write_pmreg(dsdt_softc, ACPIREG_PM1_CNT, 0, x);
+ acpi_write_pmreg(acpi_softc, ACPIREG_PM1_CNT, 0, x);
return;
}
/* PCI */
pciaddr = 0;
- if (!aml_evalinteger(dsdt_softc, root, "_ADR", 0, NULL, &tmpres)) {
+ if (!aml_evalinteger(acpi_softc, root, "_ADR", 0, NULL, &tmpres)) {
/* Device:Function are bits 16-31,32-47 */
pciaddr += (tmpres << 16L);
dnprintf(20, "got _adr [%s]\n", aml_nodename(root));
return pciaddr;
}
- if (!aml_evalinteger(dsdt_softc, root, "_BBN", 0, NULL, &tmpres)) {
+ if (!aml_evalinteger(acpi_softc, root, "_BBN", 0, NULL, &tmpres)) {
/* PCI bus is in bits 48-63 */
pciaddr += (tmpres << 48L);
dnprintf(20, "got _bbn [%s]\n", aml_nodename(root));
return (0);
val->v_opregion.iobase =
ACPI_PCI_REG(val->v_opregion.iobase) +
- aml_getpciaddr(dsdt_softc, node);
+ aml_getpciaddr(acpi_softc, node);
dnprintf(20, "late ioaddr : %s:%llx\n",
aml_nodename(node), val->v_opregion.iobase);
}
scope->pos = scope->start;
scope->parent = parent;
scope->type = type;
- scope->sc = dsdt_softc;
+ scope->sc = acpi_softc;
aml_lastscope = scope;
int
aml_evalhid(struct aml_node *node, struct aml_value *val)
{
- if (aml_evalname(dsdt_softc, node, "_HID", 0, NULL, val))
+ if (aml_evalname(acpi_softc, node, "_HID", 0, NULL, val))
return (-1);
/* Integer _HID: convert to EISA ID */
{
int64_t res;
- if (aml_evalinteger(dsdt_softc, pcidev, "_ADR", 0, NULL, &res) == 0) {
+ if (aml_evalinteger(acpi_softc, pcidev, "_ADR", 0, NULL, &res) == 0) {
addr->fun = res & 0xFFFF;
addr->dev = res >> 16;
}
while (pcidev != NULL) {
/* HID device (PCI or PCIE root): eval _BBN */
if (__aml_search(pcidev, "_HID", 0)) {
- if (aml_evalinteger(dsdt_softc, pcidev, "_BBN", 0, NULL, &res) == 0) {
+ if (aml_evalinteger(acpi_softc, pcidev, "_BBN", 0, NULL, &res) == 0) {
addr->bus = res;
break;
}
if (mode == ACPI_IOREAD) {
/* Read bits from opregion */
- acpi_gasio(dsdt_softc, ACPI_IOREAD, type, pi.addr, sz, slen, tbit);
+ acpi_gasio(acpi_softc, ACPI_IOREAD, type, pi.addr, sz, slen, tbit);
aml_bufcpy(vbit, 0, tbit, bpos & 7, blen);
} else {
/* Write bits to opregion */
}
if (AML_FIELD_UPDATE(flag) == AML_FIELD_PRESERVE && ((bpos|blen) & 7)) {
/* If not aligned and preserve, read existing value */
- acpi_gasio(dsdt_softc, ACPI_IOREAD, type, pi.addr, sz, slen, tbit);
+ acpi_gasio(acpi_softc, ACPI_IOREAD, type, pi.addr, sz, slen, tbit);
} else if (AML_FIELD_UPDATE(flag) == AML_FIELD_WRITEASONES) {
memset(tbit, 0xFF, tmp.length);
}
/* Copy target bits, then write to region */
aml_bufcpy(tbit, bpos & 7, vbit, 0, blen);
- acpi_gasio(dsdt_softc, ACPI_IOWRITE, type, pi.addr, sz, slen, tbit);
+ acpi_gasio(acpi_softc, ACPI_IOWRITE, type, pi.addr, sz, slen, tbit);
aml_xdelref(&val, "fld.write");
}
mtx->v_mtx.owner = scope;
if (mtx == aml_global_lock) {
dnprintf(10,"LOCKING GLOBAL\n");
- err = acpi_acquire_global_lock(&dsdt_softc->sc_facs->global_lock);
+ err = acpi_acquire_global_lock(&acpi_softc->sc_facs->global_lock);
}
dnprintf(5,"%s acquires mutex %s\n", scope->node->name,
mtx->node->name);
if (mtx == aml_global_lock) {
dnprintf(10,"UNLOCKING GLOBAL\n");
- err=acpi_release_global_lock(&dsdt_softc->sc_facs->global_lock);
+ err=acpi_release_global_lock(&acpi_softc->sc_facs->global_lock);
}
dnprintf(5, "%s releases mutex %s\n", scope->node->name,
mtx->node->name);
break;
case AMLOP_LOAD:
/* Load(Object:NameString, DDBHandle:SuperName) */
- mscope = aml_load(dsdt_softc, scope, opargs[0], opargs[1]);
+ mscope = aml_load(acpi_softc, scope, opargs[0], opargs[1]);
break;
case AMLOP_UNLOAD:
/* DDBHandle */
struct aml_scope *scope;
struct aml_value res;
- dsdt_softc = sc;
-
aml_root.start = start;
memset(&res, 0, sizeof(res));
res.type = AML_OBJTYPE_SCOPE;