From patchwork Wed May 6 14:57:07 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leon Alrae X-Patchwork-Id: 468987 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id F2D271401B5 for ; Thu, 7 May 2015 01:00:34 +1000 (AEST) Received: from localhost ([::1]:45631 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yq0oL-0000tX-3c for incoming@patchwork.ozlabs.org; Wed, 06 May 2015 11:00:33 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33941) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yq0mR-0006cV-N4 for qemu-devel@nongnu.org; Wed, 06 May 2015 10:58:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Yq0mO-0005vQ-EY for qemu-devel@nongnu.org; Wed, 06 May 2015 10:58:35 -0400 Received: from mailapp01.imgtec.com ([195.59.15.196]:31281) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yq0mO-0005v4-9O for qemu-devel@nongnu.org; Wed, 06 May 2015 10:58:32 -0400 Received: from KLMAIL01.kl.imgtec.org (unknown [192.168.5.35]) by Websense Email Security Gateway with ESMTPS id ABCE8E8B2766F; Wed, 6 May 2015 15:58:28 +0100 (IST) Received: from lalrae-linux.kl.imgtec.org (192.168.14.163) by KLMAIL01.kl.imgtec.org (192.168.5.35) with Microsoft SMTP Server (TLS) id 14.3.195.1; Wed, 6 May 2015 15:57:28 +0100 From: Leon Alrae To: Date: Wed, 6 May 2015 15:57:07 +0100 Message-ID: <1430924229-20469-3-git-send-email-leon.alrae@imgtec.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1430924229-20469-1-git-send-email-leon.alrae@imgtec.com> References: <1430924229-20469-1-git-send-email-leon.alrae@imgtec.com> MIME-Version: 1.0 X-Originating-IP: [192.168.14.163] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 195.59.15.196 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 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Follow the semihosting_enabled() approach and move semihosting_target related stuff to semihost.h. Signed-off-by: Leon Alrae --- 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 */