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

Subversion Repositories or1k

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

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

Rev 1353 Rev 1358
Line 1... Line 1...
/* config.c -- Simulator configuration
/* sim-config.c -- Simulator configuration
   Copyright (C) 1999 Damjan Lampret, lampret@opencores.org
   Copyright (C) 1999 Damjan Lampret, lampret@opencores.org
 
 
This file is part of OpenRISC 1000 Architectural Simulator.
This file is part of OpenRISC 1000 Architectural Simulator.
 
 
This program is free software; you can redistribute it and/or modify
This program is free software; you can redistribute it and/or modify
Line 44... Line 44...
 
 
#include "profiler.h"
#include "profiler.h"
#include "mprofiler.h"
#include "mprofiler.h"
#include "cuc.h"
#include "cuc.h"
 
 
#define WARNING(s) fprintf (stderr, "WARNING: config.%s: %s\n", sections[section].name, (s))
#include "debug.h"
#define ERROR(s) {fprintf (stderr, "ERROR: config.%s:%s\n", sections[section].name, s); if (runtime.sim.init) exit (1);}
 
 
#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);}
 
 
#if !FAST_SIM
#if !FAST_SIM
struct config config;
struct config config;
#endif
#endif
struct runtime runtime;
struct runtime runtime;
 
 
int section = 0;
struct config_section *cur_section;
extern struct section {
 
  char *name;
struct config_section *sections = NULL;
  int flags;
 
} sections[];
 
 
 
void init_defconfig()
void init_defconfig()
{
{
  int i;
  int i;
 
 
Line 271... Line 270...
    return 0;
    return 0;
 
 
  return 0;
  return 0;
}
}
 
 
#if !FAST_SIM
 
#define CNV(x) ((isspace(x) || (x) == 0) ? ' ' : (x))
 
 
 
/* Substitute for less powerful fscanf */
 
int fscanf_ex (FILE *f, char *fmt, void *buf, char *str)
 
{
 
  char tmp[STR_SIZE];
 
  char ch;
 
  int i = 0;
 
  while (*fmt) {
 
    switch (*fmt) {
 
      case '%':
 
        while(*fmt != 0 && !isalpha (*fmt))
 
          tmp[i++] = *(fmt++);
 
        tmp[i++] = *(fmt++);
 
        if (tmp[i - 1] == 's') {
 
          char *cbuf = (char *)buf;
 
          i = 0;
 
          while (ch = (f ? fgetc (f) : *str++), isspace(ch))
 
            if (f ? feof (f) : *str) return 1;
 
          if (f)
 
            ungetc (ch, f);
 
          else
 
            str--;
 
          while ((*(cbuf++) = ch = (f ? fgetc (f) : *str++), CNV(ch) ) != *fmt) {
 
            if ((f ? feof (f) : *str)) return 1;
 
            if (++i >= STR_SIZE) {
 
              fprintf (stderr, "ERROR: string too long.\n");
 
              return 1;
 
            }
 
          }
 
          *(--cbuf) = 0;
 
          fmt++;
 
        } else {
 
          tmp[i++] = 0;
 
          if (f)
 
            fscanf (f, tmp, buf);
 
          else
 
            sscanf (str, tmp, buf);
 
        }
 
        break;
 
      default:
 
        while ((ch = (f ? fgetc (f) : *str++)) != *fmt) {
 
          if (!isspace (ch)) {
 
            char tmp[200];
 
            sprintf (tmp, "unexpected char '%c' (expecting '%c')\n", ch, *fmt);
 
            fprintf (stderr, "WARNING: config.%s: %s\n", sections[section].name, tmp);
 
            WARNING(tmp);
 
          }
 
          if ((f ? feof (f) : *str)) return 1;
 
        }
 
        fmt++;
 
        break;
 
    }
 
  }
 
  return 0;
 
}
 
#endif /* !FAST_SIM */
 
 
 
void print_config()
void print_config()
{
{
  if (config.sim.verbose) {
  if (config.sim.verbose) {
    char temp[20];
    char temp[20];
    PRINTF("Verbose on, ");
    PRINTF("Verbose on, ");
Line 367... Line 307...
      PRINTF("BTIC simulation off.\n");
      PRINTF("BTIC simulation off.\n");
  }
  }
}
}
 
 
#if !FAST_SIM
#if !FAST_SIM
/* Forward declarations of functions */
struct config_param {
void base_include ();
  char *name;
void sim_clkcycle ();
  enum param_t type;
void sim_exe_log_type ();
  void (*func)(union param_val, void *dat);
void change_device ();
  struct config_param *next;
void end_device ();
 
void uart_nuarts ();
 
void uart_baseaddr ();
 
void uart_channel ();
 
void uart_newway ();
 
void uart_jitter ();
 
void uart_irq ();
 
void uart_16550 ();
 
void uart_vapi_id ();
 
void dma_ndmas ();
 
void dma_baseaddr ();
 
void dma_irq ();
 
void dma_vapi_id ();
 
void memory_type ();
 
void memory_nmemories ();
 
void memory_ce ();
 
void memory_baseaddr ();
 
void memory_size ();
 
void memory_name ();
 
void memory_log ();
 
void memory_delayr ();
 
void memory_delayw ();
 
void cpu_sbuf_len ();
 
void eth_nethernets ();
 
void eth_baseaddr ();
 
void eth_irq ();
 
void eth_dma ();
 
void eth_rtx_type ();
 
void eth_rx_channel ();
 
void eth_tx_channel ();
 
void eth_rxfile ();
 
void eth_txfile ();
 
void eth_sockif ();
 
void eth_vapi_id ();
 
void gpio_ngpios ();
 
void gpio_baseaddr ();
 
void gpio_irq ();
 
void gpio_base_vapi_id ();
 
void vga_nvgas ();
 
void vga_baseaddr ();
 
void vga_irq ();
 
void vga_refresh_rate ();
 
//void vga_filename ();
 
void vga_bufaddr ();
 
void vga_paladdr ();
 
void vga_refresh_rate ();
 
void vga_filename ();
 
void ata_natas ();
 
void ata_baseaddr ();
 
void ata_irq ();
 
void ata_dev_type0 ();
 
void ata_dev_file0 ();
 
void ata_dev_size0 ();
 
void ata_dev_packet0 ();
 
void ata_dev_type1 ();
 
void ata_dev_file1 ();
 
void ata_dev_size1 ();
 
void ata_dev_packet1 ();
 
void immu_enabled ();
 
void immu_nsets ();
 
void immu_nways ();
 
void immu_pagesize ();
 
void immu_entrysize ();
 
void immu_ustates ();
 
void dmmu_enabled ();
 
void dmmu_nsets ();
 
void dmmu_nways ();
 
void dmmu_pagesize ();
 
void dmmu_entrysize ();
 
void dmmu_ustates ();
 
void ic_enabled ();
 
void ic_nsets ();
 
void ic_nways ();
 
void ic_blocksize ();
 
void ic_ustates ();
 
void dc_enabled ();
 
void dc_nsets ();
 
void dc_nways ();
 
void dc_blocksize ();
 
void dc_ustates ();
 
void cuc_memory_order ();
 
 
 
unsigned long tempL;
 
unsigned long tempUL;
 
char tempS[STR_SIZE];
 
 
 
#define CPF_SUBSECTION 1
 
#define CPF_SUBFIELD   2
 
#define CPF_GLOBAL     4   /* Not part of the substructure (group) in config */
 
 
 
struct section sections[] = {
 
  {"base",    0},   /* 0  */
 
  {"mc",      0},
 
  {"uart",    0},
 
  {"dma",     0},
 
  {"memory",  0},
 
  {"cpu",     0},   /* 5  */
 
  {"sim",     0},
 
  {"debug",   0},
 
  {"VAPI",    0},
 
  {"ethernet",0},
 
  {"",        0},   /* 10 */
 
  {"immu",    0},
 
  {"dmmu",    0},
 
  {"ic",      0},
 
  {"dc",      0},
 
  {"gpio",    0},   /* 15 */
 
  {"bpb",     0},
 
  {"pm",      0},
 
  {"vga",     0},
 
  {"fb",      0},
 
  {"kbd",     0},   /* 20 */
 
  {"ata",     0},
 
  {"cuc",     0},
 
  {"test",    0}
 
};
};
 
 
/* *INDENT-OFF* */
/* FIXME: These will be removed */
 
int current_device = -1;
 
