summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/amd64/amd64/acpi_machdep.c16
-rw-r--r--sys/arch/amd64/amd64/hibernate_machdep.c7
-rw-r--r--sys/arch/i386/i386/acpi_machdep.c17
-rw-r--r--sys/arch/i386/i386/hibernate_machdep.c7
-rw-r--r--sys/dev/acpi/acpi.c90
-rw-r--r--sys/dev/acpi/acpivar.h17
6 files changed, 99 insertions, 55 deletions
diff --git a/sys/arch/amd64/amd64/acpi_machdep.c b/sys/arch/amd64/amd64/acpi_machdep.c
index 4f1809b63aa..ce27079fdbb 100644
--- a/sys/arch/amd64/amd64/acpi_machdep.c
+++ b/sys/arch/amd64/amd64/acpi_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: acpi_machdep.c,v 1.81 2018/06/05 06:39:10 guenther Exp $ */
+/* $OpenBSD: acpi_machdep.c,v 1.82 2018/06/25 22:33:24 kettenis Exp $ */
/*
* Copyright (c) 2005 Thorsten Lockert <tholo@sigmasoft.com>
*
@@ -95,6 +95,20 @@ acpi_unmap(struct acpi_mem_map *handle)
uvm_km_free(kernel_map, handle->baseva, handle->vsize);
}
+int
+acpi_bus_space_map(bus_space_tag_t t, bus_addr_t addr, bus_size_t size,
+ int flags, bus_space_handle_t *bshp)
+{
+ return _bus_space_map(t, addr, size, flags, bshp);
+}
+
+void
+acpi_bus_space_unmap(bus_space_tag_t t, bus_space_handle_t bsh,
+ bus_size_t size)
+{
+ _bus_space_unmap(t, bsh, size, NULL);
+}
+
void *
acpi_intr_establish(int irq, int flags, int level,
int (*handler)(void *), void *arg, const char *what)
diff --git a/sys/arch/amd64/amd64/hibernate_machdep.c b/sys/arch/amd64/amd64/hibernate_machdep.c
index f25fe027dde..d20c8c02a86 100644
--- a/sys/arch/amd64/amd64/hibernate_machdep.c
+++ b/sys/arch/amd64/amd64/hibernate_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hibernate_machdep.c,v 1.42 2018/06/21 07:33:30 mlarkin Exp $ */
+/* $OpenBSD: hibernate_machdep.c,v 1.43 2018/06/25 22:33:24 kettenis Exp $ */
/*
* Copyright (c) 2012 Mike Larkin <mlarkin@openbsd.org>
@@ -28,11 +28,10 @@
#include <sys/kcore.h>
#include <sys/atomic.h>
-#include <dev/acpi/acpivar.h>
-
#include <uvm/uvm_extern.h>
#include <uvm/uvm_pmemrange.h>
+#include <machine/biosvar.h>
#include <machine/cpu.h>
#include <machine/hibernate_var.h>
#include <machine/pte.h>
@@ -42,6 +41,8 @@
#include <machine/mpbiosvar.h>
#endif /* MULTIPROCESSOR */
+#include <dev/acpi/acpivar.h>
+
#include "acpi.h"
#include "wd.h"
#include "ahci.h"
diff --git a/sys/arch/i386/i386/acpi_machdep.c b/sys/arch/i386/i386/acpi_machdep.c
index e87dae851bd..e14e91f29bc 100644
--- a/sys/arch/i386/i386/acpi_machdep.c
+++ b/sys/arch/i386/i386/acpi_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: acpi_machdep.c,v 1.65 2018/03/31 13:45:03 bluhm Exp $ */
+/* $OpenBSD: acpi_machdep.c,v 1.66 2018/06/25 22:33:24 kettenis Exp $ */
/*
* Copyright (c) 2005 Thorsten Lockert <tholo@sigmasoft.com>
*
@@ -28,6 +28,7 @@
#include <uvm/uvm_extern.h>
+#include <machine/biosvar.h>
#include <machine/bus.h>
#include <machine/conf.h>
#include <machine/acpiapm.h>
@@ -104,6 +105,20 @@ acpi_unmap(struct acpi_mem_map *handle)
uvm_km_free(kernel_map, handle->baseva, handle->vsize);
}
+int
+acpi_bus_space_map(bus_space_tag_t t, bus_addr_t addr, bus_size_t size,
+ int flags, bus_space_handle_t *bshp)
+{
+ return _bus_space_map(t, addr, size, flags, bshp);
+}
+
+void
+acpi_bus_space_unmap(bus_space_tag_t t, bus_space_handle_t bsh,
+ bus_size_t size)
+{
+ _bus_space_unmap(t, bsh, size, NULL);
+}
+
u_int8_t *
acpi_scan(struct acpi_mem_map *handle, paddr_t pa, size_t len)
{
diff --git a/sys/arch/i386/i386/hibernate_machdep.c b/sys/arch/i386/i386/hibernate_machdep.c
index c8164705183..0c7e4262861 100644
--- a/sys/arch/i386/i386/hibernate_machdep.c
+++ b/sys/arch/i386/i386/hibernate_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hibernate_machdep.c,v 1.52 2018/06/21 07:33:30 mlarkin Exp $ */
+/* $OpenBSD: hibernate_machdep.c,v 1.53 2018/06/25 22:33:24 kettenis Exp $ */
/*
* Copyright (c) 2011 Mike Larkin <mlarkin@openbsd.org>
@@ -26,11 +26,10 @@
#include <sys/timeout.h>
#include <sys/malloc.h>
-#include <dev/acpi/acpivar.h>
-
#include <uvm/uvm_extern.h>
#include <uvm/uvm_pmemrange.h>
+#include <machine/biosvar.h>
#include <machine/hibernate.h>
#include <machine/hibernate_var.h>
#include <machine/kcore.h>
@@ -40,6 +39,8 @@
#include <machine/mpbiosvar.h>
#endif /* MULTIPROCESSOR */
+#include <dev/acpi/acpivar.h>
+
#include "acpi.h"
#include "wd.h"
#include "ahci.h"
diff --git a/sys/dev/acpi/acpi.c b/sys/dev/acpi/acpi.c
index 9536a7e6f23..4b60b233f27 100644
--- a/sys/dev/acpi/acpi.c
+++ b/sys/dev/acpi/acpi.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: acpi.c,v 1.344 2018/05/20 09:12:35 kettenis Exp $ */
+/* $OpenBSD: acpi.c,v 1.345 2018/06/25 22:33:24 kettenis Exp $ */
/*
* Copyright (c) 2005 Thorsten Lockert <tholo@sigmasoft.com>
* Copyright (c) 2005 Jordan Hargrave <jordan@openbsd.org>
@@ -79,8 +79,6 @@ pcireg_t acpi_pci_min_powerstate(pci_chipset_tag_t, pcitag_t);
void acpi_pci_set_powerstate(pci_chipset_tag_t, pcitag_t, int, int);
int acpi_pci_notify(struct aml_node *, int, void *);
-int acpi_match(struct device *, void *, void *);
-void acpi_attach(struct device *, struct device *, void *);
int acpi_submatch(struct device *, void *, void *);
int acpi_print(void *, const char *);
@@ -198,21 +196,55 @@ static const char *sbtn_pnp[] = {
int mouse_has_softbtn;
#endif /* SMALL_KERNEL */
+struct acpi_softc *acpi_softc;
+
/* XXX move this into dsdt softc at some point */
extern struct aml_node aml_root;
+struct cfdriver acpi_cd = {
+ NULL, "acpi", DV_DULL
+};
+
+#if defined(__amd64__) || defined(__i386__)
+
+#include <machine/biosvar.h>
+
+int acpi_match(struct device *, void *, void *);
+void acpi_attach(struct device *, struct device *, void *);
+
struct cfattach acpi_ca = {
sizeof(struct acpi_softc), acpi_match, acpi_attach
};
-struct cfdriver acpi_cd = {
- NULL, "acpi", DV_DULL
-};
+int
+acpi_match(struct device *parent, void *match, void *aux)
+{
+ struct bios_attach_args *ba = aux;
+ struct cfdata *cf = match;
-struct acpi_softc *acpi_softc;
+ /* sanity */
+ if (strcmp(ba->ba_name, cf->cf_driver->cd_name))
+ return (0);
-#define acpi_bus_space_map _bus_space_map
-#define acpi_bus_space_unmap _bus_space_unmap
+ if (!acpi_probe(parent, cf, ba))
+ return (0);
+
+ return (1);
+}
+
+void
+acpi_attach(struct device *parent, struct device *self, void *aux)
+{
+ struct acpi_softc *sc = (struct acpi_softc *)self;
+ struct bios_attach_args *ba = aux;
+
+ sc->sc_iot = ba->ba_iot;
+ sc->sc_memt = ba->ba_memt;
+
+ acpi_attach_common(sc, ba->ba_acpipbase);
+}
+
+#endif
uint8_t
acpi_pci_conf_read_1(pci_chipset_tag_t pc, pcitag_t tag, int reg)
@@ -336,7 +368,7 @@ acpi_gasio(struct acpi_softc *sc, int iodir, int iospace, uint64_t address,
}
}
}
- acpi_bus_space_unmap(iot, ioh, len, NULL);
+ acpi_bus_space_unmap(iot, ioh, len);
break;
case GAS_PCI_CFG_SPACE:
@@ -492,22 +524,6 @@ acpi_foundprt(struct aml_node *node, void *arg)
return 0;
}
-int
-acpi_match(struct device *parent, void *match, void *aux)
-{
- struct bios_attach_args *ba = aux;
- struct cfdata *cf = match;
-
- /* sanity */
- if (strcmp(ba->ba_name, cf->cf_driver->cd_name))
- return (0);
-
- if (!acpi_probe(parent, cf, ba))
- return (0);
-
- return (1);
-}
-
TAILQ_HEAD(, acpi_pci) acpi_pcidevs =
TAILQ_HEAD_INITIALIZER(acpi_pcidevs);
TAILQ_HEAD(, acpi_pci) acpi_pcirootdevs =
@@ -942,10 +958,8 @@ acpi_register_gsb(struct acpi_softc *sc, struct aml_node *devnode)
#endif
void
-acpi_attach(struct device *parent, struct device *self, void *aux)
+acpi_attach_common(struct acpi_softc *sc, paddr_t base)
{
- struct bios_attach_args *ba = aux;
- struct acpi_softc *sc = (struct acpi_softc *)self;
struct acpi_mem_map handle;
struct acpi_rsdp *rsdp;
struct acpi_q *entry;
@@ -959,14 +973,11 @@ acpi_attach(struct device *parent, struct device *self, void *aux)
uint16_t pm1;
int s;
- sc->sc_iot = ba->ba_iot;
- sc->sc_memt = ba->ba_memt;
-
rw_init(&sc->sc_lck, "acpilk");
acpi_softc = sc;
- if (acpi_map(ba->ba_acpipbase, sizeof(struct acpi_rsdp), &handle)) {
+ if (acpi_map(base, sizeof(struct acpi_rsdp), &handle)) {
printf(": can't map memory\n");
return;
}
@@ -1150,11 +1161,7 @@ acpi_attach(struct device *parent, struct device *self, void *aux)
aaa.aaa_name = "acpitimer";
aaa.aaa_iot = sc->sc_iot;
aaa.aaa_memt = sc->sc_memt;
-#if 0
- aaa.aaa_pcit = sc->sc_pcit;
- aaa.aaa_smbust = sc->sc_smbust;
-#endif
- config_found(self, &aaa, acpi_print);
+ config_found(&sc->sc_dev, &aaa, acpi_print);
}
#endif /* SMALL_KERNEL */
@@ -1167,12 +1174,8 @@ acpi_attach(struct device *parent, struct device *self, void *aux)
memset(&aaa, 0, sizeof(aaa));
aaa.aaa_iot = sc->sc_iot;
aaa.aaa_memt = sc->sc_memt;
- #if 0
- aaa.aaa_pcit = sc->sc_pcit;
- aaa.aaa_smbust = sc->sc_smbust;
- #endif
aaa.aaa_table = entry->q_table;
- config_found_sm(self, &aaa, acpi_print, acpi_submatch);
+ config_found_sm(&sc->sc_dev, &aaa, acpi_print, acpi_submatch);
}
/* initialize runtime environment */
@@ -3402,4 +3405,5 @@ acpikqfilter(dev_t dev, struct knote *kn)
{
return (ENXIO);
}
+
#endif /* SMALL_KERNEL */
diff --git a/sys/dev/acpi/acpivar.h b/sys/dev/acpi/acpivar.h
index 82fc12ba740..451bb10c7f1 100644
--- a/sys/dev/acpi/acpivar.h
+++ b/sys/dev/acpi/acpivar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: acpivar.h,v 1.90 2018/05/17 20:21:15 kettenis Exp $ */
+/* $OpenBSD: acpivar.h,v 1.91 2018/06/25 22:33:24 kettenis Exp $ */
/*
* Copyright (c) 2005 Thorsten Lockert <tholo@sigmasoft.com>
*
@@ -25,7 +25,8 @@
#include <sys/timeout.h>
#include <sys/rwlock.h>
-#include <machine/biosvar.h>
+
+#include <machine/bus.h>
#include "acpipwrres.h"
@@ -296,14 +297,22 @@ struct acpi_dev_rank {
#define ACPI_IOC_SETSLEEPSTATE _IOW('A', 2, int)
#if defined(_KERNEL)
+
struct acpi_gas;
-int acpi_map_address(struct acpi_softc *, struct acpi_gas *, bus_addr_t, bus_size_t,
- bus_space_handle_t *, bus_space_tag_t *);
+int acpi_map_address(struct acpi_softc *, struct acpi_gas *, bus_addr_t,
+ bus_size_t, bus_space_handle_t *, bus_space_tag_t *);
int acpi_map(paddr_t, size_t, struct acpi_mem_map *);
void acpi_unmap(struct acpi_mem_map *);
+
+int acpi_bus_space_map(bus_space_tag_t, bus_addr_t, bus_size_t, int,
+ bus_space_handle_t *);
+void acpi_bus_space_unmap(bus_space_tag_t, bus_space_handle_t, bus_size_t);
+
+struct bios_attach_args;
int acpi_probe(struct device *, struct cfdata *, struct bios_attach_args *);
u_int acpi_checksum(const void *, size_t);
+void acpi_attach_common(struct acpi_softc *, paddr_t);
void acpi_attach_machdep(struct acpi_softc *);
int acpi_interrupt(void *);
void acpi_powerdown(void);