Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
target/riscv: add support for Zcmt extension
Add encode, trans* functions and helper functions support for Zcmt instrutions. Add support for jvt csr. Signed-off-by: Weiwei Li <liweiwei@iscas.ac.cn> Signed-off-by: Junqiang Wang <wangjunqiang@iscas.ac.cn> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Message-Id: <20230307081403.61950-8-liweiwei@iscas.ac.cn> Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
- Loading branch information
1 parent
193eb52
commit ce3af0b
Showing
9 changed files
with
157 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| /* | ||
| * RISC-V Zcmt Extension Helper for QEMU. | ||
| * | ||
| * Copyright (c) 2021-2022 PLCT Lab | ||
| * | ||
| * 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/>. | ||
| */ | ||
|
|
||
| #include "qemu/osdep.h" | ||
| #include "cpu.h" | ||
| #include "exec/exec-all.h" | ||
| #include "exec/helper-proto.h" | ||
| #include "exec/cpu_ldst.h" | ||
|
|
||
| target_ulong HELPER(cm_jalt)(CPURISCVState *env, uint32_t index) | ||
| { | ||
|
|
||
| #if !defined(CONFIG_USER_ONLY) | ||
| RISCVException ret = smstateen_acc_ok(env, 0, SMSTATEEN0_JVT); | ||
| if (ret != RISCV_EXCP_NONE) { | ||
| riscv_raise_exception(env, ret, 0); | ||
| } | ||
| #endif | ||
|
|
||
| target_ulong target; | ||
| target_ulong val = env->jvt; | ||
| int xlen = riscv_cpu_xlen(env); | ||
| uint8_t mode = get_field(val, JVT_MODE); | ||
| target_ulong base = val & JVT_BASE; | ||
| target_ulong t0; | ||
|
|
||
| if (mode != 0) { | ||
| riscv_raise_exception(env, RISCV_EXCP_ILLEGAL_INST, 0); | ||
| } | ||
|
|
||
| if (xlen == 32) { | ||
| t0 = base + (index << 2); | ||
| target = cpu_ldl_code(env, t0); | ||
| } else { | ||
| t0 = base + (index << 3); | ||
| target = cpu_ldq_code(env, t0); | ||
| } | ||
|
|
||
| return target & ~0x1; | ||
| } |