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
This commit is contained in:
Corvin Köhne 2023-02-06 11:13:56 +01:00
parent ffaed739a8
commit b72e06b13e
No known key found for this signature in database
GPG Key ID: D854DA56315E026A
2 changed files with 22 additions and 6 deletions

View File

@ -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

View File

@ -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);
}