void change_device (union param_val val, void *dat) {
 
  current_device = val.int_val;
 
}
 
 
/* Parameter definitions */
void end_device (union param_val val, void *dat) {
struct config_params {
  current_device = -1;
  int section;
}
  char *name;
 
  char *type;
 
  void (*func)();
 
  void *addr;
 
  int attr;
 
} config_params[] = {
 
{0, "include",            "\"%s\"",      base_include,  (void *)(&tempS), 0},
 
 
 
{1, "enabled",            "=%i",         NULL,          (void *)(&config.mc.enabled), 0},
 
{1, "baseaddr",           "=0x%x",       NULL,          (void *)(&config.mc.baseaddr), 0},
 
{1, "POC",                "=0x%x",       NULL,          (void *)(&config.mc.POC), 0},
 
 
 
{2, "nuarts",             "=%i",         uart_nuarts,   (void *)(&tempL), CPF_GLOBAL},
 
{2, "device",             "%i",          change_device, (void *)(&tempL), 0},
 
{2, "enddevice",          "",            end_device,    NULL, 0},
 
{2, "baseaddr",           "=0x%x",       uart_baseaddr, (void *)(&tempUL), 0},
 
{2, "irq",                "=%i",         uart_irq,      (void *)(&tempL), 0},
 
{2, "16550",              "=%i",         uart_16550,    (void *)(&tempL), 0},
 
{2, "jitter",             "=%i",         uart_jitter,   (void *)(&tempL), 0},
 
{2, "channel",            "=\"%s\"",     uart_channel,  (void *)(&tempS[0]), 0},
 
{2, "txfile",             "=\"%s\"",     uart_newway,   (void *)(&tempS[0]), 0},
 
{2, "rxfile",             "=\"%s\"",     uart_newway,   (void *)(&tempS[0]), 0},
 
{2, "vapi_id",            "=0x%x",       uart_vapi_id,  (void *)(&tempUL), 0},
 
 
 
{3, "ndmas",              "=%i",         dma_ndmas,     (void *)(&tempL), CPF_GLOBAL},
 
{3, "device",             "%i",          change_device, (void *)(&tempL), 0},
 
{3, "enddevice",          "",            end_device,    NULL, 0},
 
{3, "baseaddr",           "=0x%x",       dma_baseaddr,  (void *)(&tempUL), 0},
 
{3, "irq",                "=%i",         dma_irq,       (void *)(&tempL), 0},
 
{3, "vapi_id",            "=0x%x",       dma_vapi_id,   (void *)(&tempUL), 0},
 
 
 
{4, "random_seed",        "=%i",         NULL,          (void *)(&config.memory.random_seed), 0},
 
{4, "pattern",            "=%i",         NULL,          (void *)(&config.memory.pattern), 0},
 
{4, "type",               "=%s ",        memory_type,   (void *)(&tempS[0]), 0},
 
{4, "nmemories",          "=%i",         memory_nmemories,(void *)(&tempL), CPF_GLOBAL},
 
{4, "device",             "%i",          change_device, (void *)(&tempL), 0},
 
{4, "enddevice",          "",            end_device,    NULL, 0},
 
{4, "ce",                 "=%i",         memory_ce,     (void *)(&tempL), 0},
 
{4, "baseaddr",           "=0x%x",       memory_baseaddr,(void *)(&tempUL), 0},
 
{4, "size",               "=0x%x",       memory_size,   (void *)(&tempUL), 0},
 
{4, "name",               "=\"%s\"",     memory_name,   (void *)(&tempS[0]), 0},
 
{4, "log",                "=\"%s\"",     memory_log,    (void *)(&tempS[0]), 0},
 
{4, "delayr",             "=%i",         memory_delayr, (void *)(&tempL), 0},
 
{4, "delayw",             "=%i",         memory_delayw, (void *)(&tempL), 0},
 
 
 
{5, "ver",                "=0x%x",       NULL,          (void *)(&config.cpu.ver), 0},
 
{5, "rev",                "=0x%x",       NULL,          (void *)(&config.cpu.rev), 0},
 
{5, "upr",                "=0x%x",       NULL,          (void *)(&config.cpu.upr), 0},
 
{5, "sr",                 "=0x%x",       NULL,          (void *)(&config.cpu.sr), 0},
 
{5, "hazards",            "=%i",         NULL,          (void *)(&config.cpu.hazards), 0},
 
{5, "superscalar",        "=%i",         NULL,          (void *)(&config.cpu.superscalar), 0},
 
{5, "dependstats",        "=%i",         NULL,          (void *)(&config.cpu.dependstats), 0},
 
{5, "sbuf_len",           "=%i",         cpu_sbuf_len,  (void *)(&config.cpu.sbuf_len), 0},
 
 
 
{6, "debug",              "=%i",         NULL,          (void *)(&config.sim.debug), 0},
 
{6, "verbose",            "=%i",         NULL,          (void *)(&config.sim.verbose), 0},
 
{6, "profile",            "=%i",         NULL,          (void *)(&config.sim.profile), 0},
 
{6, "prof_fn",            "=\"%s\"",     NULL,          (void *)(&config.sim.prof_fn[0]), 0},
 
{6, "mprofile",           "=%i",         NULL,          (void *)(&config.sim.mprofile), 0},
 
{6, "mprof_fn",           "=\"%s\"",     NULL,          (void *)(&config.sim.mprof_fn[0]), 0},
 
{6, "history",            "=%i",         NULL,          (void *)(&config.sim.history), 0},
 
{6, "exe_log",            "=%i",         NULL,          (void *)(&config.sim.exe_log), 0},
 
{6, "exe_log_type",       "=%s ",        sim_exe_log_type, (void *)(&tempS[0]), 0},
 
{6, "exe_log_start",      "=%i",         NULL,          (void *)(&config.sim.exe_log_start), 0},
 
{6, "exe_log_end",        "=%i",         NULL,          (void *)(&config.sim.exe_log_end), 0},
 
{6, "exe_log_marker",     "=%i",         NULL,          (void *)(&config.sim.exe_log_marker), 0},
 
{6, "exe_log_fn",         "=\"%s\"",     NULL,          (void *)(&config.sim.exe_log_fn[0]), 0},
 
{6, "spr_log",            "=%i",         NULL,          (void *)(&config.sim.spr_log), 0},
 
{6, "spr_log_fn",         "=\"%s\"",     NULL,          (void *)(&config.sim.spr_log_fn[0]), 0},
 
{6, "clkcycle",           "=%s ",        sim_clkcycle,  (void *)(&tempS[0]), 0},
 
{6, "stdout",             "=\"%s\"",     NULL,          (void *)(&config.sim.fstdout[0]), 0},
 
 
 
{7, "enabled",            "=%i",         NULL,          (void *)(&config.debug.enabled), 0},
 
{7, "gdb_enabled",        "=%i",         NULL,          (void *)(&config.debug.gdb_enabled), 0},
 
{7, "server_port",        "=%i",         NULL,          (void *)(&config.debug.server_port), 0},
 
{7, "vapi_id",            "=0x%x",       NULL,          (void *)(&config.debug.vapi_id), 0},
 
 
 
{8, "enabled",            "=%i",         NULL,          (void *)(&config.vapi.enabled), 0},
 
{8, "server_port",        "=%i",         NULL,          (void *)(&config.vapi.server_port), 0},
 
{8, "log_enabled",        "=%i",         NULL,          (void *)(&config.vapi.log_enabled), 0},
 
{8, "hide_device_id",     "=%i",         NULL,          (void *)(&config.vapi.hide_device_id), 0},
 
{8, "vapi_log_fn",        "=\"%s\"",     NULL,          (void *)(&config.vapi.vapi_fn[0]), 0},
 
 
 
{9, "nethernets",         "=%i",         eth_nethernets,(void *)(&tempL), CPF_GLOBAL},
 
{9, "device",             "%i",          change_device, (void *)(&tempL), 0},
 
{9, "irq",                "=%i",         eth_irq,       (void *)(&tempUL), 15},
 
{9, "enddevice",          "",            end_device,    NULL, 0},
 
{9, "baseaddr",           "=0x%x",       eth_baseaddr,  (void *)(&tempUL), 0},
 
{9, "dma",                "=%i",         eth_dma,       (void *)(&tempL), 0},
 
{9, "rtx_type",           "=%i",         eth_rtx_type,  (void *)(&tempUL), 0},
 
{9, "rx_channel",         "=%i",         eth_rx_channel,(void *)(&tempL), 0},
 
{9, "tx_channel",         "=%i",         eth_tx_channel,(void *)(&tempL), 0},
 
{9, "rxfile",             "=\"%s\"",     eth_rxfile,    (void *)(&tempS[0]), 0},
 
{9, "txfile",             "=\"%s\"",     eth_txfile,    (void *)(&tempS[0]), 0},
 
{9, "sockif",             "=\"%s\"",     eth_sockif,    (void *)(&tempS[0]), 0},
 
{9, "vapi_id",            "=0x%x",       eth_vapi_id,   (void *)(&tempUL), 0},
 
 
 
{11, "enabled",           "=%i",         immu_enabled,  (void *)(&tempL), 0},
 
{11, "nsets",             "=%i",         immu_nsets,    (void *)(&tempL), 0},
 
{11, "nways",             "=%i",         immu_nways,    (void *)(&tempL), 0},
 
{11, "pagesize",          "=%i",         immu_pagesize, (void *)(&tempL), 0},
 
{11, "entrysize",         "=%i",         immu_entrysize,(void *)(&tempL), 0},
 
{11, "ustates",           "=%i",         immu_ustates,  (void *)(&tempL), 0},
 
{11, "missdelay",         "=%i",         NULL,          (void *)(&config.immu.missdelay), 0},
 
{11, "hitdelay",          "=%i",         NULL,          (void *)(&config.immu.hitdelay), 0},
 
 
 
{12, "enabled",           "=%i",         dmmu_enabled,  (void *)(&tempL), 0},
 
{12, "nsets",             "=%i",         dmmu_nsets,    (void *)(&tempL), 0},
 
{12, "nways",             "=%i",         dmmu_nways,    (void *)(&tempL), 0},
 
{12, "pagesize",          "=%i",         dmmu_pagesize, (void *)(&tempL), 0},
 
{12, "entrysize",         "=%i",         dmmu_entrysize,(void *)(&tempL), 0},
 
{12, "ustates",           "=%i",         dmmu_ustates,  (void *)(&tempL), 0},
 
{12, "missdelay",         "=%i",         NULL,          (void *)(&config.dmmu.missdelay), 0},
 
{12, "hitdelay",          "=%i",         NULL,          (void *)(&config.dmmu.hitdelay), 0},
 
 
 
{13, "enabled",           "=%i",         ic_enabled,    (void *)(&tempL), 0},
 
{13, "nsets",             "=%i",         ic_nsets,      (void *)(&tempL), 0},
 
{13, "nways",             "=%i",         ic_nways,      (void *)(&tempL), 0},
 
{13, "blocksize",         "=%i",         ic_blocksize,  (void *)(&tempL), 0},
 
{13, "ustates",           "=%i",         ic_ustates,    (void *)(&tempL), 0},
 
{13, "missdelay",         "=%i",         NULL,          (void *)(&config.ic.missdelay), 0},
 
{13, "hitdelay",          "=%i",         NULL,          (void *)(&config.ic.hitdelay), 0},
 
 
 
{14, "enabled",           "=%i",         dc_enabled,    (void *)(&tempL), 0},
 
{14, "nsets",             "=%i",         dc_nsets,      (void *)(&tempL), 0},
 
{14, "nways",             "=%i",         dc_nways,      (void *)(&tempL), 0},
 
{14, "blocksize",         "=%i",         dc_blocksize,  (void *)(&tempL), 0},
 
{14, "ustates",           "=%i",         dc_ustates,    (void *)(&tempL), 0},
 
{14, "load_missdelay",    "=%i",         NULL,          (void *)(&config.dc.load_missdelay), 0},
 
{14, "load_hitdelay",     "=%i",         NULL,          (void *)(&config.dc.load_hitdelay), 0},
 
{14, "store_missdelay",   "=%i",         NULL,          (void *)(&config.dc.store_missdelay), 0},
 
{14, "store_hitdelay",    "=%i",         NULL,          (void *)(&config.dc.store_hitdelay), 0},
 
 
 
{15, "ngpios",            "=%i",         gpio_ngpios,   (void *)(&tempL), CPF_GLOBAL},
 
{15, "device",            "%i",          change_device, (void *)(&tempL), 0},
 
{15, "baseaddr",          "=0x%x",       gpio_baseaddr, (void *)(&tempUL), 0},
 
{15, "irq",               "=%i",         gpio_irq,      (void *)(&tempL), 0},
 
{15, "base_vapi_id",      "=0x%x",       gpio_base_vapi_id,   (void *)(&tempUL), 0},
 
{15, "enddevice",         "",            end_device,    NULL, 0},
 
 
 
{16, "enabled",           "=%i",         NULL,          (void *)(&config.bpb.enabled), 0},
 
{16, "btic",              "=%i",         NULL,          (void *)(&config.bpb.btic), 0},
 
{16, "sbp_bnf_fwd",       "=%i",         NULL,          (void *)(&config.bpb.sbp_bnf_fwd), 0},
 
{16, "sbp_bf_fwd",        "=%i",         NULL,          (void *)(&config.bpb.sbp_bf_fwd), 0},
 
{16, "missdelay",         "=%i",         NULL,          (void *)(&config.bpb.missdelay), 0},
 
{16, "hitdelay",          "=%i",         NULL,          (void *)(&config.bpb.hitdelay), 0},
 
 
 
{17, "enabled",           "=%i",         NULL,          (void *)(&config.pm.enabled), 0},
 
 
 
{18, "nvgas",             "=%i",         vga_nvgas,     (void *)(&tempL), CPF_GLOBAL},
 
{18, "device",            "%i",          change_device, (void *)(&tempL), 0},
 
{18, "baseaddr",          "=0x%x",       vga_baseaddr,  (void *)(&tempUL), 0},
 
{18, "irq",               "=%i",         vga_irq,       (void *)(&tempL), 0},
 
{18, "refresh_rate",      "=%i",         vga_refresh_rate, (void *)(&tempUL), 0},
 
{18, "filename",          "=\"%s\"",     vga_filename,  (void *)(&tempS[0]), 0},
 
{18, "enddevice",         "",            end_device,    NULL, 0},
 
 
 
{19, "enabled",           "=%i",         NULL,          (void *)(&config.fb.enabled), 0},
 
{19, "baseaddr",          "=0x%x",       NULL,          (void *)(&config.fb.baseaddr), 0},
 
{19, "refresh_rate",      "=%i",         NULL,          (void *)(&config.fb.refresh_rate), 0},
 
{19, "filename",          "=\"%s\"",     NULL,          (void *)(&config.fb.filename), 0},
 
 
 
{20, "enabled",           "=%i",         NULL,          (void *)(&config.kbd.enabled), 0},
 
{20, "baseaddr",          "=0x%x",       NULL,          (void *)(&config.kbd.baseaddr), 0},
 
{20, "irq",               "=%i",         NULL,          (void *)(&config.kbd.irq), 0},
 
{20, "rxfile",            "=\"%s\"",     NULL,          (void *)(&config.kbd.rxfile), 0},
 
 
 
{21, "natas",             "=%i",         ata_natas,     (void *)(&tempL ), CPF_GLOBAL},
 
{21, "device",            "%i",          change_device, (void *)(&tempL ), 0},
 
{21, "baseaddr",          "=0x%x",       ata_baseaddr,  (void *)(&tempUL), 0},
 
{21, "irq",               "=%i",         ata_irq,       (void *)(&tempL ), 0},
 
{21, "dev_type0",         "=%i",         ata_dev_type0, (void *)(&tempL ), 0},
 
{21, "dev_file0",         "=\"%s\"",     ata_dev_file0, (void *)(&tempS ), 0},
 
{21, "dev_size0",         "=%i",         ata_dev_size0, (void *)(&tempUL), 0},
 
{21, "dev_packet0",       "=%i",         ata_dev_packet0, (void *)(&tempL ), 0},
 
{21, "dev_type1",         "=%i",         ata_dev_type1, (void *)(&tempL ), 0},
 
{21, "dev_file1",         "=\"%s\"",     ata_dev_file1, (void *)(&tempS ), 0},
 
{21, "dev_size1",         "=%i",         ata_dev_size1, (void *)(&tempUL), 0},
 
{21, "dev_packet1",       "=%i",         ata_dev_packet1, (void *)(&tempL ), 0},
 
{21, "enddevice",         "",            end_device,    NULL, 0},
 
 
 
{22, "calling_convention","=%i",         NULL,          (void *)&config.cuc.calling_convention, 0},
 
{22, "enable_bursts",     "=%i",         NULL,          (void *)&config.cuc.enable_bursts, 0},
 
{22, "no_multicycle",     "=%i",         NULL,          (void *)&config.cuc.no_multicycle, 0},
 
{22, "memory_order",      "=%s ",        cuc_memory_order, (void *)&tempS, 0},
 
{22, "timings_fn",        "=\"%s\"",     NULL,          (void *)config.cuc.timings_fn},
 
 
 
{23, "enabled",           "=%i",         NULL,          (void *)(&config.test.enabled), 0},
void base_include (union param_val val, void *dat) {
{23, "baseaddr",          "=0x%x",       NULL,          (void *)(&config.test.baseaddr), 0}
  read_script_file (val.str_val);
};
  cur_section = NULL;
 
}
 
 
/* *INDENT-ON* */
/*----------------------------------------------[ Simulator configuration ]---*/
 
