From patchwork Fri Dec 30 15:21:47 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corey Minyard X-Patchwork-Id: 89385 Delivered-To: patch@linaro.org Received: by 10.140.20.101 with SMTP id 92csp6489875qgi; Fri, 30 Dec 2016 07:33:16 -0800 (PST) X-Received: by 10.55.0.19 with SMTP id 19mr42609812qka.79.1483111996465; Fri, 30 Dec 2016 07:33:16 -0800 (PST) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id s65si19265606qkc.110.2016.12.30.07.33.16 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 30 Dec 2016 07:33:16 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org Received: from localhost ([::1]:40353 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cMzBE-0002fT-0k for patch@linaro.org; Fri, 30 Dec 2016 10:33:16 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43336) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cMz0T-0002KL-0f for qemu-devel@nongnu.org; Fri, 30 Dec 2016 10:22:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cMz0R-0000GX-Q6 for qemu-devel@nongnu.org; Fri, 30 Dec 2016 10:22:09 -0500 Received: from mail-pg0-x243.google.com ([2607:f8b0:400e:c05::243]:35736) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cMz0R-0000Fj-Kg for qemu-devel@nongnu.org; Fri, 30 Dec 2016 10:22:07 -0500 Received: by mail-pg0-x243.google.com with SMTP id i5so22381151pgh.2 for ; Fri, 30 Dec 2016 07:22:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=8EQ1zd65GTMydSF1GoccbYKGmXF0QMhtQ1CqJ7GsEcA=; b=aw3FPvOb/xZybt2KdOoUpGvWJrZsVYMusZl9Lwco4bi8I7oNAK2QRgjNbe7a0Gh81P Qu5V5VLQTsX7wl/hruzyLRBQ3pQ7Z1MGoCPvRoxIbjDYchB/OZAoRn4O9gMmgsrXFB0d aNrY92ZePVzE1HSkhX2IwDkk7bHKznDC7CQRBrk7mSC6kWlhDSCK4oBMXxCmgVTpaYYV k30VHFTIj5TRJXz6/EnPh9A9CbsnZLSjGj8gTFyTQXdmt8HGipOquRxxTAr06ll6kJiY c0Zz3AXDW8o0W1bpSLiVeWOuyRM+kX9v0niiUYfTbKy+aZ3eiqqMEB9WSXrrjyNXrFid 7DtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=8EQ1zd65GTMydSF1GoccbYKGmXF0QMhtQ1CqJ7GsEcA=; b=hGy6NFNdXcqha6xWVhwqYBsbod8ktT/qkeELfEbcipUInIIRbjyU97/VDWf+7DKwwB Pd+RIMpe6NDQlOJbjBaDQnmRdEoMJCqiHRbvMcq1uDlB9ykFComi5TDHsxjYzmZf+vMT UmPbEWPO2owWdNdd6GkWcT5Au/M5OTgInxuJ/GfcLy+RZ0DxRlJYZ7IARbI3dVln6ABm DntPC5W35LASbkITaFdequ1VR3zA5t0mFPmACFxhPCnMaWIzg3wzPxL98AWuMyIDMvl9 WcqV+ht/spWzQb4/0a9YKEl//a06hzF8dqHcy76UezRqE30YVISSc1kz25RxpjGz/atF bdUQ== X-Gm-Message-State: AIkVDXLYDd1Mjrdjy4N0sHZKDl0nhLlr5b+l4WGFXLXex9d1hEPP1BnfDSSDiPp9GpDK9g== X-Received: by 10.84.213.130 with SMTP id g2mr99605709pli.43.1483111326792; Fri, 30 Dec 2016 07:22:06 -0800 (PST) Received: from serve.minyard.net ([47.184.183.230]) by smtp.gmail.com with ESMTPSA id n84sm64090822pfk.25.2016.12.30.07.22.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 30 Dec 2016 07:22:01 -0800 (PST) Received: from t430.minyard.net (unknown [IPv6:2001:470:b8f6:1b:3850:e313:ed7:8ae4]) by serve.minyard.net (Postfix) with ESMTPA id 11FBEA142; Fri, 30 Dec 2016 09:21:57 -0600 (CST) Received: by t430.minyard.net (Postfix, from userid 1000) id DE664300098; Fri, 30 Dec 2016 09:21:54 -0600 (CST) From: minyard@acm.org To: qemu-devel@nongnu.org Date: Fri, 30 Dec 2016 09:21:47 -0600 Message-Id: <1483111310-24808-17-git-send-email-minyard@acm.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1483111310-24808-1-git-send-email-minyard@acm.org> References: <1483111310-24808-1-git-send-email-minyard@acm.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400e:c05::243 Subject: [Qemu-devel] [PATCH 16/19] isa: Add an irq device. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Corey Minyard , minyard@acm.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Corey Minyard This uses the new irq interface to allow an ISA irq to be specified by name. This will let other things (like the upcoming smbus alert device) to specify ISA irqs by name. To create an name ISA irq, add: -device isa-irq,irq=,irq= where you will use the name to look up the irq on a following device. Signed-off-by: Corey Minyard --- hw/isa/Makefile.objs | 2 +- hw/isa/isa-irq.c | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+), 1 deletion(-) create mode 100644 hw/isa/isa-irq.c -- 2.7.4 diff --git a/hw/isa/Makefile.objs b/hw/isa/Makefile.objs index 9164556..338dd08 100644 --- a/hw/isa/Makefile.objs +++ b/hw/isa/Makefile.objs @@ -1,4 +1,4 @@ -common-obj-y += isa-bus.o +common-obj-y += isa-bus.o isa-irq.o common-obj-$(CONFIG_APM) += apm.o common-obj-$(CONFIG_I82378) += i82378.o common-obj-$(CONFIG_PC87312) += pc87312.o diff --git a/hw/isa/isa-irq.c b/hw/isa/isa-irq.c new file mode 100644 index 0000000..eee6c0e --- /dev/null +++ b/hw/isa/isa-irq.c @@ -0,0 +1,84 @@ +/* + * QEMU ISA named IRQ + * + * Copyright (c) 2015,2016 Corey Minyard, MontaVista Software, LLC + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +#include "qemu/osdep.h" +#include "hw/irqif.h" +#include "hw/isa/isa.h" + +/* This is the type the user specifies on the -device command line */ +#define TYPE_ISA_IRQ "isa-irq" +#define ISA_IRQ(obj) OBJECT_CHECK(ISAIRQDevice, (obj), TYPE_ISA_IRQ) + +typedef struct ISAIRQDevice { + ISADevice dev; + int32_t isairq; + qemu_irq irq; +} ISAIRQDevice; + +static qemu_irq *irq_isa_get_irq(IRQInterface *ii) +{ + ISAIRQDevice *iid = ISA_IRQ(ii); + + return &iid->irq; +} + +static void irq_isa_realizefn(DeviceState *dev, Error **errp) +{ + ISADevice *isadev = ISA_DEVICE(dev); + ISAIRQDevice *iid = ISA_IRQ(dev); + + isa_init_irq(isadev, &iid->irq, iid->isairq); +} + +static Property irq_isa_properties[] = { + DEFINE_PROP_INT32("irq", ISAIRQDevice, isairq, 5), + DEFINE_PROP_END_OF_LIST(), +}; + +static void irq_isa_class_initfn(ObjectClass *oc, void *data) +{ + DeviceClass *dc = DEVICE_CLASS(oc); + IRQInterfaceClass *ii = IRQ_INTERFACE_CLASS(oc); + + dc->realize = irq_isa_realizefn; + dc->props = irq_isa_properties; + ii->get_irq = irq_isa_get_irq; +} + +static const TypeInfo irq_isa_info = { + .name = TYPE_ISA_IRQ, + .parent = TYPE_ISA_DEVICE, + .instance_size = sizeof(ISAIRQDevice), + .class_init = irq_isa_class_initfn, + .interfaces = (InterfaceInfo[]) { + { TYPE_IRQ_INTERFACE }, + { } + } +}; + +static void irq_register_types(void) +{ + type_register_static(&irq_isa_info); +} + +type_init(irq_register_types)