1221828Sgrehan/*- 2221828Sgrehan * Copyright (c) 2011 NetApp, Inc. 3221828Sgrehan * All rights reserved. 4221828Sgrehan * 5221828Sgrehan * Redistribution and use in source and binary forms, with or without 6221828Sgrehan * modification, are permitted provided that the following conditions 7221828Sgrehan * are met: 8221828Sgrehan * 1. Redistributions of source code must retain the above copyright 9221828Sgrehan * notice, this list of conditions and the following disclaimer. 10221828Sgrehan * 2. Redistributions in binary form must reproduce the above copyright 11221828Sgrehan * notice, this list of conditions and the following disclaimer in the 12221828Sgrehan * documentation and/or other materials provided with the distribution. 13221828Sgrehan * 14221828Sgrehan * THIS SOFTWARE IS PROVIDED BY NETAPP, INC ``AS IS'' AND 15221828Sgrehan * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16221828Sgrehan * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17221828Sgrehan * ARE DISCLAIMED. IN NO EVENT SHALL NETAPP, INC OR CONTRIBUTORS BE LIABLE 18221828Sgrehan * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19221828Sgrehan * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20221828Sgrehan * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21221828Sgrehan * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22221828Sgrehan * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23221828Sgrehan * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24221828Sgrehan * SUCH DAMAGE. 25221828Sgrehan * 26221828Sgrehan * $FreeBSD: releng/11.0/usr.sbin/bhyve/pci_hostbridge.c 283264 2015-05-21 20:11:52Z tychon $ 27221828Sgrehan */ 28221828Sgrehan 29221828Sgrehan#include <sys/cdefs.h> 30221828Sgrehan__FBSDID("$FreeBSD: releng/11.0/usr.sbin/bhyve/pci_hostbridge.c 283264 2015-05-21 20:11:52Z tychon $"); 31221828Sgrehan 32221828Sgrehan#include "pci_emul.h" 33221828Sgrehan 34221828Sgrehanstatic int 35221828Sgrehanpci_hostbridge_init(struct vmctx *ctx, struct pci_devinst *pi, char *opts) 36221828Sgrehan{ 37221828Sgrehan 38221828Sgrehan /* config space */ 39221828Sgrehan pci_set_cfgdata16(pi, PCIR_VENDOR, 0x1275); /* NetApp */ 40221828Sgrehan pci_set_cfgdata16(pi, PCIR_DEVICE, 0x1275); /* NetApp */ 41283264Stychon pci_set_cfgdata8(pi, PCIR_HDRTYPE, PCIM_HDRTYPE_NORMAL); 42221828Sgrehan pci_set_cfgdata8(pi, PCIR_CLASS, PCIC_BRIDGE); 43221828Sgrehan pci_set_cfgdata8(pi, PCIR_SUBCLASS, PCIS_BRIDGE_HOST); 44221828Sgrehan 45246846Sneel pci_emul_add_pciecap(pi, PCIEM_TYPE_ROOT_PORT); 46246846Sneel 47221828Sgrehan return (0); 48221828Sgrehan} 49221828Sgrehan 50256711Sgrehanstatic int 51256711Sgrehanpci_amd_hostbridge_init(struct vmctx *ctx, struct pci_devinst *pi, char *opts) 52256711Sgrehan{ 53256711Sgrehan (void) pci_hostbridge_init(ctx, pi, opts); 54256711Sgrehan pci_set_cfgdata16(pi, PCIR_VENDOR, 0x1022); /* AMD */ 55256711Sgrehan pci_set_cfgdata16(pi, PCIR_DEVICE, 0x7432); /* made up */ 56256711Sgrehan 57256711Sgrehan return (0); 58256711Sgrehan} 59256711Sgrehan 60256711Sgrehanstruct pci_devemu pci_de_amd_hostbridge = { 61256711Sgrehan .pe_emu = "amd_hostbridge", 62256711Sgrehan .pe_init = pci_amd_hostbridge_init, 63256711Sgrehan}; 64256711SgrehanPCI_EMUL_SET(pci_de_amd_hostbridge); 65256711Sgrehan 66221828Sgrehanstruct pci_devemu pci_de_hostbridge = { 67221828Sgrehan .pe_emu = "hostbridge", 68221828Sgrehan .pe_init = pci_hostbridge_init, 69221828Sgrehan}; 70221828SgrehanPCI_EMUL_SET(pci_de_hostbridge); 71