--semihosting-cmdline added
PATCH 1/1 --semihosting-cmdline added
This patch adds a new option (--semihosting-cmdline) to define the entire command line to be passed via semihosting, since -kernal and -append might generate very long lines.
This option must be placed at the end, all subsequent arguments are passed to the application.
Other changes:
- typedef struct ... Semihosting added, with
all semihosting config variables
- use a minimalistic boot info in armv7m.c
Signed-off-by Liviu Ionescu <[email protected]>
--- gdbstub.c | 6 ++-- hw/arm/armv7m.c | 12 +++++++ include/exec/gdbstub.h | 6 ---- include/sysemu/sysemu.h | 21 +++++++++++- qemu-options.hx | 13 ++++++++ target-arm/arm-semi.c | 21 +++++++++--- vl.c | 85 ++++++++++++++++++++++++++++++++++++++++++------- 7 files changed, 138 insertions(+), 26 deletions(-)
gdbstub.c +2 -4
@@ -317,8 +317,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 +354,10 @@ 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 ) { +if (semihosting.target ==SEMIHOSTING_TARGET_NATIVE ) {/* -semihosting-config target=native */ return false; - }else if (semihosting_target ==SEMIHOSTING_TARGET_GDB ) { + }else if (semihosting.target ==SEMIHOSTING_TARGET_GDB ) {/* -semihosting-config target=gdb */ return true; }
hw/arm/armv7m.c +12 -0
@@ -179,6 +179,7 @@ qemu_irq *armv7m_init(MemoryRegion *system_memory, int mem_size, int num_irq,int i;int big_endian;MemoryRegion *hack =g_new (MemoryRegion,1 ); +static struct arm_boot_info boot_info;if (cpu_model ==NULL ) { cpu_model ="cortex-m3" ;
@@ -213,6 +214,17 @@ qemu_irq *armv7m_init(MemoryRegion *system_memory, int mem_size, int num_irq,exit (1 ); } +/* +* Fill-in a minimalistic boot info, required for semihosting. +* kernel_cmdline should be initialised with machine->kernel_cmdline, +* but we do not have machine here. Suggestion: change prototype +* and add "MachineState *machine". +*/ + boot_info.kernel_cmdline ="" ; + boot_info.kernel_filename = kernel_filename; + + env->boot_info = &boot_info; +if (kernel_filename) { image_size =load_elf (kernel_filename,NULL ,NULL , &entry, &lowaddr,NULL , big_endian,ELF_MACHINE ,1 );
include/exec/gdbstub.h +0 -6
@@ -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
include/sysemu/sysemu.h +20 -1
@@ -125,7 +125,26 @@ extern int cursor_hide;extern int graphic_rotate;extern int no_quit;extern int no_shutdown; -extern int semihosting_enabled; + +/* Define where the semihosting calls are sent. */ +#define SEMIHOSTING_TARGET_AUTO 0 +#define SEMIHOSTING_TARGET_NATIVE 1 +#define SEMIHOSTING_TARGET_GDB 2 + +/* Semihosting status */ +typedef struct { +int enabled;/* 1 if enabled */ +int target;/* see above */ +int argc; +char **argv; +const char *cmdline;/* concatenated argv */ +}Semihosting ; + +extern Semihosting semihosting; + +/* Temporary definition, until all references are replaced. */ +#define semihosting_enabled semihosting.enabled +extern int old_param;extern int boot_menu;extern bool boot_strict;
qemu-options.hx +13 -0
@@ -3305,6 +3305,19 @@ Enable semihosting and define where the semihosting calls will be addressed, to QEMU (@code{native}) or to GDB (@code{gdb}). The default is @code{auto}, which means @code{gdb} during debug sessions and @code{native} otherwise (ARM, M68K, Xtensa only). ETEXI +DEF("semihosting-cmdline", 0, QEMU_OPTION_semihosting_cmdline, + "-semihosting-cmdline semihosting command line\n", +QEMU_ARCH_ARM | QEMU_ARCH_M68K | QEMU_ARCH_XTENSA | QEMU_ARCH_LM32) +STEXI +@item -semihosting-cmdline +@findex -semihosting-cmdline +The +@code{cmdline} defines the entire command line passed to the application via the +semihosting calls, including the program name that will be +passed as argv[0]. Must be the last option, all following arguments +are passed to the application unchanged. +(ARM, M68K, Xtensa only) +ETEXI DEF("old-param", 0, QEMU_OPTION_old_param, "-old-param old param mode\n", QEMU_ARCH_ARM) STEXI
target-arm/arm-semi.c +17 -4
@@ -35,6 +35,9 @@#include "qemu-common.h" #include "exec/gdbstub.h" #include "hw/arm/arm.h" +#include "qemu/option.h" +#include "qemu/config-file.h" +#include "sysemu/sysemu.h" #endif #define TARGET_SYS_OPEN 0x01
@@ -440,10 +443,14 @@ uint32_t do_arm_semihosting(CPUARMState *env) input_size = arg1;/* Compute the size of the output string. */ #if !defined(CONFIG_USER_ONLY ) - output_size =strlen (ts->boot_info->kernel_filename) +if (semihosting.cmdline) { + output_size =strlen (semihosting.cmdline) +1 ; + }else { + output_size =strlen (ts->boot_info->kernel_filename) +1 /* Separating space. */ +strlen (ts->boot_info->kernel_cmdline) +1 ;/* Terminating null byte. */ + }#else unsigned int i;
@@ -474,9 +481,15 @@ uint32_t do_arm_semihosting(CPUARMState *env)/* Copy the command-line arguments. */ #if !defined(CONFIG_USER_ONLY ) -pstrcpy (output_buffer, output_size, ts->boot_info->kernel_filename); -pstrcat (output_buffer, output_size," " ); -pstrcat (output_buffer, output_size, ts->boot_info->kernel_cmdline); +if (semihosting.cmdline) { +pstrcpy (output_buffer, output_size, semihosting.cmdline); + }else { +pstrcpy (output_buffer, output_size, + ts->boot_info->kernel_filename); +pstrcat (output_buffer, output_size," " ); +pstrcat (output_buffer, output_size, + ts->boot_info->kernel_cmdline); + }#else if (output_size ==1 ) {/* Empty command-line. */
vl.c +74 -11
144 lines not on this page · raw message
Signature · 1 line
2.3.2 (Apple Git-55)