diff options
author | Corvin Köhne <corvink@FreeBSD.org> | 2023-02-06 10:13:56 +0000 |
---|---|---|
committer | Corvin Köhne <corvink@FreeBSD.org> | 2023-03-27 08:10:24 +0000 |
commit | b72e06b13ee08b94a3e74ac2473e889aeb7a3d1a (patch) | |
tree | 2fed1da8a29c0b9ea43901f6fde72b3cc4085544 | |
parent | ffaed739a80319a56d0b1dfd6cedeb3d194ff42c (diff) | |
download | src-b72e06b13ee08b94a3e74ac2473e889aeb7a3d1a.tar.gz src-b72e06b13ee08b94a3e74ac2473e889aeb7a3d1a.zip |
bhyve: make use of helper to read PCI IDs from bhyve config
For compatibilty reasons, the old config values are still supported.
Reviewed by: jhb
MFC after: 1 week
Sponsored by: Beckhoff Automation GmbH & Co. KG
Differential Revision: https://reviews.freebsd.org/D38403
-rw-r--r-- | usr.sbin/bhyve/bhyve_config.5 | 11 | ||||
-rw-r--r-- | usr.sbin/bhyve/pci_hostbridge.c | 17 |
2 files changed, 22 insertions, 6 deletions
diff --git a/usr.sbin/bhyve/bhyve_config.5 b/usr.sbin/bhyve/bhyve_config.5 index 32658c11f9e2..ddfcae8c51d3 100644 --- a/usr.sbin/bhyve/bhyve_config.5 +++ b/usr.sbin/bhyve/bhyve_config.5 @@ -412,12 +412,15 @@ to use standard input and output of the process. .El .Ss Host Bridge Settings -.Bl -column "vendor" "integer" "Default" +.Bl -column "pcireg.*" "integer" "Default" .It Sy Name Ta Sy Format Ta Sy Default Ta Sy Description +.It Va pcireg.* Ta integer Ta Ta +Values of PCI register. +.Bl -column "device" "Default" +.It Sy Name Ta Sy Default .It Va vendor Ta integer Ta 0x1275 Ta -PCI vendor ID. -.It Va devid Ta integer Ta 0x1275 Ta -PCI device ID. +.It Va device Ta integer Ta 0x1275 Ta +.El .El .Ss AHCI Controller Settings AHCI controller devices contain zero or more ports each of which diff --git a/usr.sbin/bhyve/pci_hostbridge.c b/usr.sbin/bhyve/pci_hostbridge.c index f0878d97a77e..cbc61893961b 100644 --- a/usr.sbin/bhyve/pci_hostbridge.c +++ b/usr.sbin/bhyve/pci_hostbridge.c @@ -31,6 +31,7 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); +#include <err.h> #include <stdlib.h> #include "config.h" @@ -48,9 +49,13 @@ pci_hostbridge_init(struct pci_devinst *pi, nvlist_t *nvl) value = get_config_value_node(nvl, "vendor"); if (value != NULL) vendor = strtol(value, NULL, 0); + else + vendor = pci_config_read_reg(NULL, nvl, PCIR_VENDOR, 2, vendor); value = get_config_value_node(nvl, "devid"); if (value != NULL) device = strtol(value, NULL, 0); + else + device = pci_config_read_reg(NULL, nvl, PCIR_DEVICE, 2, device); /* config space */ pci_set_cfgdata16(pi, PCIR_VENDOR, vendor); @@ -67,8 +72,16 @@ pci_hostbridge_init(struct pci_devinst *pi, nvlist_t *nvl) static int pci_amd_hostbridge_legacy_config(nvlist_t *nvl, const char *opts __unused) { - set_config_value_node(nvl, "vendor", "0x1022"); /* AMD */ - set_config_value_node(nvl, "devid", "0x7432"); /* made up */ + nvlist_t *pci_regs; + + pci_regs = create_relative_config_node(nvl, "pcireg"); + if (pci_regs == NULL) { + warnx("amd_hostbridge: failed to create pciregs node"); + return (-1); + } + + set_config_value_node(pci_regs, "vendor", "0x1022"); /* AMD */ + set_config_value_node(pci_regs, "device", "0x7432"); /* made up */ return (0); } |