diff options
author | Jason Baron <jbaron@redhat.com> | 2012-11-14 15:54:02 -0500 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2012-11-26 09:35:35 -0600 |
commit | d8ee03843fcacfb70c0260af74f20ba9808d4f2e (patch) | |
tree | 4eb48d62260481feafb91cdce31b217c13de5563 /hw/kvm/ioapic.c | |
parent | a39e356458335418973ca7d388c02712145cd177 (diff) | |
download | qemu-d8ee03843fcacfb70c0260af74f20ba9808d4f2e.zip qemu-d8ee03843fcacfb70c0260af74f20ba9808d4f2e.tar.gz qemu-d8ee03843fcacfb70c0260af74f20ba9808d4f2e.tar.bz2 |
pc_piix: Move kvm irq routing functions out of pc_piix.c
Rename: kvm_piix3_gsi_handlei() -> kvm_pc_gsi_handler()
kvm_piix3_setup_irq_routing() -> kvm_pc_setup_irq_routing()
This is in preparation for other users, namely q35 at this time.
Signed-off-by: Jason Baron <jbaron@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'hw/kvm/ioapic.c')
-rw-r--r-- | hw/kvm/ioapic.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/hw/kvm/ioapic.c b/hw/kvm/ioapic.c index 6c3b8fe..f95c157 100644 --- a/hw/kvm/ioapic.c +++ b/hw/kvm/ioapic.c @@ -15,6 +15,46 @@ #include "hw/apic_internal.h" #include "kvm.h" +/* PC Utility function */ +void kvm_pc_setup_irq_routing(bool pci_enabled) +{ + KVMState *s = kvm_state; + int i; + + if (kvm_check_extension(s, KVM_CAP_IRQ_ROUTING)) { + for (i = 0; i < 8; ++i) { + if (i == 2) { + continue; + } + kvm_irqchip_add_irq_route(s, i, KVM_IRQCHIP_PIC_MASTER, i); + } + for (i = 8; i < 16; ++i) { + kvm_irqchip_add_irq_route(s, i, KVM_IRQCHIP_PIC_SLAVE, i - 8); + } + if (pci_enabled) { + for (i = 0; i < 24; ++i) { + if (i == 0) { + kvm_irqchip_add_irq_route(s, i, KVM_IRQCHIP_IOAPIC, 2); + } else if (i != 2) { + kvm_irqchip_add_irq_route(s, i, KVM_IRQCHIP_IOAPIC, i); + } + } + } + } +} + +void kvm_pc_gsi_handler(void *opaque, int n, int level) +{ + GSIState *s = opaque; + + if (n < ISA_NUM_IRQS) { + /* Kernel will forward to both PIC and IOAPIC */ + qemu_set_irq(s->i8259_irq[n], level); + } else { + qemu_set_irq(s->ioapic_irq[n], level); + } +} + typedef struct KVMIOAPICState KVMIOAPICState; struct KVMIOAPICState { |