[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2 18/27] i8259.c: introduce TYPE_I8259_PIC device
- To: Peter Maydell <peter.maydell@xxxxxxxxxx>
- From: Mark Cave-Ayland <mark.caveayland@xxxxxxxxxxx>
- Date: Mon, 19 Oct 2026 10:31:15 +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=qT+xoMU5DdQzgmI2sVD9hkL+V19lhJieKAElBE3tGP0=; b=DnD/AT29JVI3tQPPghljsA7dxjvnJKv/7XqjcSKS2amu8ehDWmSmgjvgK+ukhF1EHVoM76XdJhCIJ7sK+4eHf9wv5xXJt5+0mQ83PfQSKlkmvTohHOXVqAjVXpla9lnucTbIxq4BP4HdTwb6IGeY0r3d4gsFB6UfCsOupyljTX3U+PuRwP1BMNgjnpQkW4CWkEQsfNnNxx8jJSr5jz+P2z6c3A1T6HzuYajEHNUcX50SrcNOL5VDk86xP/lVvj8sYTNUMGq5VsLNNBIo+fd7HKlCoa4sPmGEoxGQg4qHH3P7JE2ip4r8/ojIk9ycIkHZe5QCMn+jQQLrFhBqaGdInQ==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=TSOSZDVP7nbEZHVlC3UZoYj7bOdit0x3IsBihUkehxFwZm1pjYquJQyvpAEORZy4GInArFJ54QkMzGwHFGFhn6gLVAWr/NB7iGH93sqnxV6aUlL0ADC9RnVy6SdRmf5SoLFJpUqIUIFLETiAhNPR8vUWuFH4vxrAwYuI1Ce2IWdKSFedIY0XzmPhVVrEsG67kxSHFwp/K2leP8m34C/D/K801WHY/JYNybSbb93lr9Z4atpdQPxxYHdH+2Hdlv+3ACSgYLIYq2jq3WZYdhCWhuOO+zRjYhzmXelwFeqU8Tcnt96RjN7t8VCqgT0awBPZ9j4MY+d0vkdsTwkzMaiYkQ==
- Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=proofpoint20171006 header.d=nutanix.com header.i="@nutanix.com" header.h="Cc: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;
- Cc: pbonzini@xxxxxxxxxx, richard.henderson@xxxxxxxxxx, mst@xxxxxxxxxx, sstabellini@xxxxxxxxxx, anthony@xxxxxxxxxxxxxx, edgar.iglesias@xxxxxxxxx, qemu-devel@xxxxxxxxxx, xen-devel@xxxxxxxxxxxxxxxxxxxx
- Delivery-date: Mon, 19 Oct 2026 09:31:41 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
On 16/10/2026 17:17, Peter Maydell wrote:
On Fri, 16 Oct 2026 at 15:23, Mark Cave-Ayland
<mark.caveayland@xxxxxxxxxxx> wrote:
This device represents a PIC for an x86 machine consisting of 2 cascaded i8259
devices wired accordingly.
Signed-off-by: Mark Cave-Ayland <mark.caveayland@xxxxxxxxxxx>
+static void i8259_pic_init(Object *obj)
+{
+ I8259PICState *s = I8259_PIC(obj);
+
+ object_initialize_child(obj, "primary", &s->i8259[0], TYPE_I8259);
+ object_initialize_child(obj, "secondary", &s->i8259[1], TYPE_I8259);
+
+ qemu_init_irq(&s->i8259_primary_out_irq, i8259_primary_out_irq, s, 1);
+
+ qdev_init_gpio_in(DEVICE(obj), i8259_pic_set_irq, ISA_NUM_IRQS);
+ qdev_init_gpio_out(DEVICE(obj), &s->pic_out_irq, 1);
+}
+
+static void i8259_pic_realize(DeviceState *dev, Error **errp)
+{
+ I8259PICState *s = I8259_PIC(dev);
+ DeviceState *pri_dev, *sec_dev;
+ int i;
+
+ /* Primary */
+ pri_dev = DEVICE(&s->i8259[0]);
+ qdev_prop_set_uint32(pri_dev, "iobase", 0x20);
+ qdev_prop_set_uint32(pri_dev, "elcr_addr", 0x4d0);
+ qdev_prop_set_uint8(pri_dev, "elcr_mask", 0xf8);
+ qdev_prop_set_bit(pri_dev, "master", 1);
+ if (!isa_realize_and_unref(ISA_DEVICE(pri_dev), s->isabus, errp)) {
+ return;
+ }
I'm not sure the _and_unref version is what we want here. The
documentation for qdev_realize_and_unref says:
* If you are embedding the device into some other QOM device and
* initialized it via some variant on object_initialize_child() then
* do not use this function, because that family of functions arrange
* for the only reference to the child device to be held by the parent
* via the child<> property, and so the reference-count-drop done here
* would be incorrect. For that use case you want qdev_realize().
Yes indeed, you're right - I missed this when porting it over from the
old i8259_init_chip() function. Even more amusing is that there is
currently no isa_realize() function, so this is obviously the first
container device being implemented for use on the ISA bus.
I'll add a suitable isa_realize() function in v3.
ATB,
Mark.
|