diff --git a/qemu/aarch64.h b/qemu/aarch64.h index 5bdc8aec..98f895c1 100644 --- a/qemu/aarch64.h +++ b/qemu/aarch64.h @@ -2582,6 +2582,11 @@ #define save_globals save_globals_aarch64 #define scr_write scr_write_aarch64 #define sctlr_write sctlr_write_aarch64 +#define semihosting_enabled semihosting_enabled_aarch64 +#define semihosting_get_target semihosting_get_target_aarch64 +#define semihosting_get_arg semihosting_get_arg_aarch64 +#define semihosting_get_argc semihosting_get_argc_aarch64 +#define semihosting_get_cmdline semihosting_get_cmdline_aarch64 #define set_bit set_bit_aarch64 #define set_bits set_bits_aarch64 #define set_default_nan_mode set_default_nan_mode_aarch64 diff --git a/qemu/aarch64eb.h b/qemu/aarch64eb.h index 370e376e..fcac2407 100644 --- a/qemu/aarch64eb.h +++ b/qemu/aarch64eb.h @@ -2582,6 +2582,11 @@ #define save_globals save_globals_aarch64eb #define scr_write scr_write_aarch64eb #define sctlr_write sctlr_write_aarch64eb +#define semihosting_enabled semihosting_enabled_aarch64eb +#define semihosting_get_target semihosting_get_target_aarch64eb +#define semihosting_get_arg semihosting_get_arg_aarch64eb +#define semihosting_get_argc semihosting_get_argc_aarch64eb +#define semihosting_get_cmdline semihosting_get_cmdline_aarch64eb #define set_bit set_bit_aarch64eb #define set_bits set_bits_aarch64eb #define set_default_nan_mode set_default_nan_mode_aarch64eb diff --git a/qemu/arm.h b/qemu/arm.h index 0b553965..f5dd7e72 100644 --- a/qemu/arm.h +++ b/qemu/arm.h @@ -2582,6 +2582,11 @@ #define save_globals save_globals_arm #define scr_write scr_write_arm #define sctlr_write sctlr_write_arm +#define semihosting_enabled semihosting_enabled_arm +#define semihosting_get_target semihosting_get_target_arm +#define semihosting_get_arg semihosting_get_arg_arm +#define semihosting_get_argc semihosting_get_argc_arm +#define semihosting_get_cmdline semihosting_get_cmdline_arm #define set_bit set_bit_arm #define set_bits set_bits_arm #define set_default_nan_mode set_default_nan_mode_arm diff --git a/qemu/armeb.h b/qemu/armeb.h index d0847eb4..5a5e5948 100644 --- a/qemu/armeb.h +++ b/qemu/armeb.h @@ -2582,6 +2582,11 @@ #define save_globals save_globals_armeb #define scr_write scr_write_armeb #define sctlr_write sctlr_write_armeb +#define semihosting_enabled semihosting_enabled_armeb +#define semihosting_get_target semihosting_get_target_armeb +#define semihosting_get_arg semihosting_get_arg_armeb +#define semihosting_get_argc semihosting_get_argc_armeb +#define semihosting_get_cmdline semihosting_get_cmdline_armeb #define set_bit set_bit_armeb #define set_bits set_bits_armeb #define set_default_nan_mode set_default_nan_mode_armeb diff --git a/qemu/header_gen.py b/qemu/header_gen.py index 2e63f65c..2a529e4c 100644 --- a/qemu/header_gen.py +++ b/qemu/header_gen.py @@ -2588,6 +2588,11 @@ symbols = ( 'save_globals', 'scr_write', 'sctlr_write', + 'semihosting_enabled', + 'semihosting_get_target', + 'semihosting_get_arg', + 'semihosting_get_argc', + 'semihosting_get_cmdline', 'set_bit', 'set_bits', 'set_default_nan_mode', diff --git a/qemu/include/exec/semihost.h b/qemu/include/exec/semihost.h new file mode 100644 index 00000000..e227bcc1 --- /dev/null +++ b/qemu/include/exec/semihost.h @@ -0,0 +1,64 @@ +/* + * Semihosting support + * + * Copyright (c) 2015 Imagination Technologies + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +#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) +{ + // UNICORN: Always return false + return false; + // 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 +bool semihosting_enabled(void); +SemihostingTarget semihosting_get_target(void); +const char *semihosting_get_arg(int i); +int semihosting_get_argc(void); +const char *semihosting_get_cmdline(void); +#endif + +#endif diff --git a/qemu/m68k.h b/qemu/m68k.h index d87688a0..571aa4c3 100644 --- a/qemu/m68k.h +++ b/qemu/m68k.h @@ -2582,6 +2582,11 @@ #define save_globals save_globals_m68k #define scr_write scr_write_m68k #define sctlr_write sctlr_write_m68k +#define semihosting_enabled semihosting_enabled_m68k +#define semihosting_get_target semihosting_get_target_m68k +#define semihosting_get_arg semihosting_get_arg_m68k +#define semihosting_get_argc semihosting_get_argc_m68k +#define semihosting_get_cmdline semihosting_get_cmdline_m68k #define set_bit set_bit_m68k #define set_bits set_bits_m68k #define set_default_nan_mode set_default_nan_mode_m68k diff --git a/qemu/mips.h b/qemu/mips.h index e0c70aad..aa41cca2 100644 --- a/qemu/mips.h +++ b/qemu/mips.h @@ -2582,6 +2582,11 @@ #define save_globals save_globals_mips #define scr_write scr_write_mips #define sctlr_write sctlr_write_mips +#define semihosting_enabled semihosting_enabled_mips +#define semihosting_get_target semihosting_get_target_mips +#define semihosting_get_arg semihosting_get_arg_mips +#define semihosting_get_argc semihosting_get_argc_mips +#define semihosting_get_cmdline semihosting_get_cmdline_mips #define set_bit set_bit_mips #define set_bits set_bits_mips #define set_default_nan_mode set_default_nan_mode_mips diff --git a/qemu/mips64.h b/qemu/mips64.h index 89d592f1..c222d46b 100644 --- a/qemu/mips64.h +++ b/qemu/mips64.h @@ -2582,6 +2582,11 @@ #define save_globals save_globals_mips64 #define scr_write scr_write_mips64 #define sctlr_write sctlr_write_mips64 +#define semihosting_enabled semihosting_enabled_mips64 +#define semihosting_get_target semihosting_get_target_mips64 +#define semihosting_get_arg semihosting_get_arg_mips64 +#define semihosting_get_argc semihosting_get_argc_mips64 +#define semihosting_get_cmdline semihosting_get_cmdline_mips64 #define set_bit set_bit_mips64 #define set_bits set_bits_mips64 #define set_default_nan_mode set_default_nan_mode_mips64 diff --git a/qemu/mips64el.h b/qemu/mips64el.h index bccf9fc7..14db43ce 100644 --- a/qemu/mips64el.h +++ b/qemu/mips64el.h @@ -2582,6 +2582,11 @@ #define save_globals save_globals_mips64el #define scr_write scr_write_mips64el #define sctlr_write sctlr_write_mips64el +#define semihosting_enabled semihosting_enabled_mips64el +#define semihosting_get_target semihosting_get_target_mips64el +#define semihosting_get_arg semihosting_get_arg_mips64el +#define semihosting_get_argc semihosting_get_argc_mips64el +#define semihosting_get_cmdline semihosting_get_cmdline_mips64el #define set_bit set_bit_mips64el #define set_bits set_bits_mips64el #define set_default_nan_mode set_default_nan_mode_mips64el diff --git a/qemu/mipsel.h b/qemu/mipsel.h index ffdc81ea..54508f1d 100644 --- a/qemu/mipsel.h +++ b/qemu/mipsel.h @@ -2582,6 +2582,11 @@ #define save_globals save_globals_mipsel #define scr_write scr_write_mipsel #define sctlr_write sctlr_write_mipsel +#define semihosting_enabled semihosting_enabled_mipsel +#define semihosting_get_target semihosting_get_target_mipsel +#define semihosting_get_arg semihosting_get_arg_mipsel +#define semihosting_get_argc semihosting_get_argc_mipsel +#define semihosting_get_cmdline semihosting_get_cmdline_mipsel #define set_bit set_bit_mipsel #define set_bits set_bits_mipsel #define set_default_nan_mode set_default_nan_mode_mipsel diff --git a/qemu/powerpc.h b/qemu/powerpc.h index bb85ed78..daec1168 100644 --- a/qemu/powerpc.h +++ b/qemu/powerpc.h @@ -2582,6 +2582,11 @@ #define save_globals save_globals_powerpc #define scr_write scr_write_powerpc #define sctlr_write sctlr_write_powerpc +#define semihosting_enabled semihosting_enabled_powerpc +#define semihosting_get_target semihosting_get_target_powerpc +#define semihosting_get_arg semihosting_get_arg_powerpc +#define semihosting_get_argc semihosting_get_argc_powerpc +#define semihosting_get_cmdline semihosting_get_cmdline_powerpc #define set_bit set_bit_powerpc #define set_bits set_bits_powerpc #define set_default_nan_mode set_default_nan_mode_powerpc diff --git a/qemu/sparc.h b/qemu/sparc.h index 7873b848..1b3dcbdb 100644 --- a/qemu/sparc.h +++ b/qemu/sparc.h @@ -2582,6 +2582,11 @@ #define save_globals save_globals_sparc #define scr_write scr_write_sparc #define sctlr_write sctlr_write_sparc +#define semihosting_enabled semihosting_enabled_sparc +#define semihosting_get_target semihosting_get_target_sparc +#define semihosting_get_arg semihosting_get_arg_sparc +#define semihosting_get_argc semihosting_get_argc_sparc +#define semihosting_get_cmdline semihosting_get_cmdline_sparc #define set_bit set_bit_sparc #define set_bits set_bits_sparc #define set_default_nan_mode set_default_nan_mode_sparc diff --git a/qemu/sparc64.h b/qemu/sparc64.h index 9fedc93e..f334cec4 100644 --- a/qemu/sparc64.h +++ b/qemu/sparc64.h @@ -2582,6 +2582,11 @@ #define save_globals save_globals_sparc64 #define scr_write scr_write_sparc64 #define sctlr_write sctlr_write_sparc64 +#define semihosting_enabled semihosting_enabled_sparc64 +#define semihosting_get_target semihosting_get_target_sparc64 +#define semihosting_get_arg semihosting_get_arg_sparc64 +#define semihosting_get_argc semihosting_get_argc_sparc64 +#define semihosting_get_cmdline semihosting_get_cmdline_sparc64 #define set_bit set_bit_sparc64 #define set_bits set_bits_sparc64 #define set_default_nan_mode set_default_nan_mode_sparc64 diff --git a/qemu/target-arm/translate-a64.c b/qemu/target-arm/translate-a64.c index 6d7f0fcd..6b551a28 100644 --- a/qemu/target-arm/translate-a64.c +++ b/qemu/target-arm/translate-a64.c @@ -32,7 +32,7 @@ #include "exec/helper-proto.h" #include "exec/helper-gen.h" - +#include "exec/semihost.h" #include "exec/gen-icount.h" #ifdef CONFIG_USER_ONLY diff --git a/qemu/vl.c b/qemu/vl.c index 8e42985f..f717db33 100644 --- a/qemu/vl.c +++ b/qemu/vl.c @@ -30,6 +30,7 @@ #include "sysemu/cpus.h" #include "vl.h" #include "uc_priv.h" +#include "exec/semihost.h" #include "crypto/init.h" #define DEFAULT_RAM_SIZE 128 @@ -54,6 +55,34 @@ void cpu_stop_current(struct uc_struct *uc) } } +/***********************************************************/ +/* Semihosting */ + +bool semihosting_enabled(void) +{ + // UNICORN: Always return false + return false; +} + +SemihostingTarget semihosting_get_target(void) +{ + return SEMIHOSTING_TARGET_AUTO; +} + +const char *semihosting_get_arg(int i) +{ + return NULL; +} + +int semihosting_get_argc(void) +{ + return 0; +} + +const char *semihosting_get_cmdline(void) +{ + return NULL; +} /***********************************************************/ /* machine registration */ diff --git a/qemu/x86_64.h b/qemu/x86_64.h index 1b5fcc13..cb209727 100644 --- a/qemu/x86_64.h +++ b/qemu/x86_64.h @@ -2582,6 +2582,11 @@ #define save_globals save_globals_x86_64 #define scr_write scr_write_x86_64 #define sctlr_write sctlr_write_x86_64 +#define semihosting_enabled semihosting_enabled_x86_64 +#define semihosting_get_target semihosting_get_target_x86_64 +#define semihosting_get_arg semihosting_get_arg_x86_64 +#define semihosting_get_argc semihosting_get_argc_x86_64 +#define semihosting_get_cmdline semihosting_get_cmdline_x86_64 #define set_bit set_bit_x86_64 #define set_bits set_bits_x86_64 #define set_default_nan_mode set_default_nan_mode_x86_64