void sim_debug (union param_val val, void *dat) {
 
  config.sim.debug = val.int_val;
 
}
 
 
int current_device = -1;
void sim_verbose (union param_val val, void *dat) {
void change_device () {
  config.sim.verbose = val.int_val;
  current_device = tempL;
 
}
}
 
 
void end_device () {
void sim_profile (union param_val val, void *dat) {
  current_device = -1;
  config.sim.profile = val.int_val;
}
}
 
 
void base_include () {
void sim_prof_fn (union param_val val, void *dat) {
  read_script_file (tempS);
  strcpy(config.sim.prof_fn, val.str_val);
  section = 0;
 
}
}
 
 
void sim_clkcycle () {
void sim_mprofile (union param_val val, void *dat) {
  int len = strlen (tempS);
  config.sim.mprofile = val.int_val;
  int pos = len - 1;
 
  long time;
 
  if (len < 2) goto err;
 
  if (tempS[pos--] != 's') goto err;
 
  switch (tempS[pos--]) {
 
    case 'p': time = 1; break;
 
    case 'n': time = 1000; break;
 
    case 'u': time = 1000000; break;
 
    case 'm': time = 1000000000; break;
 
  default:
 
    goto err;
 
  }
  }
  tempS[pos + 1] = 0;
 
  config.sim.clkcycle_ps = time * atol (tempS);
void sim_mprof_fn (union param_val val, void *dat) {
  return;
  strcpy(config.sim.mprof_fn, val.str_val);
err:
}
  ERROR("invalid time format.");
 
 
void sim_history (union param_val val, void *dat) {
 
  config.sim.history = val.int_val;
 
}
 
 
 
void sim_exe_log (union param_val val, void *dat) {
 
  config.sim.exe_log = val.int_val;
}
}
 
 
void sim_exe_log_type () {
void sim_exe_log_type (union param_val val, void *dat) {
  if (strcmp (tempS, "default") == 0)
  if (strcmp (val.str_val, "default") == 0)
    config.sim.exe_log_type = EXE_LOG_HARDWARE;
    config.sim.exe_log_type = EXE_LOG_HARDWARE;
  else if (strcmp (tempS, "hardware") == 0)
  else if (strcmp (val.str_val, "hardware") == 0)
    config.sim.exe_log_type = EXE_LOG_HARDWARE;
    config.sim.exe_log_type = EXE_LOG_HARDWARE;
  else if (strcmp (tempS, "simple") == 0)
  else if (strcmp (val.str_val, "simple") == 0)
    config.sim.exe_log_type = EXE_LOG_SIMPLE;
    config.sim.exe_log_type = EXE_LOG_SIMPLE;
  else if (strcmp (tempS, "software") == 0) {
  else if (strcmp (val.str_val, "software") == 0) {
    config.sim.exe_log_type = EXE_LOG_SOFTWARE;
    config.sim.exe_log_type = EXE_LOG_SOFTWARE;
  } else {
  } else {
    char tmp[200];
    char tmp[200];
    sprintf (tmp, "invalid execute log type '%s'.\n", tempS);
    sprintf (tmp, "invalid execute log type '%s'.\n", val.str_val);
    ERROR(tmp);
    CONFIG_ERROR(tmp);
  }
  }
}
}
 
 
void uart_nuarts () {
void sim_exe_log_start (union param_val val, void *dat) {
  if (tempL >= 0 && tempL < MAX_UARTS)
  config.sim.exe_log_start = val.int_val;
    config.nuarts = tempL;
 
  else
 
    ERROR("invalid number of devices.");
 
}
}
 
 
void uart_baseaddr () {
void sim_exe_log_end (union param_val val, void *dat) {
  if (current_device >= 0 && current_device < config.nuarts)
  config.sim.exe_log_end = val.int_val;
    config.uarts[current_device].baseaddr = tempUL;
 
  else
 
    ERROR("invalid device number.");
 
}
}
 
 
void uart_jitter () {
void sim_exe_log_marker (union param_val val, void *dat) {
  if (current_device >= 0 && current_device < config.nuarts)
  config.sim.exe_log_marker = val.int_val;
    config.uarts[current_device].jitter = tempL;
 
  else
 
    ERROR("invalid device number.");
 
}
}
 
 
void uart_irq () {
void sim_exe_log_fn (union param_val val, void *dat) {
  if (current_device >= 0 && current_device < config.nuarts)
  strcpy(config.sim.exe_log_fn, val.str_val);
    config.uarts[current_device].irq = tempL;
 
  else
 
    ERROR("invalid device number.");
 
}
}
 
 
void uart_16550 () {
void sim_clkcycle (union param_val val, void *dat) {
  if (current_device >= 0 && current_device < config.nuarts)
  int len = strlen (val.str_val);
    config.uarts[current_device].uart16550 = tempL;
  int pos = len - 1;
  else
  long time;
    ERROR("invalid device number.");
  if (len < 2) goto err;
 
  if (val.str_val[pos--] != 's') goto err;
 
  switch (val.str_val[pos--]) {
 
    case 'p': time = 1; break;
 
    case 'n': time = 1000; break;
 
    case 'u': time = 1000000; break;
 
    case 'm': time = 1000000000; break;
 
  default:
 
    goto err;
}
}
 
  val.str_val[pos + 1] = 0;
void uart_channel () {
  config.sim.clkcycle_ps = time * atol (val.str_val);
  if (current_device >= 0 && current_device < config.nuarts)
  return;
    strcpy (config.uarts[current_device].channel, tempS);
err:
  else
  CONFIG_ERROR("invalid time format.");
    ERROR("invalid device number.");
 
}
}
 
 
void uart_newway () {
void sim_stdout (union param_val val, void *dat) {
  ERROR(" txfile and rxfile and now obsolete.\n\tUse 'channel = \"file:rxfile,txfile\"' instead.");
  strcpy(config.sim.fstdout, val.str_val);
  exit(1);
 
}
}
 
 
void uart_vapi_id () {
void sim_spr_log (union param_val val, void *dat) {
  if (current_device >= 0 && current_device < config.nuarts)
  config.sim.spr_log = val.int_val;
    config.uarts[current_device].vapi_id = tempUL;
 
  else
 
    ERROR("invalid device number.");
 
}
}
 
 
void dma_ndmas () {
void sim_spr_log_fn (union param_val val, void *dat) {
  if (tempL >= 0 && tempL < MAX_DMAS)
  strcpy(config.sim.spr_log_fn, val.str_val);
    config.ndmas = tempL;
 
  else
 
    ERROR("invalid number of devices.");
 
}
}
 
 
void dma_baseaddr () {
void reg_sim_sec (void) {
  if (current_device >= 0 && current_device < config.ndmas)
  struct config_section *sec = reg_config_sec("sim", NULL, NULL);
    config.dmas[current_device].baseaddr = tempUL;
 
  else
  reg_config_param(sec, "debug", paramt_int, sim_debug);
    ERROR("invalid device number.");
  reg_config_param(sec, "verbose", paramt_int, sim_verbose);
 
  reg_config_param(sec, "profile", paramt_int, sim_profile);
 
  reg_config_param(sec, "prof_fn", paramt_str, sim_prof_fn);
 
  reg_config_param(sec, "mprofile", paramt_int, sim_mprofile);
 
  reg_config_param(sec, "mprof_fn", paramt_str, sim_mprof_fn);
 
  reg_config_param(sec, "history", paramt_int, sim_history);
 
  reg_config_param(sec, "exe_log", paramt_int, sim_exe_log);
 
  reg_config_param(sec, "exe_log_type", paramt_word, sim_exe_log_type);
 
  reg_config_param(sec, "exe_log_start", paramt_int, sim_exe_log_start);
 
  reg_config_param(sec, "exe_log_end", paramt_int, sim_exe_log_end);
 
  reg_config_param(sec, "exe_log_marker", paramt_int, sim_exe_log_marker);
 
  reg_config_param(sec, "exe_log_fn", paramt_str, sim_exe_log_fn);
 
  reg_config_param(sec, "spr_log", paramt_int, sim_spr_log);
 
  reg_config_param(sec, "spr_log_fn", paramt_str, sim_spr_log_fn);
 
  reg_config_param(sec, "clkcycle", paramt_word, sim_clkcycle);
 
  reg_config_param(sec, "stdout", paramt_str, sim_stdout);
}
}
 
 
void dma_irq () {
/*-------------------------------------------------[ Memory configuration ]---*/
  if (current_device >= 0 && current_device < config.ndmas)
void memory_random_seed(union param_val val, void *dat) {
    config.dmas[current_device].irq = tempL;
  config.memory.random_seed = val.int_val;
  else
 
    ERROR("invalid device number.");
 
}
}
 
 
void dma_vapi_id () {
void memory_pattern(union param_val val, void *dat) {
  if (current_device >= 0 && current_device < config.ndmas)
  config.memory.pattern = val.int_val;
    config.dmas[current_device].vapi_id = tempUL;
 
  else
 
    ERROR("invalid device number.");
 
}
}
 
 
void memory_nmemories () {
void memory_nmemories (union param_val val, void *dat) {
  if (tempL >= 0 && tempL < MAX_MEMORIES)
  if (val.int_val >= 0 && val.int_val < MAX_MEMORIES)
    config.memory.nmemories = tempL;
    config.memory.nmemories = val.int_val;
  else
  else
    ERROR("invalid number of devices.");
    CONFIG_ERROR("invalid number of devices.");
}
}
 
 
void memory_type () {
void memory_type (union param_val val, void *dat) {
  if (strcmp (tempS, "unknown") == 0)
  if (strcmp (val.str_val, "unknown") == 0)
    config.memory.type = MT_UNKNOWN;
    config.memory.type = MT_UNKNOWN;
  else if (strcmp (tempS, "random") == 0)
  else if (strcmp (val.str_val, "random") == 0)
    config.memory.type = MT_RANDOM;
    config.memory.type = MT_RANDOM;
  else if (strcmp (tempS, "pattern") == 0)
  else if (strcmp (val.str_val, "pattern") == 0)
    config.memory.type = MT_PATTERN;
    config.memory.type = MT_PATTERN;
  else if (strcmp (tempS, "zero") == 0) {
  else if (strcmp (val.str_val, "zero") == 0) {
    config.memory.type = MT_PATTERN;
    config.memory.type = MT_PATTERN;
    config.memory.pattern = 0;
    config.memory.pattern = 0;
  } else {
  } else {
    char tmp[200];
    char tmp[200];
    sprintf (tmp, "invalid memory type '%s'.\n", tempS);
    sprintf (tmp, "invalid memory type '%s'.\n", val.str_val);
    ERROR(tmp);
    CONFIG_ERROR(tmp);
  }
  }
}
}
 
 
void memory_ce () {
void memory_ce (union param_val val, void *dat) {
  if (current_device >= 0 && current_device < config.memory.nmemories)
  if (current_device >= 0 && current_device < config.memory.nmemories)
    config.memory.table[current_device].ce = tempL;
    config.memory.table[current_device].ce = val.int_val;
  else
  else
    ERROR("invalid device number.");
    CONFIG_ERROR("invalid device number.");
}
}
 
 
void memory_baseaddr () {
void memory_baseaddr (union param_val val, void *dat) {
  if (current_device >= 0 && current_device < config.memory.nmemories)
  if (current_device >= 0 && current_device < config.memory.nmemories)
    config.memory.table[current_device].baseaddr = tempUL;
    config.memory.table[current_device].baseaddr = val.addr_val;
  else
  else
    ERROR("invalid device number.");
    CONFIG_ERROR("invalid device number.");
}
}
 
 
void memory_size () {
void memory_size (union param_val val, void *dat) {
  if (current_device >= 0 && current_device < config.memory.nmemories)
  if (current_device >= 0 && current_device < config.memory.nmemories)
    config.memory.table[current_device].size = tempUL;
    config.memory.table[current_device].size = val.int_val;
  else
  else
    ERROR("invalid device number.");
    CONFIG_ERROR("invalid device number.");
}
}
 
 
void memory_name () {
void memory_name (union param_val val, void *dat) {
  if (current_device >= 0 && current_device < config.memory.nmemories)
  if (current_device >= 0 && current_device < config.memory.nmemories)
    strcpy (config.memory.table[current_device].name, tempS);
    strcpy (config.memory.table[current_device].name, val.str_val);
  else
  else
    ERROR("invalid device number.");
    CONFIG_ERROR("invalid device number.");
}
}
 
 
void memory_log () {
void memory_log (union param_val val, void *dat) {
  if (current_device >= 0 && current_device < config.memory.nmemories)
  if (current_device >= 0 && current_device < config.memory.nmemories)
    strcpy (config.memory.table[current_device].log, tempS);
    strcpy (config.memory.table[current_device].log, val.str_val);
  else
  else
    ERROR("invalid device number.");
    CONFIG_ERROR("invalid device number.");
}
}
 
 
void memory_delayr () {
void memory_delayr (union param_val val, void *dat) {
  if (current_device >= 0 && current_device < config.memory.nmemories)
  if (current_device >= 0 && current_device < config.memory.nmemories)
    config.memory.table[current_device].delayr = tempL;
    config.memory.table[current_device].delayr = val.int_val;
  else
  else
    ERROR("invalid device number.");
    CONFIG_ERROR("invalid device number.");
}
}
 
 
void memory_delayw () {
void memory_delayw (union param_val val, void *dat) {
  if (current_device >= 0 && current_device < config.memory.nmemories)
  if (current_device >= 0 && current_device < config.memory.nmemories)
    config.memory.table[current_device].delayw = tempL;
    config.memory.table[current_device].delayw = val.int_val;
  else
 
    ERROR("invalid device number.");
 
}
 
 
 
void cpu_sbuf_len () {
 
  if (config.cpu.sbuf_len >= MAX_SBUF_LEN) {
 
    config.cpu.sbuf_len = MAX_SBUF_LEN - 1;
 
    WARNING("sbuf_len too large; truncated.");
 
  } else if (config.cpu.sbuf_len < 0) {
 
    config.cpu.sbuf_len = 0;
 
    WARNING("sbuf_len negative; disabled.");
 
  }
 
}
 
 
 
void eth_nethernets () {
 
  if (tempL >= 0 && tempL < MAX_ETHERNETS)
 
    config.nethernets = tempL;
 
  else
  else
    ERROR("invalid number of devices.");
    CONFIG_ERROR("invalid device number.");
}
}
 
 
void eth_baseaddr () {
void reg_memory_sec(void) {
  if (current_device >= 0 && current_device < config.nethernets)
  struct config_section *sec = reg_config_sec("memory", NULL, NULL);
    config.ethernets[current_device].baseaddr = tempUL;
 
  else
 
    ERROR("invalid device number.");
 
}
 
 
 
void eth_dma () {
  reg_config_param(sec, "random_seed", paramt_int, memory_random_seed);
  if (current_device >= 0 && current_device < config.nethernets)
  reg_config_param(sec, "pattern", paramt_int, memory_pattern);
    config.ethernets[current_device].dma = tempL;
  reg_config_param(sec, "type", paramt_word, memory_type);
  else
  reg_config_param(sec, "nmemories", paramt_int, memory_nmemories);
    ERROR("invalid device number.");
  reg_config_param(sec, "device", paramt_int, change_device);
 
  reg_config_param(sec, "enddevice", paramt_none, end_device);
 
  reg_config_param(sec, "ce", paramt_int, memory_ce);
 
  reg_config_param(sec, "baseaddr", paramt_addr, memory_baseaddr);
 
  reg_config_param(sec, "size", paramt_int, memory_size);
 
  reg_config_param(sec, "name", paramt_str, memory_name);
 
  reg_config_param(sec, "log", paramt_str, memory_log);
 
  reg_config_param(sec, "delayr", paramt_int, memory_delayr);
 
  reg_config_param(sec, "delayw", paramt_int, memory_delayw);
}
}
 
 
void eth_rtx_type () {
/*----------------------------------------------------[ CPU configuration ]---*/
  if (current_device >= 0 && current_device < config.nethernets)
void cpu_ver (union param_val val, void *dat) {
    config.ethernets[current_device].rtx_type = tempUL;
  config.cpu.ver = val.int_val;
  else
 
    ERROR("invalid device number.");
 
}
}
 
 
void eth_rx_channel () {
void cpu_rev (union param_val val, void *dat) {
  if (current_device >= 0 && current_device < config.nethernets)
  config.cpu.rev = val.int_val;
    config.ethernets[current_device].rx_channel = tempL;
 
  else
 
    ERROR("invalid device number.");
 
}
}
 
 
void eth_tx_channel () {
void cpu_upr (union param_val val, void *dat) {
  if (current_device >= 0 && current_device < config.nethernets)
  config.cpu.upr = val.int_val;
    config.ethernets[current_device].rx_channel = tempL;
 
  else
 
    ERROR("invalid device number.");
 
}
}
 
 
void eth_rxfile () {
void cpu_sr (union param_val val, void *dat) {
  if (current_device >= 0 && current_device < config.nethernets)
  config.cpu.sr = val.int_val;
    strcpy (config.ethernets[current_device].rxfile, tempS);
 
  else
 
    ERROR("invalid device number.");
 
}
}
 
 
void eth_txfile () {
void cpu_hazards (union param_val val, void *dat) {
  if (current_device >= 0 && current_device < config.nethernets)
  config.cpu.hazards = val.int_val;
    strcpy (config.ethernets[current_device].txfile, tempS);
 
  else
 
    ERROR("invalid device number.");
 
}
}
 
 
void eth_sockif () {
void cpu_superscalar (union param_val val, void *dat) {
  if (current_device >= 0 && current_device < config.nethernets)
  config.cpu.superscalar = val.int_val;
    strcpy (config.ethernets[current_device].sockif, tempS);
 
  else
 
    ERROR("invalid device number.");
 
}
}
 
 
void eth_irq () {
void cpu_dependstats (union param_val val, void *dat) {
  if (current_device >= 0 && current_device < config.nethernets)
  config.cpu.dependstats = val.int_val;
    config.ethernets[current_device].irq = tempUL;
 
  else
 
    ERROR("invalid device number.");
 
}
}
 
 
void eth_vapi_id () {
void cpu_sbuf_len (union param_val val, void *dat) {
  if (current_device >= 0 && current_device < config.nethernets)
  if (val.int_val >= MAX_SBUF_LEN) {
    config.ethernets[current_device].base_vapi_id = tempUL;
    config.cpu.sbuf_len = MAX_SBUF_LEN - 1;
  else
    WARNING("sbuf_len too large; truncated.");
    ERROR("invalid device number.");
  } else if (val.int_val < 0) {
}
    config.cpu.sbuf_len = 0;
 
    WARNING("sbuf_len negative; disabled.");
void gpio_ngpios () {
  } else
  if (tempL >= 0 && tempL < MAX_GPIOS)
    config.cpu.sbuf_len = val.int_val;
    config.ngpios = tempL;
 
  else
 
    ERROR("invalid number of devices.");
 
}
 
 
 
void gpio_baseaddr () {
 
  if (current_device >= 0 && current_device < config.ngpios)
 
    config.gpios[current_device].baseaddr = tempUL;
 
  else
 
    ERROR("invalid device number.");
 
}
}
 
 
void gpio_irq () {
void reg_cpu_sec(void)
  if (current_device >= 0 && current_device < config.ngpios)
{
    config.gpios[current_device].irq = tempL;
  struct config_section *sec = reg_config_sec("cpu", NULL, NULL);
  else
 
    ERROR("invalid device number.");
 
}
 
 
 
void gpio_base_vapi_id () {
  reg_config_param(sec, "ver", paramt_int, cpu_ver);
  if (current_device >= 0 && current_device < config.ngpios)
  reg_config_param(sec, "rev", paramt_int, cpu_rev);
    config.gpios[current_device].base_vapi_id = tempUL;
  reg_config_param(sec, "upr", paramt_int, cpu_upr);
  else
  reg_config_param(sec, "sr", paramt_int, cpu_sr);
    ERROR("invalid device number.");
  reg_config_param(sec, "hazards", paramt_int, cpu_hazards);
 
  reg_config_param(sec, "superscalar", paramt_int, cpu_superscalar);
 
  reg_config_param(sec, "dependstats", paramt_int, cpu_dependstats);
 
  reg_config_param(sec, "sbuf_len", paramt_int, cpu_sbuf_len);
}
}
 
 
int is_power2 (int x) {
int is_power2 (int x) {
  while (!(x & 1))
  while (!(x & 1))
    x >>= 1;
    x >>= 1;
  return x == 1;
  return x == 1;
}
}
 
 
void immu_enabled () {
void reg_config_secs(void)
  setsprbits (SPR_UPR, SPR_UPR_IMP, tempL & 1);
{
  config.immu.enabled = tempL;
  reg_config_param(reg_config_sec("base", NULL, NULL), "include", paramt_str,
}
                   base_include);
 
 
void dmmu_enabled () {
 
  setsprbits (SPR_UPR, SPR_UPR_DMP, tempL & 1);
 
  config.dmmu.enabled = tempL;
 
}
 
 
 
void immu_nsets () {
 
  if (is_power2(tempL) && tempL <= 256)
 
    config.immu.nsets = tempL;
 
  else
 
    ERROR("value of power of two and lower or equal than 256 expected.");
 
}
 
 
 
void dmmu_nsets () {
 
  if (is_power2(tempL) && tempL <= 256)
 
    config.dmmu.nsets = tempL;
 
  else
 
    ERROR("value of power of two and lower or equal than 256 expected.");
 
}
 
 
 
void immu_nways () {
 
  if (tempL >= 1 && tempL <= 4)
 
    config.immu.nways = tempL;
 
  else
 
    ERROR("value 1, 2, 3 or 4 expected.");
 
}
 
 
 
void dmmu_nways () {
 
  if (tempL >= 1 && tempL <= 4)
 
    config.dmmu.nways = tempL;
 
  else
 
    ERROR("value 1, 2, 3 or 4 expected.");
 
}
 
 
 
void immu_pagesize () {
 
  if (is_power2(tempL))
 
    config.immu.pagesize = tempL;
 
  else
 
    ERROR("value of power of two expected.");
 
}
 
 
 
void dmmu_pagesize () {
 
  if (is_power2(tempL))
 
    config.dmmu.pagesize = tempL;
 
  else
 
    ERROR("value of power of two expected.");
 
}
 
 
 
void immu_entrysize () {
 
  if (is_power2(tempL))
 
    config.immu.entrysize = tempL;
 
  else
 
    ERROR("value of power of two expected.");
 
}
 
 
 
void dmmu_entrysize () {
 
  if (is_power2(tempL))
 
    config.dmmu.entrysize = tempL;
 
  else
 
    ERROR("value of power of two expected.");
 
}
 
 
 
void immu_ustates () {
 
  if (tempL >= 2 && tempL <= 4)
 
    config.immu.ustates = tempL;
 
  else
 
    ERROR("invalid USTATE.");
 
}
 
 
 
void dmmu_ustates () {
 
  if (tempL >= 2 && tempL <= 4)
 
    config.dmmu.ustates = tempL;
 
  else
 
    ERROR("invalid USTATE.");
 
}
 
 
 
void ic_enabled () {
 
  config.ic.enabled = tempL;
 
  setsprbits (SPR_UPR, SPR_UPR_ICP, tempL & 1);
 
}
 
 
 
void ic_nsets () {
 
  if (is_power2(tempL) && tempL <= MAX_IC_SETS)
 
    config.ic.nsets = tempL;
 
  else {
 
    char tmp[200];
 
    sprintf (tmp, "value of power of two and lower or equal than %i expected.", MAX_IC_SETS);
 
    ERROR(tmp);
 
  }
 
}
 
 
 
void ic_nways () {
 
  if (tempL >= 1 && tempL <= MAX_IC_WAYS)
 
    config.ic.nways = tempL;
 
  else
 
    ERROR("value 1, 2, 3 or 4 expected.");
 
}
 
 
 
void ic_blocksize () {
 
  if (is_power2(tempL))
 
    config.ic.blocksize = tempL;
 
  else
 
    ERROR("value of power of two expected.");
 
}
 
 
 
void ic_ustates () {
 
  if (tempL >= 2 && tempL <= 4)
 
    config.ic.ustates = tempL;
 
  else
 
    ERROR("invalid USTATE.");
 
}
 
 
 
void dc_enabled () {
 
  config.dc.enabled = tempL;
 
  setsprbits (SPR_UPR, SPR_UPR_DCP, tempL & 1);
 
}
 
 
 
void dc_nsets () {
 
  if (is_power2(tempL) && tempL <= MAX_DC_SETS)
 
    config.dc.nsets = tempL;
 
  else {
 
    char tmp[200];
 
    sprintf (tmp, "value of power of two and lower or equal than %i expected.", MAX_DC_SETS);
 
    ERROR(tmp);
 
  }
 
}
 
 
 
void dc_nways () {
 
  if (tempL >= 1 && tempL <= MAX_IC_WAYS)
 
    config.dc.nways = tempL;
 
  else
 
    ERROR("value 1, 2, 3 or 4 expected.");
 
}
 
 
 
void dc_blocksize () {
 
  if (is_power2(tempL))
 
    config.dc.blocksize = tempL;
 
  else
 
    ERROR("value of power of two expected.");
 
}
 
 
 
void dc_ustates () {
 
  if (tempL >= 2 && tempL <= 4)
 
    config.dc.ustates = tempL;
 
  else
 
    ERROR("invalid USTATE.");
 
}
 
 
 
void vga_nvgas () {
 
  if (tempL >= 0 && tempL < MAX_VGAS)
 
    config.nvgas = tempL;
 
  else
 
    ERROR("invalid number of devices.");
 
}
 
 
 
void vga_baseaddr () {
 
  if (current_device >= 0 && current_device < config.nvgas)
 
    config.vgas[current_device].baseaddr = tempUL;
 
  else
 
    ERROR("invalid device number.");
 
}
 
 
 
void vga_irq () {
  reg_sim_sec();
  if (current_device >= 0 && current_device < config.nvgas)
  reg_cpu_sec();
    config.vgas[current_device].irq = tempL;
  reg_memory_sec();
  else
  reg_mc_sec();
    ERROR("invalid device number.");
  reg_uart_sec();
}
  reg_dma_sec();
 
  reg_debug_sec();
 
  reg_vapi_sec();
 
  reg_ethernet_sec();
 
  reg_immu_sec();
 
  reg_dmmu_sec();
 
  reg_ic_sec();
 
  reg_dc_sec();
 
  reg_gpio_sec();
 
  reg_bpb_sec();
 
  reg_pm_sec();
 
  reg_vga_sec();
 
  reg_fb_sec();
 
  reg_kbd_sec();
 
  reg_ata_sec();
 
  reg_cuc_sec();
 
  reg_test_sec();
 
}
 
 
 
