[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 27/39] hw/i386/pc: Extract pc_gsi_create()
From: |
Paolo Bonzini |
Subject: |
[PULL 27/39] hw/i386/pc: Extract pc_gsi_create() |
Date: |
Thu, 24 Oct 2019 16:03:43 +0200 |
From: Philippe Mathieu-Daudé <address@hidden>
The GSI creation code is common to all PC machines, extract the
common code.
Reviewed-by: Aleksandar Markovic <address@hidden>
Reviewed-by: Thomas Huth <address@hidden>
Signed-off-by: Philippe Mathieu-Daudé <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
---
hw/i386/pc.c | 15 +++++++++++++++
hw/i386/pc_piix.c | 9 +--------
hw/i386/pc_q35.c | 9 +--------
include/hw/i386/pc.h | 2 ++
4 files changed, 19 insertions(+), 16 deletions(-)
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index a8888dd..e8a54ac 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -355,6 +355,21 @@ void gsi_handler(void *opaque, int n, int level)
qemu_set_irq(s->ioapic_irq[n], level);
}
+GSIState *pc_gsi_create(qemu_irq **irqs, bool pci_enabled)
+{
+ GSIState *s;
+
+ s = g_new0(GSIState, 1);
+ if (kvm_ioapic_in_kernel()) {
+ kvm_pc_setup_irq_routing(pci_enabled);
+ *irqs = qemu_allocate_irqs(kvm_pc_gsi_handler, s, GSI_NUM_PINS);
+ } else {
+ *irqs = qemu_allocate_irqs(gsi_handler, s, GSI_NUM_PINS);
+ }
+
+ return s;
+}
+
static void ioport80_write(void *opaque, hwaddr addr, uint64_t data,
unsigned size)
{
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index a86317c..0cc951a 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -189,14 +189,7 @@ static void pc_init1(MachineState *machine,
xen_load_linux(pcms);
}
- gsi_state = g_malloc0(sizeof(*gsi_state));
- if (kvm_ioapic_in_kernel()) {
- kvm_pc_setup_irq_routing(pcmc->pci_enabled);
- x86ms->gsi = qemu_allocate_irqs(kvm_pc_gsi_handler, gsi_state,
- GSI_NUM_PINS);
- } else {
- x86ms->gsi = qemu_allocate_irqs(gsi_handler, gsi_state, GSI_NUM_PINS);
- }
+ gsi_state = pc_gsi_create(&x86ms->gsi, pcmc->pci_enabled);
if (pcmc->pci_enabled) {
pci_bus = i440fx_init(host_type,
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index 75c8caf..255c803 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -212,14 +212,7 @@ static void pc_q35_init(MachineState *machine)
}
/* irq lines */
- gsi_state = g_malloc0(sizeof(*gsi_state));
- if (kvm_ioapic_in_kernel()) {
- kvm_pc_setup_irq_routing(pcmc->pci_enabled);
- x86ms->gsi = qemu_allocate_irqs(kvm_pc_gsi_handler, gsi_state,
- GSI_NUM_PINS);
- } else {
- x86ms->gsi = qemu_allocate_irqs(gsi_handler, gsi_state, GSI_NUM_PINS);
- }
+ gsi_state = pc_gsi_create(&x86ms->gsi, pcmc->pci_enabled);
/* create pci host bus */
q35_host = Q35_HOST_DEVICE(qdev_create(NULL, TYPE_Q35_HOST_DEVICE));
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index 13c4eac..8c5dc39 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -157,6 +157,8 @@ typedef struct GSIState {
void gsi_handler(void *opaque, int n, int level);
+GSIState *pc_gsi_create(qemu_irq **irqs, bool pci_enabled);
+
/* vmport.c */
#define TYPE_VMPORT "vmport"
typedef uint32_t (VMPortReadFunc)(void *opaque, uint32_t address);
--
1.8.3.1
- [PULL 28/39] hw/i386/pc: Move gsi_state creation code, (continued)
- [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, 2019/10/24
- [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 <=
- [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
- [PULL 39/39] i386: implement IGNNE, Paolo Bonzini, 2019/10/24
- [PULL 36/39] core: replace getpagesize() with qemu_real_host_page_size, Paolo Bonzini, 2019/10/24
- Re: [PULL 00/39] Misc (mostly x86) patches for 2019-10-24, no-reply, 2019/10/25