* sim-memopt.c (memory_options): Mention that the memory-size switch accepts suffixes.
(parse_size): Handle a suffix on the size value. * sim-options.c (standard_options): Mention that the mem-size switch accepts suffixes. (standard_option_handler): Handle a suffix on the size value.
This commit is contained in:
parent
ec8cbbf6de
commit
f40f1a01c5
3 changed files with 47 additions and 7 deletions
|
@ -1,3 +1,12 @@
|
||||||
|
2007-08-10 Nick Clifton <nickc@redhat.com>
|
||||||
|
|
||||||
|
* sim-memopt.c (memory_options): Mention that the
|
||||||
|
--memory-size switch accepts suffixes.
|
||||||
|
(parse_size): Handle a suffix on the size value.
|
||||||
|
* sim-options.c (standard_options): Mention that the mem-size
|
||||||
|
switch accepts suffixes.
|
||||||
|
(standard_option_handler): Handle a suffix on the size value.
|
||||||
|
|
||||||
2006-12-21 Hans-Peter Nilsson <hp@axis.com>
|
2006-12-21 Hans-Peter Nilsson <hp@axis.com>
|
||||||
|
|
||||||
* acconfig.h: Remove.
|
* acconfig.h: Remove.
|
||||||
|
|
|
@ -90,8 +90,8 @@ static const OPTION memory_options[] =
|
||||||
memory_option_handler },
|
memory_option_handler },
|
||||||
|
|
||||||
{ {"memory-size", required_argument, NULL, OPTION_MEMORY_SIZE },
|
{ {"memory-size", required_argument, NULL, OPTION_MEMORY_SIZE },
|
||||||
'\0', "SIZE", "Add memory at address zero",
|
'\0', "<size>[in bytes, Kb (k suffix), Mb (m suffix) or Gb (g suffix)]",
|
||||||
memory_option_handler },
|
"Add memory at address zero", memory_option_handler },
|
||||||
|
|
||||||
{ {"memory-fill", required_argument, NULL, OPTION_MEMORY_FILL },
|
{ {"memory-fill", required_argument, NULL, OPTION_MEMORY_FILL },
|
||||||
'\0', "VALUE", "Fill subsequently added memory regions",
|
'\0', "VALUE", "Fill subsequently added memory regions",
|
||||||
|
@ -286,11 +286,28 @@ parse_size (char *chp,
|
||||||
address_word *nr_bytes,
|
address_word *nr_bytes,
|
||||||
unsigned *modulo)
|
unsigned *modulo)
|
||||||
{
|
{
|
||||||
/* <nr_bytes> [ "%" <modulo> ] */
|
/* <nr_bytes>[K|M|G] [ "%" <modulo> ] */
|
||||||
*nr_bytes = strtoul (chp, &chp, 0);
|
*nr_bytes = strtoul (chp, &chp, 0);
|
||||||
if (*chp == '%')
|
switch (*chp)
|
||||||
{
|
{
|
||||||
|
case '%':
|
||||||
*modulo = strtoul (chp + 1, &chp, 0);
|
*modulo = strtoul (chp + 1, &chp, 0);
|
||||||
|
break;
|
||||||
|
case 'g': case 'G': /* Gigabyte suffix. */
|
||||||
|
*nr_bytes <<= 10;
|
||||||
|
/* Fall through. */
|
||||||
|
case 'm': case 'M': /* Megabyte suffix. */
|
||||||
|
*nr_bytes <<= 10;
|
||||||
|
/* Fall through. */
|
||||||
|
case 'k': case 'K': /* Kilobyte suffix. */
|
||||||
|
*nr_bytes <<= 10;
|
||||||
|
/* Check for a modulo specifier after the suffix. */
|
||||||
|
++ chp;
|
||||||
|
if (* chp == 'b' || * chp == 'B')
|
||||||
|
++ chp;
|
||||||
|
if (* chp == '%')
|
||||||
|
*modulo = strtoul (chp + 1, &chp, 0);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return chp;
|
return chp;
|
||||||
}
|
}
|
||||||
|
|
|
@ -167,8 +167,8 @@ static const OPTION standard_options[] =
|
||||||
|
|
||||||
#ifdef SIM_HAVE_FLATMEM
|
#ifdef SIM_HAVE_FLATMEM
|
||||||
{ {"mem-size", required_argument, NULL, OPTION_MEM_SIZE},
|
{ {"mem-size", required_argument, NULL, OPTION_MEM_SIZE},
|
||||||
'm', "MEMORY SIZE", "Specify memory size",
|
'm', "<size>[in bytes, Kb (k suffix), Mb (m suffix) or Gb (g suffix)]",
|
||||||
standard_option_handler },
|
"Specify memory size", standard_option_handler },
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
{ {"do-command", required_argument, NULL, OPTION_DO_COMMAND},
|
{ {"do-command", required_argument, NULL, OPTION_DO_COMMAND},
|
||||||
|
@ -381,7 +381,21 @@ standard_option_handler (SIM_DESC sd, sim_cpu *cpu, int opt,
|
||||||
#ifdef SIM_HAVE_FLATMEM
|
#ifdef SIM_HAVE_FLATMEM
|
||||||
case OPTION_MEM_SIZE:
|
case OPTION_MEM_SIZE:
|
||||||
{
|
{
|
||||||
unsigned long ul = strtol (arg, NULL, 0);
|
char * endp;
|
||||||
|
unsigned long ul = strtol (arg, &endp, 0);
|
||||||
|
|
||||||
|
switch (* endp)
|
||||||
|
{
|
||||||
|
case 'k': case 'K': size <<= 10; break;
|
||||||
|
case 'm': case 'M': size <<= 20; break;
|
||||||
|
case 'g': case 'G': size <<= 30; break;
|
||||||
|
case ' ': case '\0': case '\t': break;
|
||||||
|
default:
|
||||||
|
if (ul > 0)
|
||||||
|
sim_io_eprintf (sd, "Ignoring strange character at end of memory size: %c\n", * endp);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
/* 16384: some minimal amount */
|
/* 16384: some minimal amount */
|
||||||
if (! isdigit (arg[0]) || ul < 16384)
|
if (! isdigit (arg[0]) || ul < 16384)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue