[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 29/39] hw/i386/pc: Extract pc_i8259_create()
From: |
Paolo Bonzini |
Subject: |
[PULL 29/39] hw/i386/pc: Extract pc_i8259_create() |
Date: |
Thu, 24 Oct 2019 16:03:45 +0200 |
From: Philippe Mathieu-Daudé <address@hidden>
The i8259 creation code is common to all PC machines, extract the
common code.
Signed-off-by: Philippe Mathieu-Daudé <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
---
hw/i386/pc.c | 19 +++++++++++++++++++
hw/i386/pc_piix.c | 13 +------------
hw/i386/pc_q35.c | 14 +-------------
include/hw/i386/pc.h | 1 +
4 files changed, 22 insertions(+), 25 deletions(-)
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index e8a54ac..5fce60c 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;
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index 0cc951a..648dc9a 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -82,7 +82,6 @@ static void pc_init1(MachineState *machine,
ISABus *isa_bus;
PCII440FXState *i440fx_state;
int piix3_devfn = -1;
- qemu_irq *i8259;
qemu_irq smi_irq;
GSIState *gsi_state;
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);
- 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());
- }
+ pc_i8259_create(isa_bus, gsi_state->i8259_irq);
- for (i = 0; i < ISA_NUM_IRQS; i++) {
- gsi_state->i8259_irq[i] = i8259[i];
- }
- g_free(i8259);
if (pcmc->pci_enabled) {
ioapic_init_gsi(gsi_state, "i440fx");
}
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index 6cf12b7..157d1da 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -130,7 +130,6 @@ static void pc_q35_init(MachineState *machine)
MemoryRegion *ram_memory;
GSIState *gsi_state;
ISABus *isa_bus;
- qemu_irq *i8259;
int i;
ICH9LPCState *ich9_lpc;
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);
isa_bus = ich9_lpc->isa_bus;
- 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 (i = 0; i < ISA_NUM_IRQS; i++) {
- gsi_state->i8259_irq[i] = i8259[i];
- }
- g_free(i8259);
+ pc_i8259_create(isa_bus, gsi_state->i8259_irq);
if (pcmc->pci_enabled) {
ioapic_init_gsi(gsi_state, "q35");
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index 8c5dc39..5923318 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -219,6 +219,7 @@ void pc_pci_device_init(PCIBus *pci_bus);
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);
ISADevice *pc_find_fdc0(void);
--
1.8.3.1
- [PULL 19/39] docs/microvm.rst: document the new microvm machine type, (continued)
- [PULL 19/39] docs/microvm.rst: document the new microvm machine type, Paolo Bonzini, 2019/10/24
- [PULL 16/39] fw_cfg: add "modify" functions for all types, Paolo Bonzini, 2019/10/24
- [PULL 24/39] hw/timer/mc146818rtc: Only include qapi-commands-misc on I386, Paolo Bonzini, 2019/10/24
- [PULL 28/39] hw/i386/pc: Move gsi_state creation code, Paolo Bonzini, 2019/10/24
- [PULL 22/39] checkpatch: suggest qemu_real_host_page_size instead of getpagesize() or sysconf(_SC_PAGESIZE), Paolo Bonzini, 2019/10/24
- [PULL 14/39] hw/i386: split PCMachineState deriving X86MachineState from it, Paolo Bonzini, 2019/10/24
- [PULL 26/39] target/i386: Add support for save/load IA32_UMWAIT_CONTROL MSR, Paolo Bonzini, 2019/10/24
- [PULL 30/39] hw/i386/pc: Remove kvm_i386.h include, Paolo Bonzini, 2019/10/24
- [PULL 32/39] mc146818rtc: Move RTC_ISA_IRQ definition, Paolo Bonzini, 2019/10/24
- [PULL 25/39] x86/cpu: Add support for UMONITOR/UMWAIT/TPAUSE, Paolo Bonzini, 2019/10/24
- [PULL 29/39] hw/i386/pc: Extract pc_i8259_create(),
Paolo Bonzini <=
- [PULL 33/39] mc146818rtc: Include mc146818rtc_regs.h directly in mc146818rtc.c, Paolo Bonzini, 2019/10/24
- [PULL 13/39] hw/i386/pc: move shared x86 functions to x86.c and export them, Paolo Bonzini, 2019/10/24
- [PULL 27/39] hw/i386/pc: Extract pc_gsi_create(), Paolo Bonzini, 2019/10/24
- [PULL 31/39] mc146818rtc: move structure to header file, Paolo Bonzini, 2019/10/24
- [PULL 35/39] audio: fix missing break, Paolo Bonzini, 2019/10/24
- [PULL 38/39] target/i386: introduce cpu_set_fpus, Paolo Bonzini, 2019/10/24
- [PULL 37/39] target/i386: move FERR handling to target/i386, Paolo Bonzini, 2019/10/24
- [PULL 34/39] mc146818rtc: always register rtc to rtc list, Paolo Bonzini, 2019/10/24