qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [RFC v3 08/10] target/mips: Add support for native library calls


From: Philippe Mathieu-Daudé
Subject: Re: [RFC v3 08/10] target/mips: Add support for native library calls
Date: Sun, 25 Jun 2023 23:53:52 +0200
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.12.0

On 25/6/23 23:27, Yeqi Fu wrote:
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() && sig) {
               if (ctx->native_call_status) {
                   ...
               } else {
                   ...
               }
               break;
           }

+        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:




reply via email to

[Prev in Thread] Current Thread [Next in Thread]