From owner-svn-src-head@FreeBSD.ORG Fri Jun 28 05:01:26 2013 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 50CF045A; Fri, 28 Jun 2013 05:01:26 +0000 (UTC) (envelope-from grehan@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 43B721219; Fri, 28 Jun 2013 05:01:26 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r5S51QnR018842; Fri, 28 Jun 2013 05:01:26 GMT (envelope-from grehan@svn.freebsd.org) Received: (from grehan@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r5S51Q3h018841; Fri, 28 Jun 2013 05:01:26 GMT (envelope-from grehan@svn.freebsd.org) Message-Id: <201306280501.r5S51Q3h018841@svn.freebsd.org> From: Peter Grehan Date: Fri, 28 Jun 2013 05:01:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r252331 - head/usr.sbin/bhyve X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 28 Jun 2013 05:01:26 -0000 Author: grehan Date: Fri Jun 28 05:01:25 2013 New Revision: 252331 URL: http://svnweb.freebsd.org/changeset/base/252331 Log: Allow the PCI config address register to be read. The Linux kernel does this. Also remove an unused header file. Submitted by: tycho nightingale at pluribusnetworks com Reviewed by: neel Modified: head/usr.sbin/bhyve/pci_emul.c Modified: head/usr.sbin/bhyve/pci_emul.c ============================================================================== --- head/usr.sbin/bhyve/pci_emul.c Fri Jun 28 03:51:20 2013 (r252330) +++ head/usr.sbin/bhyve/pci_emul.c Fri Jun 28 05:01:25 2013 (r252331) @@ -47,13 +47,14 @@ __FBSDID("$FreeBSD$"); #include "bhyverun.h" #include "inout.h" #include "mem.h" -#include "mptbl.h" #include "pci_emul.h" #include "ioapic.h" #define CONF1_ADDR_PORT 0x0cf8 #define CONF1_DATA_PORT 0x0cfc +#define CONF1_ENABLE 0x80000000ul + #define CFGWRITE(pi,off,val,b) \ do { \ if ((b) == 1) { \ @@ -1224,20 +1225,29 @@ pci_emul_cfgaddr(struct vmctx *ctx, int { uint32_t x; - assert(!in); - - if (bytes != 4) - return (-1); + if (bytes != 4) { + if (in) + *eax = (bytes == 2) ? 0xffff : 0xff; + return (0); + } - x = *eax; - cfgoff = x & PCI_REGMAX; - cfgfunc = (x >> 8) & PCI_FUNCMAX; - cfgslot = (x >> 11) & PCI_SLOTMAX; - cfgbus = (x >> 16) & PCI_BUSMAX; + if (in) { + x = (cfgbus << 16) | + (cfgslot << 11) | + (cfgfunc << 8) | + cfgoff; + *eax = x | CONF1_ENABLE; + } else { + x = *eax; + cfgoff = x & PCI_REGMAX; + cfgfunc = (x >> 8) & PCI_FUNCMAX; + cfgslot = (x >> 11) & PCI_SLOTMAX; + cfgbus = (x >> 16) & PCI_BUSMAX; + } return (0); } -INOUT_PORT(pci_cfgaddr, CONF1_ADDR_PORT, IOPORT_F_OUT, pci_emul_cfgaddr); +INOUT_PORT(pci_cfgaddr, CONF1_ADDR_PORT, IOPORT_F_INOUT, pci_emul_cfgaddr); static uint32_t bits_changed(uint32_t old, uint32_t new, uint32_t mask)