The diff below shuffles things around to make it easier to add arm64 support later. The main thing is to avoid including <machine/biosvar.h> in <dev/acpi/acpivar.h>, since that header file doesn't exist on arm64. The bulk of acpi_attach() is split out into a new function and the current acpi_match() and acpi_attach() functions are compiled on amd64 and i386 only.
ok? Index: arch/amd64/amd64/acpi_machdep.c =================================================================== RCS file: /cvs/src/sys/arch/amd64/amd64/acpi_machdep.c,v retrieving revision 1.81 diff -u -p -r1.81 acpi_machdep.c --- arch/amd64/amd64/acpi_machdep.c 5 Jun 2018 06:39:10 -0000 1.81 +++ arch/amd64/amd64/acpi_machdep.c 24 Jun 2018 21:58:24 -0000 @@ -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) Index: arch/amd64/amd64/hibernate_machdep.c =================================================================== RCS file: /cvs/src/sys/arch/amd64/amd64/hibernate_machdep.c,v retrieving revision 1.42 diff -u -p -r1.42 hibernate_machdep.c --- arch/amd64/amd64/hibernate_machdep.c 21 Jun 2018 07:33:30 -0000 1.42 +++ arch/amd64/amd64/hibernate_machdep.c 24 Jun 2018 21:58:24 -0000 @@ -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> @@ -41,6 +40,8 @@ #ifdef MULTIPROCESSOR #include <machine/mpbiosvar.h> #endif /* MULTIPROCESSOR */ + +#include <dev/acpi/acpivar.h> #include "acpi.h" #include "wd.h" Index: arch/i386/i386/acpi_machdep.c =================================================================== RCS file: /cvs/src/sys/arch/i386/i386/acpi_machdep.c,v retrieving revision 1.65 diff -u -p -r1.65 acpi_machdep.c --- arch/i386/i386/acpi_machdep.c 31 Mar 2018 13:45:03 -0000 1.65 +++ arch/i386/i386/acpi_machdep.c 24 Jun 2018 21:58:24 -0000 @@ -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> @@ -102,6 +103,20 @@ acpi_unmap(struct acpi_mem_map *handle) { pmap_kremove(handle->baseva, handle->vsize); 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 * Index: arch/i386/i386/hibernate_machdep.c =================================================================== RCS file: /cvs/src/sys/arch/i386/i386/hibernate_machdep.c,v retrieving revision 1.52 diff -u -p -r1.52 hibernate_machdep.c --- arch/i386/i386/hibernate_machdep.c 21 Jun 2018 07:33:30 -0000 1.52 +++ arch/i386/i386/hibernate_machdep.c 24 Jun 2018 21:58:24 -0000 @@ -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> @@ -39,6 +38,8 @@ #ifdef MULTIPROCESSOR #include <machine/mpbiosvar.h> #endif /* MULTIPROCESSOR */ + +#include <dev/acpi/acpivar.h> #include "acpi.h" #include "wd.h" Index: dev/acpi/acpi.c =================================================================== RCS file: /cvs/src/sys/dev/acpi/acpi.c,v retrieving revision 1.344 diff -u -p -r1.344 acpi.c --- dev/acpi/acpi.c 20 May 2018 09:12:35 -0000 1.344 +++ dev/acpi/acpi.c 24 Jun 2018 21:58:25 -0000 @@ -79,8 +79,6 @@ pcireg_t acpi_pci_min_powerstate(pci_chi 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 io } } } - 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, voi 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, #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, struc 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, struc 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, struc 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 */ Index: dev/acpi/acpivar.h =================================================================== RCS file: /cvs/src/sys/dev/acpi/acpivar.h,v retrieving revision 1.90 diff -u -p -r1.90 acpivar.h --- dev/acpi/acpivar.h 17 May 2018 20:21:15 -0000 1.90 +++ dev/acpi/acpivar.h 24 Jun 2018 21:58:25 -0000 @@ -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);