Line 32... |
Line 32... |
unsigned long val;
|
unsigned long val;
|
|
|
memset(&config, 0, sizeof(config));
|
memset(&config, 0, sizeof(config));
|
/* Sim */
|
/* Sim */
|
config.script_file = "sim.cfg";
|
config.script_file = "sim.cfg";
|
config.sim.fprof = 0;
|
|
strcpy (config.sim.prof_fn, "sim.profile");
|
config.sim.exe_log = 0;
|
|
config.sim.fexe_log = 0;
|
|
strcpy (config.sim.exe_log_fn, "executed.log");
|
|
|
config.sim.debug = 0;
|
config.sim.debug = 0;
|
config.sim.profile = 0;
|
|
config.sim.verbose = 1;
|
config.sim.verbose = 1;
|
config.sim.iprompt = 0;
|
config.sim.iprompt = 0;
|
|
|
|
config.sim.profile = 0;
|
|
config.sim.fprof = 0;
|
|
strcpy (config.sim.prof_fn, "sim.profile");
|
|
|
/* Memory */
|
/* Memory */
|
config.memory.type = MT_PATTERN;
|
config.memory.type = MT_PATTERN;
|
config.memory.pattern = 0;
|
config.memory.pattern = 0;
|
config.memory.random_seed = -1; /* Generate new seed */
|
config.memory.random_seed = -1; /* Generate new seed */
|
strcpy(config.memory.memory_table_file, "simmem.cfg");
|
strcpy(config.memory.memory_table_file, "simmem.cfg");
|
Line 141... |
Line 147... |
return 0;
|
return 0;
|
|
|
return 0;
|
return 0;
|
}
|
}
|
|
|
|
#define CNV(x) ((isblank(x) || (x) == 0) ? ' ' : (x))
|
|
|
|
/* Substitute for less powerful fscanf */
|
|
int fscanf_ex (FILE *f, char *fmt, void *buf) {
|
|
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 = fgetc (f), isblank(ch))
|
|
if (feof (f)) return 1;
|
|
ungetc (ch, f);
|
|
while ((*(cbuf++) = ch = fgetc (f), CNV(ch) ) != *fmt) {
|
|
if (feof (f)) return 1;
|
|
if (++i >= STR_SIZE) {
|
|
fprintf (stderr, "ERROR: string too long.\n");
|
|
return 1;
|
|
}
|
|
}
|
|
*(--cbuf) = 0;
|
|
fmt++;
|
|
} else {
|
|
tmp[i++] = 0;
|
|
fscanf (f, tmp, buf);
|
|
}
|
|
break;
|
|
default:
|
|
while ((ch = fgetc (f)) != *fmt) {
|
|
if (!isblank (ch))
|
|
fprintf (stderr, "WARNING: unexpected char '%c' (expecting '%c')\n", ch, *fmt);
|
|
if (feof (f)) return 1;
|
|
}
|
|
fmt++;
|
|
break;
|
|
}
|
|
}
|
|
return 0;
|
|
}
|
|
|
void print_config()
|
void print_config()
|
{
|
{
|
printf("Machine initialization...\n");
|
printf("Machine initialization...\n");
|
if (testsprbits(SPR_UPR, SPR_UPR_DCP))
|
if (testsprbits(SPR_UPR, SPR_UPR_DCP))
|
printf("Data cache tag: %s\n", config.dc.tagtype == VIRTUAL ? "virtual" : "physical");
|
printf("Data cache tag: %s\n", config.dc.tagtype == VIRTUAL ? "virtual" : "physical");
|
Line 224... |
Line 276... |
{2, "nuarts", "= %i", NULL, (void *)(&config.nuarts)},
|
{2, "nuarts", "= %i", NULL, (void *)(&config.nuarts)},
|
{2, "device", "%i", change_device, (void *)(&tempL)},
|
{2, "device", "%i", change_device, (void *)(&tempL)},
|
{2, "enddevice", "", end_device, NULL},
|
{2, "enddevice", "", end_device, NULL},
|
{2, "baseaddr", "= 0x%x", uart_baseaddr, (void *)(&tempUL)},
|
{2, "baseaddr", "= 0x%x", uart_baseaddr, (void *)(&tempUL)},
|
{2, "jitter", "= %i", uart_jitter, (void *)(&tempL)},
|
{2, "jitter", "= %i", uart_jitter, (void *)(&tempL)},
|
{2, "rxfile", "= \"%255s\"", uart_rxfile, (void *)(&tempS[0])},
|
{2, "rxfile", "=\"%s\"", uart_rxfile, (void *)(&tempS[0])},
|
{2, "txfile", "= \"%255s\"", uart_txfile, (void *)(&tempS[0])},
|
{2, "txfile", "=\"%s\"", uart_txfile, (void *)(&tempS[0])},
|
|
|
{3, "enabled", "= %i", NULL, (void *)(&config.dmas_enabled)},
|
{3, "enabled", "= %i", NULL, (void *)(&config.dmas_enabled)},
|
{3, "ndmas", "= %i", NULL, (void *)(&config.ndmas)},
|
{3, "ndmas", "= %i", NULL, (void *)(&config.ndmas)},
|
{3, "device", "%i", change_device, (void *)(&tempL)},
|
{3, "device", "%i", change_device, (void *)(&tempL)},
|
{3, "enddevice", "", end_device, NULL},
|
{3, "enddevice", "", end_device, NULL},
|
{3, "baseaddr", "= 0x%x", dma_baseaddr, (void *)(&tempUL)},
|
{3, "baseaddr", "= 0x%x", dma_baseaddr, (void *)(&tempUL)},
|
{3, "irq", "= %i", dma_baseaddr, (void *)(&tempL)},
|
{3, "irq", "= %i", dma_baseaddr, (void *)(&tempL)},
|
|
|
{4, "memory_table_file", "= \"%255s\"", NULL, (void *)(&config.memory.memory_table_file[0])},
|
{4, "memory_table_file", "=\"%s\"", NULL, (void *)(&config.memory.memory_table_file[0])},
|
{4, "random_seed", "= %i", NULL, (void *)(&config.memory.random_seed)},
|
{4, "random_seed", "= %i", NULL, (void *)(&config.memory.random_seed)},
|
{4, "pattern", "= %i", NULL, (void *)(&config.memory.pattern)},
|
{4, "pattern", "= %i", NULL, (void *)(&config.memory.pattern)},
|
{4, "type", "= %255s", memory_type, (void *)(&tempS[0])},
|
{4, "type", "=%s ", memory_type, (void *)(&tempS[0])},
|
|
|
{5, "ver", "= 0x%x", NULL, (void *)(&config.cpu.ver)},
|
{5, "ver", "= 0x%x", NULL, (void *)(&config.cpu.ver)},
|
{5, "rev", "= 0x%x", NULL, (void *)(&config.cpu.rev)},
|
{5, "rev", "= 0x%x", NULL, (void *)(&config.cpu.rev)},
|
{5, "upr", "= 0x%x", NULL, (void *)(&config.cpu.upr)},
|
{5, "upr", "= 0x%x", NULL, (void *)(&config.cpu.upr)},
|
{5, "hazards", "= %i", NULL, (void *)(&config.cpu.hazards)},
|
{5, "hazards", "= %i", NULL, (void *)(&config.cpu.hazards)},
|
Line 252... |
Line 304... |
{5, "slp", "= %i", NULL, (void *)(&config.cpu.slp)},
|
{5, "slp", "= %i", NULL, (void *)(&config.cpu.slp)},
|
{5, "bpb", "= %i", NULL, (void *)(&config.cpu.bpb)},
|
{5, "bpb", "= %i", NULL, (void *)(&config.cpu.bpb)},
|
{5, "btic_sim", "= %i", NULL, (void *)(&config.cpu.btic_sim)},
|
{5, "btic_sim", "= %i", NULL, (void *)(&config.cpu.btic_sim)},
|
|
|
{6, "debug", "= %i", NULL, (void *)(&config.sim.debug)},
|
{6, "debug", "= %i", NULL, (void *)(&config.sim.debug)},
|
{6, "prof_fn", "= \"%255s\"", NULL, (void *)(&config.sim.prof_fn[0])},
|
|
{6, "profile", "= %i", NULL, (void *)(&config.sim.profile)},
|
|
{6, "iprompt", "= %i", NULL, (void *)(&config.sim.iprompt)},
|
{6, "iprompt", "= %i", NULL, (void *)(&config.sim.iprompt)},
|
{6, "verbose", "= %i", NULL, (void *)(&config.sim.verbose)},
|
{6, "verbose", "= %i", NULL, (void *)(&config.sim.verbose)},
|
|
{6, "profile", "=%i", NULL, (void *)(&config.sim.profile)},
|
|
{6, "prof_fn", "=\"%s\"", NULL, (void *)(&config.sim.prof_fn[0])},
|
|
|
|
{6, "exe_log", "=%i", NULL, (void *)(&config.sim.exe_log)},
|
|
{6, "exe_log_fn", "=\"%s\"", NULL, (void *)(&config.sim.exe_log_fn[0])},
|
|
|
{7, "enabled", "= %i", NULL, (void *)(&config.debug.enabled)},
|
{7, "enabled", "= %i", NULL, (void *)(&config.debug.enabled)},
|
{7, "gdb_enabled", "= %i", NULL, (void *)(&config.debug.gdb_enabled)},
|
{7, "gdb_enabled", "= %i", NULL, (void *)(&config.debug.gdb_enabled)},
|
{7, "server_port", "= %i", NULL, (void *)(&config.debug.server_port)},
|
{7, "server_port", "= %i", NULL, (void *)(&config.debug.server_port)},
|
|
|
Line 388... |
Line 443... |
section = 0;
|
section = 0;
|
if (fscanf (f, "%s\n", ¶m) != 1) {
|
if (fscanf (f, "%s\n", ¶m) != 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(char *); i++)
|
for (i = 1; i < sizeof(sections) / sizeof(struct section); i++)
|
if (strcmp (sections[i].name, param) == 0) {
|
if (strcmp (sections[i].name, param) == 0) {
|
section = i;
|
section = i;
|
break;
|
break;
|
}
|
}
|
if (!section) {
|
if (!section) {
|
Line 425... |
Line 480... |
continue;
|
continue;
|
}
|
}
|
|
|
/* Parse parameter value */
|
/* Parse parameter value */
|
{
|
{
|
char fmt[STR_SIZE];
|
if (config_params[found].type[0])
|
if (config_params[found].type[0]) {
|
if(fscanf_ex (f, config_params[found].type, config_params[found].addr))
|
sprintf (fmt, "%s\n", config_params[found].type);
|
exit (1);
|
fscanf (f, fmt, config_params[found].addr);
|
|
}
|
|
}
|
}
|
if (config_params[found].func)
|
if (config_params[found].func)
|
config_params[found].func();
|
config_params[found].func();
|
}
|
}
|
}
|
}
|