diff options
Diffstat (limited to 'semihosting')
-rw-r--r-- | semihosting/meson.build | 10 | ||||
-rw-r--r-- | semihosting/stubs-all.c | 6 | ||||
-rw-r--r-- | semihosting/stubs-system.c | 6 | ||||
-rw-r--r-- | semihosting/uaccess.c | 16 | ||||
-rw-r--r-- | semihosting/user.c | 21 |
5 files changed, 40 insertions, 19 deletions
diff --git a/semihosting/meson.build b/semihosting/meson.build index 86f5004..b1ab250 100644 --- a/semihosting/meson.build +++ b/semihosting/meson.build @@ -3,14 +3,12 @@ specific_ss.add(when: 'CONFIG_SEMIHOSTING', if_true: files( 'syscalls.c', )) -specific_ss.add(when: ['CONFIG_SEMIHOSTING', 'CONFIG_SYSTEM_ONLY'], if_true: files( - 'uaccess.c', -)) - -common_ss.add(when: ['CONFIG_SEMIHOSTING', 'CONFIG_SYSTEM_ONLY'], if_false: files('stubs-all.c')) -system_ss.add(when: ['CONFIG_SEMIHOSTING'], 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', )) 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/uaccess.c b/semihosting/uaccess.c index 382a366..ff944d8 100644 --- a/semihosting/uaccess.c +++ b/semihosting/uaccess.c @@ -8,12 +8,14 @@ */ #include "qemu/osdep.h" -#include "exec/cpu-all.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) { @@ -25,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; @@ -73,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) { @@ -83,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; +} |