aboutsummaryrefslogtreecommitdiff
path: root/target
diff options
context:
space:
mode:
authorRichard Henderson <richard.henderson@linaro.org>2022-04-29 16:44:44 -0700
committerRichard Henderson <richard.henderson@linaro.org>2022-06-28 10:13:16 +0530
commitab294b6c3adfc8a9241f2aaff0709c51acf0370b (patch)
tree4d1ac8cde03b5324a93b882c3fc74665b9aacf4e /target
parent1b9177f7495086f1595d7c989c810013f1c9eb5a (diff)
target/m68k: Eliminate m68k_semi_is_fseek
Reorg m68k_semi_return_* to gdb_syscall_complete_cb. Use the 32-bit version normally, and the 64-bit version for HOSTED_LSEEK. Reviewed-by: Laurent Vivier <laurent@vivier.eu> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Diffstat (limited to 'target')
-rw-r--r--target/m68k/m68k-semi.c55
1 files changed, 23 insertions, 32 deletions
diff --git a/target/m68k/m68k-semi.c b/target/m68k/m68k-semi.c
index 8c186c0e9f..37b409b0b9 100644
--- a/target/m68k/m68k-semi.c
+++ b/target/m68k/m68k-semi.c
@@ -95,8 +95,11 @@ static void translate_stat(CPUM68KState *env, target_ulong addr, struct stat *s)
unlock_user(p, addr, sizeof(struct gdb_stat));
}
-static void m68k_semi_return_u32(CPUM68KState *env, uint32_t ret, int err)
+static void m68k_semi_u32_cb(CPUState *cs, uint64_t ret, int err)
{
+ M68kCPU *cpu = M68K_CPU(cs);
+ CPUM68KState *env = &cpu->env;
+
target_ulong args = env->dregs[1];
if (put_user_u32(ret, args) ||
put_user_u32(err, args + 4)) {
@@ -110,8 +113,11 @@ static void m68k_semi_return_u32(CPUM68KState *env, uint32_t ret, int err)
}
}
-static void m68k_semi_return_u64(CPUM68KState *env, uint64_t ret, int err)
+static void m68k_semi_u64_cb(CPUState *cs, uint64_t ret, int err)
{
+ M68kCPU *cpu = M68K_CPU(cs);
+ CPUM68KState *env = &cpu->env;
+
target_ulong args = env->dregs[1];
if (put_user_u32(ret >> 32, args) ||
put_user_u32(ret, args + 4) ||
@@ -122,21 +128,6 @@ static void m68k_semi_return_u64(CPUM68KState *env, uint64_t ret, int err)
}
}
-static int m68k_semi_is_fseek;
-
-static void m68k_semi_cb(CPUState *cs, uint64_t ret, int err)
-{
- M68kCPU *cpu = M68K_CPU(cs);
- CPUM68KState *env = &cpu->env;
-
- if (m68k_semi_is_fseek) {
- m68k_semi_return_u64(env, ret, err);
- m68k_semi_is_fseek = 0;
- } else {
- m68k_semi_return_u32(env, ret, err);
- }
-}
-
/*
* Read the input value from the argument block; fail the semihosting
* call if the memory read fails.
@@ -151,6 +142,7 @@ static void m68k_semi_cb(CPUState *cs, uint64_t ret, int err)
void do_m68k_semihosting(CPUM68KState *env, int nr)
{
+ CPUState *cs = env_cpu(env);
uint32_t args;
target_ulong arg0, arg1, arg2, arg3;
void *p;
@@ -169,7 +161,7 @@ void do_m68k_semihosting(CPUM68KState *env, int nr)
GET_ARG(2);
GET_ARG(3);
if (use_gdb_syscalls()) {
- gdb_do_syscall(m68k_semi_cb, "open,%s,%x,%x", arg0, (int)arg1,
+ gdb_do_syscall(m68k_semi_u32_cb, "open,%s,%x,%x", arg0, (int)arg1,
arg2, arg3);
return;
} else {
@@ -190,7 +182,7 @@ void do_m68k_semihosting(CPUM68KState *env, int nr)
int fd = arg0;
if (fd > 2) {
if (use_gdb_syscalls()) {
- gdb_do_syscall(m68k_semi_cb, "close,%x", arg0);
+ gdb_do_syscall(m68k_semi_u32_cb, "close,%x", arg0);
return;
} else {
result = close(fd);
@@ -206,7 +198,7 @@ void do_m68k_semihosting(CPUM68KState *env, int nr)
GET_ARG(2);
len = arg2;
if (use_gdb_syscalls()) {
- gdb_do_syscall(m68k_semi_cb, "read,%x,%x,%x",
+ gdb_do_syscall(m68k_semi_u32_cb, "read,%x,%x,%x",
arg0, arg1, len);
return;
} else {
@@ -226,7 +218,7 @@ void do_m68k_semihosting(CPUM68KState *env, int nr)
GET_ARG(2);
len = arg2;
if (use_gdb_syscalls()) {
- gdb_do_syscall(m68k_semi_cb, "write,%x,%x,%x",
+ gdb_do_syscall(m68k_semi_u32_cb, "write,%x,%x,%x",
arg0, arg1, len);
return;
} else {
@@ -249,12 +241,11 @@ void do_m68k_semihosting(CPUM68KState *env, int nr)
GET_ARG(3);
off = (uint32_t)arg2 | ((uint64_t)arg1 << 32);
if (use_gdb_syscalls()) {
- m68k_semi_is_fseek = 1;
- gdb_do_syscall(m68k_semi_cb, "fseek,%x,%lx,%x",
+ gdb_do_syscall(m68k_semi_u64_cb, "fseek,%x,%lx,%x",
arg0, off, arg3);
} else {
off = lseek(arg0, off, arg3);
- m68k_semi_return_u64(env, off, errno);
+ m68k_semi_u64_cb(cs, off, errno);
}
return;
}
@@ -264,7 +255,7 @@ void do_m68k_semihosting(CPUM68KState *env, int nr)
GET_ARG(2);
GET_ARG(3);
if (use_gdb_syscalls()) {
- gdb_do_syscall(m68k_semi_cb, "rename,%s,%s",
+ gdb_do_syscall(m68k_semi_u32_cb, "rename,%s,%s",
arg0, (int)arg1, arg2, (int)arg3);
return;
} else {
@@ -284,7 +275,7 @@ void do_m68k_semihosting(CPUM68KState *env, int nr)
GET_ARG(0);
GET_ARG(1);
if (use_gdb_syscalls()) {
- gdb_do_syscall(m68k_semi_cb, "unlink,%s",
+ gdb_do_syscall(m68k_semi_u32_cb, "unlink,%s",
arg0, (int)arg1);
return;
} else {
@@ -303,7 +294,7 @@ void do_m68k_semihosting(CPUM68KState *env, int nr)
GET_ARG(1);
GET_ARG(2);
if (use_gdb_syscalls()) {
- gdb_do_syscall(m68k_semi_cb, "stat,%s,%x",
+ gdb_do_syscall(m68k_semi_u32_cb, "stat,%s,%x",
arg0, (int)arg1, arg2);
return;
} else {
@@ -325,7 +316,7 @@ void do_m68k_semihosting(CPUM68KState *env, int nr)
GET_ARG(0);
GET_ARG(1);
if (use_gdb_syscalls()) {
- gdb_do_syscall(m68k_semi_cb, "fstat,%x,%x",
+ gdb_do_syscall(m68k_semi_u32_cb, "fstat,%x,%x",
arg0, arg1);
return;
} else {
@@ -340,7 +331,7 @@ void do_m68k_semihosting(CPUM68KState *env, int nr)
GET_ARG(0);
GET_ARG(1);
if (use_gdb_syscalls()) {
- gdb_do_syscall(m68k_semi_cb, "gettimeofday,%x,%x",
+ gdb_do_syscall(m68k_semi_u32_cb, "gettimeofday,%x,%x",
arg0, arg1);
return;
} else {
@@ -361,7 +352,7 @@ void do_m68k_semihosting(CPUM68KState *env, int nr)
case HOSTED_ISATTY:
GET_ARG(0);
if (use_gdb_syscalls()) {
- gdb_do_syscall(m68k_semi_cb, "isatty,%x", arg0);
+ gdb_do_syscall(m68k_semi_u32_cb, "isatty,%x", arg0);
return;
} else {
result = isatty(arg0);
@@ -371,7 +362,7 @@ void do_m68k_semihosting(CPUM68KState *env, int nr)
GET_ARG(0);
GET_ARG(1);
if (use_gdb_syscalls()) {
- gdb_do_syscall(m68k_semi_cb, "system,%s",
+ gdb_do_syscall(m68k_semi_u32_cb, "system,%s",
arg0, (int)arg1);
return;
} else {
@@ -429,5 +420,5 @@ void do_m68k_semihosting(CPUM68KState *env, int nr)
result = 0;
}
failed:
- m68k_semi_return_u32(env, result, errno);
+ m68k_semi_u32_cb(cs, result, errno);
}