1*bf21cd93STycho Nightingale /*- 2*bf21cd93STycho Nightingale * Copyright (c) 2011 NetApp, Inc. 3*bf21cd93STycho Nightingale * All rights reserved. 4*bf21cd93STycho Nightingale * 5*bf21cd93STycho Nightingale * Redistribution and use in source and binary forms, with or without 6*bf21cd93STycho Nightingale * modification, are permitted provided that the following conditions 7*bf21cd93STycho Nightingale * are met: 8*bf21cd93STycho Nightingale * 1. Redistributions of source code must retain the above copyright 9*bf21cd93STycho Nightingale * notice, this list of conditions and the following disclaimer. 10*bf21cd93STycho Nightingale * 2. Redistributions in binary form must reproduce the above copyright 11*bf21cd93STycho Nightingale * notice, this list of conditions and the following disclaimer in the 12*bf21cd93STycho Nightingale * documentation and/or other materials provided with the distribution. 13*bf21cd93STycho Nightingale * 14*bf21cd93STycho Nightingale * THIS SOFTWARE IS PROVIDED BY NETAPP, INC ``AS IS'' AND 15*bf21cd93STycho Nightingale * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16*bf21cd93STycho Nightingale * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17*bf21cd93STycho Nightingale * ARE DISCLAIMED. IN NO EVENT SHALL NETAPP, INC OR CONTRIBUTORS BE LIABLE 18*bf21cd93STycho Nightingale * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19*bf21cd93STycho Nightingale * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20*bf21cd93STycho Nightingale * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21*bf21cd93STycho Nightingale * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22*bf21cd93STycho Nightingale * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23*bf21cd93STycho Nightingale * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24*bf21cd93STycho Nightingale * SUCH DAMAGE. 25*bf21cd93STycho Nightingale * 26*bf21cd93STycho Nightingale * $FreeBSD: head/usr.sbin/bhyve/pci_hostbridge.c 283264 2015-05-21 20:11:52Z tychon $ 27*bf21cd93STycho Nightingale */ 28*bf21cd93STycho Nightingale 29*bf21cd93STycho Nightingale #include <sys/cdefs.h> 30*bf21cd93STycho Nightingale __FBSDID("$FreeBSD: head/usr.sbin/bhyve/pci_hostbridge.c 283264 2015-05-21 20:11:52Z tychon $"); 31*bf21cd93STycho Nightingale 32*bf21cd93STycho Nightingale #include "pci_emul.h" 33*bf21cd93STycho Nightingale 34*bf21cd93STycho Nightingale static int 35*bf21cd93STycho Nightingale pci_hostbridge_init(struct vmctx *ctx, struct pci_devinst *pi, char *opts) 36*bf21cd93STycho Nightingale { 37*bf21cd93STycho Nightingale 38*bf21cd93STycho Nightingale /* config space */ 39*bf21cd93STycho Nightingale pci_set_cfgdata16(pi, PCIR_VENDOR, 0x1275); /* NetApp */ 40*bf21cd93STycho Nightingale pci_set_cfgdata16(pi, PCIR_DEVICE, 0x1275); /* NetApp */ 41*bf21cd93STycho Nightingale pci_set_cfgdata8(pi, PCIR_HDRTYPE, PCIM_HDRTYPE_NORMAL); 42*bf21cd93STycho Nightingale pci_set_cfgdata8(pi, PCIR_CLASS, PCIC_BRIDGE); 43*bf21cd93STycho Nightingale pci_set_cfgdata8(pi, PCIR_SUBCLASS, PCIS_BRIDGE_HOST); 44*bf21cd93STycho Nightingale 45*bf21cd93STycho Nightingale pci_emul_add_pciecap(pi, PCIEM_TYPE_ROOT_PORT); 46*bf21cd93STycho Nightingale 47*bf21cd93STycho Nightingale return (0); 48*bf21cd93STycho Nightingale } 49*bf21cd93STycho Nightingale 50*bf21cd93STycho Nightingale static int 51*bf21cd93STycho Nightingale pci_amd_hostbridge_init(struct vmctx *ctx, struct pci_devinst *pi, char *opts) 52*bf21cd93STycho Nightingale { 53*bf21cd93STycho Nightingale (void) pci_hostbridge_init(ctx, pi, opts); 54*bf21cd93STycho Nightingale pci_set_cfgdata16(pi, PCIR_VENDOR, 0x1022); /* AMD */ 55*bf21cd93STycho Nightingale pci_set_cfgdata16(pi, PCIR_DEVICE, 0x7432); /* made up */ 56*bf21cd93STycho Nightingale 57*bf21cd93STycho Nightingale return (0); 58*bf21cd93STycho Nightingale } 59*bf21cd93STycho Nightingale 60*bf21cd93STycho Nightingale struct pci_devemu pci_de_amd_hostbridge = { 61*bf21cd93STycho Nightingale .pe_emu = "amd_hostbridge", 62*bf21cd93STycho Nightingale .pe_init = pci_amd_hostbridge_init, 63*bf21cd93STycho Nightingale }; 64*bf21cd93STycho Nightingale PCI_EMUL_SET(pci_de_amd_hostbridge); 65*bf21cd93STycho Nightingale 66*bf21cd93STycho Nightingale struct pci_devemu pci_de_hostbridge = { 67*bf21cd93STycho Nightingale .pe_emu = "hostbridge", 68*bf21cd93STycho Nightingale .pe_init = pci_hostbridge_init, 69*bf21cd93STycho Nightingale }; 70*bf21cd93STycho Nightingale PCI_EMUL_SET(pci_de_hostbridge); 71