OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [tags/] [nog_patch_69/] [or1ksim/] [sim-config.c] - Diff between revs 1350 and 1353

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 1350 Rev 1353
Line 317... Line 317...
      default:
      default:
        while ((ch = (f ? fgetc (f) : *str++)) != *fmt) {
        while ((ch = (f ? fgetc (f) : *str++)) != *fmt) {
          if (!isspace (ch)) {
          if (!isspace (ch)) {
            char tmp[200];
            char tmp[200];
            sprintf (tmp, "unexpected char '%c' (expecting '%c')\n", ch, *fmt);
            sprintf (tmp, "unexpected char '%c' (expecting '%c')\n", ch, *fmt);
            fprintf (stderr, "WARNING: config.%s: %s\n", sections[section], tmp);
            fprintf (stderr, "WARNING: config.%s: %s\n", sections[section].name, tmp);
            WARNING(tmp);
            WARNING(tmp);
          }
          }
          if ((f ? feof (f) : *str)) return 1;
          if ((f ? feof (f) : *str)) return 1;
        }
        }
        fmt++;
        fmt++;
Line 1395... Line 1395...
    if (config.sim.verbose)
    if (config.sim.verbose)
      fprintf (stderr, "WARNING: Cannot read script file from '%s',\nneither '%s'.\n", filename, ctmp);
      fprintf (stderr, "WARNING: Cannot read script file from '%s',\nneither '%s'.\n", filename, ctmp);
}
}
 
 
/* Utility for execution of set sim command.  */
/* Utility for execution of set sim command.  */
static int set_config (char *s)
static int set_config (int argc, char **argv)
{
{
  char *sec, *item, *params;
  int i;
  int noparams = 0, i, noitem = 0;
 
  while (*s && isspace (*s)) s++;
  if (argc < 2) return 1;
  sec = s;
 
  PRINTF ("s:%s\n", s);
  PRINTF ("sec:%s\n", argv[1]);
  while (*s && *s != ' ') s++;
 
  if (!(*s)) noitem = 1;
 
  *s = 0;
 
  PRINTF ("sec:%s\n", sec);
 
  section = 0;
  section = 0;
  for (i = 1; i < sizeof(sections) / sizeof(struct section); i++)
  for (i = 1; i < sizeof(sections) / sizeof(struct section); i++)
    if (strcmp (sections[i].name, sec) == 0) {
    if (strcmp (sections[i].name, argv[1]) == 0) {
      section = i;
      section = i;
      break;
      break;
    }
    }
 
 
  if (!section) return 1;
  if (!section) return 1;
  if (noitem) return 2;
 
 
 
  item = ++s;
  if (argc < 3) return 2;
 
 
  while (*s && *s != ' ') s++;
  PRINTF ("item:%s\n", argv[2]);
  if (!(*s)) {
 
    noparams = 1;
 
    params = "";
 
  } else
 
    params = s + 1;
 
  *s = 0;
 
  PRINTF ("item:%s\n", item);
 
  PRINTF ("params:%s\n", params);
 
  {
  {
    int i, found = -1;
    int found = -1;
    for (i = 0; i < sizeof(config_params)/sizeof(struct config_params); i++)
    for (i = 0; i < sizeof(config_params)/sizeof(struct config_params); i++)
      if (config_params[i].section == section && strcmp (config_params[i].name, item) == 0) {
      if (config_params[i].section == section && strcmp (config_params[i].name, argv[2]) == 0) {
        found = i;
        found = i;
        break;
        break;
      }
      }
    if (found < 0) return 2;
    if (found < 0) return 2;
 
 
    /* Parse parameter value */
    /* Parse parameter value */
    if (config_params[found].type[0])
    if (config_params[found].type[0]) {
      if(fscanf_ex (0, config_params[found].type, config_params[found].addr, params))
      if (argc < 4) return 3;
 
      if (fscanf_ex (0, config_params[found].type, config_params[found].addr, argv[3]))
        return 3;
        return 3;
 
      PRINTF ("params:%s\n", argv[3]);
 
    }
    if (config_params[found].func)
    if (config_params[found].func)
      config_params[found].func();
      config_params[found].func();
  }
  }
  return 0;
  return 0;
}
}
 
 
/* Executes set sim command, displays error.  */
/* Executes set sim command, displays error.  */
void set_config_command(char *s)
void set_config_command(int argc, char **argv)
{
{
  int i;
  int i;
  switch (set_config (s)) {
 
 
  switch (set_config (argc, argv)) {
    case 1:
    case 1:
      PRINTF ("Invalid or missing section name.  One of valid sections must be specified:\n");
      PRINTF ("Invalid or missing section name.  One of valid sections must be specified:\n");
      for (i = 1; i < sizeof(sections) / sizeof(struct section); i++)
      for (i = 1; i < sizeof(sections) / sizeof(struct section); i++)
        PRINTF ("%s ", sections[i].name);
        PRINTF ("%s ", sections[i].name);
      PRINTF ("\n");
      PRINTF ("\n");

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.