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

[PATCH v3 26/28] i8259.c: switch isa_pic from I8259State to I8259PICState


  • To: pbonzini@xxxxxxxxxx, richard.henderson@xxxxxxxxxx, mst@xxxxxxxxxx, sstabellini@xxxxxxxxxx, anthony@xxxxxxxxxxxxxx, edgar.iglesias@xxxxxxxxx, qemu-devel@xxxxxxxxxx, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • From: Mark Cave-Ayland <mark.caveayland@xxxxxxxxxxx>
  • Date: Mon, 19 Oct 2026 13:04:58 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nutanix.com; dmarc=pass action=none header.from=nutanix.com; dkim=pass header.d=nutanix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=qMHM6pEmEweBChs82szaxAk8IybJ8PAiFa8eJRnz4zo=; b=Z3aPWhMw9dfGHR1O43CxT3fT01LIFRcjCDFUIOCliQCwnQnXfVDO4pblYYEDLjxA/KLXbmttTbaEfycIcj7YTFH7WtfjMn6CmKre78qz0V3SXZrZlMusDiz6rAZQlEO6UQqEMFSvTy1+dZiPo2K66Qy3YwMN+f8sGKVMj6AVpKwHWj1MVbOYrMauwpbW5IyO9DUzXY0ibYlYRyB1n26LEyd8cz2q66EDyV0o7pbPfWiXY088TiwWSqoPxzTu+VUvn5PFpdVlCm6AUAaCAzi32wdMCoOmyzpUNddLQgU6ktt40wWbb0YQXcgFEuL2iiGZGOVTJTew4FAW659COnexRA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=UQX5tKrmyZ35Aj/cTBGgxgBA+t3Vgi6/WaR4qPBjoS98PbPI13QOztUAH0IMQDBru84WKxRBJH1UTZWnujSuiudpJ+G6P8mgx9xT1M+Sril/+UQOxtuLwM3ySB4+lX7vO2AXBl+6Sz91JO2vfXjhQK1R70vU5X804TtfkhSeg+CYlJSNguRRrLfKL+dHLjpkKmkk2BFYOYQrOC19pVYBa7j6Pw6Tgj+FHlZGXbSoIN78vLhZ6rwH+3lEmS5Qdf04VQHIKW9B3hkdow4Sp5Q0DYyEV91M3I2Ufv36QCJB4DULjDu6tl+s2+7+ZjHhNdzO67OINkXQME6sJtfgl/Rdvw==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=proofpoint20171006 header.d=nutanix.com header.i="@nutanix.com" header.h="Content-Transfer-Encoding:Content-Type:Date:From:In-Reply-To:Message-ID:MIME-Version:References:Subject:To"; dkim=pass header.s=selector1 header.d=nutanix.com header.i="@nutanix.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck"
  • Authentication-results: mx.microsoft.com 1; dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nutanix.com;
  • Delivery-date: Mon, 19 Oct 2026 12:06:54 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

The isa_pic variable exists to allow the output to be fetched or read (fetched
and acknowledged) from the x86 PIC. Since this can also contain a cascaded
interrupt from a slave i8259, switch isa_pic from I8259State to I8259PICState
and update both pic_get_output() and pic_read_irq() accordingly.

This has the advantage that a i8259-based PIC device contains its own internal
reference to both the primary and secondary i8259s, and therefore it becomes
possible to completely remove the slave_pic variable.

Signed-off-by: Mark Cave-Ayland <mark.caveayland@xxxxxxxxxxx>
Reviewed-by: Peter Maydell <peter.maydell@xxxxxxxxxx>
---
 include/hw/intc/i8259.h |  8 ++++----
 hw/intc/i8259.c         | 34 +++++++++++++++-------------------
 2 files changed, 19 insertions(+), 23 deletions(-)

diff --git a/include/hw/intc/i8259.h b/include/hw/intc/i8259.h
index d51a7fde32..4922f88d5b 100644
--- a/include/hw/intc/i8259.h
+++ b/include/hw/intc/i8259.h
@@ -5,9 +5,9 @@
 
 /* i8259.c */
 
-typedef struct I8259State I8259State;
+typedef struct I8259PICState I8259PICState;
 
