[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC v3 08/10] target/mips: Add support for native library calls
From: |
Yeqi Fu |
Subject: |
[RFC v3 08/10] target/mips: Add support for native library calls |
Date: |
Mon, 26 Jun 2023 05:27:05 +0800 |
Upon encountering specialized instructions reserved for native calls,
store the function id and argument types, then invoke helper.
Signed-off-by: Yeqi Fu <fufuyqqqqqq@gmail.com>
---
target/mips/tcg/translate.c | 26 ++++++++++++++++++++++++++
target/mips/tcg/translate.h | 2 ++
2 files changed, 28 insertions(+)
diff --git a/target/mips/tcg/translate.c b/target/mips/tcg/translate.c
index a6ca2e5a3b..15ab889dca 100644
--- a/target/mips/tcg/translate.c
+++ b/target/mips/tcg/translate.c
@@ -36,6 +36,7 @@
#include "qemu/qemu-print.h"
#include "fpu_helper.h"
#include "translate.h"
+#include "native/native-defs.h"
/*
* Many sysemu-only helpers are not reachable for user-only.
@@ -13592,6 +13593,31 @@ static void decode_opc_special(CPUMIPSState *env,
DisasContext *ctx)
#endif
break;
case OPC_SYSCALL:
+ uint32_t sig = (ctx->opcode) >> 6;
+ if (native_call_enabled() && (!ctx->native_call_status) && sig) {
+ ctx->native_call_status = true;
+ ctx->native_call_id = sig;
+ break;
+ } else if (native_call_enabled() && (ctx->native_call_status) && sig) {
+ TCGv arg1 = tcg_temp_new();
+ TCGv arg2 = tcg_temp_new();
+ TCGv arg3 = 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]);
+
+ TCGv_i32 abi_map = tcg_constant_i32(sig);
+ TCGv_i32 func_id = tcg_constant_i32(ctx->native_call_id);
+ TCGv res = tcg_temp_new();
+ TCGv_i32 mmu_idx = tcg_constant_i32(MMU_USER_IDX);
+ gen_helper_native_call(res, cpu_env, arg1, arg2, arg3,
+ abi_map, func_id, mmu_idx);
+ tcg_gen_mov_tl(cpu_gpr[2], res);
+ ctx->native_call_status = false;
+ ctx->native_call_id = 0;
+ break;
+ }
generate_exception_end(ctx, EXCP_SYSCALL);
break;
case OPC_BREAK:
diff --git a/target/mips/tcg/translate.h b/target/mips/tcg/translate.h
index 69f85841d2..bc603297cc 100644
--- a/target/mips/tcg/translate.h
+++ b/target/mips/tcg/translate.h
@@ -49,6 +49,8 @@ typedef struct DisasContext {
bool saar;
bool mi;
int gi;
+ bool native_call_status;
+ int native_call_id;
} DisasContext;
#define DISAS_STOP DISAS_TARGET_0
--
2.34.1
- [RFC v3 00/10] Native Library Calls, Yeqi Fu, 2023/06/25
- [RFC v3 01/10] docs: Add specification for native library calls, Yeqi Fu, 2023/06/25
- [RFC v3 02/10] build: Add configure options for native calls, Yeqi Fu, 2023/06/25
- [RFC v3 03/10] build: Implement libnative library and configure options, Yeqi Fu, 2023/06/25
- [RFC v3 04/10] linux-user: Implement envlist_appendenv, Yeqi Fu, 2023/06/25
- [RFC v3 05/10] linux-user: Implement native-bypass option support, Yeqi Fu, 2023/06/25
- [RFC v3 06/10] accel/tcg: Add support for native library calls, Yeqi Fu, 2023/06/25
- [RFC v3 07/10] target/i386: Add support for native library calls, Yeqi Fu, 2023/06/25
- [RFC v3 08/10] target/mips: Add support for native library calls,
Yeqi Fu <=
- [RFC v3 09/10] target/arm: Add support for native library calls, Yeqi Fu, 2023/06/25
- [RFC v3 10/10] tests/tcg/multiarch: Add nativecalls.c test, Yeqi Fu, 2023/06/25