mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-05 08:43:55 -06:00
RISC-V: Adding XTheadCmo ISA extension
This patch adds support for the XTheadCmo ISA extension. To avoid interfering with standard extensions, decoder and translation are in its own xthead* specific files. Future patches should be able to easily add additional T-Head extension. The implementation does not have much functionality (besides accepting the instructions and not qualifying them as illegal instructions if the hart executes in the required privilege level for the instruction), as QEMU does not model CPU caches and instructions are documented to not raise any exceptions. Co-developed-by: LIU Zhiwei <zhiwei_liu@linux.alibaba.com> Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu> Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Message-Id: <20230131202013.2541053-2-christoph.muellner@vrull.eu> Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
This commit is contained in:
parent
4b402886ac
commit
49a7f3aabb
6 changed files with 131 additions and 0 deletions
81
target/riscv/insn_trans/trans_xthead.c.inc
Normal file
81
target/riscv/insn_trans/trans_xthead.c.inc
Normal file
|
@ -0,0 +1,81 @@
|
|||
/*
|
||||
* RISC-V translation routines for the T-Head vendor extensions (xthead*).
|
||||
*
|
||||
* Copyright (c) 2022 VRULL GmbH.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
* version 2 or later, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#define REQUIRE_XTHEADCMO(ctx) do { \
|
||||
if (!ctx->cfg_ptr->ext_xtheadcmo) { \
|
||||
return false; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
/* XTheadCmo */
|
||||
|
||||
static inline int priv_level(DisasContext *ctx)
|
||||
{
|
||||
#ifdef CONFIG_USER_ONLY
|
||||
return PRV_U;
|
||||
#else
|
||||
/* Priv level is part of mem_idx. */
|
||||
return ctx->mem_idx & TB_FLAGS_PRIV_MMU_MASK;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Test if priv level is M, S, or U (cannot fail). */
|
||||
#define REQUIRE_PRIV_MSU(ctx)
|
||||
|
||||
/* Test if priv level is M or S. */
|
||||
#define REQUIRE_PRIV_MS(ctx) \
|
||||
do { \
|
||||
int priv = priv_level(ctx); \
|
||||
if (!(priv == PRV_M || \
|
||||
priv == PRV_S)) { \
|
||||
return false; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define NOP_PRIVCHECK(insn, extcheck, privcheck) \
|
||||
static bool trans_ ## insn(DisasContext *ctx, arg_ ## insn * a) \
|
||||
{ \
|
||||
(void) a; \
|
||||
extcheck(ctx); \
|
||||
privcheck(ctx); \
|
||||
return true; \
|
||||
}
|
||||
|
||||
NOP_PRIVCHECK(th_dcache_call, REQUIRE_XTHEADCMO, REQUIRE_PRIV_MS)
|
||||
NOP_PRIVCHECK(th_dcache_ciall, REQUIRE_XTHEADCMO, REQUIRE_PRIV_MS)
|
||||
NOP_PRIVCHECK(th_dcache_iall, REQUIRE_XTHEADCMO, REQUIRE_PRIV_MS)
|
||||
NOP_PRIVCHECK(th_dcache_cpa, REQUIRE_XTHEADCMO, REQUIRE_PRIV_MS)
|
||||
NOP_PRIVCHECK(th_dcache_cipa, REQUIRE_XTHEADCMO, REQUIRE_PRIV_MS)
|
||||
NOP_PRIVCHECK(th_dcache_ipa, REQUIRE_XTHEADCMO, REQUIRE_PRIV_MS)
|
||||
NOP_PRIVCHECK(th_dcache_cva, REQUIRE_XTHEADCMO, REQUIRE_PRIV_MSU)
|
||||
NOP_PRIVCHECK(th_dcache_civa, REQUIRE_XTHEADCMO, REQUIRE_PRIV_MSU)
|
||||
NOP_PRIVCHECK(th_dcache_iva, REQUIRE_XTHEADCMO, REQUIRE_PRIV_MSU)
|
||||
NOP_PRIVCHECK(th_dcache_csw, REQUIRE_XTHEADCMO, REQUIRE_PRIV_MS)
|
||||
NOP_PRIVCHECK(th_dcache_cisw, REQUIRE_XTHEADCMO, REQUIRE_PRIV_MS)
|
||||
NOP_PRIVCHECK(th_dcache_isw, REQUIRE_XTHEADCMO, REQUIRE_PRIV_MS)
|
||||
NOP_PRIVCHECK(th_dcache_cpal1, REQUIRE_XTHEADCMO, REQUIRE_PRIV_MS)
|
||||
NOP_PRIVCHECK(th_dcache_cval1, REQUIRE_XTHEADCMO, REQUIRE_PRIV_MS)
|
||||
|
||||
NOP_PRIVCHECK(th_icache_iall, REQUIRE_XTHEADCMO, REQUIRE_PRIV_MS)
|
||||
NOP_PRIVCHECK(th_icache_ialls, REQUIRE_XTHEADCMO, REQUIRE_PRIV_MS)
|
||||
NOP_PRIVCHECK(th_icache_ipa, REQUIRE_XTHEADCMO, REQUIRE_PRIV_MS)
|
||||
NOP_PRIVCHECK(th_icache_iva, REQUIRE_XTHEADCMO, REQUIRE_PRIV_MSU)
|
||||
|
||||
NOP_PRIVCHECK(th_l2cache_call, REQUIRE_XTHEADCMO, REQUIRE_PRIV_MS)
|
||||
NOP_PRIVCHECK(th_l2cache_ciall, REQUIRE_XTHEADCMO, REQUIRE_PRIV_MS)
|
||||
NOP_PRIVCHECK(th_l2cache_iall, REQUIRE_XTHEADCMO, REQUIRE_PRIV_MS)
|
Loading…
Add table
Add a link
Reference in a new issue