mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 00:03:54 -06:00
semihosting: Move user-only implementation out-of-line
Avoid testing CONFIG_USER_ONLY in semihost.h. The only function that's required is semihosting_enabled. Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
parent
690793e005
commit
d0b4cfa629
5 changed files with 31 additions and 35 deletions
|
@ -26,32 +26,6 @@ typedef enum SemihostingTarget {
|
|||
SEMIHOSTING_TARGET_GDB
|
||||
} SemihostingTarget;
|
||||
|
||||
#ifdef CONFIG_USER_ONLY
|
||||
static inline bool semihosting_enabled(bool is_user)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
static inline SemihostingTarget semihosting_get_target(void)
|
||||
{
|
||||
return SEMIHOSTING_TARGET_AUTO;
|
||||
}
|
||||
|
||||
static inline const char *semihosting_get_arg(int i)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static inline int semihosting_get_argc(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline const char *semihosting_get_cmdline(void)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
#else /* !CONFIG_USER_ONLY */
|
||||
/**
|
||||
* semihosting_enabled:
|
||||
* @is_user: true if guest code is in usermode (i.e. not privileged)
|
||||
|
@ -59,17 +33,18 @@ static inline const char *semihosting_get_cmdline(void)
|
|||
* Return true if guest code is allowed to make semihosting calls.
|
||||
*/
|
||||
bool semihosting_enabled(bool is_user);
|
||||
|
||||
SemihostingTarget semihosting_get_target(void);
|
||||
const char *semihosting_get_arg(int i);
|
||||
int semihosting_get_argc(void);
|
||||
const char *semihosting_get_cmdline(void);
|
||||
void semihosting_arg_fallback(const char *file, const char *cmd);
|
||||
|
||||
/* for vl.c hooks */
|
||||
void qemu_semihosting_enable(void);
|
||||
int qemu_semihosting_config_options(const char *optstr);
|
||||
void qemu_semihosting_chardev_init(void);
|
||||
void qemu_semihosting_console_init(Chardev *);
|
||||
#endif /* CONFIG_USER_ONLY */
|
||||
void qemu_semihosting_guestfd_init(void);
|
||||
|
||||
#endif /* SEMIHOST_H */
|
||||
|
|
|
@ -7,8 +7,9 @@ specific_ss.add(when: ['CONFIG_SEMIHOSTING', 'CONFIG_SYSTEM_ONLY'], if_true: fil
|
|||
'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',
|
||||
), if_false: files(
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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.
|
||||
|
|
20
semihosting/user.c
Normal file
20
semihosting/user.c
Normal file
|
@ -0,0 +1,20 @@
|
|||
/*
|
||||
* 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)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
SemihostingTarget semihosting_get_target(void)
|
||||
{
|
||||
return SEMIHOSTING_TARGET_AUTO;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue