diff mbox

[3/4] semihosting: create SemihostingConfig struct

Message ID 1430924229-20469-4-git-send-email-leon.alrae@imgtec.com
State New
Headers show

Commit Message

Leon Alrae May 6, 2015, 2:57 p.m. UTC
Group semihosting config related variables in a single structure.

Signed-off-by: Leon Alrae <leon.alrae@imgtec.com>
---
 vl.c | 28 ++++++++++++++++------------
 1 file changed, 16 insertions(+), 12 deletions(-)
diff mbox

Patch

diff --git a/vl.c b/vl.c
index a42f127..82586c7 100644
--- a/vl.c
+++ b/vl.c
@@ -1227,17 +1227,21 @@  static void configure_msg(QemuOpts *opts)
 /***********************************************************/
 /* Semihosting */
 
-static bool semihosting_allowed;
-static SemihostingTarget semihosting_target;
+typedef struct SemihostingConfig {
+    bool allowed;
+    SemihostingTarget target;
+} SemihostingConfig;
+
+static SemihostingConfig semihosting;
 
 bool semihosting_enabled(void)
 {
-    return semihosting_allowed;
+    return semihosting.allowed;
 }
 
 SemihostingTarget semihosting_get_target(void)
 {
-    return semihosting_target;
+    return semihosting.target;
 }
 
 /***********************************************************/
@@ -3561,24 +3565,24 @@  int main(int argc, char **argv, char **envp)
                 nb_option_roms++;
                 break;
             case QEMU_OPTION_semihosting:
-                semihosting_allowed = true;
-                semihosting_target = SEMIHOSTING_TARGET_AUTO;
+                semihosting.allowed = true;
+                semihosting.target = SEMIHOSTING_TARGET_AUTO;
                 break;
             case QEMU_OPTION_semihosting_config:
-                semihosting_allowed = true;
+                semihosting.allowed = true;
                 opts = qemu_opts_parse(qemu_find_opts("semihosting-config"),
                                            optarg, 0);
                 if (opts != NULL) {
-                    semihosting_allowed = qemu_opt_get_bool(opts, "enable",
+                    semihosting.allowed = qemu_opt_get_bool(opts, "enable",
                                                             true);
                     const char *target = qemu_opt_get(opts, "target");
                     if (target != NULL) {
                         if (strcmp("native", target) == 0) {
-                            semihosting_target = SEMIHOSTING_TARGET_NATIVE;
+                            semihosting.target = SEMIHOSTING_TARGET_NATIVE;
                         } else if (strcmp("gdb", target) == 0) {
-                            semihosting_target = SEMIHOSTING_TARGET_GDB;
+                            semihosting.target = SEMIHOSTING_TARGET_GDB;
                         } else  if (strcmp("auto", target) == 0) {
-                            semihosting_target = SEMIHOSTING_TARGET_AUTO;
+                            semihosting.target = SEMIHOSTING_TARGET_AUTO;
                         } else {
                             fprintf(stderr, "Unsupported semihosting-config"
                                     " %s\n",
@@ -3586,7 +3590,7 @@  int main(int argc, char **argv, char **envp)
                             exit(1);
                         }
                     } else {
-                        semihosting_target = SEMIHOSTING_TARGET_AUTO;
+                        semihosting.target = SEMIHOSTING_TARGET_AUTO;
                     }
                 } else {
                     fprintf(stderr, "Unsupported semihosting-config %s\n",