master
inc 62 lines 1.97 KB
Raw
1 /*
2 * RISC-V translation routines for the RISC-V Zawrs Extension.
3 *
4 * Copyright (c) 2022 Christoph Muellner, christoph.muellner@vrull.io
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2 or later, as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 *
15 * You should have received a copy of the GNU General Public License along with
16 * this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19 static bool trans_wrs_sto(DisasContext *ctx, arg_wrs_sto *a)
20 {
21 if (!ctx->cfg_ptr->ext_zawrs) {
22 return false;
23 }
24
25 /*
26 * The specification says:
27 * While stalled, an implementation is permitted to occasionally
28 * terminate the stall and complete execution for any reason.
29 *
30 * So let's just exit TB and return to the main loop.
31 */
32
33 /* Clear the load reservation (if any). */
34 tcg_gen_movi_tl(load_res, -1);
35
36 gen_update_pc(ctx, ctx->cur_insn_len);
37 tcg_gen_exit_tb(NULL, 0);
38 ctx->base.is_jmp = DISAS_NORETURN;
39
40 return true;
41 }
42
43 static bool trans_wrs_nto(DisasContext *ctx, arg_wrs_nto *a)
44 {
45 if (!ctx->cfg_ptr->ext_zawrs) {
46 return false;
47 }
48
49 /*
50 * Depending on the mode of execution, mstatus.TW and hstatus.VTW, wrs.nto
51 * should raise an exception when the implementation-specific bounded time
52 * limit has expired. Our time limit is zero, so we either return
53 * immediately, as does our implementation of wrs.sto, or raise an
54 * exception, as handled by the wrs.nto helper.
55 */
56 #ifndef CONFIG_USER_ONLY
57 gen_helper_wrs_nto(tcg_env);
58 #endif
59
60 /* We only get here when helper_wrs_nto() doesn't raise an exception. */
61 return trans_wrs_sto(ctx, NULL);
62 }