diff options
author | Peter Grehan <grehan@FreeBSD.org> | 2013-06-28 05:01:25 +0000 |
---|---|---|
committer | Peter Grehan <grehan@FreeBSD.org> | 2013-06-28 05:01:25 +0000 |
commit | 7554303627b0c866d9be4ac649cd4feaa8886c24 (patch) | |
tree | 1460870a14211de66e2839aa582cdcb7a226a359 /usr.sbin | |
parent | 5f5183664537af80666787b606e005b33d01cdc2 (diff) | |
download | src-7554303627b0c866d9be4ac649cd4feaa8886c24.tar.gz src-7554303627b0c866d9be4ac649cd4feaa8886c24.zip |
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
Notes
Notes:
svn path=/head/; revision=252331
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/bhyve/pci_emul.c | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/usr.sbin/bhyve/pci_emul.c b/usr.sbin/bhyve/pci_emul.c index 37f177801df6..a30dde5a8fcb 100644 --- a/usr.sbin/bhyve/pci_emul.c +++ b/usr.sbin/bhyve/pci_emul.c @@ -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 vcpu, int in, int port, int bytes, { 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) |