diff options
author | Mark Kettenis <kettenis@cvs.openbsd.org> | 2018-03-27 21:11:18 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@cvs.openbsd.org> | 2018-03-27 21:11:18 +0000 |
commit | cba170dee4c4aefd3226ef7a1cf9d69fea80fdfe (patch) | |
tree | 77c0ea3241c63b2c4e02be5544bc70c0f17e0ebb /sys | |
parent | 25f4ab68a920d5d0f61d0dfa51fdec8987c269dc (diff) |
Add acpicmos(4), a driver that implements SystemCMOS OperationRegion
access support. This fixes machines where the AML doesn't check whether
support for this OperationRegion type has been registered by the OS.
ok mlarkin@
Diffstat (limited to 'sys')
-rw-r--r-- | sys/arch/amd64/conf/GENERIC | 3 | ||||
-rw-r--r-- | sys/arch/amd64/conf/RAMDISK | 3 | ||||
-rw-r--r-- | sys/arch/i386/conf/GENERIC | 3 | ||||
-rw-r--r-- | sys/arch/i386/conf/RAMDISK | 3 | ||||
-rw-r--r-- | sys/arch/i386/conf/RAMDISK_CD | 3 | ||||
-rw-r--r-- | sys/dev/acpi/acpi.c | 3 | ||||
-rw-r--r-- | sys/dev/acpi/acpicmos.c | 90 | ||||
-rw-r--r-- | sys/dev/acpi/files.acpi | 7 |
8 files changed, 107 insertions, 8 deletions
diff --git a/sys/arch/amd64/conf/GENERIC b/sys/arch/amd64/conf/GENERIC index 6c53c13bac1..d04139bd2a0 100644 --- a/sys/arch/amd64/conf/GENERIC +++ b/sys/arch/amd64/conf/GENERIC @@ -1,4 +1,4 @@ -# $OpenBSD: GENERIC,v 1.451 2018/03/14 18:52:16 patrick Exp $ +# $OpenBSD: GENERIC,v 1.452 2018/03/27 21:11:16 kettenis Exp $ # # For further information on compiling OpenBSD kernels, see the config(8) # man page. @@ -44,6 +44,7 @@ acpiac* at acpi? acpibat* at acpi? acpibtn* at acpi? acpicpu* at acpi? +acpicmos* at acpi? acpidock* at acpi? acpiec* at acpi? acpiprt* at acpi? diff --git a/sys/arch/amd64/conf/RAMDISK b/sys/arch/amd64/conf/RAMDISK index f4939df3d46..bbc452fe4cc 100644 --- a/sys/arch/amd64/conf/RAMDISK +++ b/sys/arch/amd64/conf/RAMDISK @@ -1,4 +1,4 @@ -# $OpenBSD: RAMDISK,v 1.70 2015/09/03 18:00:11 kettenis Exp $ +# $OpenBSD: RAMDISK,v 1.71 2018/03/27 21:11:16 kettenis Exp $ machine amd64 maxusers 4 @@ -29,6 +29,7 @@ acpi0 at bios? #acpibat* at acpi? #acpibtn* at acpi? #acpicpu* at acpi? +acpicmos* at acpi? acpiec* at acpi? acpiprt* at acpi? acpimadt0 at acpi? diff --git a/sys/arch/i386/conf/GENERIC b/sys/arch/i386/conf/GENERIC index b6ddc871f33..015f4a7b7cc 100644 --- a/sys/arch/i386/conf/GENERIC +++ b/sys/arch/i386/conf/GENERIC @@ -1,4 +1,4 @@ -# $OpenBSD: GENERIC,v 1.829 2017/08/28 19:32:53 jasper Exp $ +# $OpenBSD: GENERIC,v 1.830 2018/03/27 21:11:17 kettenis Exp $ # # For further information on compiling OpenBSD kernels, see the config(8) # man page. @@ -47,6 +47,7 @@ acpiac* at acpi? acpibat* at acpi? acpibtn* at acpi? acpicpu* at acpi? +acpicmos* at acpi? acpidock* at acpi? acpiec* at acpi? acpimadt0 at acpi? diff --git a/sys/arch/i386/conf/RAMDISK b/sys/arch/i386/conf/RAMDISK index f75b2b7ab3a..d855c680240 100644 --- a/sys/arch/i386/conf/RAMDISK +++ b/sys/arch/i386/conf/RAMDISK @@ -1,4 +1,4 @@ -# $OpenBSD: RAMDISK,v 1.192 2017/07/31 13:23:42 deraadt Exp $ +# $OpenBSD: RAMDISK,v 1.193 2018/03/27 21:11:17 kettenis Exp $ machine i386 maxusers 4 @@ -29,6 +29,7 @@ acpi0 at bios? #acpibat* at acpi? #acpibtn* at acpi? #acpicpu* at acpi? +acpicmos* at acpi? acpiec* at acpi? acpiprt* at acpi? acpimadt0 at acpi? diff --git a/sys/arch/i386/conf/RAMDISK_CD b/sys/arch/i386/conf/RAMDISK_CD index a1f1df9377e..0b6bf39c285 100644 --- a/sys/arch/i386/conf/RAMDISK_CD +++ b/sys/arch/i386/conf/RAMDISK_CD @@ -1,4 +1,4 @@ -# $OpenBSD: RAMDISK_CD,v 1.234 2016/12/30 22:36:07 deraadt Exp $ +# $OpenBSD: RAMDISK_CD,v 1.235 2018/03/27 21:11:17 kettenis Exp $ machine i386 maxusers 4 @@ -36,6 +36,7 @@ acpi0 at bios? #acpibat* at acpi? #acpibtn* at acpi? #acpicpu* at acpi? +acpicmos* at acpi? acpiec* at acpi? acpimadt0 at acpi? acpiprt* at acpi? diff --git a/sys/dev/acpi/acpi.c b/sys/dev/acpi/acpi.c index e2428a31320..ae863d03625 100644 --- a/sys/dev/acpi/acpi.c +++ b/sys/dev/acpi/acpi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: acpi.c,v 1.340 2018/02/19 08:59:52 mpi Exp $ */ +/* $OpenBSD: acpi.c,v 1.341 2018/03/27 21:11:16 kettenis Exp $ */ /* * Copyright (c) 2005 Thorsten Lockert <tholo@sigmasoft.com> * Copyright (c) 2005 Jordan Hargrave <jordan@openbsd.org> @@ -2907,7 +2907,6 @@ const char *acpi_skip_hids[] = { "PNP0800", /* Microsoft Sound System Compatible Device */ "PNP0A03", /* PCI Bus */ "PNP0A08", /* PCI Express Bus */ - "PNP0B00", /* AT Real-Time Clock */ "PNP0C01", /* System Board */ "PNP0C02", /* PNP Motherboard Resources */ "PNP0C04", /* x87-compatible Floating Point Processing Unit */ diff --git a/sys/dev/acpi/acpicmos.c b/sys/dev/acpi/acpicmos.c new file mode 100644 index 00000000000..0b1a2cf9509 --- /dev/null +++ b/sys/dev/acpi/acpicmos.c @@ -0,0 +1,90 @@ +/* $OpenBSD: acpicmos.c,v 1.1 2018/03/27 21:11:16 kettenis Exp $ */ +/* + * Copyright (c) 2018 Mark Kettenis + * + * 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 <sys/param.h> +#include <sys/systm.h> + +#include <dev/acpi/acpireg.h> +#include <dev/acpi/acpivar.h> +#include <dev/acpi/dsdt.h> + +#include <dev/ic/mc146818reg.h> + +struct acpicmos_softc { + struct device sc_dev; + struct aml_node *sc_node; +}; + +int acpicmos_match(struct device *, void *, void *); +void acpicmos_attach(struct device *, struct device *, void *); + +struct cfattach acpicmos_ca = { + sizeof(struct acpicmos_softc), acpicmos_match, acpicmos_attach +}; + +struct cfdriver acpicmos_cd = { + NULL, "acpicmos", DV_DULL +}; + +const char *acpicmos_hids[] = { + "PNP0B00", + "PNP0B01", + "PNP0B02", + NULL +}; + +int acpicmos_opreg_handler(void *, int, uint64_t, int, uint64_t *); + +int +acpicmos_match(struct device *parent, void *match, void *aux) +{ + struct acpi_attach_args *aaa = aux; + struct cfdata *cf = match; + + return acpi_matchhids(aaa, acpicmos_hids, cf->cf_driver->cd_name); +} + +void +acpicmos_attach(struct device *parent, struct device *self, void *aux) +{ + struct acpicmos_softc *sc = (struct acpicmos_softc *)self; + struct acpi_attach_args *aaa = aux; + + printf("\n"); + + sc->sc_node = aaa->aaa_node; + aml_register_regionspace(sc->sc_node, ACPI_OPREG_CMOS, + sc, acpicmos_opreg_handler); +} + + +int +acpicmos_opreg_handler(void *cookie, int iodir, uint64_t address, int size, + uint64_t *value) +{ + /* Only allow 8-bit access. */ + if (size != 8 || address > 0xff) + return -1; + + if (iodir == ACPI_IOREAD) + *value = mc146818_read(NULL, address); + else + mc146818_write(NULL, address, *value); + + + return 0; +} diff --git a/sys/dev/acpi/files.acpi b/sys/dev/acpi/files.acpi index 58cce95eba0..310a9a88850 100644 --- a/sys/dev/acpi/files.acpi +++ b/sys/dev/acpi/files.acpi @@ -1,4 +1,4 @@ -# $OpenBSD: files.acpi,v 1.39 2018/03/14 18:52:16 patrick Exp $ +# $OpenBSD: files.acpi,v 1.40 2018/03/27 21:11:16 kettenis Exp $ # # Config file and device description for machine-independent ACPI code. # Included by ports that need it. @@ -31,6 +31,11 @@ device acpibtn attach acpibtn at acpi file dev/acpi/acpibtn.c acpibtn +# cmos device +device acpicmos +attach acpicmos at acpi +file dev/acpi/acpicmos.c acpicmos + # cpu device device acpicpu attach acpicpu at acpi |