2020-04-04 00:05:01 +03:00
|
|
|
/*
|
|
|
|
* RISC-V translation routines for the RVXI Base Integer Instruction Set.
|
|
|
|
*
|
|
|
|
* Copyright (c) 2020 Western Digital
|
|
|
|
*
|
|
|
|
* 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/>.
|
|
|
|
*/
|
|
|
|
|
2023-04-12 14:43:18 +03:00
|
|
|
#ifdef CONFIG_USER_ONLY
|
|
|
|
#define do_hlv(ctx, a, func) false
|
|
|
|
#define do_hsv(ctx, a, func) false
|
|
|
|
#else
|
|
|
|
static void gen_helper_hyp_hlv_b(TCGv r, TCGv_env e, TCGv a)
|
|
|
|
{
|
|
|
|
gen_helper_hyp_hlv_bu(r, e, a);
|
|
|
|
tcg_gen_ext8s_tl(r, r);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gen_helper_hyp_hlv_h(TCGv r, TCGv_env e, TCGv a)
|
|
|
|
{
|
|
|
|
gen_helper_hyp_hlv_hu(r, e, a);
|
|
|
|
tcg_gen_ext16s_tl(r, r);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gen_helper_hyp_hlv_w(TCGv r, TCGv_env e, TCGv a)
|
|
|
|
{
|
|
|
|
gen_helper_hyp_hlv_wu(r, e, a);
|
|
|
|
tcg_gen_ext32s_tl(r, r);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool do_hlv(DisasContext *ctx, arg_r2 *a,
|
|
|
|
void (*func)(TCGv, TCGv_env, TCGv))
|
|
|
|
{
|
|
|
|
TCGv dest = dest_gpr(ctx, a->rd);
|
|
|
|
TCGv addr = get_gpr(ctx, a->rs1, EXT_NONE);
|
|
|
|
|
|
|
|
decode_save_opc(ctx);
|
2023-09-14 02:37:36 +03:00
|
|
|
func(dest, tcg_env, addr);
|
2023-04-12 14:43:18 +03:00
|
|
|
gen_set_gpr(ctx, a->rd, dest);
|
2021-08-23 22:55:28 +03:00
|
|
|
return true;
|
2020-11-04 07:43:31 +03:00
|
|
|
}
|
|
|
|
|
2023-04-12 14:43:18 +03:00
|
|
|
static bool do_hsv(DisasContext *ctx, arg_r2_s *a,
|
|
|
|
void (*func)(TCGv_env, TCGv, TCGv))
|
2020-08-12 22:13:19 +03:00
|
|
|
{
|
2023-04-12 14:43:18 +03:00
|
|
|
TCGv addr = get_gpr(ctx, a->rs1, EXT_NONE);
|
|
|
|
TCGv data = get_gpr(ctx, a->rs2, EXT_NONE);
|
|
|
|
|
2023-01-20 15:59:50 +03:00
|
|
|
decode_save_opc(ctx);
|
2023-09-14 02:37:36 +03:00
|
|
|
func(tcg_env, addr, data);
|
2021-08-23 22:55:28 +03:00
|
|
|
return true;
|
2020-08-12 22:13:19 +03:00
|
|
|
}
|
2023-04-12 14:43:18 +03:00
|
|
|
#endif /* CONFIG_USER_ONLY */
|
2020-08-12 22:13:19 +03:00
|
|
|
|
2021-08-23 22:55:28 +03:00
|
|
|
static bool trans_hlv_b(DisasContext *ctx, arg_hlv_b *a)
|
2020-08-12 22:13:19 +03:00
|
|
|
{
|
|
|
|
REQUIRE_EXT(ctx, RVH);
|
2023-04-12 14:43:18 +03:00
|
|
|
return do_hlv(ctx, a, gen_helper_hyp_hlv_b);
|
2021-08-23 22:55:28 +03:00
|
|
|
}
|
2020-08-12 22:13:19 +03:00
|
|
|
|
2021-08-23 22:55:28 +03:00
|
|
|
static bool trans_hlv_h(DisasContext *ctx, arg_hlv_h *a)
|
|
|
|
{
|
|
|
|
REQUIRE_EXT(ctx, RVH);
|
2023-04-12 14:43:18 +03:00
|
|
|
return do_hlv(ctx, a, gen_helper_hyp_hlv_h);
|
2020-08-12 22:13:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static bool trans_hlv_w(DisasContext *ctx, arg_hlv_w *a)
|
|
|
|
{
|
|
|
|
REQUIRE_EXT(ctx, RVH);
|
2023-04-12 14:43:18 +03:00
|
|
|
return do_hlv(ctx, a, gen_helper_hyp_hlv_w);
|
2020-08-12 22:13:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static bool trans_hlv_bu(DisasContext *ctx, arg_hlv_bu *a)
|
|
|
|
{
|
|
|
|
REQUIRE_EXT(ctx, RVH);
|
2023-04-12 14:43:18 +03:00
|
|
|
return do_hlv(ctx, a, gen_helper_hyp_hlv_bu);
|
2020-08-12 22:13:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static bool trans_hlv_hu(DisasContext *ctx, arg_hlv_hu *a)
|
|
|
|
{
|
|
|
|
REQUIRE_EXT(ctx, RVH);
|
2023-04-12 14:43:18 +03:00
|
|
|
return do_hlv(ctx, a, gen_helper_hyp_hlv_hu);
|
2020-08-12 22:13:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static bool trans_hsv_b(DisasContext *ctx, arg_hsv_b *a)
|
|
|
|
{
|
|
|
|
REQUIRE_EXT(ctx, RVH);
|
2023-04-12 14:43:18 +03:00
|
|
|
return do_hsv(ctx, a, gen_helper_hyp_hsv_b);
|
2020-08-12 22:13:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static bool trans_hsv_h(DisasContext *ctx, arg_hsv_h *a)
|
|
|
|
{
|
|
|
|
REQUIRE_EXT(ctx, RVH);
|
2023-04-12 14:43:18 +03:00
|
|
|
return do_hsv(ctx, a, gen_helper_hyp_hsv_h);
|
2020-08-12 22:13:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static bool trans_hsv_w(DisasContext *ctx, arg_hsv_w *a)
|
|
|
|
{
|
|
|
|
REQUIRE_EXT(ctx, RVH);
|
2023-04-12 14:43:18 +03:00
|
|
|
return do_hsv(ctx, a, gen_helper_hyp_hsv_w);
|
2020-08-12 22:13:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static bool trans_hlv_wu(DisasContext *ctx, arg_hlv_wu *a)
|
|
|
|
{
|
2021-04-24 06:34:12 +03:00
|
|
|
REQUIRE_64BIT(ctx);
|
2020-08-12 22:13:19 +03:00
|
|
|
REQUIRE_EXT(ctx, RVH);
|
2023-04-12 14:43:18 +03:00
|
|
|
return do_hlv(ctx, a, gen_helper_hyp_hlv_wu);
|
2020-08-12 22:13:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static bool trans_hlv_d(DisasContext *ctx, arg_hlv_d *a)
|
|
|
|
{
|
2021-04-24 06:34:12 +03:00
|
|
|
REQUIRE_64BIT(ctx);
|
2020-08-12 22:13:19 +03:00
|
|
|
REQUIRE_EXT(ctx, RVH);
|
2023-04-12 14:43:18 +03:00
|
|
|
return do_hlv(ctx, a, gen_helper_hyp_hlv_d);
|
2020-08-12 22:13:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static bool trans_hsv_d(DisasContext *ctx, arg_hsv_d *a)
|
|
|
|
{
|
2021-04-24 06:34:12 +03:00
|
|
|
REQUIRE_64BIT(ctx);
|
2020-08-12 22:13:19 +03:00
|
|
|
REQUIRE_EXT(ctx, RVH);
|
2023-04-12 14:43:18 +03:00
|
|
|
return do_hsv(ctx, a, gen_helper_hyp_hsv_d);
|
2020-08-12 22:13:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static bool trans_hlvx_hu(DisasContext *ctx, arg_hlvx_hu *a)
|
|
|
|
{
|
|
|
|
REQUIRE_EXT(ctx, RVH);
|
2023-04-12 14:43:18 +03:00
|
|
|
return do_hlv(ctx, a, gen_helper_hyp_hlvx_hu);
|
2020-08-12 22:13:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static bool trans_hlvx_wu(DisasContext *ctx, arg_hlvx_wu *a)
|
|
|
|
{
|
|
|
|
REQUIRE_EXT(ctx, RVH);
|
2023-04-12 14:43:18 +03:00
|
|
|
return do_hlv(ctx, a, gen_helper_hyp_hlvx_wu);
|
2020-08-12 22:13:19 +03:00
|
|
|
}
|
|
|
|
|
2020-04-04 00:05:01 +03:00
|
|
|
static bool trans_hfence_gvma(DisasContext *ctx, arg_sfence_vma *a)
|
|
|
|
{
|
2020-04-04 01:54:59 +03:00
|
|
|
REQUIRE_EXT(ctx, RVH);
|
2020-04-04 00:05:01 +03:00
|
|
|
#ifndef CONFIG_USER_ONLY
|
2022-06-05 02:10:04 +03:00
|
|
|
decode_save_opc(ctx);
|
2023-09-14 02:37:36 +03:00
|
|
|
gen_helper_hyp_gvma_tlb_flush(tcg_env);
|
2020-04-04 01:54:59 +03:00
|
|
|
return true;
|
2020-04-04 00:05:01 +03:00
|
|
|
#endif
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool trans_hfence_vvma(DisasContext *ctx, arg_sfence_vma *a)
|
|
|
|
{
|
2020-04-04 01:54:59 +03:00
|
|
|
REQUIRE_EXT(ctx, RVH);
|
2020-04-04 00:05:01 +03:00
|
|
|
#ifndef CONFIG_USER_ONLY
|
2022-06-05 02:10:04 +03:00
|
|
|
decode_save_opc(ctx);
|
2023-09-14 02:37:36 +03:00
|
|
|
gen_helper_hyp_tlb_flush(tcg_env);
|
2020-04-04 01:54:59 +03:00
|
|
|
return true;
|
2020-04-04 00:05:01 +03:00
|
|
|
#endif
|
|
|
|
return false;
|
|
|
|
}
|