void reg_config_param(struct config_section *sec, const char *param,
 
                      enum param_t type,
 
                      void (*param_cb)(union param_val, void *))
 
{
 
  struct config_param *new = malloc(sizeof(struct config_param));
 
 
void vga_refresh_rate () {
  if(!new) {
  if (current_device >= 0 && current_device < config.nvgas)
    fprintf(stderr, "Out-of-memory\n");
    config.vgas[current_device].refresh_rate = tempUL;
    exit(1);
  else
 
    ERROR("invalid device number.");
 
}
}
 
 
void vga_filename () {
  if(!(new->name = strdup(param))) {
  if (current_device >= 0 && current_device < config.nvgas)
    fprintf(stderr, "Out-of-memory\n");
    strcpy (config.vgas[current_device].filename, tempS);
    exit(1);
  else
 
    ERROR("invalid device number.");
 
}
}
 
 
 
  new->func = param_cb;
 
  new->type = type;
 
 
void ata_natas () {
  new->next = sec->params;
  if (tempL >= 0 && tempL < MAX_ATAS)
  sec->params = new;
    config.natas = tempL;
 
  else
 
    ERROR("invalid number of devices.");
 
}
}
 
 
void ata_baseaddr () {
struct config_section *reg_config_sec(const char *section,
  if (current_device >= 0 && current_device < config.natas)
                                      void *(*sec_start)(void),
    config.atas[current_device].baseaddr = tempUL;
                                      void (*sec_end)(void *))
  else
{
    ERROR("invalid device number.");
  struct config_section *new = malloc(sizeof(struct config_section));
}
 
 
 
void ata_irq () {
  if(!new) {
  if (current_device >= 0 && current_device < config.natas)
    fprintf(stderr, "Out-of-memory\n");
    config.atas[current_device].irq = tempL;
    exit(1);
  else
 
    ERROR("invalid device number.");
 
}
}
 
 
void ata_dev_type0 () {
  if(!(new->name = strdup(section))) {
  if (current_device >= 0 && current_device < config.natas)
    fprintf(stderr, "Out-of-memory\n");
    config.atas[current_device].dev_type0 = tempL;
    exit(1);
  else
 
    ERROR("invalid device number.");
 
}
}
 
 
void ata_dev_file0 () {
  new->next = sections;
  if (current_device >= 0 && current_device < config.natas)
  new->sec_start = sec_start;
    strcpy (config.atas[current_device].dev_file0, tempS);
  new->sec_end = sec_end;
  else
  new->params = NULL;
    ERROR("invalid device number.");
 
}
 
 
 
void ata_dev_size0 () {
  sections = new;
  if (current_device >= 0 && current_device < config.natas)
 
    config.atas[current_device].dev_size0 = tempUL;
 
  else
 
    ERROR("invalid device number.");
 
}
 
 
 
void ata_dev_packet0 () {
  return new;
  if (current_device >= 0 && current_device < config.natas)
 
    config.atas[current_device].dev_packet0 = tempL;
 
  else
 
    ERROR("invalid device number.");
 
}
}
 
 
void ata_dev_type1 () {
static void switch_param(char *param, struct config_param *cur_param)
  if (current_device >= 0 && current_device < config.natas)
{
    config.atas[current_device].dev_type1 = tempL;
  char *end_p;
  else
  union param_val val;
    ERROR("invalid device number.");
 
}
 
 
 
void ata_dev_file1 () {
    /* Skip over an = sign if it exists */
  if (current_device >= 0 && current_device < config.natas)
  if(*param == '=') {
    strcpy (config.atas[current_device].dev_file1, tempS);
    param++;
  else
    while(*param && isspace(*param)) param++;
    ERROR("invalid device number.");
 
}
}
 
 
void ata_dev_size1 () {
  switch (cur_param->type) {
  if (current_device >= 0 && current_device < config.natas)
  case paramt_int:
    config.atas[current_device].dev_size1 = tempUL;
    val.int_val = strtol(param, NULL, 0);
  else
  case paramt_addr:
    ERROR("invalid device number.");
    val.addr_val = strtoul(param, NULL, 0);
 
    break;
 
  case paramt_str:
 
    if(*param != '"') {
 
      CONFIG_ERROR("String value expected\n");
 
      return;
}
}
 
 
void ata_dev_packet1 () {
    param++;
  if (current_device >= 0 && current_device < config.natas)
    end_p = param;
    config.atas[current_device].dev_packet1 = tempL;
    while(*end_p && (*end_p != '"')) end_p++;
  else
    *end_p = '\0';
    ERROR("invalid device number.");
    val.str_val = param;
 
    break;
 
  case paramt_word:
 
    end_p = param;
 
    while(*end_p && !isspace(*end_p)) end_p++;
 
    *end_p = '\0';
 
    val.str_val = param;
 
    break;
 
  case paramt_none:
 
    break;
}
}
 
 
void cuc_memory_order () {
  cur_param->func(val, cur_section->dat);
  if (strcmp (tempS, "none") == 0)
 
    config.cuc.memory_order = MO_NONE;
 
  else if (strcmp (tempS, "weak") == 0)
 
    config.cuc.memory_order = MO_WEAK;
 
  else if (strcmp (tempS, "strong") == 0)
 
    config.cuc.memory_order = MO_STRONG;
 
  else if (strcmp (tempS, "exact") == 0) {
 
    config.cuc.memory_order = MO_EXACT;
 
  } else {
 
    char tmp[200];
 
    sprintf (tmp, "invalid memory order '%s'.\n", tempS);
 
    ERROR(tmp);
 
  }
 
}
}
 
 
/* Read environment from a script file. Does not fail - assumes default configuration instead.
/* Read environment from a script file. Does not fail - assumes default configuration instead.
   The syntax of script file is:
   The syntax of script file is:
   param = value
   param = value
Line 1318... Line 752...
{
{
  FILE *f;
  FILE *f;
  char *home = getenv("HOME");
  char *home = getenv("HOME");
  char ctmp[STR_SIZE];
  char ctmp[STR_SIZE];
  int local = 1;
  int local = 1;
  section = 0;
  cur_section = NULL;
 
 
  sprintf(ctmp, "%s/.or1k/%s", home, filename);
  sprintf(ctmp, "%s/.or1k/%s", home, filename);
  if ((f = fopen (filename, "rt")) != NULL
  if ((f = fopen (filename, "rt")) != NULL
      || home != NULL && !(local = 0) && (f = fopen (ctmp, "rt")) != NULL) {
      || home != NULL && !(local = 0) && (f = fopen (ctmp, "rt")) != NULL) {
    if (config.sim.verbose && !runtime.sim.output_cfg)
    if (config.sim.verbose && !runtime.sim.output_cfg)
Line 1330... Line 764...
    strcpy (runtime.sim.script_fn, local ? filename : ctmp);
    strcpy (runtime.sim.script_fn, local ? filename : ctmp);
 
 
    while (!feof(f)) {
    while (!feof(f)) {
      char param[STR_SIZE];
      char param[STR_SIZE];
      if (fscanf(f, "%s ", param) != 1) break;
      if (fscanf(f, "%s ", param) != 1) break;
      /* Is this a sections? */
      /* Is this a section? */
      if (strcmp (param, "section") == 0) {
      if (strcmp (param, "section") == 0) {
        int i;
        struct config_section *cur;
        section = 0;
        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);
        }
        }
        for (i = 1; i < sizeof(sections) / sizeof(struct section); i++)
        for (cur = sections; cur; cur = cur->next)
          if (strcmp (sections[i].name, param) == 0) {
          if (strcmp (cur->name, param) == 0) {
            section = i;
            cur_section = cur;
            break;
            break;
          }
          }
        if (!section) {
        if (!cur) {
          char tmp[200];
          fprintf (stderr, "WARNING: config: Unknown section: %s; ignoring.", param);
          sprintf (tmp, "Unknown section: %s; ignoring.", param);
 
          WARNING(tmp);
 
          /* just skip section */
          /* just skip section */
          while (fscanf (f, "%s\n", param) != 1 && strcmp (param, "end"));
          while (fscanf (f, "%s\n", param) != 1 && strcmp (param, "end"));
 
        } else {
 
          cur->dat = NULL;
 
          if (cur->sec_start)
 
            cur->dat = cur->sec_start();
        }
        }
      } else if (strcmp (param, "end") == 0) {
      } else if (strcmp (param, "end") == 0) {
        section = 0;
        if(cur_section->sec_end)
 
          cur_section->sec_end(cur_section->dat);
 
        cur_section = NULL;
      } else if (strncmp (param, "/*", 2) == 0) {
      } else if (strncmp (param, "/*", 2) == 0) {
        char c0 = 0, c1 = 0;
        char c0 = 0, c1 = 0;
        while (c0 != '*' || c1 != '/') {
        while (c0 != '*' || c1 != '/') {
          c0 = c1;
          c0 = c1;
          c1 = fgetc(f);
          c1 = fgetc(f);
Line 1363... Line 801...
            fprintf (stderr, "%s: ERROR: Comment reached EOF.\n", local ? filename : ctmp);
            fprintf (stderr, "%s: ERROR: Comment reached EOF.\n", local ? filename : ctmp);
            exit (1);
            exit (1);
          }
          }
        }
        }
      } else {
      } else {
        int i, found = -1;
        struct config_param *cur_param;
        for (i = 0; i < sizeof(config_params)/sizeof(struct config_params); i++)
        char *cur_p;
          if (config_params[i].section == section && strcmp (config_params[i].name, param) == 0) {
        for (cur_param = cur_section->params; cur_param; cur_param = cur_param->next)
            found = i;
          if (strcmp (cur_param->name, param) == 0) {
            break;
            break;
          }
          }
        if (found < 0) {
        if (!cur_param) {
          char tmp[200];
          char tmp[200];
          sprintf (tmp, "Invalid parameter: %s; ignoring.\n", param);
          sprintf (tmp, "Invalid parameter: %s; ignoring.\n", param);
          WARNING(tmp);
          WARNING(tmp);
          while (fgetc(f) != '\n' || feof(f));
          while (fgetc(f) != '\n' || feof(f));
          continue;
          continue;
        }
        }
 
 
 
        if(cur_param->type == paramt_none)
 
          continue;
 
 
        /* Parse parameter value */
        /* Parse parameter value */
        {
        cur_p = fgets (param, STR_SIZE, f);
          if (config_params[found].type[0])
 
            if(fscanf_ex (f, config_params[found].type, config_params[found].addr, 0))
        while(*cur_p && isspace(*cur_p)) cur_p++;
              exit (1);
 
        }
        switch_param(cur_p, cur_param);
        if (config_params[found].func)
 
          config_params[found].func();
 
      }
      }
    }
    }
    fclose (f);
    fclose (f);
    runtime.sim.script_file_specified = 1;
    runtime.sim.script_file_specified = 1;
  } else
  } else
