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.c41
1 files changed, 30 insertions, 11 deletions
diff --git a/usr.sbin/bhyve/pci_hostbridge.c b/usr.sbin/bhyve/pci_hostbridge.c
index 9fce225bb1d6..df75da4283a5 100644
--- a/usr.sbin/bhyve/pci_hostbridge.c
+++ b/usr.sbin/bhyve/pci_hostbridge.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2011 NetApp, Inc.
* All rights reserved.
@@ -24,20 +24,17 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * $FreeBSD$
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
+#include <err.h>
#include <stdlib.h>
#include "config.h"
#include "pci_emul.h"
static int
-pci_hostbridge_init(struct vmctx *ctx, struct pci_devinst *pi, nvlist_t *nvl)
+pci_hostbridge_init(struct pci_devinst *pi, nvlist_t *nvl)
{
const char *value;
u_int vendor, device;
@@ -48,9 +45,13 @@ pci_hostbridge_init(struct vmctx *ctx, 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);
@@ -65,24 +66,42 @@ pci_hostbridge_init(struct vmctx *ctx, struct pci_devinst *pi, nvlist_t *nvl)
}
static int
-pci_amd_hostbridge_legacy_config(nvlist_t *nvl, const char *opts)
+pci_amd_hostbridge_legacy_config(nvlist_t *nvl, const char *opts __unused)
{
+ 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 */
- set_config_value_node(nvl, "vendor", "0x1022"); /* AMD */
- set_config_value_node(nvl, "devid", "0x7432"); /* made up */
+ return (0);
+}
+#ifdef BHYVE_SNAPSHOT
+static int
+pci_de_snapshot(struct vm_snapshot_meta *meta __unused)
+{
return (0);
}
+#endif
-struct pci_devemu pci_de_amd_hostbridge = {
+static const struct pci_devemu pci_de_amd_hostbridge = {
.pe_emu = "amd_hostbridge",
.pe_legacy_config = pci_amd_hostbridge_legacy_config,
.pe_alias = "hostbridge",
};
PCI_EMUL_SET(pci_de_amd_hostbridge);
-struct pci_devemu pci_de_hostbridge = {
+static const struct pci_devemu pci_de_hostbridge = {
.pe_emu = "hostbridge",
.pe_init = pci_hostbridge_init,
+#ifdef BHYVE_SNAPSHOT
+ .pe_snapshot = pci_de_snapshot,
+#endif
};
PCI_EMUL_SET(pci_de_hostbridge);