aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin/bhyve/pci_hostbridge.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin/bhyve/pci_hostbridge.c')
-rw-r--r--usr.sbin/bhyve/pci_hostbridge.c17
1 files changed, 15 insertions, 2 deletions
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);
}