[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC v4 08/11] target/mips: Add support for native library calls
From: |
Yeqi Fu |
Subject: |
[RFC v4 08/11] target/mips: Add support for native library calls |
Date: |
Tue, 8 Aug 2023 22:17:36 +0800 |
This commit introduces support for native library calls on the
mips target. When special instructions reserved for native calls
are encountered, the code now performs address translation 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 | 21 ++++++++++++++++++++-
3 files changed, 22 insertions(+), 1 deletion(-)
diff --git a/configs/targets/mips-linux-user.mak
b/configs/targets/mips-linux-user.mak
index b4569a9893..fa005d487a 100644
--- a/configs/targets/mips-linux-user.mak
+++ b/configs/targets/mips-linux-user.mak
@@ -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
diff --git a/configs/targets/mips64-linux-user.mak
b/configs/targets/mips64-linux-user.mak
index d2ff509a11..ecfe6bcf73 100644
--- a/configs/targets/mips64-linux-user.mak
+++ b/configs/targets/mips64-linux-user.mak
@@ -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
diff --git a/target/mips/tcg/translate.c b/target/mips/tcg/translate.c
index 74af91e4f5..51a5c1d49b 100644
--- a/target/mips/tcg/translate.c
+++ b/target/mips/tcg/translate.c
@@ -36,6 +36,7 @@
#include "exec/helper-info.c.inc"
#undef HELPER_H
+#include "native/native.h"
/*
* Many sysemu-only helpers are not reachable for user-only.
@@ -13487,7 +13488,7 @@ static void decode_opc_special_legacy(CPUMIPSState
*env, DisasContext *ctx)
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 +13584,24 @@ static void decode_opc_special(CPUMIPSState *env,
DisasContext *ctx)
#endif
break;
case OPC_SYSCALL:
+ sig = (ctx->opcode) >> 6;
+ if ((sig == 0xffff) && native_bypass_enabled()) {
+ TCGv arg1 = tcg_temp_new();
+ TCGv arg2 = tcg_temp_new();
+ TCGv arg3 = tcg_temp_new();
+ TCGv ret = tcg_temp_new();
+ const char *fun_name = lookup_symbol((ctx->base.pc_next) & 0xfff);
+ tcg_gen_mov_tl(arg1, cpu_gpr[4]);
+ tcg_gen_mov_tl(arg2, cpu_gpr[5]);
+ tcg_gen_mov_tl(arg3, cpu_gpr[6]);
+#if defined(TARGET_MIPS64)
+ gen_native_call_i64(fun_name, ret, arg1, arg2, arg3);
+#else
+ gen_native_call_i32(fun_name, ret, arg1, arg2, arg3);
+#endif
+ tcg_gen_mov_tl(cpu_gpr[2], ret);
+ break;
+ }
generate_exception_end(ctx, EXCP_SYSCALL);
break;
case OPC_BREAK:
--
2.34.1
- [RFC v4 05/11] linux-user/elfload: Add support for parsing symbols of native libraries., (continued)
- [RFC v4 05/11] linux-user/elfload: Add support for parsing symbols of native libraries., Yeqi Fu, 2023/08/08
- [RFC v4 04/11] linux-user: Implement native-bypass option support, Yeqi Fu, 2023/08/08
- [RFC v4 06/11] tcg: Add tcg opcodes and helpers for native library calls, Yeqi Fu, 2023/08/08
- [RFC v4 07/11] target/i386: Add support for native library calls, Yeqi Fu, 2023/08/08
- [RFC v4 08/11] target/mips: Add support for native library calls,
Yeqi Fu <=
- [RFC v4 09/11] target/arm: Add support for native library calls, Yeqi Fu, 2023/08/08
- [RFC v4 10/11] tests/tcg/multiarch: Add nativecall.c test, Yeqi Fu, 2023/08/08
- [RFC v4 11/11] docs/user: Add doc for native library calls, Yeqi Fu, 2023/08/08