From patchwork Mon Apr 15 23:19:32 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Scott Wood X-Patchwork-Id: 236765 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 1B0522C00EC for ; Tue, 16 Apr 2013 09:20:42 +1000 (EST) Received: from localhost ([::1]:53252 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1URshU-0004jJ-8b for incoming@patchwork.ozlabs.org; Mon, 15 Apr 2013 19:20:40 -0400 Received: from eggs.gnu.org ([208.118.235.92]:51465) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1URsgr-0004bD-FH for qemu-devel@nongnu.org; Mon, 15 Apr 2013 19:20:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1URsgj-0004od-M2 for qemu-devel@nongnu.org; Mon, 15 Apr 2013 19:20:01 -0400 Received: from va3ehsobe001.messaging.microsoft.com ([216.32.180.11]:5505 helo=va3outboundpool.messaging.microsoft.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1URsgZ-0004cS-JS; Mon, 15 Apr 2013 19:19:43 -0400 Received: from mail230-va3-R.bigfish.com (10.7.14.239) by VA3EHSOBE003.bigfish.com (10.7.40.23) with Microsoft SMTP Server id 14.1.225.23; Mon, 15 Apr 2013 23:19:42 +0000 Received: from mail230-va3 (localhost [127.0.0.1]) by mail230-va3-R.bigfish.com (Postfix) with ESMTP id 696F07002BA; Mon, 15 Apr 2013 23:19:42 +0000 (UTC) X-Forefront-Antispam-Report: CIP:70.37.183.190; KIP:(null); UIP:(null); IPV:NLI; H:mail.freescale.net; RD:none; EFVD:NLI X-SpamScore: 1 X-BigFish: VS1(z551bizzz1f42h1fc6h1ee6h1de0h1fdah1202h1e76h1d1ah1d2ahzz8275bhz2dh2a8h668h839hd24he5bhf0ah1288h12a5h12a9h12bdh12e5h137ah139eh13b6h1441h1504h1537h162dh1631h1758h1898h18e1h1946h19b5h1ad9h1b0ah1155h) Received: from mail230-va3 (localhost.localdomain [127.0.0.1]) by mail230-va3 (MessageSwitch) id 1366067980134355_29179; Mon, 15 Apr 2013 23:19:40 +0000 (UTC) Received: from VA3EHSMHS019.bigfish.com (unknown [10.7.14.241]) by mail230-va3.bigfish.com (Postfix) with ESMTP id 18A6E3A020F; Mon, 15 Apr 2013 23:19:40 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by VA3EHSMHS019.bigfish.com (10.7.99.29) with Microsoft SMTP Server (TLS) id 14.1.225.23; Mon, 15 Apr 2013 23:19:39 +0000 Received: from tx30smr01.am.freescale.net (10.81.153.31) by 039-SN1MMR1-001.039d.mgd.msft.net (10.84.1.13) with Microsoft SMTP Server (TLS) id 14.2.328.11; Mon, 15 Apr 2013 23:19:38 +0000 Received: from snotra.am.freescale.net ([10.214.83.122]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id r3FNJYs3017756; Mon, 15 Apr 2013 16:19:37 -0700 From: Scott Wood To: Alexander Graf Date: Mon, 15 Apr 2013 18:19:32 -0500 Message-ID: <1366067974-5413-5-git-send-email-scottwood@freescale.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1366067974-5413-1-git-send-email-scottwood@freescale.com> References: <1360823521-32306-1-git-send-email-scottwood@freescale.com> <1366067974-5413-1-git-send-email-scottwood@freescale.com> MIME-Version: 1.0 X-OriginatorOrg: freescale.com X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 X-Received-From: 216.32.180.11 Cc: Scott Wood , qemu-ppc@nongnu.org, qemu-devel@nongnu.org Subject: [Qemu-devel] [RFC PATCH v2 4/6] openpic: factor out some common defines into openpic.h X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org ...for use by the KVM in-kernel irqchip stub. Signed-off-by: Scott Wood --- hw/openpic.c | 40 ++++++++++++++++++---------------------- hw/openpic.h | 11 +++++++++++ 2 files changed, 29 insertions(+), 22 deletions(-) diff --git a/hw/openpic.c b/hw/openpic.c index 03a7075..b655381 100644 --- a/hw/openpic.c +++ b/hw/openpic.c @@ -57,11 +57,7 @@ static const int debug_openpic = 0; } while (0) #define MAX_CPU 32 -#define MAX_SRC 256 -#define MAX_TMR 4 -#define MAX_IPI 4 #define MAX_MSI 8 -#define MAX_IRQ (MAX_SRC + MAX_IPI + MAX_TMR) #define VID 0x03 /* MPIC version ID */ /* OpenPIC capability flags */ @@ -78,7 +74,7 @@ static const int debug_openpic = 0; #define OPENPIC_SUMMARY_REG_START 0x3800 #define OPENPIC_SUMMARY_REG_SIZE 0x800 #define OPENPIC_SRC_REG_START 0x10000 -#define OPENPIC_SRC_REG_SIZE (MAX_SRC * 0x20) +#define OPENPIC_SRC_REG_SIZE (OPENPIC_MAX_SRC * 0x20) #define OPENPIC_CPU_REG_START 0x20000 #define OPENPIC_CPU_REG_SIZE 0x100 + ((MAX_CPU - 1) * 0x1000) @@ -86,8 +82,8 @@ static const int debug_openpic = 0; #define RAVEN_MAX_CPU 2 #define RAVEN_MAX_EXT 48 #define RAVEN_MAX_IRQ 64 -#define RAVEN_MAX_TMR MAX_TMR -#define RAVEN_MAX_IPI MAX_IPI +#define RAVEN_MAX_TMR OPENPIC_MAX_TMR +#define RAVEN_MAX_IPI OPENPIC_MAX_IPI /* Interrupt definitions */ #define RAVEN_FE_IRQ (RAVEN_MAX_EXT) /* Internal functional IRQ */ @@ -209,7 +205,7 @@ typedef struct IRQQueue { /* Round up to the nearest 64 IRQs so that the queue length * won't change when moving between 32 and 64 bit hosts. */ - unsigned long queue[BITS_TO_LONGS((MAX_IRQ + 63) & ~63)]; + unsigned long queue[BITS_TO_LONGS((OPENPIC_MAX_IRQ + 63) & ~63)]; int next; int priority; } IRQQueue; @@ -283,7 +279,7 @@ typedef struct OpenPICState { uint32_t spve; /* Spurious vector register */ uint32_t tfrr; /* Timer frequency reporting register */ /* Source registers */ - IRQSource src[MAX_IRQ]; + IRQSource src[OPENPIC_MAX_IRQ]; /* Local registers per output pin */ IRQDest dst[MAX_CPU]; uint32_t nb_cpus; @@ -291,7 +287,7 @@ typedef struct OpenPICState { struct { uint32_t tccr; /* Global timer current count register */ uint32_t tbcr; /* Global timer base count register */ - } timers[MAX_TMR]; + } timers[OPENPIC_MAX_TMR]; /* Shared MSI registers */ struct { uint32_t msir; /* Shared Message Signaled Interrupt Register */ @@ -503,7 +499,7 @@ static void openpic_set_irq(void *opaque, int n_IRQ, int level) OpenPICState *opp = opaque; IRQSource *src; - if (n_IRQ >= MAX_IRQ) { + if (n_IRQ >= OPENPIC_MAX_IRQ) { fprintf(stderr, "%s: IRQ %d out of range\n", __func__, n_IRQ); abort(); } @@ -576,7 +572,7 @@ static void openpic_reset(DeviceState *d) opp->dst[i].servicing.next = -1; } /* Initialise timers */ - for (i = 0; i < MAX_TMR; i++) { + for (i = 0; i < OPENPIC_MAX_TMR; i++) { opp->timers[i].tccr = 0; opp->timers[i].tbcr = TBCR_CI; } @@ -1182,7 +1178,7 @@ static uint32_t openpic_iack(OpenPICState *opp, IRQDest *dst, int cpu) IRQ_resetbit(&dst->raised, irq); } - if ((irq >= opp->irq_ipi0) && (irq < (opp->irq_ipi0 + MAX_IPI))) { + if ((irq >= opp->irq_ipi0) && (irq < (opp->irq_ipi0 + OPENPIC_MAX_IPI))) { src->destmask &= ~(1 << cpu); if (src->destmask && !src->level) { /* trigger on CPUs that didn't know about it yet */ @@ -1381,7 +1377,7 @@ static void openpic_save(QEMUFile* f, void *opaque) sizeof(opp->dst[i].outputs_active)); } - for (i = 0; i < MAX_TMR; i++) { + for (i = 0; i < OPENPIC_MAX_TMR; i++) { qemu_put_be32s(f, &opp->timers[i].tccr); qemu_put_be32s(f, &opp->timers[i].tbcr); } @@ -1440,7 +1436,7 @@ static int openpic_load(QEMUFile* f, void *opaque, int version_id) sizeof(opp->dst[i].outputs_active)); } - for (i = 0; i < MAX_TMR; i++) { + for (i = 0; i < OPENPIC_MAX_TMR; i++) { qemu_get_be32s(f, &opp->timers[i].tccr); qemu_get_be32s(f, &opp->timers[i].tbcr); } @@ -1473,7 +1469,7 @@ typedef struct MemReg { static void fsl_common_init(OpenPICState *opp) { int i; - int virq = MAX_SRC; + int virq = OPENPIC_MAX_SRC; opp->vid = VID_REVISION_1_2; opp->vir = VIR_GENERIC; @@ -1481,14 +1477,14 @@ static void fsl_common_init(OpenPICState *opp) opp->tfrr_reset = 0; opp->ivpr_reset = IVPR_MASK_MASK; opp->idr_reset = 1 << 0; - opp->max_irq = MAX_IRQ; + opp->max_irq = OPENPIC_MAX_IRQ; opp->irq_ipi0 = virq; - virq += MAX_IPI; + virq += OPENPIC_MAX_IPI; opp->irq_tim0 = virq; - virq += MAX_TMR; + virq += OPENPIC_MAX_TMR; - assert(virq <= MAX_IRQ); + assert(virq <= OPENPIC_MAX_IRQ); opp->irq_msi = 224; @@ -1498,13 +1494,13 @@ static void fsl_common_init(OpenPICState *opp) } /* Internal interrupts, including message and MSI */ - for (i = 16; i < MAX_SRC; i++) { + for (i = 16; i < OPENPIC_MAX_SRC; i++) { opp->src[i].type = IRQ_TYPE_FSLINT; opp->src[i].level = true; } /* timers and IPIs */ - for (i = MAX_SRC; i < virq; i++) { + for (i = OPENPIC_MAX_SRC; i < virq; i++) { opp->src[i].type = IRQ_TYPE_FSLSPECIAL; opp->src[i].level = false; } diff --git a/hw/openpic.h b/hw/openpic.h index 9dcaf0e..d873bb6 100644 --- a/hw/openpic.h +++ b/hw/openpic.h @@ -1,6 +1,9 @@ #if !defined(__OPENPIC_H__) #define __OPENPIC_H__ +#include "qemu-common.h" +#include "hw/qdev.h" + /* OpenPIC have 5 outputs per CPU connected and one IRQ out single output */ enum { OPENPIC_OUTPUT_INT = 0, /* IRQ */ @@ -15,4 +18,12 @@ enum { #define OPENPIC_MODEL_FSL_MPIC_20 1 #define OPENPIC_MODEL_FSL_MPIC_42 2 +#define OPENPIC_MAX_SRC 256 +#define OPENPIC_MAX_TMR 4 +#define OPENPIC_MAX_IPI 4 +#define OPENPIC_MAX_IRQ (OPENPIC_MAX_SRC + OPENPIC_MAX_IPI + \ + OPENPIC_MAX_TMR) + +DeviceState *kvm_openpic_create(BusState *bus, int model); + #endif /* __OPENPIC_H__ */