aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorvin Köhne <corvink@FreeBSD.org>2023-02-06 10:13:56 +0000
committerCorvin Köhne <corvink@FreeBSD.org>2023-04-05 10:00:39 +0000
commitab64356b1c9d5c30875303c231c772df553d3bb2 (patch)
treea5a15ef308c9f7ce9c3cdaf787ea366a00e63974
parentee3a7907bb987b104246efd149c4af251e7bc402 (diff)
downloadsrc-ab64356b1c9d5c30875303c231c772df553d3bb2.tar.gz
src-ab64356b1c9d5c30875303c231c772df553d3bb2.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 (cherry picked from commit b72e06b13ee08b94a3e74ac2473e889aeb7a3d1a)
-rw-r--r--usr.sbin/bhyve/bhyve_config.511
-rw-r--r--usr.sbin/bhyve/pci_hostbridge.c17
2 files changed, 22 insertions, 6 deletions
diff --git a/usr.sbin/bhyve/bhyve_config.5 b/usr.sbin/bhyve/bhyve_config.5
index 31f848740aa8..9482d1260e05 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);
}