From patchwork Tue Jul 28 13:22:24 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 51597 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f198.google.com (mail-lb0-f198.google.com [209.85.217.198]) by patches.linaro.org (Postfix) with ESMTPS id 5026920323 for ; Tue, 28 Jul 2015 13:22:41 +0000 (UTC) Received: by lbcjj5 with SMTP id jj5sf37979304lbc.1 for ; Tue, 28 Jul 2015 06:22:40 -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=QgJkuzK7SqfMpUkATixAJOrM/dXo2SjooGG1crZ9/Vs=; b=QyYYcFXM+ZYA0O/uheqllJ4F6PYW3OouxjTIRyJPYpLGTG6WbF7pbM4W88Ocd59G5v wUkNsXgGTuo7pMHfBjVX+eRkbtWTSn44eP/XPcSPF6BwMfB/HMwlRgLyMzSEG8oBWKuJ 5pu8375TfarVxDefPDKqQY5k07vB+KiRDXG8pZQMVYyhjga3zxZc66+YULODdCCwZSOz iL6o29RWMOSMb/OPP6qo3d4/OPwkrWgRcO+1SwVyE70xbj3I2dlO2RvbjeFd542a+TxP wJp7hjw8jIZyhnsDunAC7sZtf2a0CUalWPQXqsNm4fbsKSieh0wGEX61PgFpUBPG/hbj rKvA== X-Gm-Message-State: ALoCoQlFsViBdQ6GF7Nzq/rO8IWvCT30sDPJJY9eAqDRKNqOyzvt4jOjhAc8/MbGJ+gVG6sllIzR X-Received: by 10.180.83.33 with SMTP id n1mr1274588wiy.4.1438089760287; Tue, 28 Jul 2015 06:22:40 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.234.108 with SMTP id ud12ls783204lac.43.gmail; Tue, 28 Jul 2015 06:22:40 -0700 (PDT) X-Received: by 10.152.182.194 with SMTP id eg2mr32637504lac.71.1438089759958; Tue, 28 Jul 2015 06:22:39 -0700 (PDT) Received: from mail-lb0-f177.google.com (mail-lb0-f177.google.com. [209.85.217.177]) by mx.google.com with ESMTPS id i6si18337594lai.30.2015.07.28.06.22.39 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 Jul 2015 06:22:39 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.177 as permitted sender) client-ip=209.85.217.177; Received: by lbbyj8 with SMTP id yj8so74531525lbb.0 for ; Tue, 28 Jul 2015 06:22:39 -0700 (PDT) X-Received: by 10.152.22.99 with SMTP id c3mr33475163laf.32.1438089759734; Tue, 28 Jul 2015 06:22:39 -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.7.198 with SMTP id l6csp2138463lba; Tue, 28 Jul 2015 06:22:38 -0700 (PDT) X-Received: by 10.202.232.67 with SMTP id f64mr32587839oih.63.1438089754806; Tue, 28 Jul 2015 06:22:34 -0700 (PDT) Received: from mnementh.archaic.org.uk (mnementh.archaic.org.uk. [2001:8b0:1d0::1]) by mx.google.com with ESMTPS id pu3si3581276pdb.177.2015.07.28.06.22.33 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 28 Jul 2015 06:22:34 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::1 as permitted sender) client-ip=2001:8b0:1d0::1; Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.80) (envelope-from ) id 1ZK4pw-0001Rg-Cv; Tue, 28 Jul 2015 14:22:28 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, "Edgar E. Iglesias" Subject: [PATCH 1/5] armv7m_nvic: Implement ICSR without using internal GIC state Date: Tue, 28 Jul 2015 14:22:24 +0100 Message-Id: <1438089748-5528-2-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1438089748-5528-1-git-send-email-peter.maydell@linaro.org> References: <1438089748-5528-1-git-send-email-peter.maydell@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: peter.maydell@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.177 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: , Change the implementation of the Interrupt Control and State Register in the v7M NVIC to not use the running_irq and last_active internal state fields in the GIC. These fields don't correspond to state in a real GIC and will be removed soon. The changes to the ICSR are: * the VECTACTIVE field is documented as identical to the IPSR[8:0] field, so implement it that way * implement RETTOBASE via looking at the active state bits Signed-off-by: Peter Maydell --- hw/intc/armv7m_nvic.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c index e13b729..3ec8408 100644 --- a/hw/intc/armv7m_nvic.c +++ b/hw/intc/armv7m_nvic.c @@ -185,26 +185,25 @@ static uint32_t nvic_readl(nvic_state *s, uint32_t offset) return cpu->midr; case 0xd04: /* Interrupt Control State. */ /* VECTACTIVE */ - val = s->gic.running_irq[0]; + cpu = ARM_CPU(current_cpu); + val = cpu->env.v7m.exception; if (val == 1023) { val = 0; } else if (val >= 32) { val -= 16; } - /* RETTOBASE */ - if (s->gic.running_irq[0] == 1023 - || s->gic.last_active[s->gic.running_irq[0]][0] == 1023) { - val |= (1 << 11); - } /* VECTPENDING */ if (s->gic.current_pending[0] != 1023) val |= (s->gic.current_pending[0] << 12); - /* ISRPENDING */ + /* ISRPENDING and RETTOBASE */ for (irq = 32; irq < s->num_irq; irq++) { if (s->gic.irq_state[irq].pending) { val |= (1 << 22); break; } + if (irq != cpu->env.v7m.exception && s->gic.irq_state[irq].active) { + val |= (1 << 11); + } } /* PENDSTSET */ if (s->gic.irq_state[ARMV7M_EXCP_SYSTICK].pending)