[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: Mark Cave-Ayland <mark.caveayland@xxxxxxxxxxx>
  • From: Peter Maydell <peter.maydell@xxxxxxxxxx>
  • Date: Fri, 16 Oct 2026 17:17:15 +0100
  • Arc-authentication-results: i=1; mx.google.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:dkim-signature; bh=luEslXfElde2BGY9lnddmW44YWpRHQM8vQe1gybMur8=; fh=lcCc1/hRSstSjLJ5ejY26T3rBtTsYFltMb5RQzuuAm8=; b=Z9Se7BNMox7kcmL8Ox3EQ3sE789yDg8upgvlvkgvDr8tlXR2EHYeQNW3pN+zGMXV8o tDYBaybjGh/FZ/pN9WE4DSSGnAGYItIu2rGx30ETXuN0heH2+8L6NLuZt4cA2ZDSFdqF Ane8cfXSavioGoBrZZv60WxDxKxj+Kd0HWY1ccVwRYojQOlOP+JDz4OEdscla4QUEuvj 6C+yxSXJcxJv1xT0hN5OCRtXGDFJByWyccf+skGds4IDYRCFBdygzRDqTCl2V9FItgal 8arQvM6H9d1qxYzXf5c8ChhkDWxA0mFPgAO/8DCiwC2Pss+8UDD9KfJs1Cl14UI0OSuY viYw==; darn=lists.xenproject.org
  • Arc-seal: i=1; a=rsa-sha256; t=1792167449; cv=none; d=google.com; s=arc-20260327; b=gQGV/E1r3AYtIYLL6gUbd9bNdlCrAigUDwDh9P2oXLAOrmG+/CoYiF8sZQ1JJ5CrKc 4HXu9L69+LGfBIC7TX1PbiJf7RThvllC2XBYnD6BlqF5T3YJVFsM/NtlgTMoDwPuwD3O KUzHJZBHtWGBOVHQ0DYAmw4wGUUwFAO/dM1f5auPP0GHIknFyYudYqCoUBUPMjT6pQv+ Fjuv29mJgcHiWglyRXt/r9Q20TpJXk7B9MxNEIHFEQlKqrfJ1yqJ4o+Wc8f0i05mUiji Vz9yl5ruccLLe24PqN+M6pfyrX0MU3qpifdwx6DVohxYLXvpFfrX6h5XElR5p6BQ7DQE teVg==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=google header.d=linaro.org header.i="@linaro.org" header.h="Content-Type:Cc:To:Subject:Message-ID:Date:From:In-Reply-To:References:MIME-Version"
  • Cc: pbonzini@xxxxxxxxxx, richard.henderson@xxxxxxxxxx, mst@xxxxxxxxxx, sstabellini@xxxxxxxxxx, anthony@xxxxxxxxxxxxxx, edgar.iglesias@xxxxxxxxx, qemu-devel@xxxxxxxxxx, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Fri, 16 Oct 2026 16:17:36 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

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().

thanks
-- PMM



 


Rackspace

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