From: Leon Alrae <leon.alrae@imgtec.com>
To: qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org, christopher.covington@linaro.org,
matthew.fortune@imgtec.com, ilg@livius.net
Subject: [Qemu-devel] [PATCH 2/4] semihosting: remove semihosting_target declaration from gdbstub.h
Date: Wed, 6 May 2015 15:57:07 +0100 [thread overview]
Message-ID: <1430924229-20469-3-git-send-email-leon.alrae@imgtec.com> (raw)
In-Reply-To: <1430924229-20469-1-git-send-email-leon.alrae@imgtec.com>
Follow the semihosting_enabled() approach and move semihosting_target
related stuff to semihost.h.
Signed-off-by: Leon Alrae <leon.alrae@imgtec.com>
---
gdbstub.c | 8 ++++----
include/exec/gdbstub.h | 6 ------
include/exec/semihost.h | 12 ++++++++++++
vl.c | 6 ++++++
4 files changed, 22 insertions(+), 10 deletions(-)
diff --git a/gdbstub.c b/gdbstub.c
index 8abcb8a..9931d81 100644
--- a/gdbstub.c
+++ b/gdbstub.c
@@ -40,6 +40,7 @@
#include "cpu.h"
#include "qemu/sockets.h"
#include "sysemu/kvm.h"
+#include "exec/semihost.h"
static inline int target_memory_rw_debug(CPUState *cpu, target_ulong addr,
uint8_t *buf, int len, bool is_write)
@@ -317,8 +318,6 @@ static GDBState *gdbserver_state;
bool gdb_has_xml;
-int semihosting_target = SEMIHOSTING_TARGET_AUTO;
-
#ifdef CONFIG_USER_ONLY
/* XXX: This is not thread safe. Do we care? */
static int gdbserver_fd = -1;
@@ -356,10 +355,11 @@ static enum {
/* Decide if either remote gdb syscalls or native file IO should be used. */
int use_gdb_syscalls(void)
{
- if (semihosting_target == SEMIHOSTING_TARGET_NATIVE) {
+ SemihostingTarget target = semihosting_get_target();
+ if (target == SEMIHOSTING_TARGET_NATIVE) {
/* -semihosting-config target=native */
return false;
- } else if (semihosting_target == SEMIHOSTING_TARGET_GDB) {
+ } else if (target == SEMIHOSTING_TARGET_GDB) {
/* -semihosting-config target=gdb */
return true;
}
diff --git a/include/exec/gdbstub.h b/include/exec/gdbstub.h
index c633248..a608a26 100644
--- a/include/exec/gdbstub.h
+++ b/include/exec/gdbstub.h
@@ -95,10 +95,4 @@ extern bool gdb_has_xml;
/* in gdbstub-xml.c, generated by scripts/feature_to_c.sh */
extern const char *const xml_builtin[][2];
-/* Command line option defining whether semihosting should go via gdb or not */
-extern int semihosting_target;
-#define SEMIHOSTING_TARGET_AUTO 0
-#define SEMIHOSTING_TARGET_NATIVE 1
-#define SEMIHOSTING_TARGET_GDB 2
-
#endif
diff --git a/include/exec/semihost.h b/include/exec/semihost.h
index 5d9a916..c2f0bcb 100644
--- a/include/exec/semihost.h
+++ b/include/exec/semihost.h
@@ -20,13 +20,25 @@
#ifndef SEMIHOST_H
#define SEMIHOST_H
+typedef enum SemihostingTarget {
+ SEMIHOSTING_TARGET_AUTO = 0,
+ SEMIHOSTING_TARGET_NATIVE,
+ SEMIHOSTING_TARGET_GDB
+} SemihostingTarget;
+
#ifdef CONFIG_USER_ONLY
static inline bool semihosting_enabled(void)
{
return true;
}
+
+static inline SemihostingTarget semihosting_get_target(void)
+{
+ return SEMIHOSTING_TARGET_AUTO;
+}
#else
bool semihosting_enabled(void);
+SemihostingTarget semihosting_get_target(void);
#endif
#endif
diff --git a/vl.c b/vl.c
index 5a8040d..a42f127 100644
--- a/vl.c
+++ b/vl.c
@@ -1228,12 +1228,18 @@ static void configure_msg(QemuOpts *opts)
/* Semihosting */
static bool semihosting_allowed;
+static SemihostingTarget semihosting_target;
bool semihosting_enabled(void)
{
return semihosting_allowed;
}
+SemihostingTarget semihosting_get_target(void)
+{
+ return semihosting_target;
+}
+
/***********************************************************/
/* USB devices */
next prev parent reply other threads:[~2015-05-06 14:58 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-06 14:57 [Qemu-devel] [PATCH 0/4] semihosting: clean up and add --semihosting-config arg Leon Alrae
2015-05-06 14:57 ` [Qemu-devel] [PATCH 1/4] semihosting: remove semihosting_enabled declaration from sysemu.h Leon Alrae
2015-05-06 14:57 ` Leon Alrae [this message]
2015-05-06 14:57 ` [Qemu-devel] [PATCH 3/4] semihosting: create SemihostingConfig struct Leon Alrae
2015-05-06 14:57 ` [Qemu-devel] [PATCH 4/4] semihosting: add --semihosting-config arg sub-argument Leon Alrae
2015-05-07 6:51 ` Liviu Ionescu
2015-05-07 9:52 ` Leon Alrae
2015-05-07 11:50 ` Liviu Ionescu
2015-05-07 12:21 ` Leon Alrae
2015-05-07 12:35 ` Liviu Ionescu
2015-05-07 12:42 ` Leon Alrae
2015-05-06 15:22 ` [Qemu-devel] [PATCH 0/4] semihosting: clean up and add --semihosting-config arg Liviu Ionescu
2015-05-06 16:12 ` Leon Alrae
2015-05-13 5:48 ` Liviu Ionescu
2015-05-13 9:29 ` Leon Alrae
2015-05-13 9:44 ` Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1430924229-20469-3-git-send-email-leon.alrae@imgtec.com \
--to=leon.alrae@imgtec.com \
--cc=christopher.covington@linaro.org \
--cc=ilg@livius.net \
--cc=matthew.fortune@imgtec.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).