From bc5570585a74a452199e58690f40ed32e99bd565 Mon Sep 17 00:00:00 2001 From: Marco Peereboom Date: Sun, 26 Feb 2006 02:49:29 +0000 Subject: Add acpicpu device. Remains disabled. ok jordan@ --- sys/arch/amd64/conf/GENERIC | 3 +- sys/arch/i386/conf/GENERIC | 3 +- sys/dev/acpi/acpicpu.c | 120 ++++++++++++++++++++++++++++++++++++++++++++ sys/dev/acpi/files.acpi | 7 ++- 4 files changed, 130 insertions(+), 3 deletions(-) create mode 100644 sys/dev/acpi/acpicpu.c (limited to 'sys') diff --git a/sys/arch/amd64/conf/GENERIC b/sys/arch/amd64/conf/GENERIC index 08a7c2604b7..03c92604380 100644 --- a/sys/arch/amd64/conf/GENERIC +++ b/sys/arch/amd64/conf/GENERIC @@ -1,4 +1,4 @@ -# $OpenBSD: GENERIC,v 1.113 2006/02/20 00:48:09 marco Exp $ +# $OpenBSD: GENERIC,v 1.114 2006/02/26 02:49:28 marco Exp $ # # For further information on compiling OpenBSD kernels, see the config(8) # man page. @@ -51,6 +51,7 @@ pci* at mainbus0 #acpiac* at acpi? #acpibat* at acpi? #acpibtn* at acpi? +#acpicpu* at acpi? ipmi0 at mainbus? # IPMI diff --git a/sys/arch/i386/conf/GENERIC b/sys/arch/i386/conf/GENERIC index aa807fcfaa0..659e1f3c3c2 100644 --- a/sys/arch/i386/conf/GENERIC +++ b/sys/arch/i386/conf/GENERIC @@ -1,4 +1,4 @@ -# $OpenBSD: GENERIC,v 1.471 2006/02/20 00:48:10 marco Exp $ +# $OpenBSD: GENERIC,v 1.472 2006/02/26 02:49:28 marco Exp $ # # For further information on compiling OpenBSD kernels, see the config(8) # man page. @@ -68,6 +68,7 @@ option ACPIVERBOSE #acpiac* at acpi? #acpibat* at acpi? #acpibtn* at acpi? +#acpicpu* at acpi? option PCIVERBOSE option EISAVERBOSE diff --git a/sys/dev/acpi/acpicpu.c b/sys/dev/acpi/acpicpu.c new file mode 100644 index 00000000000..bd937ada416 --- /dev/null +++ b/sys/dev/acpi/acpicpu.c @@ -0,0 +1,120 @@ +/* $OpenBSD: acpicpu.c,v 1.1 2006/02/26 02:49:28 marco Exp $ */ +/* + * Copyright (c) 2005 Marco Peereboom + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include + +#include + +int acpicpu_match(struct device *, void *, void *); +void acpicpu_attach(struct device *, struct device *, void *); +int acpicpu_notify(struct aml_node *, int, void *); + +struct acpicpu_softc { + struct device sc_dev; + + bus_space_tag_t sc_iot; + bus_space_handle_t sc_ioh; + + struct acpi_softc *sc_acpi; + struct aml_node *sc_devnode; +}; + +int acpicpu_getsta(struct acpicpu_softc *); + +struct cfattach acpicpu_ca = { + sizeof(struct acpicpu_softc), acpicpu_match, acpicpu_attach +}; + +struct cfdriver acpicpu_cd = { + NULL, "acpicpu", DV_DULL +}; + +int +acpicpu_match(struct device *parent, void *match, void *aux) +{ + struct acpi_attach_args *aa = aux; + struct cfdata *cf = match; + + /* sanity */ + if (aa->aaa_name == NULL || + strcmp(aa->aaa_name, cf->cf_driver->cd_name) != 0 || + aa->aaa_table != NULL) + return (0); + + return (1); +} + +void +acpicpu_attach(struct device *parent, struct device *self, void *aux) +{ + struct acpicpu_softc *sc = (struct acpicpu_softc *)self; + struct acpi_attach_args *aa = aux; + + sc->sc_acpi = (struct acpi_softc *)parent; + sc->sc_devnode = aa->aaa_node->child; + + acpicpu_getsta(sc); + + printf(":\n"); + + aml_register_notify(sc->sc_devnode->parent, aa->aaa_dev, acpicpu_notify, sc); +} + +int +acpicpu_getsta(struct acpicpu_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(20, "%s: no _STA\n", DEVNAME(sc)); + /* XXX not all buttons have _STA so FALLTROUGH */ + } + + return (0); +} + +int +acpicpu_notify(struct aml_node *node, int notify_type, void *arg) +{ + struct acpicpu_softc *sc = arg; + + dnprintf(10, "acpicpu_notify: %.2x %s\n", notify_type, + sc->sc_devnode->parent->name); + + printf("acpicpu_notify: %.2x %s\n", notify_type, + sc->sc_devnode->parent->name); + + return (0); +} diff --git a/sys/dev/acpi/files.acpi b/sys/dev/acpi/files.acpi index 357d7981c90..23b85d8f8e9 100644 --- a/sys/dev/acpi/files.acpi +++ b/sys/dev/acpi/files.acpi @@ -1,4 +1,4 @@ -# $OpenBSD: files.acpi,v 1.7 2006/02/20 00:48:10 marco Exp $ +# $OpenBSD: files.acpi,v 1.8 2006/02/26 02:49:28 marco Exp $ # # Config file and device description for machine-independent ACPI code. # Included by ports that need it. @@ -30,6 +30,11 @@ device acpibtn attach acpibtn at acpi file dev/acpi/acpibtn.c acpibtn +# cpu device +device acpicpu +attach acpicpu at acpi +file dev/acpi/acpicpu.c acpicpu + # High Precision Event Timer device hpet attach hpet at acpi -- cgit v1.2.3