diff options
author | grehan <grehan@FreeBSD.org> | 2013-06-28 05:01:25 +0000 |
---|---|---|
committer | grehan <grehan@FreeBSD.org> | 2013-06-28 05:01:25 +0000 |
commit | 535e6386b1d3a14d9f696331bab61b9c0d4af4cc (patch) | |
tree | 1460870a14211de66e2839aa582cdcb7a226a359 /usr.sbin | |
parent | e725dd5c1ef985f6374f7a36ebdaaf10964b0131 (diff) | |
download | FreeBSD-src-535e6386b1d3a14d9f696331bab61b9c0d4af4cc.zip FreeBSD-src-535e6386b1d3a14d9f696331bab61b9c0d4af4cc.tar.gz |
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
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 37f1778..a30dde5 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) |