Line 1397... Line 836...
}
}
 
 
/* Utility for execution of set sim command.  */
/* Utility for execution of set sim command.  */
static int set_config (int argc, char **argv)
static int set_config (int argc, char **argv)
{
{
  int i;
  struct config_section *cur;
 
  struct config_param *cur_param;
 
 
  if (argc < 2) return 1;
  if (argc < 2) return 1;
 
 
  PRINTF ("sec:%s\n", argv[1]);
  PRINTF ("sec:%s\n", argv[1]);
  section = 0;
  cur_section = NULL;
  for (i = 1; i < sizeof(sections) / sizeof(struct section); i++)
  for (cur = sections; cur; cur = cur->next)
    if (strcmp (sections[i].name, argv[1]) == 0) {
    if (strcmp (cur->name, argv[1]) == 0) {
      section = i;
      cur_section = cur;
      break;
      break;
    }
    }
 
 
  if (!section) return 1;
  if (!cur_section) return 1;
 
 
  if (argc < 3) return 2;
  if (argc < 3) return 2;
 
 
  PRINTF ("item:%s\n", argv[2]);
  PRINTF ("item:%s\n", argv[2]);
  {
  {
    int found = -1;
    for (cur_param = cur->params; cur_param; cur_param = cur_param->next)
    for (i = 0; i < sizeof(config_params)/sizeof(struct config_params); i++)
      if (strcmp (cur_param->name, argv[2]) == 0) {
      if (config_params[i].section == section && strcmp (config_params[i].name, argv[2]) == 0) {
 
        found = i;
 
        break;
        break;
      }
      }
    if (found < 0) return 2;
    if (!cur_param) return 2;
 
 
    /* Parse parameter value */
    /* Parse parameter value */
    if (config_params[found].type[0]) {
    if (cur_param->type) {
      if (argc < 4) return 3;
      if (argc < 4) return 3;
      if (fscanf_ex (0, config_params[found].type, config_params[found].addr, argv[3]))
 
        return 3;
 
      PRINTF ("params:%s\n", argv[3]);
      PRINTF ("params:%s\n", argv[3]);
    }
    }
    if (config_params[found].func)
 
      config_params[found].func();
    switch_param(argv[3], cur_param);
  }
  }
  return 0;
  return 0;
}
}
 
 
/* Executes set sim command, displays error.  */
/* Executes set sim command, displays error.  */
void set_config_command(int argc, char **argv)
void set_config_command(int argc, char **argv)
{
{
  int i;
  struct config_section *cur;
 
  struct config_param *cur_param;
 
 
  switch (set_config (argc, argv)) {
  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 (cur = sections; cur; cur = cur->next)
        PRINTF ("%s ", sections[i].name);
        PRINTF ("%s ", cur->name);
      PRINTF ("\n");
      PRINTF ("\n");
      break;
      break;
    case 2:
    case 2:
      PRINTF ("Invalid or missing item name.  One of valid items must be specified:\n");
      PRINTF ("Invalid or missing item name.  One of valid items must be specified:\n");
      for (i = 0; i < sizeof(config_params)/sizeof(struct config_params); i++)
      for (cur_param = cur_section->params; cur_param; cur_param = cur_param->next)
        if (config_params[i].section == section)
        PRINTF ("%s ", cur_param->name);
          PRINTF ("%s ", config_params[i].name);
 
      PRINTF ("\n");
      PRINTF ("\n");
      break;
      break;
    case 3:
    case 3:
      PRINTF ("Invalid parameters specified.\n");
      PRINTF ("Invalid parameters specified.\n");
      break;
      break;

powered by: WebSVN 2.1.0

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