From patchwork Sun Apr 23 22:40:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stafford Horne X-Patchwork-Id: 9695303 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C0FBD601AE for ; Sun, 23 Apr 2017 22:42:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C3BCA25F31 for ; Sun, 23 Apr 2017 22:42:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B5C42262AE; Sun, 23 Apr 2017 22:42:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2E3DB25F31 for ; Sun, 23 Apr 2017 22:42:29 +0000 (UTC) Received: from localhost ([::1]:40829 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d2QD6-0000R3-A5 for patchwork-qemu-devel@patchwork.kernel.org; Sun, 23 Apr 2017 18:42:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55769) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d2QBx-0000PT-Kl for qemu-devel@nongnu.org; Sun, 23 Apr 2017 18:41:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d2QBw-0000MF-Fy for qemu-devel@nongnu.org; Sun, 23 Apr 2017 18:41:17 -0400 Received: from mail-it0-x243.google.com ([2607:f8b0:4001:c0b::243]:35128) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1d2QBw-0000M1-Br for qemu-devel@nongnu.org; Sun, 23 Apr 2017 18:41:16 -0400 Received: by mail-it0-x243.google.com with SMTP id e132so11952980ite.2 for ; Sun, 23 Apr 2017 15:41:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=B22Il4U+lW9qJRmIpKE7jAR5AR4P5G5MCstdmwVkA+0=; b=nZkeRedOqBvyJwfWh0dOUxgJNykPohKYmpp9bgHC+5Nogzct+/AWzpaseEailrAvTU uy0h3iqg8jzpEHHukoftpAlB+tcQgge5aUwJwnOB34cRrExOIPypvw0tvNb7HXsTQXgA D2FZT3hF5P1qspvvpPz/ee5ShIH0uiHv+7LFlqAqYAgs0ZcyW1AosY7EAUgPvb41uPeH K8VOrafxjuW/uP2lBsCkOdQr6v0pejtLHlji6CTqgae33Zx6OAObfOi0SNcD+Ie4uRAo Y5445HY6Segx93DpNQ/F4MHycEGgpJMuK2SBrd3yoJDWcPsJjhUCO0ki3jhAv0dPmn2e Kk6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=B22Il4U+lW9qJRmIpKE7jAR5AR4P5G5MCstdmwVkA+0=; b=cupi1Bp05FfQSmoVgArZfGmtxwAKscw/SgyABHHPNbtjs5XzorxJimksaO0s6qQSSz 9SzG3nJQaQLOG5iSe149IGx2sDAysQKHpVVyLxclfLJo+xHYfwG76QDiZJTApFiCEmOU K8mGzIApAT8QF0mZcymuJSGFWZXCxdJaYTS/2C8Skh/D7GGEq2vlWJT4TcRhkCdAh9UM ZUE3idcNZGqyjxYum6bdMhAZFujUIiCLsJEm0GDaMdnvPCF4Yj/VF2C1dC8RndO9tEvt 464kQ+m0eMWmVLYyixLFH/2K62idEYcUC1x9WBQdRA73uH0QooqqAnZAbf0Sm2H+CM8F o3Yw== X-Gm-Message-State: AN3rC/4DBq6paUX/CO6Ea/Ef286bUdwWdnH9z41Lr0hJmu5Tv85QdFxO Nj0gaZgyGx0Q9g== X-Received: by 10.84.142.101 with SMTP id 92mr16615371plw.112.1492987275628; Sun, 23 Apr 2017 15:41:15 -0700 (PDT) Received: from localhost (z64.124-44-184.ppp.wakwak.ne.jp. [124.44.184.64]) by smtp.gmail.com with ESMTPSA id a77sm26938403pfe.33.2017.04.23.15.41.14 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 23 Apr 2017 15:41:15 -0700 (PDT) From: Stafford Horne To: QEMU Development Date: Mon, 24 Apr 2017 07:40:49 +0900 Message-Id: <356a2db3c6f84e8e79e5afa3913514184bff5f50.1492986468.git.shorne@gmail.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4001:c0b::243 Subject: [Qemu-devel] [PATCH v2 1/9] target/openrisc: Implement EVBAR register X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Stafford Horne , Openrisc , "Tim \\'mithro\\' Ansell" Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Tim 'mithro' Ansell Exception Vector Base Address Register (EVBAR) - This optional register can be used to apply an offset to the exception vector addresses. The significant bits (31-12) of the vector offset address for each exception depend on the setting of the Supervision Register (SR)'s EPH bit and the Exception Vector Base Address Register (EVBAR). Its presence is indicated by the EVBARP bit in the CPU Configuration Register (CPUCFGR). Signed-off-by: Tim 'mithro' Ansell Signed-off-by: Stafford Horne --- target/openrisc/cpu.c | 2 ++ target/openrisc/cpu.h | 7 +++++++ target/openrisc/interrupt.c | 6 +++++- target/openrisc/sys_helper.c | 7 +++++++ 4 files changed, 21 insertions(+), 1 deletion(-) diff --git a/target/openrisc/cpu.c b/target/openrisc/cpu.c index 7fd2b9a..1524ed9 100644 --- a/target/openrisc/cpu.c +++ b/target/openrisc/cpu.c @@ -134,6 +134,7 @@ static void or1200_initfn(Object *obj) set_feature(cpu, OPENRISC_FEATURE_OB32S); set_feature(cpu, OPENRISC_FEATURE_OF32S); + set_feature(cpu, OPENRISC_FEATURE_EVBAR); } static void openrisc_any_initfn(Object *obj) @@ -141,6 +142,7 @@ static void openrisc_any_initfn(Object *obj) OpenRISCCPU *cpu = OPENRISC_CPU(obj); set_feature(cpu, OPENRISC_FEATURE_OB32S); + set_feature(cpu, OPENRISC_FEATURE_EVBAR); } typedef struct OpenRISCCPUInfo { diff --git a/target/openrisc/cpu.h b/target/openrisc/cpu.h index 418a0e6..1958b72 100644 --- a/target/openrisc/cpu.h +++ b/target/openrisc/cpu.h @@ -111,6 +111,11 @@ enum { CPUCFGR_OF32S = (1 << 7), CPUCFGR_OF64S = (1 << 8), CPUCFGR_OV64S = (1 << 9), + /* CPUCFGR_ND = (1 << 10), */ + /* CPUCFGR_AVRP = (1 << 11), */ + CPUCFGR_EVBARP = (1 << 12), + /* CPUCFGR_ISRP = (1 << 13), */ + /* CPUCFGR_AECSRP = (1 << 14), */ }; /* DMMU configure register */ @@ -200,6 +205,7 @@ enum { OPENRISC_FEATURE_OF32S = (1 << 7), OPENRISC_FEATURE_OF64S = (1 << 8), OPENRISC_FEATURE_OV64S = (1 << 9), + OPENRISC_FEATURE_EVBAR = (1 << 12), }; /* Tick Timer Mode Register */ @@ -289,6 +295,7 @@ typedef struct CPUOpenRISCState { uint32_t dmmucfgr; /* DMMU configure register */ uint32_t immucfgr; /* IMMU configure register */ uint32_t esr; /* Exception supervisor register */ + uint32_t evbar; /* Exception vector base address register */ uint32_t fpcsr; /* Float register */ float_status fp_status; diff --git a/target/openrisc/interrupt.c b/target/openrisc/interrupt.c index a2eec6f..78f0ba9 100644 --- a/target/openrisc/interrupt.c +++ b/target/openrisc/interrupt.c @@ -65,7 +65,11 @@ void openrisc_cpu_do_interrupt(CPUState *cs) env->lock_addr = -1; if (cs->exception_index > 0 && cs->exception_index < EXCP_NR) { - env->pc = (cs->exception_index << 8); + hwaddr vect_pc = cs->exception_index << 8; + if (env->cpucfgr & CPUCFGR_EVBARP) { + vect_pc |= env->evbar; + } + env->pc = vect_pc; } else { cpu_abort(cs, "Unhandled exception 0x%x\n", cs->exception_index); } diff --git a/target/openrisc/sys_helper.c b/target/openrisc/sys_helper.c index 60c3193..6ba8162 100644 --- a/target/openrisc/sys_helper.c +++ b/target/openrisc/sys_helper.c @@ -39,6 +39,10 @@ void HELPER(mtspr)(CPUOpenRISCState *env, env->vr = rb; break; + case TO_SPR(0, 11): /* EVBAR */ + env->evbar = rb; + break; + case TO_SPR(0, 16): /* NPC */ cpu_restore_state(cs, GETPC()); /* ??? Mirror or1ksim in not trashing delayed branch state @@ -206,6 +210,9 @@ target_ulong HELPER(mfspr)(CPUOpenRISCState *env, case TO_SPR(0, 4): /* IMMUCFGR */ return env->immucfgr; + case TO_SPR(0, 11): /* EVBAR */ + return env->evbar; + case TO_SPR(0, 16): /* NPC (equals PC) */ cpu_restore_state(cs, GETPC()); return env->pc;