[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 20/32] hw/i386/pc: Extract pc_gsi_create()
From: |
Philippe Mathieu-Daudé |
Subject: |
[PATCH 20/32] hw/i386/pc: Extract pc_gsi_create() |
Date: |
Tue, 15 Oct 2019 18:26:53 +0200 |
The GSI creation code is common to all PC machines, extract the
common code.
Signed-off-by: Philippe Mathieu-Daudé <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 bcda50efcc..a7597c6c44 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -357,6 +357,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 431965d921..452b107e1b 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -188,14 +188,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);
- pcms->gsi = qemu_allocate_irqs(kvm_pc_gsi_handler, gsi_state,
- GSI_NUM_PINS);
- } else {
- pcms->gsi = qemu_allocate_irqs(gsi_handler, gsi_state, GSI_NUM_PINS);
- }
+ gsi_state = pc_gsi_create(&pcms->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 8fad20f314..52261962b8 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -210,14 +210,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);
- pcms->gsi = qemu_allocate_irqs(kvm_pc_gsi_handler, gsi_state,
- GSI_NUM_PINS);
- } else {
- pcms->gsi = qemu_allocate_irqs(gsi_handler, gsi_state, GSI_NUM_PINS);
- }
+ gsi_state = pc_gsi_create(&pcms->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 b63fc7631e..d0c6b9d469 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -174,6 +174,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);
--
2.21.0
- [PATCH 15/32] piix4: add a i8254 pit controller as specified in datasheet, (continued)
- [PATCH 15/32] piix4: add a i8254 pit controller as specified in datasheet, Philippe Mathieu-Daudé, 2019/10/15
- [PATCH 16/32] piix4: add a mc146818rtc controller as specified in datasheet, Philippe Mathieu-Daudé, 2019/10/15
- [PATCH 17/32] hw/mips/mips_malta: Create IDE hard drive array dynamically, Philippe Mathieu-Daudé, 2019/10/15
- [PATCH 18/32] hw/mips/mips_malta: Extract the PIIX4 creation code as piix4_create(), Philippe Mathieu-Daudé, 2019/10/15
- [PATCH 19/32] hw/isa/piix4: Move piix4_create() to hw/isa/piix4.c, Philippe Mathieu-Daudé, 2019/10/15
- [PATCH 20/32] hw/i386/pc: Extract pc_gsi_create(),
Philippe Mathieu-Daudé <=
- [PATCH 21/32] hw/i386/pc: Reduce gsi_handler scope, Philippe Mathieu-Daudé, 2019/10/15
- Re: [PATCH 21/32] hw/i386/pc: Reduce gsi_handler scope, Thomas Huth, 2019/10/17
- [PATCH 22/32] hw/i386/pc: Move gsi_state creation code, Philippe Mathieu-Daudé, 2019/10/15
- [PATCH 23/32] hw/i386/pc: Extract pc_i8259_create(), Philippe Mathieu-Daudé, 2019/10/15