From nobody Tue Feb 10 11:55:36 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1672929832; cv=none; d=zohomail.com; s=zohoarc; b=UFXe4npJ/01+hPmTlq7G7Q0okNSGfpg3j/x/Aux3/VKJc+syLd8x5dOME05D6u7eTTI15dK99L7JC4wb1HSlvBIhK8IF3Rn6aKNvzqRLyaRZOUQx05ZuF1k93MGnUhjOLjlBqHKtXnFQJVha1xOHzL4puaGdWN9dRqVCUFc1VAc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1672929832; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=f/stOBuXzPq61GBvXikiJZFmsdbNLA8hzR8SMDeaVvE=; b=YkVx5g0a+4ry9aQohGWOtu/lTPhAsrdXoeyAYAqk9RYA1PfIChw+QPGPekhf46I7rgjEeAG22BRtDrFAZvQEzKBFsuBXjuzYcXRXeIYI+sBAMSWWIL1ySrxA/l9tOCDRtPabYdDCy+mkgLVllbiUZv38PzJTUhtZx0Gm+r2FGsU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1672929832210114.36829429046088; Thu, 5 Jan 2023 06:43:52 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pDRJG-0002qX-Sd; Thu, 05 Jan 2023 09:33:34 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pDRJ8-0002kz-Hi; Thu, 05 Jan 2023 09:33:26 -0500 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pDRJ4-0006xI-FP; Thu, 05 Jan 2023 09:33:23 -0500 Received: by mail-wr1-x432.google.com with SMTP id az7so11916074wrb.5; Thu, 05 Jan 2023 06:33:21 -0800 (PST) Received: from osoxes.fritz.box (p200300faaf0bb2009c4947838afc41b6.dip0.t-ipconnect.de. [2003:fa:af0b:b200:9c49:4783:8afc:41b6]) by smtp.gmail.com with ESMTPSA id bt15-20020a056000080f00b00297dcfdc90fsm12260447wrb.24.2023.01.05.06.33.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Jan 2023 06:33:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=f/stOBuXzPq61GBvXikiJZFmsdbNLA8hzR8SMDeaVvE=; b=Zq7hi7IndJ4NmCJuscL9M7umWvmAeuFZX6yl104VtkwPJdt+JyKjOVxxM1ZdHFfb3Z D/hnUoOWhroRDMqbJm+Kr719hVlNQ8Y7NbGx9qiOicYjdAm8Ma2xWOLU5f1Ik5jWUpcL C04mXCXJ4zzvWqBTvf5UWRT7QXBAmB2E9gUQzWUEInUwqEIRaWsxLkkyMvbNA72xxsVd XhXZhHM4MCtyBVs8UX1qoicfE4EuduSSA1rwK+WipYWV4QgJKZQDmbXcJoDkBh63Rvz7 yZJ8Zn4JWzU6DA/pXv2BbCdw6ZS6r4sE3FC1FTtvL0v3SQQylGnSpgvgTqTuOic+/HK5 A8zQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=f/stOBuXzPq61GBvXikiJZFmsdbNLA8hzR8SMDeaVvE=; b=jfjoey07ARF0IlVUbtSD92oD8dqD9hrR+bI1oCaWFOXOJXqoTLQEP3Q37mYP3h1++h 5GsASlMB5d7IIbB7V1p+4Gid7cgphlFoVZobGqH7ew8pT48AFUdxE+DgyzYvgkpv0KjG 7SBQs+foOrl5RswIR+UbbMnpGce6ax9tqVRdQXJZLfOLIoLXJkNtZE0uG4n74OLleP9v EN8ud7RVtLkz/eQH4FrqnLxzf99LMUlKu5kPJo1yY6V7oVxi9YaClMTse/qq18UORATq +1hMoNO4x/yvHVAfsAgfFWF/26Q9np8TTf7OVADWgSmFEQrNBozRBIe34NdBtSQvL2LD pa3Q== X-Gm-Message-State: AFqh2kozbFnFoAUgtxb0iOrVQxanYpxaDxWXo/T3em2k9ciRqWb1U14q rgWqB05kMIdFkJi3MrjQv2jwvxgRVIJVxw== X-Google-Smtp-Source: AMrXdXuQsyJpuizROKSy7VeEZrAkQz7wd++Au3xDLMDQD3L8fu1dVhL4Eckp9mboJs8O3XUrFeK9XQ== X-Received: by 2002:a5d:6283:0:b0:278:806e:e8f8 with SMTP id k3-20020a5d6283000000b00278806ee8f8mr24550734wru.42.1672929200353; Thu, 05 Jan 2023 06:33:20 -0800 (PST) From: Bernhard Beschow To: qemu-devel@nongnu.org Cc: Eduardo Habkost , qemu-block@nongnu.org, =?UTF-8?q?Herv=C3=A9=20Poussineau?= , Ani Sinha , Richard Henderson , Jiaxun Yang , Aurelien Jarno , "Michael S. Tsirkin" , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Paolo Bonzini , Igor Mammedov , Marcel Apfelbaum , John Snow , Gerd Hoffmann , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Bernhard Beschow , Mark Cave-Ayland Subject: [PATCH v5 13/31] hw/intc/i8259: Introduce i8259 proxy "isa-pic" Date: Thu, 5 Jan 2023 15:32:10 +0100 Message-Id: <20230105143228.244965-14-shentey@gmail.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230105143228.244965-1-shentey@gmail.com> References: <20230105143228.244965-1-shentey@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::432; envelope-from=shentey@gmail.com; helo=mail-wr1-x432.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1672929833503100007 Content-Type: text/plain; charset="utf-8" Having an i8259 proxy allows for ISA PICs to be created and wired up in southbridges. This is especially interesting for PIIX3 for two reasons: First, the southbridge doesn't need to care about the virtualization technology used (KVM, TCG, Xen) due to in-IRQs (where devices get attached) and out-IRQs (which will trigger the IRQs of the respective virtualization technology) are separated. Second, since the in-IRQs are populated with fully initialized qemu_irq's, they can already be wired up inside PIIX3. Cc: Mark Cave-Ayland Signed-off-by: Bernhard Beschow Reviewed-by: Mark Cave-Ayland --- include/hw/intc/i8259.h | 19 +++++++++++++++++++ hw/intc/i8259.c | 27 +++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/include/hw/intc/i8259.h b/include/hw/intc/i8259.h index a0e34dd990..f666f5ee09 100644 --- a/include/hw/intc/i8259.h +++ b/include/hw/intc/i8259.h @@ -1,6 +1,25 @@ #ifndef HW_I8259_H #define HW_I8259_H =20 +#include "qom/object.h" +#include "hw/isa/isa.h" +#include "qemu/typedefs.h" + +#define TYPE_ISA_PIC "isa-pic" +OBJECT_DECLARE_SIMPLE_TYPE(ISAPICState, ISA_PIC) + +/* + * TYPE_ISA_PIC is currently a PIC proxy which allows for interrupt wiring= in + * a virtualization technology agnostic way. It could be turned into a pro= per + * GPIO-based ISA PIC in the future. + */ +struct ISAPICState { + DeviceState parent_obj; + + qemu_irq in_irqs[ISA_NUM_IRQS]; + qemu_irq out_irqs[ISA_NUM_IRQS]; +}; + /* i8259.c */ =20 extern PICCommonState *isa_pic; diff --git a/hw/intc/i8259.c b/hw/intc/i8259.c index 0261f087b2..e99d02136d 100644 --- a/hw/intc/i8259.c +++ b/hw/intc/i8259.c @@ -455,9 +455,36 @@ static const TypeInfo i8259_info =3D { .class_size =3D sizeof(PICClass), }; =20 +static void isapic_set_irq(void *opaque, int irq, int level) +{ + ISAPICState *s =3D opaque; + + qemu_set_irq(s->out_irqs[irq], level); +} + +static void isapic_init(Object *obj) +{ + ISAPICState *s =3D ISA_PIC(obj); + + qdev_init_gpio_in(DEVICE(s), isapic_set_irq, ISA_NUM_IRQS); + qdev_init_gpio_out(DEVICE(s), s->out_irqs, ISA_NUM_IRQS); + + for (int i =3D 0; i < ISA_NUM_IRQS; ++i) { + s->in_irqs[i] =3D qdev_get_gpio_in(DEVICE(s), i); + } +} + +static const TypeInfo isapic_info =3D { + .name =3D TYPE_ISA_PIC, + .parent =3D TYPE_DEVICE, + .instance_size =3D sizeof(ISAPICState), + .instance_init =3D isapic_init, +}; + static void pic_register_types(void) { type_register_static(&i8259_info); + type_register_static(&isapic_info); } =20 type_init(pic_register_types) --=20 2.39.0