Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 28 Jun 2013 05:01:26 +0000 (UTC)
From:      Peter Grehan <grehan@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r252331 - head/usr.sbin/bhyve
Message-ID:  <201306280501.r5S51Q3h018841@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201306280501.r5S51Q3h018841>