mirror of
https://github.com/qemu/qemu.git
synced 2025-01-26 15:40:11 +08:00
hw/i386/pc: Extract pc_gsi_create()
The GSI creation code is common to all PC machines, extract the common code. Reviewed-by: Aleksandar Markovic <amarkovic@wavecomp.com> Reviewed-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> Message-Id: <20191018135910.24286-2-philmd@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
6508799707
commit
417258f139
15
hw/i386/pc.c
15
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)
|
||||
{
|
||||
|
@ -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,
|
||||
|
@ -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));
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user