Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/acpi Add acpimcfg_conf_valid helper for pcie control...
details: https://anonhg.NetBSD.org/src/rev/15f04825fac6
branches: trunk
changeset: 848603:15f04825fac6
user: jmcneill <jmcneill%NetBSD.org@localhost>
date: Sun Feb 02 16:31:25 2020 +0000
description:
Add acpimcfg_conf_valid helper for pcie controllers with nonstandard
config space layouts.
diffstat:
sys/dev/acpi/acpi_mcfg.c | 29 +++++++++++++++++++++++++++--
sys/dev/acpi/acpi_mcfg.h | 3 ++-
2 files changed, 29 insertions(+), 3 deletions(-)
diffs (64 lines):
diff -r ba3e240a6188 -r 15f04825fac6 sys/dev/acpi/acpi_mcfg.c
--- a/sys/dev/acpi/acpi_mcfg.c Sun Feb 02 16:30:31 2020 +0000
+++ b/sys/dev/acpi/acpi_mcfg.c Sun Feb 02 16:31:25 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_mcfg.c,v 1.17 2019/10/14 00:15:13 jmcneill Exp $ */
+/* $NetBSD: acpi_mcfg.c,v 1.18 2020/02/02 16:31:25 jmcneill Exp $ */
/*-
* Copyright (C) 2015 NONAKA Kimihiro <nonaka%NetBSD.org@localhost>
@@ -28,7 +28,7 @@
#include "opt_pci.h"
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi_mcfg.c,v 1.17 2019/10/14 00:15:13 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_mcfg.c,v 1.18 2020/02/02 16:31:25 jmcneill Exp $");
#include <sys/param.h>
#include <sys/device.h>
@@ -962,3 +962,28 @@
mcfg_ops->ao_write(seg->ms_bst, mb->bsh[dev][func], reg, data);
return 0;
}
+
+bool
+acpimcfg_conf_valid(pci_chipset_tag_t pc, pcitag_t tag, int reg)
+{
+ struct mcfg_segment *seg = NULL;
+ struct mcfg_bus *mb;
+ int bus, dev, func;
+
+ if (!mcfg_inited)
+ return false;
+
+ pci_decompose_tag(pc, tag, &bus, &dev, &func);
+
+ seg = acpimcfg_get_segment(pc, bus);
+ if (seg == NULL)
+ return false;
+
+ mb = &seg->ms_bus[bus - seg->ms_bus_start];
+ if (!PCIDEV_IS_VALID(mb, dev, func))
+ return false;
+ if (!EXTCONF_IS_VALID(mb, dev, func) && reg >= PCI_CONF_SIZE)
+ return false;
+
+ return true;
+}
diff -r ba3e240a6188 -r 15f04825fac6 sys/dev/acpi/acpi_mcfg.h
--- a/sys/dev/acpi/acpi_mcfg.h Sun Feb 02 16:30:31 2020 +0000
+++ b/sys/dev/acpi/acpi_mcfg.h Sun Feb 02 16:31:25 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_mcfg.h,v 1.2 2018/10/15 10:01:32 jmcneill Exp $ */
+/* $NetBSD: acpi_mcfg.h,v 1.3 2020/02/02 16:31:25 jmcneill Exp $ */
/*-
* Copyright (C) 2015 NONAKA Kimihiro <nonaka%NetBSD.org@localhost>
@@ -36,6 +36,7 @@
int acpimcfg_conf_read(pci_chipset_tag_t, pcitag_t, int, pcireg_t *);
int acpimcfg_conf_write(pci_chipset_tag_t, pcitag_t, int, pcireg_t);
+bool acpimcfg_conf_valid(pci_chipset_tag_t, pcitag_t, int);
struct acpimcfg_ops {
/* validate MCFG memory region */
Home |
Main Index |
Thread Index |
Old Index