diff options
author | Nick Clifton <nickc@redhat.com> | 2002-05-20 14:32:50 +0000 |
---|---|---|
committer | Nick Clifton <nickc@redhat.com> | 2002-05-20 14:32:50 +0000 |
commit | 480b0e0e9c4efe2cc4e206eb5dce20e4dbdf5e4f (patch) | |
tree | 51e9d70be5f1da8af9fffce4a0ef0f4de0cb2cd9 /sim/arm/wrapper.c | |
parent | 01420bf702f075c4b804b5f53d2a389ac0102e0a (diff) | |
download | gdb-480b0e0e9c4efe2cc4e206eb5dce20e4dbdf5e4f.tar.gz |
Add support for target specific command line switches to old-style simualtors.
Make use of this support in the ARM simulator to add a --swi-support= switch
to select whcih SWI protocols to emulate.
Diffstat (limited to 'sim/arm/wrapper.c')
-rw-r--r-- | sim/arm/wrapper.c | 118 |
1 files changed, 118 insertions, 0 deletions
diff --git a/sim/arm/wrapper.c b/sim/arm/wrapper.c index 773ef354d86..7493e8c9b9b 100644 --- a/sim/arm/wrapper.c +++ b/sim/arm/wrapper.c @@ -35,6 +35,7 @@ #include "dbg_rdi.h" #include "ansidecl.h" #include "sim-utils.h" +#include "run-sim.h" host_callback *sim_callback; @@ -426,6 +427,119 @@ sim_fetch_register (sd, rn, memory, length) return -1; } +#ifdef SIM_TARGET_SWITCHES + +static void sim_target_parse_arg_array PARAMS ((char **)); + +typedef struct +{ + char * swi_option; + unsigned int swi_mask; +} swi_options; + +#define SWI_SWITCH "--swi-support" + +static swi_options options[] = + { + { "none", 0 }, + { "demon", SWI_MASK_DEMON }, + { "angel", SWI_MASK_ANGEL }, + { "redboot", SWI_MASK_REDBOOT }, + { "all", -1 }, + { "NONE", 0 }, + { "DEMON", SWI_MASK_DEMON }, + { "ANGEL", SWI_MASK_ANGEL }, + { "REDBOOT", SWI_MASK_REDBOOT }, + { "ALL", -1 } + }; + + +int +sim_target_parse_command_line (argc, argv) + int argc; + char ** argv; +{ + int i; + + for (i = 1; i < argc; i++) + { + char * ptr = argv[i]; + int arg; + + if ((ptr == NULL) || (* ptr != '-')) + break; + + if (strncmp (ptr, SWI_SWITCH, sizeof SWI_SWITCH - 1) != 0) + continue; + + if (ptr[sizeof SWI_SWITCH - 1] == 0) + { + /* Remove this option from the argv array. */ + for (arg = i; arg < argc; arg ++) + argv[arg] = argv[arg + 1]; + argc --; + + ptr = argv[i]; + } + else + ptr += sizeof SWI_SWITCH; + + swi_mask = 0; + + while (* ptr) + { + int i; + + for (i = sizeof options / sizeof options[0]; i--;) + if (strncmp (ptr, options[i].swi_option, + strlen (options[i].swi_option)) == 0) + { + swi_mask |= options[i].swi_mask; + ptr += strlen (options[i].swi_option); + + if (* ptr == ',') + ++ ptr; + + break; + } + + if (i < 0) + break; + } + + if (* ptr != 0) + fprintf (stderr, "Ignoring swi options: %s\n", ptr); + + /* Remove this option from the argv array. */ + for (arg = i; arg < argc; arg ++) + argv[arg] = argv[arg + 1]; + argc --; + i --; + } + return argc; +} + +static void +sim_target_parse_arg_array (argv) + char ** argv; +{ + int i; + + for (i = 0; argv[i]; i++) + ; + + return (void) sim_target_parse_command_line (i, argv); +} + +void +sim_target_display_usage () +{ + fprintf (stderr, "%s=<list> Comma seperated list of SWI protocols to supoport.\n\ + This list can contain: NONE, DEMON, ANGEL, REDBOOT and/or ALL.\n", + SWI_SWITCH); +} +#endif + SIM_DESC sim_open (kind, ptr, abfd, argv) SIM_OPEN_KIND kind; @@ -438,6 +552,10 @@ sim_open (kind, ptr, abfd, argv) myname = (char *) xstrdup (argv[0]); sim_callback = ptr; +#ifdef SIM_TARGET_SWITCHES + sim_target_parse_arg_array (argv); +#endif + /* Decide upon the endian-ness of the processor. If we can, get the information from the bfd itself. Otherwise look to see if we have been given a command |