@@ -3,3 +3,4 @@ TARGET_ABI_MIPSO32=y
TARGET_SYSTBL_ABI=o32
TARGET_SYSTBL=syscall_o32.tbl
TARGET_BIG_ENDIAN=y
+CONFIG_NATIVE_CALL=y
@@ -4,3 +4,4 @@ TARGET_BASE_ARCH=mips
TARGET_SYSTBL_ABI=n64
TARGET_SYSTBL=syscall_n64.tbl
TARGET_BIG_ENDIAN=y
+CONFIG_NATIVE_CALL=y
@@ -31,6 +31,7 @@
#include "trace.h"
#include "disas/disas.h"
#include "fpu_helper.h"
+#include "native/native.h"
#define HELPER_H "helper.h"
#include "exec/helper-info.c.inc"
@@ -13484,10 +13485,32 @@ static void decode_opc_special_legacy(CPUMIPSState *env, DisasContext *ctx)
}
}
+static void gen_native_call(DisasContext *ctx, CPUMIPSState *env)
+{
+#ifdef CONFIG_USER_ONLY
+ char *func_name;
+ uint32_t func_tmp;
+ TCGv arg1 = tcg_temp_new();
+ TCGv arg2 = tcg_temp_new();
+ TCGv arg3 = tcg_temp_new();
+ TCGv ret = tcg_temp_new();
+ tcg_gen_mov_tl(arg1, cpu_gpr[4]);
+ tcg_gen_mov_tl(arg2, cpu_gpr[5]);
+ tcg_gen_mov_tl(arg3, cpu_gpr[6]);
+ ctx->base.pc_next += 4;
+ func_tmp = translator_ldl(env, &ctx->base, ctx->base.pc_next);
+ func_name = g2h(env_cpu(env), ctx->base.pc_next + func_tmp);
+ if (!gen_native_call_tl(func_name, ret, arg1, arg2, arg3)) {
+ gen_reserved_instruction(ctx);
+ }
+ tcg_gen_mov_tl(cpu_gpr[2], ret);
+#endif
+}
+
static void decode_opc_special(CPUMIPSState *env, DisasContext *ctx)
{
int rs, rt, rd, sa;
- uint32_t op1;
+ uint32_t op1, sig;
rs = (ctx->opcode >> 21) & 0x1f;
rt = (ctx->opcode >> 16) & 0x1f;
@@ -13583,6 +13606,11 @@ static void decode_opc_special(CPUMIPSState *env, DisasContext *ctx)
#endif
break;
case OPC_SYSCALL:
+ sig = (ctx->opcode) >> 6;
+ if ((sig == 0xffff) && native_bypass_enabled()) {
+ gen_native_call(ctx, env);
+ break;
+ }
generate_exception_end(ctx, EXCP_SYSCALL);
break;
case OPC_BREAK:
This commit introduces support for native library calls on the mips target. When encountering special instructions reserved for native calls, this commit extracts the function name and generates the corresponding native call. Signed-off-by: Yeqi Fu <fufuyqqqqqq@gmail.com> --- configs/targets/mips-linux-user.mak | 1 + configs/targets/mips64-linux-user.mak | 1 + target/mips/tcg/translate.c | 30 ++++++++++++++++++++++++++- 3 files changed, 31 insertions(+), 1 deletion(-)