Changeset View
Changeset View
Standalone View
Standalone View
usr.sbin/bhyve/pci_hostbridge.c
| Show All 25 Lines | |||||
| * SUCH DAMAGE. | * SUCH DAMAGE. | ||||
| * | * | ||||
| * $FreeBSD$ | * $FreeBSD$ | ||||
| */ | */ | ||||
| #include <sys/cdefs.h> | #include <sys/cdefs.h> | ||||
| __FBSDID("$FreeBSD$"); | __FBSDID("$FreeBSD$"); | ||||
| #include <stdlib.h> | |||||
| #include "config.h" | |||||
| #include "pci_emul.h" | #include "pci_emul.h" | ||||
| static int | static int | ||||
| pci_hostbridge_init(struct vmctx *ctx, struct pci_devinst *pi, char *opts) | pci_hostbridge_init(struct vmctx *ctx, struct pci_devinst *pi, nvlist_t *nvl) | ||||
| { | { | ||||
| const char *value; | |||||
| u_int vendor, device; | |||||
| vendor = 0x1275; /* NetApp */ | |||||
| device = 0x1275; /* NetApp */ | |||||
| value = get_config_value_node(nvl, "vendor"); | |||||
| if (value != NULL) | |||||
| vendor = strtol(value, NULL, 0); | |||||
| value = get_config_value_node(nvl, "device"); | |||||
| if (value != NULL) | |||||
| device = strtol(value, NULL, 0); | |||||
| /* config space */ | /* config space */ | ||||
| pci_set_cfgdata16(pi, PCIR_VENDOR, 0x1275); /* NetApp */ | pci_set_cfgdata16(pi, PCIR_VENDOR, vendor); | ||||
| pci_set_cfgdata16(pi, PCIR_DEVICE, 0x1275); /* NetApp */ | pci_set_cfgdata16(pi, PCIR_DEVICE, device); | ||||
| pci_set_cfgdata8(pi, PCIR_HDRTYPE, PCIM_HDRTYPE_NORMAL); | pci_set_cfgdata8(pi, PCIR_HDRTYPE, PCIM_HDRTYPE_NORMAL); | ||||
| pci_set_cfgdata8(pi, PCIR_CLASS, PCIC_BRIDGE); | pci_set_cfgdata8(pi, PCIR_CLASS, PCIC_BRIDGE); | ||||
| pci_set_cfgdata8(pi, PCIR_SUBCLASS, PCIS_BRIDGE_HOST); | pci_set_cfgdata8(pi, PCIR_SUBCLASS, PCIS_BRIDGE_HOST); | ||||
| pci_emul_add_pciecap(pi, PCIEM_TYPE_ROOT_PORT); | pci_emul_add_pciecap(pi, PCIEM_TYPE_ROOT_PORT); | ||||
| return (0); | return (0); | ||||
| } | } | ||||
| static int | static int | ||||
| pci_amd_hostbridge_init(struct vmctx *ctx, struct pci_devinst *pi, char *opts) | pci_amd_hostbridge_legacy_config(nvlist_t *nvl, const char *opts) | ||||
| { | { | ||||
| (void) pci_hostbridge_init(ctx, pi, opts); | |||||
| pci_set_cfgdata16(pi, PCIR_VENDOR, 0x1022); /* AMD */ | |||||
| pci_set_cfgdata16(pi, PCIR_DEVICE, 0x7432); /* made up */ | |||||
| set_config_value_node(nvl, "vendor", "0x1022"); /* AMD */ | |||||
| set_config_value_node(nvl, "device", "0x7432"); /* made up */ | |||||
| return (0); | return (0); | ||||
| } | } | ||||
| struct pci_devemu pci_de_amd_hostbridge = { | struct pci_devemu pci_de_amd_hostbridge = { | ||||
| .pe_emu = "amd_hostbridge", | .pe_emu = "amd_hostbridge", | ||||
| .pe_init = pci_amd_hostbridge_init, | .pe_legacy_config = pci_amd_hostbridge_legacy_config, | ||||
| .pe_alias = "hostbridge", | |||||
| }; | }; | ||||
| PCI_EMUL_SET(pci_de_amd_hostbridge); | PCI_EMUL_SET(pci_de_amd_hostbridge); | ||||
| struct pci_devemu pci_de_hostbridge = { | struct pci_devemu pci_de_hostbridge = { | ||||
| .pe_emu = "hostbridge", | .pe_emu = "hostbridge", | ||||
| .pe_init = pci_hostbridge_init, | .pe_init = pci_hostbridge_init, | ||||
| }; | }; | ||||
| PCI_EMUL_SET(pci_de_hostbridge); | PCI_EMUL_SET(pci_de_hostbridge); | ||||