summaryrefslogtreecommitdiffstats
path: root/hw/i386/pc.c
diff options
context:
space:
mode:
authorPhilippe Mathieu-Daudé2019-10-18 15:59:09 +0200
committerPaolo Bonzini2019-10-24 14:24:54 +0200
commit4501d317b50e52de090192aab6244060fbe42da0 (patch)
tree4b938b99fc8523547b7304083a11d90fe5319bb3 /hw/i386/pc.c
parenthw/i386/pc: Move gsi_state creation code (diff)
downloadqemu-4501d317b50e52de090192aab6244060fbe42da0.tar.gz
qemu-4501d317b50e52de090192aab6244060fbe42da0.tar.xz
qemu-4501d317b50e52de090192aab6244060fbe42da0.zip
hw/i386/pc: Extract pc_i8259_create()
The i8259 creation code is common to all PC machines, extract the common code. Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> Message-Id: <20191018135910.24286-5-philmd@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'hw/i386/pc.c')
-rw-r--r--hw/i386/pc.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index e8a54acc38..5fce60c856 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1474,6 +1474,25 @@ void pc_nic_init(PCMachineClass *pcmc, ISABus *isa_bus, PCIBus *pci_bus)
rom_reset_order_override();
}
+void pc_i8259_create(ISABus *isa_bus, qemu_irq *i8259_irqs)
+{
+ qemu_irq *i8259;
+
+ if (kvm_pic_in_kernel()) {
+ i8259 = kvm_i8259_init(isa_bus);
+ } else if (xen_enabled()) {
+ i8259 = xen_interrupt_controller_init();
+ } else {
+ i8259 = i8259_init(isa_bus, pc_allocate_cpu_irq());
+ }
+
+ for (size_t i = 0; i < ISA_NUM_IRQS; i++) {
+ i8259_irqs[i] = i8259[i];
+ }
+
+ g_free(i8259);
+}
+
void ioapic_init_gsi(GSIState *gsi_state, const char *parent_name)
{
DeviceState *dev;