From patchwork Mon Feb 27 14:01:11 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: 657114 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp2389775wrb; Mon, 27 Feb 2023 06:45:58 -0800 (PST) X-Google-Smtp-Source: AK7set8rXXrNyjQYjzecEFGV6VS0OVSg3VHoaMhhrHtXqM568XatxE7qYhmL3vyjaMDx/i5SR6hk X-Received: by 2002:ad4:5ec9:0:b0:56e:af49:7a1d with SMTP id jm9-20020ad45ec9000000b0056eaf497a1dmr44994734qvb.24.1677509157945; Mon, 27 Feb 2023 06:45:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677509157; cv=none; d=google.com; s=arc-20160816; b=oHCpWEtOP5d59Pmu7Kr917svREoRWKCD2zfDfB4DSBxN4dgWp+3FL0rIZsQ29rrh+0 fDWiVSbKp9jj4DU5T2PLwENA47necfZDNt1AFJZvoZJT6bJBRBUHAJFPG7gxYpkuo2FE ud/KxathKqSTdFDg0CMBhCpiIeLPX5VrUDe1EgKrt2aVKF4f0+TiV+M2m5inux7FYEqU z3fgnlYwpRJxwTm5R1Na/nlQl3xp+Zjfqe09Fw/ADGT38FYCEXCAHoXf60+AfC3M5SsZ F3CcKI5GqnvAOONHK0GvtVbXbjqgY1jBf6ipdjbCSeutCQOKIrLC5hnyrImsO4wNbXVW +p2g== 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:to:from :dkim-signature; bh=Wvgc1q+JeB9mB1p5KKDFDthHdUae8hWBwy/9CcINALg=; b=FMkAm6YKMNU/LP2eAllHl8QFeb1df5jvdQKgdfTx8VvpOVY40JSdv+l06abTTaYMhw bcdsopVRnC2B8jar6xJsYS85IvT1d6KlKr1x9fiQl4sfWJNxOPg4LBmo+R+8LGihM4Z1 W4xxj47Ea2fP6jjbupsGGuWLbhOIzRdsOQD+TiOOE2GSICxXZZQZ7WlcenVdacJmTIv0 K0X55JMEWNxjT7cZAUYLX86AWa/mW34gebq75OlIRNl8fqrvh/xkwwEUlxjEt7SeTilP bUx38T2aZDUm8ZM4X/ZG+Zizt3FJVSfWN++qaqC5lVW4B6h+kxQ85mac8XrHtzkHFqj5 Aj9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Ye+RJJYY; 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 d13-20020a0ce44d000000b0056ee2c2c9edsi6364468qvm.422.2023.02.27.06.45.57 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 27 Feb 2023 06:45:57 -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=Ye+RJJYY; 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 1pWeAQ-0008H5-Kx; Mon, 27 Feb 2023 09:07:50 -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 1pWe9s-0007jp-OY for qemu-devel@nongnu.org; Mon, 27 Feb 2023 09:07:26 -0500 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pWe9r-0000F2-1b for qemu-devel@nongnu.org; Mon, 27 Feb 2023 09:07:16 -0500 Received: by mail-wr1-x434.google.com with SMTP id h14so6362568wru.4 for ; Mon, 27 Feb 2023 06:07:13 -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:to:from:from:to:cc:subject:date:message-id :reply-to; bh=Wvgc1q+JeB9mB1p5KKDFDthHdUae8hWBwy/9CcINALg=; b=Ye+RJJYYiExrYT2Kv7dBdmNHikfxupx84XMOdqPhIB0aA9MCFslL8IuTCSt5wex5F5 IHBsiYcpvDMgCp3eXhYwDc05oQnhfO/n7mp7YgnLwxyFOEQMBlqKrHn8LcFe+/5hfASl HstlfmP/GHUraPaYzLxhVLk0yGOFCmj2MnyUnvAKNIltsHh0xo8k2wpEaqimXvn5DS6K okdLONUiLz/S0mI4zBeNHVURE7VNPTz0xtnkE3y6n7odPbT85IVVe9EPBKB23ya9CKkT GUau2cVGIFhQb0+7+Y9QlsFWgebMg47h34DeJJ+A3RNHoPl11GpoBRLfIC6blCTVOR7J Cvkw== 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:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Wvgc1q+JeB9mB1p5KKDFDthHdUae8hWBwy/9CcINALg=; b=ZBVcRcU44YorH63vZfFCn+U2GpqGDfzzcpR6pkVBNyH9oSa8oD9weqgiQGFo3LHwfZ Gs5++gV6SgvP7suGy+JxikOJuWbCbaTsnr8rfKULlPucQTDM/EAVXpw+hS1+1wFhubtO B08DpMNzM1nYq4gD2x3wvEAMpYEMVxSHRDfY3ve/46HMGmV70/+bgJbva548Wh0Drprq 7rrUsemsgYzr/wpr65bWJsEKf2H1UUm3Gn5Jdu8P4/QRJk0fiLPtL3Hw4M1oRLdbv/1J a+La1avZiD4T0xoyKcj+Z3e1Ol3sPPVG9wek9D88iQy0VgZIHN8rv/tcY6OioYfhQJQv utZw== X-Gm-Message-State: AO0yUKWeL+g9MX4V2V1SQVR+pfS1ixQar5xKki8gb2GdROKyNiXcMzGW QwKVPKeEfQoBqM9olIf0DswKTek88cEjnBO5 X-Received: by 2002:adf:e450:0:b0:2c3:fb3e:ae85 with SMTP id t16-20020adfe450000000b002c3fb3eae85mr22364261wrm.44.1677506832595; Mon, 27 Feb 2023 06:07:12 -0800 (PST) Received: from localhost.localdomain ([81.0.6.76]) by smtp.gmail.com with ESMTPSA id y18-20020a5d4ad2000000b002c5584d0e3dsm7294008wrs.24.2023.02.27.06.07.11 for (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 27 Feb 2023 06:07:12 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PULL 064/126] hw/isa: Factor isa_bus_get_irq() out of isa_get_irq() Date: Mon, 27 Feb 2023 15:01:11 +0100 Message-Id: <20230227140213.35084-55-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230227140213.35084-1-philmd@linaro.org> References: <20230227140213.35084-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::434; envelope-from=philmd@linaro.org; helo=mail-wr1-x434.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. Reviewed-by: Richard Henderson Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Thomas Huth Message-Id: <20230215161641.32663-3-philmd@linaro.org> --- 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 80d8fb4c5b..a289eccfb1 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 3a60f6afa6..40d6224a4e 100644 --- a/include/hw/isa/isa.h +++ b/include/hw/isa/isa.h @@ -72,6 +72,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_bus_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);