From patchwork Fri Feb 10 16:37:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 652348 Delivered-To: patch@linaro.org Received: by 2002:adf:f90f:0:0:0:0:0 with SMTP id b15csp1060105wrr; Fri, 10 Feb 2023 08:40:01 -0800 (PST) X-Google-Smtp-Source: AK7set9RlO/sGQercT8tF7TMzNiqhP1ZnIiYDc4rwDJFbJXTTJvw2JkbOvt8AfHFozON6cZThM4M X-Received: by 2002:ac8:5756:0:b0:3b7:ed2c:fbb7 with SMTP id 22-20020ac85756000000b003b7ed2cfbb7mr31225526qtx.0.1676047201782; Fri, 10 Feb 2023 08:40:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676047201; cv=none; d=google.com; s=arc-20160816; b=BpNKP2llrpA67VsTJNdwt5QnOYtqwBHKt9EddKqc+hHF/AFqAfPBEY0vcfx/BMZF1O cMWso3dMeJIaah9kXC9O1efT2O4bWhiu+StpCD70b75Hk+sIOfdQMlINWDCQEcopxk4L Gf6XhmEnvIRGhu+InvutbL/H/xjgmJo0IceDD5Q5u3McB3LNDO1TN3IEiA9EeRiAeSBn bGksXhmOKgNI3aNW6x1vKBv1QeytBNEvxASONX/ff4QvYrlszvbITPuvuoZNGGuTgZCE K5t1pHxEZVtgjD58bhl5vWAzCpuIqHgmtvuHm5FBckYjcJ1igk/YUuqFW/cCH9A9RLXE bO6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=lXmJ/9H6tejYaoSigJ9Gtxd/ZVq77Quhr/7jqB7U4d8=; b=tcq+iiusdzVFV4v9oB2C9khXgv9EJlh9SqB+UWc6zupBpx/QvepEzEPwqt8CFJDXTk huMnORAyNTdeXJerUGaIgZvXLuO+OoWtAp5T07uWWRpTT6W0uDI2Fc9QgkpIowhhMrX1 dItKGabzra1XbIbZYGMEGTJ5XPGXg/H2+BJoRDQJCOkbKtYdG1Md3uco5HwPo49lKczq oKWOfTowSXBDZKs80YUmMxw4SB8rhl6B20awr3+n+3YcJIE98vy/XkWji2rdKLwdttF+ cK8Ac++nOHz1UZrJP8SXKPGUau1LedGC1g0xm5ssSzyK7YcEr0tGhI0bC5tDlA2LpXon IUpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ORGfwVBu; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d19-20020a05622a15d300b003bb7c7948a2si4228192qty.556.2023.02.10.08.40.01 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 10 Feb 2023 08:40:01 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ORGfwVBu; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pQWQI-000275-M5; Fri, 10 Feb 2023 11:38:54 -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 1pQWQE-0001qu-CB for qemu-devel@nongnu.org; Fri, 10 Feb 2023 11:38:50 -0500 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pQWQ8-0000L1-CZ for qemu-devel@nongnu.org; Fri, 10 Feb 2023 11:38:50 -0500 Received: by mail-wr1-x429.google.com with SMTP id h16so5596363wrz.12 for ; Fri, 10 Feb 2023 08:38:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=lXmJ/9H6tejYaoSigJ9Gtxd/ZVq77Quhr/7jqB7U4d8=; b=ORGfwVBuN2tpiBwuF4seeFzozkDoKiLEWxteSiyfPa0CljkC8X6cItJvGgtged/P8E 6wHX4Ga4eB/fyblOUP7WFwj18wlm60IaznFQOw2YTWzK+Hk8T/xsbdel1MMjOdEtkRNa eJMbpVe+DC7z2JTYlbjR0wsjt0/zIFYjH/f7luhxV97jvFfWxRVoBWX9yAfLWUA8HhnJ RoOPdtcsumhVMPeszrM9UKUVFPN0shipz8YPUIpvpNZTzxHHtfZDksoDB7ozqaD4UoVX e6MykytDueEusLv7qGaF8Qr4hM0P1A+pr0Lz8M05sz7cgvTeLnRmarVIQbvxiXyH4SO9 AUXg== 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=lXmJ/9H6tejYaoSigJ9Gtxd/ZVq77Quhr/7jqB7U4d8=; b=wgFbykQ/d8+P+mu/vQOGU+RIRghXX2EIxRfVRfkybiWTdj84t5fkSgTY6HuDf6+oqt JNCBRYug3uZJY0KycWGAgh5bisZM4cf/MmVn17rEMjK8QMh14CcEN62KFovga7nX9W6R 7zRrt9kaRFPpiQ49n1ggt55UQo1zhETb9dt0hFJzzYTxK6yS87zmlgXlIJhci4bMezX5 kOi9pkp2QJWcVw+wYAvgzdj0Ggf90Bowwuy9I5TjwDOcSgw2m3tQeaDIrHrvB6EE8CZw Sw99J+YuIKDM1FH5R/WHGlDUyb4QciQzepxjpTinXEmkT7Jx3R7GtTOQfHvsaH6F4d0S 0MfA== X-Gm-Message-State: AO0yUKXOHICq3GZKxPCx54kVe6ZMFAP9cXbCUg8hktAy2XcYlur9O0LQ xxMBWAZnuGI7qQ/7AGghaAbMJBLzHUl9c0E+ X-Received: by 2002:a5d:674b:0:b0:2c4:98c:1c4b with SMTP id l11-20020a5d674b000000b002c4098c1c4bmr4723392wrw.18.1676047121363; Fri, 10 Feb 2023 08:38:41 -0800 (PST) Received: from localhost.localdomain ([81.0.6.76]) by smtp.gmail.com with ESMTPSA id e2-20020a5d5002000000b002c4c1a47adfsm4080952wrt.23.2023.02.10.08.38.40 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 10 Feb 2023 08:38:41 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Thomas Huth , Sergio Lopez , Richard Henderson , qemu-ppc@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH 11/11] hw/isa: Factor isa_bus_get_irq() out of isa_get_irq() Date: Fri, 10 Feb 2023 17:37:44 +0100 Message-Id: <20230210163744.32182-12-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230210163744.32182-1-philmd@linaro.org> References: <20230210163744.32182-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::429; envelope-from=philmd@linaro.org; helo=mail-wr1-x429.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, 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org isa_get_irq() was added in commit 3a38d437ca ("Add isa_reserve_irq()" Fri Aug 14 11:36:15 2009) as: a temporary interface to be used to allocate ISA IRQs for devices which have not yet been converted to qdev, and for special cases which are not suited for qdev conversions, such as the 'ferr'. We still use it 14 years later, using the global 'isabus' singleton. In order to get rid of such *temporary* interface, extract isa_bus_get_irq() which can take any ISABus* object. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- hw/isa/isa-bus.c | 14 ++++++++++---- include/hw/isa/isa.h | 8 ++++++++ 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/hw/isa/isa-bus.c b/hw/isa/isa-bus.c index d12973103f..4cf26510bf 100644 --- a/hw/isa/isa-bus.c +++ b/hw/isa/isa-bus.c @@ -72,6 +72,13 @@ void isa_bus_register_input_irqs(ISABus *bus, qemu_irq *irqs_in) bus->irqs_in = irqs_in; } +qemu_irq isa_bus_get_irq(ISABus *bus, unsigned irqnum) +{ + assert(irqnum < ISA_NUM_IRQS); + assert(bus->irqs_in); + return bus->irqs_in[irqnum]; +} + /* * isa_get_irq() returns the corresponding input qemu_irq entry for the i8259. * @@ -81,14 +88,13 @@ void isa_bus_register_input_irqs(ISABus *bus, qemu_irq *irqs_in) qemu_irq isa_get_irq(ISADevice *dev, unsigned isairq) { assert(!dev || ISA_BUS(qdev_get_parent_bus(DEVICE(dev))) == isabus); - assert(isairq < ISA_NUM_IRQS); - return isabus->irqs_in[isairq]; + return isa_bus_get_irq(isabus, isairq); } void isa_connect_gpio_out(ISADevice *isadev, int gpioirq, unsigned isairq) { - qemu_irq irq = isa_get_irq(isadev, isairq); - qdev_connect_gpio_out(DEVICE(isadev), gpioirq, irq); + qemu_irq input_irq = isa_get_irq(isadev, isairq); + qdev_connect_gpio_out(DEVICE(isadev), gpioirq, input_irq); } void isa_bus_dma(ISABus *bus, IsaDma *dma8, IsaDma *dma16) diff --git a/include/hw/isa/isa.h b/include/hw/isa/isa.h index 0aa36d4115..ba62a2e6c8 100644 --- a/include/hw/isa/isa.h +++ b/include/hw/isa/isa.h @@ -76,6 +76,14 @@ ISABus *isa_bus_new(DeviceState *dev, MemoryRegion *address_space, void isa_bus_register_input_irqs(ISABus *bus, qemu_irq *irqs_in); void isa_bus_dma(ISABus *bus, IsaDma *dma8, IsaDma *dma16); IsaDma *isa_get_dma(ISABus *bus, int nchan); +/** + * isa_bus_get_irq: Return input IRQ on ISA bus. + * @bus: the #ISABus to plug ISA devices on. + * @irqnum: the ISA IRQ number. + * + * Return IRQ @irqnum from the PIC associated on ISA @bus. + */ +qemu_irq isa_bus_get_irq(ISABus *bus, unsigned irqnum); ISADevice *isa_new(const char *name); ISADevice *isa_try_new(const char *name); bool isa_realize_and_unref(ISADevice *dev, ISABus *bus, Error **errp);