From patchwork Thu Apr 23 08:49:36 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Auger Eric X-Patchwork-Id: 47449 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f200.google.com (mail-wi0-f200.google.com [209.85.212.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 8B82B2121F for ; Thu, 23 Apr 2015 08:49:49 +0000 (UTC) Received: by wiun10 with SMTP id n10sf17638077wiu.1 for ; Thu, 23 Apr 2015 01:49:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=yisctVgpr1bz27ixRZULzNTAHKxhYCe4Xns/wvcXapY=; b=YQUrHFOW06CP4cmo2p7UScB7XAo6hoN/DJbGqxvR5LwX8tARJrgs2MWneX2lZ78GvN BEiVbIY9SHgrU6Q2/TR9/+Jj0Q/79ZnYCtXxz06LlCLIb6uWfQozeiRdI/bnJzMS9Gay UjtJvEHMdp9H2IEnOU0k32nztngL/cgOKp4QAxgHXppgW7pWj4m7wxxShgjylAi54SSH nDksYwWpSenB66q5vWjR6ArHu2htnwX6Zxo715fn6NIOUtGNyoVxS2B72L3YLjcqsCi5 0/5t7VGr/QcHEjYgN/Y8Di7SQV+gDktZZ9GTCpIoh7oY+GSMAs72ZVvCsL+21vUk9DiT rJUg== X-Gm-Message-State: ALoCoQnlVzJ6rExbmX4phpGg5YfB/k3dwL2rl54CRaCdPKGhvuFLMxMGGzUWTzEZhgqiiwu01XrI X-Received: by 10.180.7.138 with SMTP id j10mr3397419wia.2.1429778988574; Thu, 23 Apr 2015 01:49:48 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.2.97 with SMTP id 1ls252180lat.57.gmail; Thu, 23 Apr 2015 01:49:48 -0700 (PDT) X-Received: by 10.152.120.70 with SMTP id la6mr801987lab.65.1429778988411; Thu, 23 Apr 2015 01:49:48 -0700 (PDT) Received: from mail-lb0-f180.google.com (mail-lb0-f180.google.com. [209.85.217.180]) by mx.google.com with ESMTPS id h1si5507680lam.172.2015.04.23.01.49.48 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Apr 2015 01:49:48 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.180 as permitted sender) client-ip=209.85.217.180; Received: by lbbuc2 with SMTP id uc2so8146806lbb.2 for ; Thu, 23 Apr 2015 01:49:48 -0700 (PDT) X-Received: by 10.112.16.196 with SMTP id i4mr1518529lbd.72.1429778988279; Thu, 23 Apr 2015 01:49:48 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.112.67.65 with SMTP id l1csp435432lbt; Thu, 23 Apr 2015 01:49:47 -0700 (PDT) X-Received: by 10.180.20.14 with SMTP id j14mr3870955wie.45.1429778985888; Thu, 23 Apr 2015 01:49:45 -0700 (PDT) Received: from mail-wi0-f178.google.com (mail-wi0-f178.google.com. [209.85.212.178]) by mx.google.com with ESMTPS id fj2si13206180wic.37.2015.04.23.01.49.45 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Apr 2015 01:49:45 -0700 (PDT) Received-SPF: pass (google.com: domain of eric.auger@linaro.org designates 209.85.212.178 as permitted sender) client-ip=209.85.212.178; Received: by widdi4 with SMTP id di4so84503583wid.0 for ; Thu, 23 Apr 2015 01:49:45 -0700 (PDT) X-Received: by 10.180.96.200 with SMTP id du8mr3985322wib.54.1429778985523; Thu, 23 Apr 2015 01:49:45 -0700 (PDT) Received: from midway01-04-00.lavalab ([81.128.185.50]) by mx.google.com with ESMTPSA id k9sm28007649wia.6.2015.04.23.01.49.44 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 23 Apr 2015 01:49:44 -0700 (PDT) From: Eric Auger To: eric.auger@st.com, eric.auger@linaro.org, qemu-devel@nongnu.org, alex.williamson@redhat.com, peter.maydell@linaro.org, agraf@suse.de, pbonzini@redhat.com Cc: christoffer.dall@linaro.org, kvmarm@lists.cs.columbia.edu, patches@linaro.org Subject: [PATCH 1/2] irq: add get_gsi callback Date: Thu, 23 Apr 2015 09:49:36 +0100 Message-Id: <1429778977-1632-2-git-send-email-eric.auger@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1429778977-1632-1-git-send-email-eric.auger@linaro.org> References: <1429778977-1632-1-git-send-email-eric.auger@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: eric.auger@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.180 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Add a new IRQState get_gsi_cb field, corresponding to a callback that transforms the interrupt controller pin number into a global system interrupt number. A setter is introduced for the interrupt controller to populate the callback. Also add a public function that calls this callback. Signed-off-by: Eric Auger --- hw/core/irq.c | 20 ++++++++++++++++++++ include/hw/irq.h | 8 ++++++++ 2 files changed, 28 insertions(+) diff --git a/hw/core/irq.c b/hw/core/irq.c index 8a62a36..7eeb742 100644 --- a/hw/core/irq.c +++ b/hw/core/irq.c @@ -31,6 +31,7 @@ struct IRQState { Object parent_obj; qemu_irq_handler handler; + qemu_irq_get_gsi_t get_gsi_cb; void *opaque; int n; }; @@ -144,6 +145,25 @@ void qemu_irq_intercept_in(qemu_irq *gpio_in, qemu_irq_handler handler, int n) } } +int qemu_irq_set_get_gsi_cb(qemu_irq irq, qemu_irq_get_gsi_t cb) +{ + if (!irq) { + return -ENXIO; + } + + irq->get_gsi_cb = cb; + return 0; +} + +int qemu_irq_get_gsi(qemu_irq irq) +{ + if (!irq) { + return -ENXIO; + } + + return irq->get_gsi_cb(irq->n); +} + static const TypeInfo irq_type_info = { .name = TYPE_IRQ, .parent = TYPE_OBJECT, diff --git a/include/hw/irq.h b/include/hw/irq.h index 4c4c2ea..658b8f2 100644 --- a/include/hw/irq.h +++ b/include/hw/irq.h @@ -8,6 +8,7 @@ typedef struct IRQState *qemu_irq; typedef void (*qemu_irq_handler)(void *opaque, int n, int level); +typedef int (*qemu_irq_get_gsi_t)(int pin); void qemu_set_irq(qemu_irq irq, int level); @@ -62,4 +63,11 @@ qemu_irq *qemu_irq_proxy(qemu_irq **target, int n); on an existing vector of qemu_irq. */ void qemu_irq_intercept_in(qemu_irq *gpio_in, qemu_irq_handler handler, int n); +/* sets the get_gsi callback (function that converts the interrupt + controller pin into a global system interrupt number */ +int qemu_irq_set_get_gsi_cb(qemu_irq irq, qemu_irq_get_gsi_t cb); + +/* returns the gsi associated to a qemu_irq handle */ +int qemu_irq_get_gsi(qemu_irq irq); + #endif