diff options
author | Mark Kettenis <kettenis@cvs.openbsd.org> | 2018-07-04 20:46:23 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@cvs.openbsd.org> | 2018-07-04 20:46:23 +0000 |
commit | 5122a3c63dc86357891a0e94d2a3f20ae1098312 (patch) | |
tree | 450e14d17a4f288ad09664503fd9cf7e8141b621 | |
parent | 11362c6c7cabcf7e045553f2434744084bf45d08 (diff) |
Properly pass around the PCI "chipset tag" in acpi(4) and refactor
acpimcfg(4) to call an MD initialization functions that sets up a tag for
PCI ECAM.
ok guenther@, mlarkin@, krw@
-rw-r--r-- | sys/arch/amd64/amd64/acpi_machdep.c | 3 | ||||
-rw-r--r-- | sys/arch/amd64/include/pci_machdep.h | 7 | ||||
-rw-r--r-- | sys/arch/amd64/pci/pci_machdep.c | 16 | ||||
-rw-r--r-- | sys/arch/i386/i386/acpi_machdep.c | 3 | ||||
-rw-r--r-- | sys/arch/i386/pci/pci_machdep.c | 13 | ||||
-rw-r--r-- | sys/arch/i386/pci/pci_machdep.h | 7 | ||||
-rw-r--r-- | sys/dev/acpi/acpi.c | 8 | ||||
-rw-r--r-- | sys/dev/acpi/acpimcfg.c | 10 | ||||
-rw-r--r-- | sys/dev/acpi/acpivar.h | 6 |
9 files changed, 48 insertions, 25 deletions
diff --git a/sys/arch/amd64/amd64/acpi_machdep.c b/sys/arch/amd64/amd64/acpi_machdep.c index 483a6fb10f9..9c820b718df 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.83 2018/07/01 15:52:12 kettenis Exp $ */ +/* $OpenBSD: acpi_machdep.c,v 1.84 2018/07/04 20:46:21 kettenis Exp $ */ /* * Copyright (c) 2005 Thorsten Lockert <tholo@sigmasoft.com> * @@ -97,6 +97,7 @@ acpi_attach(struct device *parent, struct device *self, void *aux) sc->sc_iot = ba->ba_iot; sc->sc_memt = ba->ba_memt; sc->sc_dmat = &pci_bus_dma_tag; + sc->sc_pc = NULL; /* Legacy 0xcf8/0xcfc access mechanism */ acpi_attach_common(sc, ba->ba_acpipbase); } diff --git a/sys/arch/amd64/include/pci_machdep.h b/sys/arch/amd64/include/pci_machdep.h index 27b833b52cc..a919dfd77e2 100644 --- a/sys/arch/amd64/include/pci_machdep.h +++ b/sys/arch/amd64/include/pci_machdep.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pci_machdep.h,v 1.25 2016/05/04 14:30:00 kettenis Exp $ */ +/* $OpenBSD: pci_machdep.h,v 1.26 2018/07/04 20:46:22 kettenis Exp $ */ /* $NetBSD: pci_machdep.h,v 1.1 2003/02/26 21:26:11 fvdl Exp $ */ /* @@ -59,9 +59,6 @@ typedef struct { * amd64-specific PCI variables and functions. * NOT TO BE USED DIRECTLY BY MACHINE INDEPENDENT CODE. */ -extern bus_addr_t pci_mcfg_addr; -extern int pci_mcfg_min_bus, pci_mcfg_max_bus; - struct pci_attach_args; extern struct extent *pciio_ex; @@ -98,6 +95,8 @@ void pci_dev_postattach(struct device *, struct pci_attach_args *); pcireg_t pci_min_powerstate(pci_chipset_tag_t, pcitag_t); void pci_set_powerstate_md(pci_chipset_tag_t, pcitag_t, int, int); +pci_chipset_tag_t pci_mcfg_init(bus_space_tag_t, bus_addr_t, int, int); + /* * ALL OF THE FOLLOWING ARE MACHINE-DEPENDENT, AND SHOULD NOT BE USED * BY PORTABLE CODE. diff --git a/sys/arch/amd64/pci/pci_machdep.c b/sys/arch/amd64/pci/pci_machdep.c index 2ea97e1ab36..5e05c750a0c 100644 --- a/sys/arch/amd64/pci/pci_machdep.c +++ b/sys/arch/amd64/pci/pci_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pci_machdep.c,v 1.67 2017/10/14 04:44:43 jsg Exp $ */ +/* $OpenBSD: pci_machdep.c,v 1.68 2018/07/04 20:46:22 kettenis Exp $ */ /* $NetBSD: pci_machdep.c,v 1.3 2003/05/07 21:33:58 fvdl Exp $ */ /*- @@ -99,9 +99,8 @@ */ bus_addr_t pci_mcfg_addr; int pci_mcfg_min_bus, pci_mcfg_max_bus; -bus_space_tag_t pci_mcfgt = X86_BUS_SPACE_MEM; +bus_space_tag_t pci_mcfgt; bus_space_handle_t pci_mcfgh[256]; -void pci_mcfg_map_bus(int); struct mutex pci_conf_lock = MUTEX_INITIALIZER(IPL_HIGH); @@ -141,6 +140,17 @@ struct bus_dma_tag pci_bus_dma_tag = { _bus_dmamem_mmap, }; +pci_chipset_tag_t +pci_mcfg_init(bus_space_tag_t iot, bus_addr_t addr, int min_bus, int max_bus) +{ + pci_mcfgt = iot; + pci_mcfg_addr = addr; + pci_mcfg_min_bus = min_bus; + pci_mcfg_max_bus = max_bus; + + return NULL; +} + void pci_attach_hook(struct device *parent, struct device *self, struct pcibus_attach_args *pba) diff --git a/sys/arch/i386/i386/acpi_machdep.c b/sys/arch/i386/i386/acpi_machdep.c index 3f2420cb51e..51c67d9267b 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.67 2018/07/01 15:52:12 kettenis Exp $ */ +/* $OpenBSD: acpi_machdep.c,v 1.68 2018/07/04 20:46:22 kettenis Exp $ */ /* * Copyright (c) 2005 Thorsten Lockert <tholo@sigmasoft.com> * @@ -107,6 +107,7 @@ acpi_attach(struct device *parent, struct device *self, void *aux) sc->sc_iot = ba->ba_iot; sc->sc_memt = ba->ba_memt; sc->sc_dmat = &pci_bus_dma_tag; + sc->sc_pc = NULL; /* Legacy 0xcf8/0xcfc access mechanism */ acpi_attach_common(sc, ba->ba_acpipbase); } diff --git a/sys/arch/i386/pci/pci_machdep.c b/sys/arch/i386/pci/pci_machdep.c index 231e6a984b9..5973a6100cc 100644 --- a/sys/arch/i386/pci/pci_machdep.c +++ b/sys/arch/i386/pci/pci_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pci_machdep.c,v 1.82 2017/09/08 05:36:51 deraadt Exp $ */ +/* $OpenBSD: pci_machdep.c,v 1.83 2018/07/04 20:46:22 kettenis Exp $ */ /* $NetBSD: pci_machdep.c,v 1.28 1997/06/06 23:29:17 thorpej Exp $ */ /*- @@ -191,6 +191,17 @@ struct bus_dma_tag pci_bus_dma_tag = { _bus_dmamem_mmap, }; +pci_chipset_tag_t +pci_mcfg_init(bus_space_tag_t iot, bus_addr_t addr, int min_bus, int max_bus) +{ + pci_mcfgt = iot; + pci_mcfg_addr = addr; + pci_mcfg_min_bus = min_bus; + pci_mcfg_max_bus = max_bus; + + return NULL; +} + void pci_attach_hook(struct device *parent, struct device *self, struct pcibus_attach_args *pba) diff --git a/sys/arch/i386/pci/pci_machdep.h b/sys/arch/i386/pci/pci_machdep.h index 283147033ca..682909eac28 100644 --- a/sys/arch/i386/pci/pci_machdep.h +++ b/sys/arch/i386/pci/pci_machdep.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pci_machdep.h,v 1.28 2016/05/04 14:30:00 kettenis Exp $ */ +/* $OpenBSD: pci_machdep.h,v 1.29 2018/07/04 20:46:22 kettenis Exp $ */ /* $NetBSD: pci_machdep.h,v 1.7 1997/06/06 23:29:18 thorpej Exp $ */ /* @@ -75,9 +75,6 @@ struct { * NOT TO BE USED DIRECTLY BY MACHINE INDEPENDENT CODE. */ extern int pci_mode; -extern bus_addr_t pci_mcfg_addr; -extern int pci_mcfg_min_bus, pci_mcfg_max_bus; - int pci_mode_detect(void); extern struct extent *pciio_ex; @@ -114,6 +111,8 @@ void pci_dev_postattach(struct device *, struct pci_attach_args *); pcireg_t pci_min_powerstate(pci_chipset_tag_t, pcitag_t); void pci_set_powerstate_md(pci_chipset_tag_t, pcitag_t, int, int); +pci_chipset_tag_t pci_mcfg_init(bus_space_tag_t, bus_addr_t, int, int); + /* * Section 6.2.4, `Miscellaneous Functions' of the PIC Specification, * says that 255 means `unknown' or `no connection' to the interrupt diff --git a/sys/dev/acpi/acpi.c b/sys/dev/acpi/acpi.c index d6d5f4d5a9e..458d3594c7e 100644 --- a/sys/dev/acpi/acpi.c +++ b/sys/dev/acpi/acpi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: acpi.c,v 1.352 2018/07/01 15:52:12 kettenis Exp $ */ +/* $OpenBSD: acpi.c,v 1.353 2018/07/04 20:46:22 kettenis Exp $ */ /* * Copyright (c) 2005 Thorsten Lockert <tholo@sigmasoft.com> * Copyright (c) 2005 Jordan Hargrave <jordan@openbsd.org> @@ -352,7 +352,7 @@ acpi_gasio(struct acpi_softc *sc, int iodir, int iospace, uint64_t address, return (0); } - pc = NULL; + pc = sc->sc_pc; tag = pci_make_tag(pc, ACPI_PCI_BUS(address), ACPI_PCI_DEV(address), ACPI_PCI_FN(address)); @@ -540,7 +540,7 @@ acpi_getpci(struct aml_node *node, void *arg) struct acpi_pci *pci, *ppci; struct aml_value res; struct acpi_softc *sc = arg; - pci_chipset_tag_t pc = NULL; + pci_chipset_tag_t pc = sc->sc_pc; pcitag_t tag; uint64_t val; uint32_t reg; @@ -776,7 +776,7 @@ int acpi_pci_notify(struct aml_node *node, int ntype, void *arg) { struct acpi_pci *pdev = arg; - pci_chipset_tag_t pc = NULL; + pci_chipset_tag_t pc = acpi_softc->sc_pc; pcitag_t tag; pcireg_t reg; int offset; diff --git a/sys/dev/acpi/acpimcfg.c b/sys/dev/acpi/acpimcfg.c index 23772cae0aa..311016dbd5e 100644 --- a/sys/dev/acpi/acpimcfg.c +++ b/sys/dev/acpi/acpimcfg.c @@ -1,4 +1,4 @@ -/* $OpenBSD: acpimcfg.c,v 1.2 2011/01/05 22:29:31 kettenis Exp $ */ +/* $OpenBSD: acpimcfg.c,v 1.3 2018/07/04 20:46:22 kettenis Exp $ */ /* * Copyright (c) 2010 Mark Kettenis <kettenis@openbsd.org> * @@ -19,8 +19,6 @@ #include <sys/systm.h> #include <sys/device.h> -#include <machine/apicvar.h> - #include <dev/acpi/acpireg.h> #include <dev/acpi/acpivar.h> #include <dev/pci/pcivar.h> @@ -61,6 +59,7 @@ acpimcfg_match(struct device *parent, void *match, void *aux) void acpimcfg_attach(struct device *parent, struct device *self, void *aux) { + struct acpi_softc *sc = (struct acpi_softc *)parent; struct acpi_attach_args *aaa = aux; struct acpi_mcfg *mcfg = (struct acpi_mcfg *)aaa->aaa_table; @@ -74,7 +73,6 @@ acpimcfg_attach(struct device *parent, struct device *self, void *aux) if (mcfg->min_bus_number == mcfg->max_bus_number) return; - pci_mcfg_addr = mcfg->base_address; - pci_mcfg_min_bus = mcfg->min_bus_number; - pci_mcfg_max_bus = mcfg->max_bus_number; + sc->sc_pc = pci_mcfg_init(aaa->aaa_memt, mcfg->base_address, + mcfg->min_bus_number, mcfg->max_bus_number); } diff --git a/sys/dev/acpi/acpivar.h b/sys/dev/acpi/acpivar.h index 121a28edcdd..575b04d5986 100644 --- a/sys/dev/acpi/acpivar.h +++ b/sys/dev/acpi/acpivar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: acpivar.h,v 1.94 2018/07/01 10:27:34 kettenis Exp $ */ +/* $OpenBSD: acpivar.h,v 1.95 2018/07/04 20:46:22 kettenis Exp $ */ /* * Copyright (c) 2005 Thorsten Lockert <tholo@sigmasoft.com> * @@ -28,6 +28,8 @@ #include <machine/bus.h> +#include <dev/pci/pcivar.h> + #include "acpipwrres.h" /* #define ACPI_DEBUG */ @@ -207,6 +209,8 @@ struct acpi_softc { bus_space_tag_t sc_memt; bus_dma_tag_t sc_dmat; + pci_chipset_tag_t sc_pc; /* XXX assume single segment */ + /* * First-level ACPI tables */ |