aboutsummaryrefslogtreecommitdiff
path: root/semihosting
diff options
context:
space:
mode:
Diffstat (limited to 'semihosting')
-rw-r--r--semihosting/arm-compat-semi.c1
-rw-r--r--semihosting/console.c3
-rw-r--r--semihosting/meson.build9
-rw-r--r--semihosting/stubs-all.c6
-rw-r--r--semihosting/stubs-system.c6
-rw-r--r--semihosting/syscalls.c2
-rw-r--r--semihosting/uaccess.c15
-rw-r--r--semihosting/user.c21
8 files changed, 46 insertions, 17 deletions
diff --git a/semihosting/arm-compat-semi.c b/semihosting/arm-compat-semi.c
index d78c642..86e5260 100644
--- a/semihosting/arm-compat-semi.c
+++ b/semihosting/arm-compat-semi.c
@@ -166,6 +166,7 @@ static LayoutInfo common_semi_find_bases(CPUState *cs)
#endif
+#include "cpu.h"
#include "common-semi-target.h"
/*
diff --git a/semihosting/console.c b/semihosting/console.c
index 60102bb..c3683a1 100644
--- a/semihosting/console.c
+++ b/semihosting/console.c
@@ -18,14 +18,15 @@
#include "qemu/osdep.h"
#include "semihosting/semihost.h"
#include "semihosting/console.h"
+#include "exec/cpu-common.h"
#include "exec/gdbstub.h"
-#include "exec/exec-all.h"
#include "qemu/log.h"
#include "chardev/char.h"
#include "chardev/char-fe.h"
#include "qemu/main-loop.h"
#include "qapi/error.h"
#include "qemu/fifo8.h"
+#include "hw/core/cpu.h"
/* Access to this structure is protected by the BQL */
typedef struct SemihostingConsole {
diff --git a/semihosting/meson.build b/semihosting/meson.build
index 34933e5..b1ab250 100644
--- a/semihosting/meson.build
+++ b/semihosting/meson.build
@@ -3,14 +3,15 @@ specific_ss.add(when: 'CONFIG_SEMIHOSTING', if_true: files(
'syscalls.c',
))
-specific_ss.add(when: ['CONFIG_SEMIHOSTING', 'CONFIG_SYSTEM_ONLY'], if_true: files(
+common_ss.add(when: 'CONFIG_SEMIHOSTING', if_false: files('stubs-all.c'))
+user_ss.add(when: 'CONFIG_SEMIHOSTING', if_true: files('user.c'))
+system_ss.add(when: 'CONFIG_SEMIHOSTING', if_true: files(
'config.c',
'console.c',
'uaccess.c',
+), if_false: files(
+ 'stubs-system.c',
))
-common_ss.add(when: ['CONFIG_SEMIHOSTING', 'CONFIG_SYSTEM_ONLY'], if_false: files('stubs-all.c'))
-system_ss.add(when: ['CONFIG_SEMIHOSTING'], if_false: files('stubs-system.c'))
-
specific_ss.add(when: ['CONFIG_ARM_COMPATIBLE_SEMIHOSTING'],
if_true: files('arm-compat-semi.c'))
diff --git a/semihosting/stubs-all.c b/semihosting/stubs-all.c
index a2a1fc9..c001c84 100644
--- a/semihosting/stubs-all.c
+++ b/semihosting/stubs-all.c
@@ -11,6 +11,12 @@
#include "qemu/osdep.h"
#include "semihosting/semihost.h"
+/* Queries to config status default to off */
+bool semihosting_enabled(bool is_user)
+{
+ return false;
+}
+
SemihostingTarget semihosting_get_target(void)
{
return SEMIHOSTING_TARGET_AUTO;
diff --git a/semihosting/stubs-system.c b/semihosting/stubs-system.c
index f26cbb7..989789f 100644
--- a/semihosting/stubs-system.c
+++ b/semihosting/stubs-system.c
@@ -22,12 +22,6 @@ QemuOptsList qemu_semihosting_config_opts = {
},
};
-/* Queries to config status default to off */
-bool semihosting_enabled(bool is_user)
-{
- return false;
-}
-
/*
* All the rest are empty subs. We could g_assert_not_reached() but
* that adds extra weight to the final binary. Waste not want not.
diff --git a/semihosting/syscalls.c b/semihosting/syscalls.c
index c40348f..f6451d9 100644
--- a/semihosting/syscalls.c
+++ b/semihosting/syscalls.c
@@ -7,6 +7,7 @@
*/
#include "qemu/osdep.h"
+#include "qemu/log.h"
#include "cpu.h"
#include "gdbstub/syscalls.h"
#include "semihosting/guestfd.h"
@@ -287,6 +288,7 @@ static void host_open(CPUState *cs, gdb_syscall_complete_cb complete,
ret = open(p, host_flags, mode);
if (ret < 0) {
+ qemu_log_mask(LOG_GUEST_ERROR, "%s: failed to open %s\n", __func__, p);
complete(cs, -1, errno);
} else {
int guestfd = alloc_guestfd();
diff --git a/semihosting/uaccess.c b/semihosting/uaccess.c
index dc587d7..ff944d8 100644
--- a/semihosting/uaccess.c
+++ b/semihosting/uaccess.c
@@ -8,11 +8,14 @@
*/
#include "qemu/osdep.h"
-#include "exec/exec-all.h"
+#include "accel/tcg/cpu-mmu-index.h"
+#include "accel/tcg/probe.h"
+#include "exec/target_page.h"
+#include "exec/tlb-flags.h"
#include "semihosting/uaccess.h"
-void *uaccess_lock_user(CPUArchState *env, target_ulong addr,
- target_ulong len, bool copy)
+void *uaccess_lock_user(CPUArchState *env, vaddr addr,
+ size_t len, bool copy)
{
void *p = malloc(len);
if (p && copy) {
@@ -24,7 +27,7 @@ void *uaccess_lock_user(CPUArchState *env, target_ulong addr,
return p;
}
-ssize_t uaccess_strlen_user(CPUArchState *env, target_ulong addr)
+ssize_t uaccess_strlen_user(CPUArchState *env, vaddr addr)
{
int mmu_idx = cpu_mmu_index(env_cpu(env), false);
size_t len = 0;
@@ -72,7 +75,7 @@ ssize_t uaccess_strlen_user(CPUArchState *env, target_ulong addr)
}
}
-char *uaccess_lock_user_string(CPUArchState *env, target_ulong addr)
+char *uaccess_lock_user_string(CPUArchState *env, vaddr addr)
{
ssize_t len = uaccess_strlen_user(env, addr);
if (len < 0) {
@@ -82,7 +85,7 @@ char *uaccess_lock_user_string(CPUArchState *env, target_ulong addr)
}
void uaccess_unlock_user(CPUArchState *env, void *p,
- target_ulong addr, target_ulong len)
+ vaddr addr, size_t len)
{
if (len) {
cpu_memory_rw_debug(env_cpu(env), addr, p, len, 1);
diff --git a/semihosting/user.c b/semihosting/user.c
new file mode 100644
index 0000000..98c144c
--- /dev/null
+++ b/semihosting/user.c
@@ -0,0 +1,21 @@
+/*
+ * Semihosting for user emulation
+ *
+ * Copyright (c) 2019 Linaro Ltd
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "qemu/osdep.h"
+#include "semihosting/semihost.h"
+
+bool semihosting_enabled(bool is_user)
+{
+ assert(is_user);
+ return true;
+}
+
+SemihostingTarget semihosting_get_target(void)
+{
+ return SEMIHOSTING_TARGET_AUTO;
+}