diff options
author | Marco Peereboom <marco@cvs.openbsd.org> | 2006-02-16 22:14:33 +0000 |
---|---|---|
committer | Marco Peereboom <marco@cvs.openbsd.org> | 2006-02-16 22:14:33 +0000 |
commit | 6f6fa1bcc70d5b7486c6a12d046ac4c7006e7e18 (patch) | |
tree | ed330dd4ec94c5269e06aaf4f788063253cd053e | |
parent | 5413bf7b9ab3c7d1578742801c146a6938972768 (diff) |
Print useful information during boot about the battery and power supply.
ok jordan.
-rw-r--r-- | sys/dev/acpi/acpiac.c | 61 | ||||
-rw-r--r-- | sys/dev/acpi/acpibat.c | 27 | ||||
-rw-r--r-- | sys/dev/acpi/acpidev.h | 6 |
3 files changed, 82 insertions, 12 deletions
diff --git a/sys/dev/acpi/acpiac.c b/sys/dev/acpi/acpiac.c index 9d89092b9ec..7afdb0bd1e4 100644 --- a/sys/dev/acpi/acpiac.c +++ b/sys/dev/acpi/acpiac.c @@ -1,4 +1,4 @@ -/* $OpenBSD: acpiac.c,v 1.2 2005/12/16 04:16:59 marco Exp $ */ +/* $OpenBSD: acpiac.c,v 1.3 2006/02/16 22:14:32 marco Exp $ */ /* * Copyright (c) 2005 Marco Peereboom <marco@openbsd.org> * @@ -25,6 +25,8 @@ #include <dev/acpi/acpireg.h> #include <dev/acpi/acpivar.h> #include <dev/acpi/acpidev.h> +#include <dev/acpi/amltypes.h> +#include <dev/acpi/dsdt.h> int acpiac_match(struct device *, void *, void *); void acpiac_attach(struct device *, struct device *, void *); @@ -34,8 +36,15 @@ struct acpiac_softc { bus_space_tag_t sc_iot; bus_space_handle_t sc_ioh; + + struct acpi_softc *sc_acpi; + struct aml_node *sc_devnode; + + int sc_ac_stat; }; +int acpiac_getsta(struct acpiac_softc *); + struct cfattach acpiac_ca = { sizeof(struct acpiac_softc), acpiac_match, acpiac_attach }; @@ -62,13 +71,51 @@ acpiac_match(struct device *parent, void *match, void *aux) void acpiac_attach(struct device *parent, struct device *self, void *aux) { -/* - struct acpiac_softc *sc = (struct acpiac_softc *) self; - struct acpi_softc *psc = (struct acpi_softc *) parent; + struct acpiac_softc *sc = (struct acpiac_softc *)self; struct acpi_attach_args *aa = aux; - bus_addr_t address; - bus_size_t size; -*/ + + sc->sc_acpi = (struct acpi_softc *)parent; + sc->sc_devnode = aa->aaa_node->child; + + acpiac_getsta(sc); + + printf(": "); + + if (sc->sc_ac_stat == PSR_ONLINE) + printf("AC unit online"); + else if (sc->sc_ac_stat == PSR_OFFLINE) + printf("AC unit offline"); + else + printf("AC unit in unknown state"); printf("\n"); } + +int +acpiac_getsta(struct acpiac_softc *sc) +{ + struct aml_value res, env; + struct acpi_context *ctx; + + memset(&res, 0, sizeof(res)); + memset(&env, 0, sizeof(env)); + + ctx = NULL; + if (aml_eval_name(sc->sc_acpi, sc->sc_devnode, "_STA", &res, &env)) { + dnprintf(10, "%s: no _STA\n", + DEVNAME(sc)); + return (1); + } + + dnprintf(40, "_STA value: %x\n", res.v_integer); + + if (aml_eval_name(sc->sc_acpi, sc->sc_devnode, "_PSR", &res, &env)) { + dnprintf(10, "%s: no _PSR\n", + DEVNAME(sc)); + return (1); + } + + sc->sc_ac_stat = aml_val2int(NULL, &res); + + return (0); +} diff --git a/sys/dev/acpi/acpibat.c b/sys/dev/acpi/acpibat.c index b5e2cebc06f..360656b068f 100644 --- a/sys/dev/acpi/acpibat.c +++ b/sys/dev/acpi/acpibat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: acpibat.c,v 1.11 2006/02/16 21:07:16 marco Exp $ */ +/* $OpenBSD: acpibat.c,v 1.12 2006/02/16 22:14:32 marco Exp $ */ /* * Copyright (c) 2005 Marco Peereboom <marco@openbsd.org> * @@ -81,7 +81,22 @@ acpibat_attach(struct device *parent, struct device *self, void *aux) acpibat_getbif(sc); acpibat_getbst(sc); - printf("\n"); +/* + printf(": max cap: %u last max cap: %u current cap: %u model: %s " + "serial: %s type: %s oem: %s\n", + sc->sc_bif.bif_capacity, + sc->sc_bif.bif_last_capacity, + sc->sc_bst.bst_capacity, + sc->sc_bif.bif_model, + sc->sc_bif.bif_serial, + sc->sc_bif.bif_type, + sc->sc_bif.bif_oem); +*/ + printf(": model: %s serial: %s type: %s oem: %s\n", + sc->sc_bif.bif_model, + sc->sc_bif.bif_serial, + sc->sc_bif.bif_type, + sc->sc_bif.bif_oem); } int @@ -94,6 +109,14 @@ acpibat_getbif(struct acpibat_softc *sc) memset(&env, 0, sizeof(env)); ctx = NULL; + if (aml_eval_name(sc->sc_acpi, sc->sc_devnode, "_STA", &res, &env)) { + dnprintf(10, "%s: no _STA\n", + DEVNAME(sc)); + return (1); + } + + dnprintf(40, "_STA value: %x\n", res.v_integer); + if (aml_eval_name(sc->sc_acpi, sc->sc_devnode, "_BIF", &res, &env)) { dnprintf(50, "%s: no _BIF\n", DEVNAME(sc)); diff --git a/sys/dev/acpi/acpidev.h b/sys/dev/acpi/acpidev.h index 415a97e694b..d823bcb64b8 100644 --- a/sys/dev/acpi/acpidev.h +++ b/sys/dev/acpi/acpidev.h @@ -1,4 +1,4 @@ -/* $OpenBSD: acpidev.h,v 1.3 2005/12/28 03:08:33 marco Exp $ */ +/* $OpenBSD: acpidev.h,v 1.4 2006/02/16 22:14:32 marco Exp $ */ /* * Copyright (c) 2005 Marco Peereboom <marco@openbsd.org> * Copyright (c) 2005 Thorsten Lockert <tholo@sigmasoft.com> @@ -166,8 +166,8 @@ struct acpibat_bmd { * Arguments: none * Results : DWORD status */ -#define PSR_ONLINE 0x00 -#define PSR_OFFLINE 0x01 +#define PSR_OFFLINE 0x00 +#define PSR_ONLINE 0x01 /* * _PCL (Power Consumer List) |