summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorJordan Hargrave <jordan@cvs.openbsd.org>2010-06-27 07:26:32 +0000
committerJordan Hargrave <jordan@cvs.openbsd.org>2010-06-27 07:26:32 +0000
commit4ae5d9c550a58fc7688b9f367a5919bfe2b5b938 (patch)
tree76faf4484b379a1b7de25e59161afb6a624ed614 /sys
parentdef2a514847eb7c795acc2c878365b71586b6b95 (diff)
Cleaned up acpi_maptable, adds to table list directly
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/acpi/acpi.c46
-rw-r--r--sys/dev/acpi/dsdt.c12
2 files changed, 27 insertions, 31 deletions
diff --git a/sys/dev/acpi/acpi.c b/sys/dev/acpi/acpi.c
index 948e265e78d..f6e8a521cee 100644
--- a/sys/dev/acpi/acpi.c
+++ b/sys/dev/acpi/acpi.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: acpi.c,v 1.157 2010/04/07 17:46:30 deraadt Exp $ */
+/* $OpenBSD: acpi.c,v 1.158 2010/06/27 07:26:31 jordan Exp $ */
/*
* Copyright (c) 2005 Thorsten Lockert <tholo@sigmasoft.com>
* Copyright (c) 2005 Jordan Hargrave <jordan@openbsd.org>
@@ -96,7 +96,7 @@ int acpiide_notify(struct aml_node *, int, void *);
void wdcattach(struct channel_softc *);
int wdcdetach(struct channel_softc *, int);
-struct acpi_q *acpi_maptable(paddr_t, const char *, const char *, const char *);
+struct acpi_q *acpi_maptable(struct acpi_softc *, paddr_t, const char *, const char *, const char *, int);
struct idechnl
{
@@ -590,13 +590,12 @@ acpi_attach(struct device *parent, struct device *self, void *aux)
* extended (64-bit) pointer if it exists
*/
if (sc->sc_fadt->hdr_revision < 3 || sc->sc_fadt->x_dsdt == 0)
- entry = acpi_maptable(sc->sc_fadt->dsdt, NULL, NULL, NULL);
+ entry = acpi_maptable(sc, sc->sc_fadt->dsdt, NULL, NULL, NULL, -1);
else
- entry = acpi_maptable(sc->sc_fadt->x_dsdt, NULL, NULL, NULL);
+ entry = acpi_maptable(sc, sc->sc_fadt->x_dsdt, NULL, NULL, NULL, -1);
if (entry == NULL)
printf(" !DSDT");
- SIMPLEQ_INSERT_HEAD(&sc->sc_tables, entry, q_next);
p_dsdt = entry->q_table;
acpi_parse_aml(sc, p_dsdt->aml, p_dsdt->hdr_length -
@@ -783,7 +782,7 @@ acpi_print(void *aux, const char *pnp)
}
struct acpi_q *
-acpi_maptable(paddr_t addr, const char *sig, const char *oem, const char *tbl)
+acpi_maptable(struct acpi_softc *sc, paddr_t addr, const char *sig, const char *oem, const char *tbl, int flag)
{
static int tblid;
struct acpi_mem_map handle;
@@ -821,6 +820,13 @@ acpi_maptable(paddr_t addr, const char *sig, const char *oem, const char *tbl)
memcpy(entry->q_data, handle.va, len);
entry->q_table = entry->q_data;
entry->q_id = ++tblid;
+
+ if (flag < 0)
+ SIMPLEQ_INSERT_HEAD(&sc->sc_tables, entry,
+ q_next);
+ else if (flag > 0)
+ SIMPLEQ_INSERT_TAIL(&sc->sc_tables, entry,
+ q_next);
}
acpi_unmap(&handle);
return entry;
@@ -829,14 +835,14 @@ acpi_maptable(paddr_t addr, const char *sig, const char *oem, const char *tbl)
int
acpi_loadtables(struct acpi_softc *sc, struct acpi_rsdp *rsdp)
{
- struct acpi_q *entry, *sdt;
+ struct acpi_q *sdt;
int i, ntables;
size_t len;
if (rsdp->rsdp_revision == 2 && rsdp->rsdp_xsdt) {
struct acpi_xsdt *xsdt;
- sdt = acpi_maptable(rsdp->rsdp_xsdt, NULL, NULL, NULL);
+ sdt = acpi_maptable(sc, rsdp->rsdp_xsdt, NULL, NULL, NULL, 0);
if (sdt == NULL) {
printf("couldn't map rsdt\n");
return (ENOMEM);
@@ -847,18 +853,15 @@ acpi_loadtables(struct acpi_softc *sc, struct acpi_rsdp *rsdp)
ntables = (len - sizeof(struct acpi_table_header)) /
sizeof(xsdt->table_offsets[0]);
- for (i = 0; i < ntables; i++) {
- entry = acpi_maptable(xsdt->table_offsets[i], NULL, NULL,
- NULL);
- if (entry != NULL)
- SIMPLEQ_INSERT_TAIL(&sc->sc_tables, entry,
- q_next);
- }
+ for (i = 0; i < ntables; i++)
+ acpi_maptable(sc, xsdt->table_offsets[i], NULL, NULL,
+ NULL, 1);
+
free(sdt, M_DEVBUF);
} else {
struct acpi_rsdt *rsdt;
- sdt = acpi_maptable(rsdp->rsdp_rsdt, NULL, NULL, NULL);
+ sdt = acpi_maptable(sc, rsdp->rsdp_rsdt, NULL, NULL, NULL, 0);
if (sdt == NULL) {
printf("couldn't map rsdt\n");
return (ENOMEM);
@@ -869,13 +872,10 @@ acpi_loadtables(struct acpi_softc *sc, struct acpi_rsdp *rsdp)
ntables = (len - sizeof(struct acpi_table_header)) /
sizeof(rsdt->table_offsets[0]);
- for (i = 0; i < ntables; i++) {
- entry = acpi_maptable(rsdt->table_offsets[i], NULL, NULL,
- NULL);
- if (entry != NULL)
- SIMPLEQ_INSERT_TAIL(&sc->sc_tables, entry,
- q_next);
- }
+ for (i = 0; i < ntables; i++)
+ acpi_maptable(sc, rsdt->table_offsets[i], NULL, NULL,
+ NULL, 1);
+
free(sdt, M_DEVBUF);
}
diff --git a/sys/dev/acpi/dsdt.c b/sys/dev/acpi/dsdt.c
index 8a23f4de209..b8324352819 100644
--- a/sys/dev/acpi/dsdt.c
+++ b/sys/dev/acpi/dsdt.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dsdt.c,v 1.158 2010/06/19 19:43:06 jordan Exp $ */
+/* $OpenBSD: dsdt.c,v 1.159 2010/06/27 07:26:31 jordan Exp $ */
/*
* Copyright (c) 2005 Jordan Hargrave <jordan@openbsd.org>
*
@@ -47,8 +47,8 @@
#define AML_INTSTRLEN 16
#define AML_NAMESEG_LEN 4
-struct acpi_q *acpi_maptable(paddr_t, const char *, const char *,
- const char *);
+struct acpi_q *acpi_maptable(struct acpi_softc *sc, paddr_t, const char *, const char *,
+ const char *, int);
struct aml_scope *aml_load(struct acpi_softc *, struct aml_scope *,
struct aml_value *, struct aml_value *);
@@ -3324,16 +3324,12 @@ aml_load(struct acpi_softc *sc, struct aml_scope *scope,
goto fail;
/* Load SSDT from memory */
- entry = acpi_maptable(rgn->v_opregion.iobase, "SSDT", NULL, NULL);
+ entry = acpi_maptable(sc, rgn->v_opregion.iobase, "SSDT", NULL, NULL, 1);
if (entry == NULL)
goto fail;
dnprintf(10, "%s: loaded SSDT %s @ %llx\n", sc->sc_dev.dv_xname,
aml_nodename(rgn->node), rgn->v_opregion.iobase);
-
- /* Add SSDT to parent list */
- SIMPLEQ_INSERT_TAIL(&sc->sc_tables, entry,
- q_next);
ddb->v_integer = entry->q_id;
p_ssdt = entry->q_table;