From d3e9ca1a88081ec26ee82339dcb210b973bdf96c Mon Sep 17 00:00:00 2001 From: Nick Clifton Date: Thu, 30 Oct 1997 21:52:16 +0000 Subject: [PATCH] Patches to support generating an executing environment. Patches from Tony Thompson at ARM: athompso@arm.com --- sim/arm/wrapper.c | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 59 insertions(+), 4 deletions(-) diff --git a/sim/arm/wrapper.c b/sim/arm/wrapper.c index 5c2eea0..2a297c2 100644 --- a/sim/arm/wrapper.c +++ b/sim/arm/wrapper.c @@ -181,10 +181,65 @@ sim_create_inferior (sd, abfd, argv, env) char **argv; char **env; { - if (abfd != NULL) - ARMul_SetPC (state, bfd_get_start_address (abfd)); - else - ARMul_SetPC (state, 0); /* ??? */ + int argvlen=0; + char **arg; + +#if 1 /* JGS */ + /* We explicitly select a processor capable of supporting the ARM + 32bit mode, and then we force the simulated CPU into the 32bit + User mode: */ + ARMul_SelectProcessor(state, ARM600); + ARMul_SetCPSR(state, USER32MODE); +#endif + + if (argv != NULL) + { + /* + ** Set up the command line (by laboriously stringing together the + ** environment carefully picked apart by our caller...) + */ + /* Free any old stuff */ + if (state->CommandLine != NULL) + { + free(state->CommandLine); + state->CommandLine = NULL; + } + + /* See how much we need */ + for (arg = argv; *arg != NULL; arg++) + argvlen += strlen(*arg)+1; + + /* allocate it... */ + state->CommandLine = malloc(argvlen+1); + if (state->CommandLine != NULL) + { + arg = argv; + state->CommandLine[0]='\0'; + for (arg = argv; *arg != NULL; arg++) + { + strcat(state->CommandLine, *arg); + strcat(state->CommandLine, " "); + } + } + } + + if (env != NULL) + { + /* Now see if there's a MEMSIZE spec in the environment */ + while (*env) + { + if (strncmp(*env, "MEMSIZE=", sizeof("MEMSIZE=")-1)==0) + { + unsigned long top_of_memory; + char *end_of_num; + + /* Set up memory limit */ + state->MemSize = strtoul(*env + sizeof("MEMSIZE=")-1, &end_of_num, 0); + } + env++; + } + } + return SIM_RC_OK; } -- 2.7.4