diff options
author | neel <neel@FreeBSD.org> | 2013-11-23 03:56:03 +0000 |
---|---|---|
committer | neel <neel@FreeBSD.org> | 2013-11-23 03:56:03 +0000 |
commit | 3b87354d1ea49068db130b4218c016fcc20cb9e2 (patch) | |
tree | 7fad39ddd3dfbac97b9f8929b0bd760f2adf73c2 /usr.sbin | |
parent | f19a97b48c8e5307668a5fa8de2acb82337c068c (diff) | |
download | FreeBSD-src-3b87354d1ea49068db130b4218c016fcc20cb9e2.zip FreeBSD-src-3b87354d1ea49068db130b4218c016fcc20cb9e2.tar.gz |
Add an ioctl to assert and deassert an ioapic pin atomically. This will be used
to inject edge triggered legacy interrupts into the guest.
Start using the new API in device models that use edge triggered interrupts:
viz. the 8254 timer and the LPC/uart device emulation.
Submitted by: Tycho Nightingale (tycho.nightingale@pluribusnetworks.com)
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/bhyve/pci_emul.c | 12 | ||||
-rw-r--r-- | usr.sbin/bhyve/pci_emul.h | 1 | ||||
-rw-r--r-- | usr.sbin/bhyve/pci_lpc.c | 11 | ||||
-rw-r--r-- | usr.sbin/bhyve/pit_8254.c | 3 |
4 files changed, 17 insertions, 10 deletions
diff --git a/usr.sbin/bhyve/pci_emul.c b/usr.sbin/bhyve/pci_emul.c index fd087fa..c7086dd 100644 --- a/usr.sbin/bhyve/pci_emul.c +++ b/usr.sbin/bhyve/pci_emul.c @@ -1135,7 +1135,11 @@ pci_lintr_assert(struct pci_devinst *pi) { assert(pi->pi_lintr_pin >= 0); - vm_ioapic_assert_irq(pi->pi_vmctx, pi->pi_lintr_pin); + + if (pi->pi_lintr_state == 0) { + pi->pi_lintr_state = 1; + vm_ioapic_assert_irq(pi->pi_vmctx, pi->pi_lintr_pin); + } } void @@ -1143,7 +1147,11 @@ pci_lintr_deassert(struct pci_devinst *pi) { assert(pi->pi_lintr_pin >= 0); - vm_ioapic_deassert_irq(pi->pi_vmctx, pi->pi_lintr_pin); + + if (pi->pi_lintr_state == 1) { + pi->pi_lintr_state = 0; + vm_ioapic_deassert_irq(pi->pi_vmctx, pi->pi_lintr_pin); + } } /* diff --git a/usr.sbin/bhyve/pci_emul.h b/usr.sbin/bhyve/pci_emul.h index ebcf834..6a1d757 100644 --- a/usr.sbin/bhyve/pci_emul.h +++ b/usr.sbin/bhyve/pci_emul.h @@ -104,6 +104,7 @@ struct pci_devinst { struct vmctx *pi_vmctx; uint8_t pi_bus, pi_slot, pi_func; int8_t pi_lintr_pin; + int8_t pi_lintr_state; char pi_name[PI_NAMESZ]; int pi_bar_getsize; diff --git a/usr.sbin/bhyve/pci_lpc.c b/usr.sbin/bhyve/pci_lpc.c index 5dc79e0..4157c5c 100644 --- a/usr.sbin/bhyve/pci_lpc.c +++ b/usr.sbin/bhyve/pci_lpc.c @@ -94,17 +94,16 @@ lpc_uart_intr_assert(void *arg) assert(sc->irq >= 0); - vm_ioapic_assert_irq(lpc_bridge->pi_vmctx, sc->irq); + vm_ioapic_pulse_irq(lpc_bridge->pi_vmctx, sc->irq); } static void lpc_uart_intr_deassert(void *arg) { - struct lpc_uart_softc *sc = arg; - - assert(sc->irq >= 0); - - vm_ioapic_deassert_irq(lpc_bridge->pi_vmctx, sc->irq); + /* + * The COM devices on the LPC bus generate edge triggered interrupts, + * so nothing more to do here. + */ } static int diff --git a/usr.sbin/bhyve/pit_8254.c b/usr.sbin/bhyve/pit_8254.c index fd05b00..9ecb565 100644 --- a/usr.sbin/bhyve/pit_8254.c +++ b/usr.sbin/bhyve/pit_8254.c @@ -105,8 +105,7 @@ pit_mevent_cb(int fd, enum ev_type type, void *param) pit_mev_count++; - vm_ioapic_assert_irq(c->ctx, 2); - vm_ioapic_deassert_irq(c->ctx, 2); + vm_ioapic_pulse_irq(c->ctx, 2); /* * Delete the timer for one-shots |