diff options
author | Mark Kettenis <kettenis@cvs.openbsd.org> | 2011-01-04 21:17:50 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@cvs.openbsd.org> | 2011-01-04 21:17:50 +0000 |
commit | 520623cefde5dd43125b0e3bd121266079514407 (patch) | |
tree | de8f57eddbfc38a2b036b8caeef560e5e8a0c342 /sys/dev/acpi | |
parent | e18c67189da470f1eb4149eae8e689e05da21f2e (diff) |
Add support for Memory Mapped Configuration space access. This gives us
access to PCIe extended configuration space access on modern i386 and amd64
machines.
Diffstat (limited to 'sys/dev/acpi')
-rw-r--r-- | sys/dev/acpi/acpimcfg.c | 73 | ||||
-rw-r--r-- | sys/dev/acpi/acpireg.h | 13 | ||||
-rw-r--r-- | sys/dev/acpi/files.acpi | 7 |
3 files changed, 91 insertions, 2 deletions
diff --git a/sys/dev/acpi/acpimcfg.c b/sys/dev/acpi/acpimcfg.c new file mode 100644 index 00000000000..ee265db9918 --- /dev/null +++ b/sys/dev/acpi/acpimcfg.c @@ -0,0 +1,73 @@ +/* $OpenBSD: acpimcfg.c,v 1.1 2011/01/04 21:17:49 kettenis Exp $ */ +/* + * Copyright (c) 2010 Mark Kettenis <kettenis@openbsd.org> + * + * 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 <sys/device.h> + +#include <machine/apicvar.h> + +#include <dev/acpi/acpireg.h> +#include <dev/acpi/acpivar.h> +#include <dev/pci/pcivar.h> + +int acpimcfg_match(struct device *, void *, void *); +void acpimcfg_attach(struct device *, struct device *, void *); + +struct cfattach acpimcfg_ca = { + sizeof(struct device), acpimcfg_match, acpimcfg_attach +}; + +struct cfdriver acpimcfg_cd = { + NULL, "acpimcfg", DV_DULL +}; + +int +acpimcfg_match(struct device *parent, void *match, void *aux) +{ + struct acpi_attach_args *aaa = aux; + struct acpi_table_header *hdr; + + /* + * If we do not have a table, it is not us + */ + if (aaa->aaa_table == NULL) + return (0); + + /* + * If it is an MCFG table, we can attach + */ + hdr = (struct acpi_table_header *)aaa->aaa_table; + if (memcmp(hdr->signature, MCFG_SIG, sizeof(MCFG_SIG) - 1) != 0) + return (0); + + return (1); +} + +void +acpimcfg_attach(struct device *parent, struct device *self, void *aux) +{ + struct acpi_attach_args *aaa = aux; + struct acpi_mcfg *mcfg = (struct acpi_mcfg *)aaa->aaa_table; + + printf(" addr 0x%llx, bus %d-%d\n", mcfg->base_address, + mcfg->min_bus_number, mcfg->max_bus_number); + + pci_mcfg_addr = mcfg->base_address; + pci_mcfg_min_bus = mcfg->min_bus_number; + pci_mcfg_max_bus = mcfg->max_bus_number; +} diff --git a/sys/dev/acpi/acpireg.h b/sys/dev/acpi/acpireg.h index 1669bec11bc..7bbb480485c 100644 --- a/sys/dev/acpi/acpireg.h +++ b/sys/dev/acpi/acpireg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: acpireg.h,v 1.23 2010/07/21 19:35:15 deraadt Exp $ */ +/* $OpenBSD: acpireg.h,v 1.24 2011/01/04 21:17:49 kettenis Exp $ */ /* * Copyright (c) 2005 Thorsten Lockert <tholo@sigmasoft.com> * Copyright (c) 2005 Marco Peereboom <marco@openbsd.org> @@ -380,6 +380,17 @@ struct acpi_hpet { u_int8_t page_protection; } __packed; +struct acpi_mcfg { + struct acpi_table_header hdr; +#define MCFG_SIG "MCFG" + u_int8_t reserved[8]; + u_int64_t base_address; + u_int16_t segment; + u_int8_t min_bus_number; + u_int8_t max_bus_number; + u_int32_t reserved1; +} __packed; + struct acpi_facs { u_int8_t signature[4]; #define FACS_SIG "FACS" diff --git a/sys/dev/acpi/files.acpi b/sys/dev/acpi/files.acpi index 58885dfc2f9..f19855b6cd8 100644 --- a/sys/dev/acpi/files.acpi +++ b/sys/dev/acpi/files.acpi @@ -1,4 +1,4 @@ -# $OpenBSD: files.acpi,v 1.24 2010/07/26 11:29:23 pirofti Exp $ +# $OpenBSD: files.acpi,v 1.25 2011/01/04 21:17:49 kettenis Exp $ # # Config file and device description for machine-independent ACPI code. # Included by ports that need it. @@ -56,6 +56,11 @@ device acpimadt attach acpimadt at acpi file dev/acpi/acpimadt.c acpimadt +# Memory Mapped Configuration Space Address Description Table +device acpimcfg +attach acpimcfg at acpi +file dev/acpi/acpimcfg.c acpimcfg + # PCI Routing Table device acpiprt attach acpiprt at acpi |