Received: from eggs.gnu.org ([2001:4830:134:3::10]:57437) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WkseY-0003bc-1a for qemu-devel@nongnu.org; Thu, 15 May 2014 06:12:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WkseP-00010j-HY for qemu-devel@nongnu.org; Thu, 15 May 2014 06:12:41 -0400 Received: from e23smtp06.au.ibm.com ([202.81.31.148]:38538) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WksSP-0005f0-Rk for qemu-devel@nongnu.org; Thu, 15 May 2014 06:00:10 -0400 Received: from /spool/local by e23smtp06.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 15 May 2014 20:00:06 +1000 From: Alexey Kardashevskiy Date: Thu, 15 May 2014 19:59:53 +1000 Message-Id: <1400147999-4793-3-git-send-email-aik@ozlabs.ru> In-Reply-To: <1400147999-4793-1-git-send-email-aik@ozlabs.ru> References: <1400147999-4793-1-git-send-email-aik@ozlabs.ru> Subject: [Qemu-devel] [PATCH v2 2/8] xics: Add xics_find_source() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Alexey Kardashevskiy , qemu-ppc@nongnu.org, Alexander Graf PAPR allows having multiple interrupt sources such as PHB. This adds a source lookup function and makes use of it. Since at the moment QEMU only supports a single source, no change in behaviour is expected. Signed-off-by: Alexey Kardashevskiy --- hw/intc/xics.c | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/hw/intc/xics.c b/hw/intc/xics.c index 220ca0e..7065978 100644 --- a/hw/intc/xics.c +++ b/hw/intc/xics.c @@ -635,14 +635,32 @@ static const TypeInfo ics_info = { /* * Exported functions */ +static int xics_find_source(XICSState *icp, int irq) +{ + int sources = 1; + int src; + + /* FIXME: implement multiple sources */ + for (src = 0; src < sources; ++src) { + ICSState *ics = &icp->ics[src]; + if (ics_valid_irq(ics, irq)) { + return src; + } + } + + return -1; +} qemu_irq xics_get_qirq(XICSState *icp, int irq) { - if (!ics_valid_irq(icp->ics, irq)) { - return NULL; + int src = xics_find_source(icp, irq); + + if (src >= 0) { + ICSState *ics = &icp->ics[src]; + return ics->qirqs[irq - ics->offset]; } - return icp->ics->qirqs[irq - icp->ics->offset]; + return NULL; } static void ics_set_irq_type(ICSState *ics, int srcno, bool lsi) @@ -655,10 +673,12 @@ static void ics_set_irq_type(ICSState *ics, int srcno, bool lsi) void xics_set_irq_type(XICSState *icp, int irq, bool lsi) { - ICSState *ics = icp->ics; + int src = xics_find_source(icp, irq); + ICSState *ics; - assert(ics_valid_irq(ics, irq)); + assert(src >= 0); + ics = &icp->ics[src]; ics_set_irq_type(ics, irq - ics->offset, lsi); } -- 1.9.rc0