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>
This commit is contained in:
parent
b00c6f18a6
commit
4501d317b5
19
hw/i386/pc.c
19
hw/i386/pc.c
|
@ -1474,6 +1474,25 @@ void pc_nic_init(PCMachineClass *pcmc, ISABus *isa_bus, PCIBus *pci_bus)
|
||||||
rom_reset_order_override();
|
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)
|
void ioapic_init_gsi(GSIState *gsi_state, const char *parent_name)
|
||||||
{
|
{
|
||||||
DeviceState *dev;
|
DeviceState *dev;
|
||||||
|
|
|
@ -82,7 +82,6 @@ static void pc_init1(MachineState *machine,
|
||||||
ISABus *isa_bus;
|
ISABus *isa_bus;
|
||||||
PCII440FXState *i440fx_state;
|
PCII440FXState *i440fx_state;
|
||||||
int piix3_devfn = -1;
|
int piix3_devfn = -1;
|
||||||
qemu_irq *i8259;
|
|
||||||
qemu_irq smi_irq;
|
qemu_irq smi_irq;
|
||||||
GSIState *gsi_state;
|
GSIState *gsi_state;
|
||||||
DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
|
DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
|
||||||
|
@ -209,18 +208,8 @@ static void pc_init1(MachineState *machine,
|
||||||
}
|
}
|
||||||
isa_bus_irqs(isa_bus, x86ms->gsi);
|
isa_bus_irqs(isa_bus, x86ms->gsi);
|
||||||
|
|
||||||
if (kvm_pic_in_kernel()) {
|
pc_i8259_create(isa_bus, gsi_state->i8259_irq);
|
||||||
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 (i = 0; i < ISA_NUM_IRQS; i++) {
|
|
||||||
gsi_state->i8259_irq[i] = i8259[i];
|
|
||||||
}
|
|
||||||
g_free(i8259);
|
|
||||||
if (pcmc->pci_enabled) {
|
if (pcmc->pci_enabled) {
|
||||||
ioapic_init_gsi(gsi_state, "i440fx");
|
ioapic_init_gsi(gsi_state, "i440fx");
|
||||||
}
|
}
|
||||||
|
|
|
@ -130,7 +130,6 @@ static void pc_q35_init(MachineState *machine)
|
||||||
MemoryRegion *ram_memory;
|
MemoryRegion *ram_memory;
|
||||||
GSIState *gsi_state;
|
GSIState *gsi_state;
|
||||||
ISABus *isa_bus;
|
ISABus *isa_bus;
|
||||||
qemu_irq *i8259;
|
|
||||||
int i;
|
int i;
|
||||||
ICH9LPCState *ich9_lpc;
|
ICH9LPCState *ich9_lpc;
|
||||||
PCIDevice *ahci;
|
PCIDevice *ahci;
|
||||||
|
@ -257,18 +256,7 @@ static void pc_q35_init(MachineState *machine)
|
||||||
pci_bus_set_route_irq_fn(host_bus, ich9_route_intx_pin_to_irq);
|
pci_bus_set_route_irq_fn(host_bus, ich9_route_intx_pin_to_irq);
|
||||||
isa_bus = ich9_lpc->isa_bus;
|
isa_bus = ich9_lpc->isa_bus;
|
||||||
|
|
||||||
if (kvm_pic_in_kernel()) {
|
pc_i8259_create(isa_bus, gsi_state->i8259_irq);
|
||||||
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 (i = 0; i < ISA_NUM_IRQS; i++) {
|
|
||||||
gsi_state->i8259_irq[i] = i8259[i];
|
|
||||||
}
|
|
||||||
g_free(i8259);
|
|
||||||
|
|
||||||
if (pcmc->pci_enabled) {
|
if (pcmc->pci_enabled) {
|
||||||
ioapic_init_gsi(gsi_state, "q35");
|
ioapic_init_gsi(gsi_state, "q35");
|
||||||
|
|
|
@ -219,6 +219,7 @@ void pc_pci_device_init(PCIBus *pci_bus);
|
||||||
|
|
||||||
typedef void (*cpu_set_smm_t)(int smm, void *arg);
|
typedef void (*cpu_set_smm_t)(int smm, void *arg);
|
||||||
|
|
||||||
|
void pc_i8259_create(ISABus *isa_bus, qemu_irq *i8259_irqs);
|
||||||
void ioapic_init_gsi(GSIState *gsi_state, const char *parent_name);
|
void ioapic_init_gsi(GSIState *gsi_state, const char *parent_name);
|
||||||
|
|
||||||
ISADevice *pc_find_fdc0(void);
|
ISADevice *pc_find_fdc0(void);
|
||||||
|
|
Loading…
Reference in a new issue