qemu-devel
[Top][All Lists]
Advanced

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

[PATCH 4/6] target/tricore: Add close semihosting call


From: Bastian Koppelmann
Subject: [PATCH 4/6] target/tricore: Add close semihosting call
Date: Sun, 15 Oct 2023 22:59:11 +0200

Signed-off-by: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>
---
 target/tricore/tricore-semi.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/target/tricore/tricore-semi.c b/target/tricore/tricore-semi.c
index 6f321391ef..2188ceeed0 100644
--- a/target/tricore/tricore-semi.c
+++ b/target/tricore/tricore-semi.c
@@ -164,6 +164,19 @@ static void tricore_vio_set_result(CPUTriCoreState *env, 
int retval,
     env->gpr_d[12] = tricore_vio_errno_h2g(host_errno);
 }
 
+static void tricore_vio_close(CPUTriCoreState *env)
+{
+    int fd = env->gpr_d[4];
+    int res = 0;
+    int err = 0;
+
+    if (fd > 2) {
+        res = close(fd);
+        err = errno;
+    }
+
+    tricore_vio_set_result(env, res, err);
+}
 
 static void tricore_vio_lseek(CPUTriCoreState *env)
 {
@@ -245,6 +258,9 @@ void helper_tricore_semihost(CPUTriCoreState *env, uint32_t 
pc)
 
     syscall = (int)env->gpr_d[12];
     switch (syscall) {
+    case SYS__CLOSE:
+        tricore_vio_close(env);
+        break;
     case SYS__LSEEK:
         tricore_vio_lseek(env);
         break;
-- 
2.42.0




reply via email to

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