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

Subversion Repositories or1k

[/] [or1k/] [tags/] [stable_0_2_0_rc1/] [or1ksim/] [sim-config.c] - Diff between revs 1455 and 1459

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

Rev 1455 Rev 1459
Line 47... Line 47...
#include "mprofiler.h"
#include "mprofiler.h"
#include "cuc.h"
#include "cuc.h"
 
 
#include "debug.h"
#include "debug.h"
 
 
 
DEFAULT_DEBUG_CHANNEL(config);
 
 
#define WARNING(s) fprintf (stderr, "WARNING: config.%s: %s\n", cur_section->name, (s))
#define WARNING(s) fprintf (stderr, "WARNING: config.%s: %s\n", cur_section->name, (s))
#define MERROR(s) {fprintf (stderr, "ERROR: %s\n", s); if (runtime.sim.init) exit (1);}
#define MERROR(s) {fprintf (stderr, "ERROR: %s\n", s); if (runtime.sim.init) exit (1);}
 
 
struct config config;
struct config config;
struct runtime runtime;
struct runtime runtime;
Line 615... Line 617...
  reg_ata_sec();
  reg_ata_sec();
  reg_cuc_sec();
  reg_cuc_sec();
  reg_test_sec();
  reg_test_sec();
}
}
 
 
 
/* Returns a user friendly string of type */
 
static char *get_paramt_str(enum param_t type)
 
{
 
  switch(type) {
 
  case paramt_int:
 
    return "integer";
 
  case paramt_addr:
 
    return "address";
 
  case paramt_str:
 
    return "string";
 
  case paramt_word:
 
    return "word";
 
  case paramt_none:
 
    return "none";
 
  }
 
  return "";
 
}
 
 
void reg_config_param(struct config_section *sec, const char *param,
void reg_config_param(struct config_section *sec, const char *param,
                      enum param_t type,
                      enum param_t type,
                      void (*param_cb)(union param_val, void *))
                      void (*param_cb)(union param_val, void *))
{
{
  struct config_param *new = malloc(sizeof(struct config_param));
  struct config_param *new = malloc(sizeof(struct config_param));
 
 
 
  TRACE("Registering config param `%s' to section `%s', type %s\n", param,
 
        sec->name, get_paramt_str(type));
 
 
  if(!new) {
  if(!new) {
    fprintf(stderr, "Out-of-memory\n");
    fprintf(stderr, "Out-of-memory\n");
    exit(1);
    exit(1);
  }
  }
 
 
Line 644... Line 667...
                                      void *(*sec_start)(void),
                                      void *(*sec_start)(void),
                                      void (*sec_end)(void *))
                                      void (*sec_end)(void *))
{
{
  struct config_section *new = malloc(sizeof(struct config_section));
  struct config_section *new = malloc(sizeof(struct config_section));
 
 
 
  TRACE("Registering config section `%s'\n", section);
 
 
  if(!new) {
  if(!new) {
    fprintf(stderr, "Out-of-memory\n");
    fprintf(stderr, "Out-of-memory\n");
    exit(1);
    exit(1);
  }
  }
 
 
Line 749... Line 774...
        cur_section = NULL;
        cur_section = NULL;
        if (fscanf (f, "%s\n", param) != 1) {
        if (fscanf (f, "%s\n", param) != 1) {
          fprintf (stderr, "%s: ERROR: Section name required.\n", local ? filename : ctmp);
          fprintf (stderr, "%s: ERROR: Section name required.\n", local ? filename : ctmp);
          exit (1);
          exit (1);
        }
        }
 
        TRACE("Came across section `%s'\n", param);
        for (cur = sections; cur; cur = cur->next)
        for (cur = sections; cur; cur = cur->next)
          if (strcmp (cur->name, param) == 0) {
          if (strcmp (cur->name, param) == 0) {
            cur_section = cur;
            cur_section = cur;
            break;
            break;
          }
          }
Line 780... Line 806...
          }
          }
        }
        }
      } else {
      } else {
        struct config_param *cur_param;
        struct config_param *cur_param;
        char *cur_p;
        char *cur_p;
 
        TRACE("Came across parameter `%s' in section `%s'\n", param,
 
              cur_section->name);
        for (cur_param = cur_section->params; cur_param; cur_param = cur_param->next)
        for (cur_param = cur_section->params; cur_param; cur_param = cur_param->next)
          if (strcmp (cur_param->name, param) == 0) {
          if (strcmp (cur_param->name, param) == 0) {
            break;
            break;
          }
          }
        if (!cur_param) {
        if (!cur_param) {

powered by: WebSVN 2.1.0

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