From patchwork Wed Jan 29 13:40:04 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 23843 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qc0-f198.google.com (mail-qc0-f198.google.com [209.85.216.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 6A89C202FA for ; Wed, 29 Jan 2014 13:43:39 +0000 (UTC) Received: by mail-qc0-f198.google.com with SMTP id c9sf3830539qcz.5 for ; Wed, 29 Jan 2014 05:43:38 -0800 (PST) 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:date :message-id:in-reply-to:references:cc:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=nhvCZSH2tkiHS/+5HQN79n7SD85HAYSLjV0NrsuUALI=; b=i1IPA0MX2+Wpp6+jK8JoZqNC8fJunskC3J2Fz1ew7LzaWRgTkhnnHRkHKYiLbAWNB2 KDYL9zboCEYqLb/cNTfZYJN1EyNfnXJwy5Ycc+8zvD4b8HulgzVxJXFupJh22rNKY4Tx VR6QzsjZNlnvC3fHonHiKL7HZH2med0YYFwCsSSRN4mlUdkHRQxgZ0R4Zyu2U2FBDcSF JiwdFa3T7KNpK9SMDYGF+VGVft9WRltlooodau3CpdoNFEmfIv7J2vvPzNfOMB0nKqHC UrdH2N131HW4cKMutjZmqeBOPkPUVb4RTIKUL2vyJyTcCQnMh6zXEAIWrXlujvgBTxge nX0A== X-Gm-Message-State: ALoCoQnZsbhilz3VGdX/pXxTebno24omH5nWinrjMDPgcm2arg+DCO7j9TwFJmvWR0LiZCwhqlwM X-Received: by 10.58.253.229 with SMTP id ad5mr2729859ved.30.1391003018614; Wed, 29 Jan 2014 05:43:38 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.44.102 with SMTP id f93ls105945qga.75.gmail; Wed, 29 Jan 2014 05:43:38 -0800 (PST) X-Received: by 10.58.49.161 with SMTP id v1mr6609089ven.5.1391003018483; Wed, 29 Jan 2014 05:43:38 -0800 (PST) Received: from mail-ve0-f173.google.com (mail-ve0-f173.google.com [209.85.128.173]) by mx.google.com with ESMTPS id dr8si811426vcb.13.2014.01.29.05.43.38 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 29 Jan 2014 05:43:38 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.173 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.173; Received: by mail-ve0-f173.google.com with SMTP id oz11so1209808veb.32 for ; Wed, 29 Jan 2014 05:43:38 -0800 (PST) X-Received: by 10.220.109.1 with SMTP id h1mr6746837vcp.20.1391003018398; Wed, 29 Jan 2014 05:43:38 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.174.196 with SMTP id u4csp113721vcz; Wed, 29 Jan 2014 05:43:37 -0800 (PST) X-Received: by 10.140.82.8 with SMTP id g8mr11541188qgd.88.1391003017776; Wed, 29 Jan 2014 05:43:37 -0800 (PST) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id j50si1762191qgf.137.2014.01.29.05.43.37 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 29 Jan 2014 05:43:37 -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; Received: from localhost ([::1]:42321 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W8VQX-000597-5y for patch@linaro.org; Wed, 29 Jan 2014 08:43:37 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48794) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W8VNV-0001Bl-NH for qemu-devel@nongnu.org; Wed, 29 Jan 2014 08:40:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W8VNU-00012k-7T for qemu-devel@nongnu.org; Wed, 29 Jan 2014 08:40:29 -0500 Received: from mnementh.archaic.org.uk ([2001:8b0:1d0::1]:45245) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W8VNU-00012F-1P for qemu-devel@nongnu.org; Wed, 29 Jan 2014 08:40:28 -0500 Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.80) (envelope-from ) id 1W8VN9-0006zq-Cw; Wed, 29 Jan 2014 13:40:07 +0000 From: Peter Maydell To: Anthony Liguori Date: Wed, 29 Jan 2014 13:40:04 +0000 Message-Id: <1391002805-26596-38-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1391002805-26596-1-git-send-email-peter.maydell@linaro.org> References: <1391002805-26596-1-git-send-email-peter.maydell@linaro.org> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:8b0:1d0::1 Cc: Blue Swirl , qemu-devel@nongnu.org, Aurelien Jarno Subject: [Qemu-devel] [PULL 37/38] arm_gic: Introduce define for GIC_NR_SGIS 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: peter.maydell@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.173 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 From: Christoffer Dall Instead of hardcoding 16 various places in the code, use a define to make it more clear what is going on. Signed-off-by: Christoffer Dall Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- hw/intc/arm_gic.c | 17 +++++++++++------ include/hw/intc/arm_gic_common.h | 1 + 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/hw/intc/arm_gic.c b/hw/intc/arm_gic.c index 9409684..98c6ff5 100644 --- a/hw/intc/arm_gic.c +++ b/hw/intc/arm_gic.c @@ -380,8 +380,10 @@ static void gic_dist_writeb(void *opaque, hwaddr offset, irq = (offset - 0x100) * 8 + GIC_BASE_IRQ; if (irq >= s->num_irq) goto bad_reg; - if (irq < 16) - value = 0xff; + if (irq < GIC_NR_SGIS) { + value = 0xff; + } + for (i = 0; i < 8; i++) { if (value & (1 << i)) { int mask = @@ -406,8 +408,10 @@ static void gic_dist_writeb(void *opaque, hwaddr offset, irq = (offset - 0x180) * 8 + GIC_BASE_IRQ; if (irq >= s->num_irq) goto bad_reg; - if (irq < 16) - value = 0; + if (irq < GIC_NR_SGIS) { + value = 0; + } + for (i = 0; i < 8; i++) { if (value & (1 << i)) { int cm = (irq < GIC_INTERNAL) ? (1 << cpu) : ALL_CPU_MASK; @@ -423,8 +427,9 @@ static void gic_dist_writeb(void *opaque, hwaddr offset, irq = (offset - 0x200) * 8 + GIC_BASE_IRQ; if (irq >= s->num_irq) goto bad_reg; - if (irq < 16) - irq = 0; + if (irq < GIC_NR_SGIS) { + irq = 0; + } for (i = 0; i < 8; i++) { if (value & (1 << i)) { diff --git a/include/hw/intc/arm_gic_common.h b/include/hw/intc/arm_gic_common.h index 40cd3d6..dbf8787 100644 --- a/include/hw/intc/arm_gic_common.h +++ b/include/hw/intc/arm_gic_common.h @@ -27,6 +27,7 @@ #define GIC_MAXIRQ 1020 /* First 32 are private to each CPU (SGIs and PPIs). */ #define GIC_INTERNAL 32 +#define GIC_NR_SGIS 16 /* Maximum number of possible CPU interfaces, determined by GIC architecture */ #define GIC_NCPU 8