qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 16/26] pc, pc_piix: split out allocating isa irqs


From: Isaku Yamahata
Subject: [Qemu-devel] [PATCH 16/26] pc, pc_piix: split out allocating isa irqs
Date: Wed, 16 Mar 2011 18:29:27 +0900

Factor out the logic of allocating isa irqs.
This simplifies the pc initialization and will reduce the code
duplication of q35 pc initialization.

Signed-off-by: Isaku Yamahata <address@hidden>
---
 hw/pc.c      |   16 ++++++++++++++--
 hw/pc.h      |    2 +-
 hw/pc_piix.c |    8 +-------
 3 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/hw/pc.c b/hw/pc.c
index 4d67d9f..39c7cf0 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -1044,9 +1044,21 @@ void pc_memory_init(ram_addr_t ram_size,
     }
 }
 
-qemu_irq *pc_allocate_cpu_irq(void)
+qemu_irq *pc_isa_irq(IsaIrqState **isa_irq_state_p)
 {
-    return qemu_allocate_irqs(pic_irq_request, NULL, 1);
+    qemu_irq *cpu_irq;
+    qemu_irq *i8259;
+    IsaIrqState *isa_irq_state;
+    qemu_irq *isa_irq;
+
+    cpu_irq = qemu_allocate_irqs(pic_irq_request, NULL, 1);;
+    i8259 = i8259_init(cpu_irq[0]);
+    isa_irq_state = qemu_mallocz(sizeof(*isa_irq_state));
+    isa_irq_state->i8259 = i8259;
+    isa_irq = qemu_allocate_irqs(isa_irq_handler, isa_irq_state, 24);
+
+    *isa_irq_state_p = isa_irq_state;
+    return isa_irq;
 }
 
 void pc_vga_init(PCIBus *pci_bus)
diff --git a/hw/pc.h b/hw/pc.h
index feb8a7a..0ee4b89 100644
--- a/hw/pc.h
+++ b/hw/pc.h
@@ -135,7 +135,7 @@ void pc_memory_init(ram_addr_t ram_size,
                     const char *initrd_filename,
                     ram_addr_t *below_4g_mem_size_p,
                     ram_addr_t *above_4g_mem_size_p);
-qemu_irq *pc_allocate_cpu_irq(void);
+qemu_irq *pc_isa_irq(IsaIrqState **isa_irq_state_p);
 void pc_vga_init(PCIBus *pci_bus);
 void pc_basic_device_init(qemu_irq *isa_irq,
                           ISADevice **rtc_state);
diff --git a/hw/pc_piix.c b/hw/pc_piix.c
index 337f2ec..1ac69ff 100644
--- a/hw/pc_piix.c
+++ b/hw/pc_piix.c
@@ -76,9 +76,7 @@ static void pc_init1(ram_addr_t ram_size,
     PCIBus *pci_bus;
     PCII440FXState *i440fx_state;
     int piix3_devfn = -1;
-    qemu_irq *cpu_irq;
     qemu_irq *isa_irq;
-    qemu_irq *i8259;
     qemu_irq *cmos_s3;
     qemu_irq *smi_irq;
     IsaIrqState *isa_irq_state;
@@ -96,14 +94,10 @@ static void pc_init1(ram_addr_t ram_size,
     pc_memory_init(ram_size, kernel_filename, kernel_cmdline, initrd_filename,
                    &below_4g_mem_size, &above_4g_mem_size);
 
-    cpu_irq = pc_allocate_cpu_irq();
-    i8259 = i8259_init(cpu_irq[0]);
-    isa_irq_state = qemu_mallocz(sizeof(*isa_irq_state));
-    isa_irq_state->i8259 = i8259;
+    isa_irq = pc_isa_irq(&isa_irq_state);
     if (pci_enabled) {
         ioapic_init(isa_irq_state);
     }
-    isa_irq = qemu_allocate_irqs(isa_irq_handler, isa_irq_state, 24);
 
     if (pci_enabled) {
         pci_bus = i440fx_init(&i440fx_state, &piix3_devfn, isa_irq, ram_size);
-- 
1.7.1.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]