-extern I8259State *isa_pic;
+extern I8259PICState *isa_pic;
 
 /*
  * i8259_init()
@@ -18,8 +18,8 @@ extern I8259State *isa_pic;
  */
 qemu_irq *i8259_init(ISABus *bus, qemu_irq parent_irq_in);
 qemu_irq *kvm_i8259_init(ISABus *bus);
-int pic_get_output(I8259State *s);
-int pic_read_irq(I8259State *s);
+int pic_get_output(I8259PICState *s);
+int pic_read_irq(I8259PICState *s);
 bool i8259_pic_get_statistics(InterruptStatsProvider *obj,
                               uint64_t **irq_counts,
                               unsigned int *nb_irqs);
diff --git a/hw/intc/i8259.c b/hw/intc/i8259.c
index c3a3199b8e..b59e26cbc6 100644
--- a/hw/intc/i8259.c
+++ b/hw/intc/i8259.c
@@ -72,8 +72,7 @@ OBJECT_DECLARE_SIMPLE_TYPE(I8259PICState, I8259_PIC)
 #ifdef DEBUG_IRQ_LATENCY
 static int64_t irq_time[16];
 #endif
-I8259State *isa_pic;
-static I8259CommonState *slave_pic;
+I8259PICState *isa_pic;
 
 /* return the highest priority found in mask (highest = smallest
    number). Return 8 if no irq */
@@ -190,34 +189,35 @@ static void i8259_intack(I8259CommonState *cs, int irq)
     i8259_update_irq(cs);
 }
 
-int pic_read_irq(I8259State *s)
+int pic_read_irq(I8259PICState *s)
 {
-    I8259CommonState *cs = I8259_COMMON(s);
+    I8259CommonState *pcs = I8259_COMMON(&s->i8259[0]);
+    I8259CommonState *scs = I8259_COMMON(&s->i8259[1]);
     int irq, intno;
 
-    irq = i8259_get_irq(cs);
+    irq = i8259_get_irq(pcs);
     if (irq >= 0) {
         int irq2;
 
         if (irq == 2) {
-            irq2 = i8259_get_irq(slave_pic);
+            irq2 = i8259_get_irq(scs);
             if (irq2 >= 0) {
-                i8259_intack(slave_pic, irq2);
+                i8259_intack(scs, irq2);
             } else {
                 /* spurious IRQ on slave controller */
                 irq2 = 7;
             }
-            intno = slave_pic->irq_base + irq2;
-            i8259_intack(cs, irq);
+            intno = scs->irq_base + irq2;
+            i8259_intack(pcs, irq);
             irq = irq2 + 8;
         } else {
-            intno = cs->irq_base + irq;
-            i8259_intack(cs, irq);
+            intno = pcs->irq_base + irq;
+            i8259_intack(pcs, irq);
         }
     } else {
         /* spurious IRQ on host controller */
         irq = 7;
-        intno = cs->irq_base + irq;
+        intno = pcs->irq_base + irq;
     }
 
 #ifdef DEBUG_IRQ_LATENCY
@@ -369,9 +369,9 @@ static uint64_t i8259_base_ioport_read(void *opaque, hwaddr 
addr,
     return ret;
 }
 
-int pic_get_output(I8259State *s)
+int pic_get_output(I8259PICState *s)
 {
-    I8259CommonState *cs = I8259_COMMON(s);
+    I8259CommonState *cs = I8259_COMMON(&s->i8259[0]);
 
     return (i8259_get_irq(cs) >= 0);
 }
@@ -428,7 +428,6 @@ qemu_irq *i8259_init(ISABus *bus, qemu_irq parent_irq_in)
 {
     qemu_irq *irq_set;
     DeviceState *dev;
-    Object *pic_obj;
     int i;
 
     irq_set = g_new0(qemu_irq, ISA_NUM_IRQS);
@@ -442,10 +441,7 @@ qemu_irq *i8259_init(ISABus *bus, qemu_irq parent_irq_in)
         irq_set[i] = qdev_get_gpio_in(dev, i);
     }
 
-    pic_obj = object_resolve_path_component(OBJECT(dev), "primary");
-    isa_pic = I8259(pic_obj);
-    pic_obj = object_resolve_path_component(OBJECT(dev), "secondary");
-    slave_pic = I8259_COMMON(pic_obj);
+    isa_pic = I8259_PIC(dev);
 
     return irq_set;
 }
-- 
2.43.0




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.