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

Subversion Repositories or1k

[/] [or1k/] [tags/] [nog_patch_61/] [or1ksim/] [sim-config.c] - Blame information for rev 326

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 7 jrydberg
/* config.c -- Simulator configuration
2
   Copyright (C) 1999 Damjan Lampret, lampret@opencores.org
3
 
4
This file is part of OpenRISC 1000 Architectural Simulator.
5
 
6
This program is free software; you can redistribute it and/or modify
7
it under the terms of the GNU General Public License as published by
8
the Free Software Foundation; either version 2 of the License, or
9
(at your option) any later version.
10
 
11
This program is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
GNU General Public License for more details.
15
 
16
You should have received a copy of the GNU General Public License
17
along with this program; if not, write to the Free Software
18
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
19
 
20
/* Simulator configuration. Eventually this one will be a lot bigger. */
21
 
22 239 markom
#include <stdlib.h>
23 7 jrydberg
#include "sim-config.h"
24 30 lampret
#include "abstract.h"
25 103 lampret
#include "spr_defs.h"
26 230 erez
#include "pic.h"
27 7 jrydberg
 
28
struct config config;
29
 
30
void init_defconfig()
31
{
32 239 markom
  unsigned long val;
33
 
34
  memset(&config, 0, sizeof(config));
35 263 markom
  /* Sim */
36
  config.script_file = "sim.cfg";
37 294 markom
 
38
  config.sim.exe_log = 0;
39
  config.sim.fexe_log = 0;
40
  strcpy (config.sim.exe_log_fn, "executed.log");
41
 
42 264 markom
  config.sim.debug = 0;
43 293 markom
  config.sim.verbose = 1;
44 264 markom
  config.sim.iprompt = 0;
45 263 markom
 
46 294 markom
  config.sim.profile = 0;
47
  config.sim.fprof = 0;
48
  strcpy (config.sim.prof_fn, "sim.profile");
49
 
50 262 markom
  /* Memory */
51
  config.memory.type = MT_PATTERN;
52
  config.memory.pattern = 0;
53
  config.memory.random_seed = -1;  /* Generate new seed */
54
  strcpy(config.memory.memory_table_file, "simmem.cfg");
55 263 markom
 
56
  /* Memory Controller */
57
  config.mc.enabled = 0;
58
 
59
  /* Uarts */
60
  config.nuarts = 0;
61
  config.uarts_enabled = 0;
62
 
63
  /* DMAs */
64
  config.ndmas = 0;
65
  config.dmas_enabled = 0;
66
 
67
  /* CPU */
68
  config.cpu.superscalar = 0;
69
  config.cpu.history = 0;
70
  config.cpu.hazards = 0;
71
  config.cpu.dependstats = 0;
72
  config.cpu.dependency = 0;
73
  config.cpu.slp = 0;
74
  config.cpu.upr = SPR_UPR_UP | SPR_UPR_DCP | SPR_UPR_ICP | SPR_UPR_DMP
75
                 | SPR_UPR_IMP | SPR_UPR_OB32P | SPR_UPR_DUP | SPR_UPR_PICP
76
                 | SPR_UPR_PMP | SPR_UPR_TTP;
77 264 markom
 
78 269 markom
  /* Debug */
79
  config.debug.enabled = 0;
80
  config.debug.gdb_enabled = 0;
81
  config.debug.server_port = 0;
82 293 markom
 
83
  /* VAPI */
84
  config.vapi.enabled = 0;
85 304 markom
 
86
  /* Ethernet */
87
  config.ethernets_enabled = 0;
88 269 markom
 
89 262 markom
  /* Old */
90 326 lampret
  config.dc.tagtype = PHYSICAL/*VIRTUAL*/;
91
  config.ic.tagtype = PHYSICAL/*VIRTUAL*/;
92 239 markom
  config.clkcycle_ns = 4; /* 4 for 4ns (250MHz) */
93 103 lampret
}
94
 
95
int parse_args(int argc, char *argv[])
96
{
97 239 markom
  unsigned long val;
98
 
99
  argv++; argc--;
100
  while (argc) {
101
    if (argc && (*argv[0] != '-')) {
102
      config.filename = argv[0];
103
      argc--;
104
      argv++;
105 242 markom
    } else
106 263 markom
    if (strcmp(*argv, "-f") == 0 || strcmp(*argv, "--file") == 0) {
107
      argv++; argc--;
108
      config.script_file = argv[0];
109
      argv++; argc--;
110
    } else
111
    if (strcmp(*argv, "--nosrv") == 0) {  /* (CZ) */
112 269 markom
      config.debug.gdb_enabled = 0;
113 239 markom
      argv++; argc--;
114
    } else
115 263 markom
    if (strcmp(*argv, "--srv") == 0) {  /* (CZ) */
116 239 markom
      char *s;
117
      if(!--argc)
118
        return 1;
119 269 markom
      config.debug.enabled = 1;
120
      config.debug.gdb_enabled = 0;
121
      config.debug.server_port = strtol(*(++argv),&s,10);
122 239 markom
      if(*s)
123
        return 1;
124
      argv++; argc--;
125
    } else
126
    if (strcmp(*argv, "-i") == 0) {
127 264 markom
      config.sim.iprompt = 1;
128 239 markom
      argv++; argc--;
129
    } else
130
    if (strcmp(*argv, "-v") == 0) {
131
      version();
132
      exit(0);
133
    } else
134 263 markom
    if (strcmp(*argv, "--profile") == 0) {
135 264 markom
      config.sim.profile = 1;
136 239 markom
      argv++; argc--;
137
    } else {
138
      printf("Unknown option: %s\n", *argv);
139
      return 1;
140
    }
141
  }
142
 
143
  if (!argc)
144
    return 0;
145
 
146
  return 0;
147
}
148 123 markom
 
149 294 markom
#define CNV(x) ((isblank(x) || (x) == 0) ? ' ' : (x))
150
 
151
/* Substitute for less powerful fscanf */
152
int fscanf_ex (FILE *f, char *fmt, void *buf) {
153
  char tmp[STR_SIZE];
154
  char ch;
155
  int i = 0;
156
  while (*fmt) {
157
    switch (*fmt) {
158
      case '%':
159
        while(*fmt != 0 && !isalpha (*fmt))
160
          tmp[i++] = *(fmt++);
161
        tmp[i++] = *(fmt++);
162
        if (tmp[i - 1] == 's') {
163
          char *cbuf = (char *)buf;
164
          i = 0;
165
          while (ch = fgetc (f), isblank(ch))
166
            if (feof (f)) return 1;
167
          ungetc (ch, f);
168
          while ((*(cbuf++) = ch = fgetc (f), CNV(ch) ) != *fmt) {
169
            if (feof (f)) return 1;
170
            if (++i >= STR_SIZE) {
171
              fprintf (stderr, "ERROR: string too long.\n");
172
              return 1;
173
            }
174
          }
175
          *(--cbuf) = 0;
176
          fmt++;
177
        } else {
178
          tmp[i++] = 0;
179
          fscanf (f, tmp, buf);
180
        }
181
        break;
182
      default:
183
        while ((ch = fgetc (f)) != *fmt) {
184
          if (!isblank (ch))
185
            fprintf (stderr, "WARNING: unexpected char '%c' (expecting '%c')\n", ch, *fmt);
186
          if (feof (f)) return 1;
187
        }
188
        fmt++;
189
        break;
190
    }
191
  }
192
  return 0;
193
}
194
 
195 239 markom
void print_config()
196
{
197
  printf("Machine initialization...\n");
198
  if (testsprbits(SPR_UPR, SPR_UPR_DCP))
199
    printf("Data cache tag: %s\n", config.dc.tagtype == VIRTUAL ? "virtual" : "physical");
200
  else
201
    printf("No data cache.\n");
202
  if (testsprbits(SPR_UPR, SPR_UPR_ICP))
203
    printf("Insn cache tag: %s\n", config.ic.tagtype == VIRTUAL ? "virtual" : "physical");
204
  else
205
    printf("No instruction cache.\n");
206 264 markom
  /*if (config.cpu.bpb_sim)
207 239 markom
    printf("BPB simulation on.\n");
208
  else
209
    printf("BPB simulation off.\n");
210 264 markom
  if (config.cpu.btic_sim)
211 239 markom
    printf("BTIC simulation on.\n");
212
  else
213 264 markom
    printf("BTIC simulation off.\n");*/
214 239 markom
  printf("Clock cycle: %d ns\n", config.clkcycle_ns);
215
 
216 264 markom
  if (config.sim.debug)
217 239 markom
    printf("simdebug on, ");
218
  else
219
    printf("simdebug off, ");
220 264 markom
  if (config.sim.iprompt)
221 239 markom
    printf("interactive prompt on\n");
222
  else
223
    printf("interactive prompt off\n");
224
}
225 123 markom
 
226 261 markom
void change_device ();
227
void end_device ();
228
void uart_baseaddr ();
229
void uart_rxfile ();
230
void uart_txfile ();
231
void uart_jitter ();
232 320 erez
void uart_vapi_id ();
233 261 markom
void dma_baseaddr ();
234
void dma_irq ();
235 320 erez
void dma_vapi_id ();
236 262 markom
void memory_type ();
237 306 markom
void eth_baseaddr ();
238
void eth_dma ();
239 310 markom
void eth_rx_channel ();
240
void eth_tx_channel ();
241
void eth_rxfile ();
242
void eth_txfile ();
243 320 erez
void eth_vapi_id ();
244 123 markom
 
245 305 markom
unsigned long tempL;
246
unsigned long tempUL;
247
char tempS[STR_SIZE];
248 123 markom
 
249 305 markom
#define CPF_SUBSECTION 1
250
#define CPF_SUBFIELD   2
251
 
252 261 markom
struct section {
253
  char *name;
254
  int flags;
255
} sections[] = {
256
  {"",       0},
257
  {"mc",     0},
258
  {"uart",   0},
259 262 markom
  {"dma",    0},
260 263 markom
  {"memory", 0},
261 264 markom
  {"cpu",    0},
262 269 markom
  {"sim",    0},
263 293 markom
  {"debug",  0},
264 304 markom
  {"VAPI",   0},
265
  {"ethernet",0}
266 239 markom
};
267
 
268 305 markom
/* *INDENT-OFF* */
269 261 markom
 
270 239 markom
/* Parameter definitions */
271
struct config_params {
272
  int section;
273
  char *name;
274
  char *type;
275 261 markom
  void (*func)();
276
  void *addr;
277 239 markom
} config_params[] = {
278 294 markom
  {1, "enabled",            "=%i",         NULL,          (void *)(&config.mc.enabled)},
279
  {1, "baseaddr",           "=0x%x",       NULL,          (void *)(&config.mc.baseaddr)},
280
  {1, "POC",                "=0x%x",       NULL,          (void *)(&config.mc.POC)},
281 261 markom
 
282 294 markom
  {2, "enabled",            "=%i",         NULL,          (void *)(&config.uarts_enabled)},
283
  {2, "nuarts",             "=%i",         NULL,          (void *)(&config.nuarts)},
284 261 markom
  {2, "device",             "%i",          change_device, (void *)(&tempL)},
285
  {2, "enddevice",          "",            end_device,    NULL},
286 294 markom
  {2, "baseaddr",           "=0x%x",       uart_baseaddr, (void *)(&tempUL)},
287
  {2, "jitter",             "=%i",         uart_jitter,   (void *)(&tempL)},
288
  {2, "rxfile",             "=\"%s\"",     uart_rxfile,   (void *)(&tempS[0])},
289
  {2, "txfile",             "=\"%s\"",     uart_txfile,   (void *)(&tempS[0])},
290 313 markom
  {2, "vapi_id",            "=%0x%x",      uart_vapi_id,  (void *)(&tempUL)},
291 261 markom
 
292 294 markom
  {3, "enabled",            "=%i",         NULL,          (void *)(&config.dmas_enabled)},
293
  {3, "ndmas",              "=%i",         NULL,          (void *)(&config.ndmas)},
294 261 markom
  {3, "device",             "%i",          change_device, (void *)(&tempL)},
295
  {3, "enddevice",          "",            end_device,    NULL},
296 294 markom
  {3, "baseaddr",           "=0x%x",       dma_baseaddr,  (void *)(&tempUL)},
297
  {3, "irq",                "=%i",         dma_baseaddr,  (void *)(&tempL)},
298 313 markom
  {3, "vapi_id",            "=%0x%x",      dma_vapi_id,   (void *)(&tempUL)},
299 262 markom
 
300 294 markom
  {4, "memory_table_file",  "=\"%s\"",     NULL,          (void *)(&config.memory.memory_table_file[0])},
301
  {4, "random_seed",        "=%i",         NULL,          (void *)(&config.memory.random_seed)},
302
  {4, "pattern",            "=%i",         NULL,          (void *)(&config.memory.pattern)},
303
  {4, "type",               "=%s ",        memory_type,   (void *)(&tempS[0])},
304 263 markom
 
305 294 markom
  {5, "ver",                "=0x%x",       NULL,          (void *)(&config.cpu.ver)},
306
  {5, "rev",                "=0x%x",       NULL,          (void *)(&config.cpu.rev)},
307
  {5, "upr",                "=0x%x",       NULL,          (void *)(&config.cpu.upr)},
308
  {5, "hazards",            "=%i",         NULL,          (void *)(&config.cpu.hazards)},
309
  {5, "history",            "=%i",         NULL,          (void *)(&config.cpu.history)},
310
  {5, "superscalar",        "=%i",         NULL,          (void *)(&config.cpu.superscalar)},
311
  {5, "dependstats",        "=%i",         NULL,          (void *)(&config.cpu.dependstats)},
312
  {5, "dependency",         "=%i",         NULL,          (void *)(&config.cpu.dependency)},
313
  {5, "slp",                "=%i",         NULL,          (void *)(&config.cpu.slp)},
314
  {5, "bpb",                "=%i",         NULL,          (void *)(&config.cpu.bpb)},
315 304 markom
  {5, "btic",               "=%i",         NULL,          (void *)(&config.cpu.btic)},
316 264 markom
 
317 294 markom
  {6, "debug",              "=%i",         NULL,          (void *)(&config.sim.debug)},
318
  {6, "iprompt",            "=%i",         NULL,          (void *)(&config.sim.iprompt)},
319
  {6, "verbose",            "=%i",         NULL,          (void *)(&config.sim.verbose)},
320
  {6, "profile",            "=%i",         NULL,          (void *)(&config.sim.profile)},
321
  {6, "prof_fn",            "=\"%s\"",     NULL,          (void *)(&config.sim.prof_fn[0])},
322 269 markom
 
323 294 markom
  {6, "exe_log",            "=%i",         NULL,          (void *)(&config.sim.exe_log)},
324
  {6, "exe_log_fn",         "=\"%s\"",     NULL,          (void *)(&config.sim.exe_log_fn[0])},
325 293 markom
 
326 294 markom
  {7, "enabled",            "=%i",         NULL,          (void *)(&config.debug.enabled)},
327
  {7, "gdb_enabled",        "=%i",         NULL,          (void *)(&config.debug.gdb_enabled)},
328
  {7, "server_port",        "=%i",         NULL,          (void *)(&config.debug.server_port)},
329
 
330 306 markom
  {8, "enabled",            "=%i",         NULL,          (void *)(&config.vapi.enabled)},
331 304 markom
  {8, "server_port",        "=%i",         NULL,          (void *)(&config.vapi.server_port)},
332
 
333 306 markom
  {9, "enabled",            "=%i",         NULL,          (void *)(&config.ethernets_enabled)},
334 310 markom
  {9, "nethernets",         "=%i",         NULL,          (void *)(&config.nethernets)},
335 304 markom
  {9, "device",             "%i",          change_device, (void *)(&tempL)},
336
  {9, "enddevice",          "",            end_device,    NULL},
337
  {9, "baseaddr",           "=0x%x",       eth_baseaddr,  (void *)(&tempUL)},
338 310 markom
  {9, "dma",                "=%i",         eth_dma,       (void *)(&tempL)},
339
  {9, "rx_channel",         "=%i",         eth_rx_channel,(void *)(&tempL)},
340
  {9, "tx_channel",         "=%i",         eth_tx_channel,(void *)(&tempL)},
341
  {9, "rxfile",             "=\"%s\"",     eth_rxfile,    (void *)(&tempS[0])},
342 313 markom
  {9, "txfile",             "=\"%s\"",     eth_txfile,    (void *)(&tempS[0])},
343
  {9, "vapi_id",            "=%0x%x",      eth_vapi_id,   (void *)(&tempUL)}
344 239 markom
};
345
 
346 305 markom
/* *INDENT-ON* */
347
 
348 261 markom
int current_device = -1;
349
void change_device () {
350
  current_device = tempL;
351
}
352
 
353
void end_device () {
354
  current_device = -1;
355
}
356
 
357
void uart_baseaddr () {
358
  if (current_device >= 0 && current_device < config.nuarts)
359
    config.uarts[current_device].baseaddr = tempUL;
360
  else {
361
    fprintf (stderr, "ERROR: invalid device number.");
362
    exit (-1);
363
  }
364
}
365
 
366
void uart_jitter () {
367
  if (current_device >= 0 && current_device < config.nuarts)
368
    config.uarts[current_device].jitter = tempL;
369
  else {
370
    fprintf (stderr, "ERROR: invalid device number.");
371
    exit (-1);
372
  }
373
}
374
 
375
void uart_rxfile () {
376
  if (current_device >= 0 && current_device < config.nuarts)
377
    strcpy (config.uarts[current_device].rxfile, tempS);
378
  else {
379
    fprintf (stderr, "ERROR: invalid device number.");
380
    exit (-1);
381
  }
382
}
383
 
384
void uart_txfile () {
385
  if (current_device >= 0 && current_device < config.nuarts)
386
    strcpy (config.uarts[current_device].txfile, tempS);
387
  else {
388
    fprintf (stderr, "ERROR: invalid device number.");
389
    exit (-1);
390
  }
391
}
392
 
393 313 markom
void uart_vapi_id () {
394
  if (current_device >= 0 && current_device < config.nuarts)
395
    config.uarts[current_device].vapi_id = tempUL;
396
  else {
397
    fprintf (stderr, "ERROR: invalid device number.");
398
    exit (-1);
399
  }
400
}
401
 
402 261 markom
void dma_baseaddr () {
403
  if (current_device >= 0 && current_device < config.ndmas)
404
    config.dmas[current_device].baseaddr = tempUL;
405
  else {
406
    fprintf (stderr, "ERROR: invalid device number.");
407
    exit (-1);
408
  }
409
}
410
 
411
void dma_irq () {
412
  if (current_device >= 0 && current_device < config.ndmas)
413
    config.dmas[current_device].irq = tempL;
414
  else {
415
    fprintf (stderr, "ERROR: invalid device number.");
416
    exit (-1);
417
  }
418
}
419
 
420 313 markom
void dma_vapi_id () {
421
  if (current_device >= 0 && current_device < config.ndmas)
422
    config.dmas[current_device].vapi_id = tempUL;
423
  else {
424
    fprintf (stderr, "ERROR: invalid device number.");
425
    exit (-1);
426
  }
427
}
428
 
429 262 markom
void memory_type () {
430 269 markom
  if (strcmp (tempS, "unknown") == 0)
431
    config.memory.type = MT_UNKNOWN;
432
  else if (strcmp (tempS, "random") == 0)
433 262 markom
    config.memory.type = MT_RANDOM;
434
  else if (strcmp (tempS, "pattern") == 0)
435
    config.memory.type = MT_PATTERN;
436
  else if (strcmp (tempS, "zero") == 0) {
437
    config.memory.type = MT_PATTERN;
438
    config.memory.pattern = 0;
439
  } else {
440 269 markom
    fprintf (stderr, "ERROR: invalid memory type '%s'.\n", tempS);
441 262 markom
    exit (-1);
442
  }
443
}
444
 
445 304 markom
void eth_baseaddr () {
446
  if (current_device >= 0 && current_device < config.nethernets)
447
    config.ethernets[current_device].baseaddr = tempUL;
448
  else {
449
    fprintf (stderr, "ERROR: invalid device number.");
450
    exit (-1);
451
  }
452
}
453
 
454
void eth_dma () {
455
  if (current_device >= 0 && current_device < config.nethernets)
456 306 markom
    config.ethernets[current_device].dma = tempL;
457 304 markom
  else {
458
    fprintf (stderr, "ERROR: invalid device number.");
459
    exit (-1);
460
  }
461
}
462
 
463 310 markom
void eth_rx_channel () {
464
  if (current_device >= 0 && current_device < config.nethernets)
465
    config.ethernets[current_device].rx_channel = tempL;
466
  else {
467
    fprintf (stderr, "ERROR: invalid device number.");
468
    exit (-1);
469
  }
470
}
471
 
472
void eth_tx_channel () {
473
  if (current_device >= 0 && current_device < config.nethernets)
474
    config.ethernets[current_device].rx_channel = tempL;
475
  else {
476
    fprintf (stderr, "ERROR: invalid device number.");
477
    exit (-1);
478
  }
479
}
480
 
481
void eth_rxfile () {
482
  if (current_device >= 0 && current_device < config.nethernets)
483
    strcpy (config.ethernets[current_device].rxfile, tempS);
484
  else {
485
    fprintf (stderr, "ERROR: invalid device number.");
486
    exit (-1);
487
  }
488
}
489
 
490
void eth_txfile () {
491
  if (current_device >= 0 && current_device < config.nethernets)
492 323 erez
    strcpy (config.ethernets[current_device].txfile, tempS);
493 310 markom
  else {
494
    fprintf (stderr, "ERROR: invalid device number.");
495
    exit (-1);
496
  }
497
}
498
 
499 313 markom
void eth_vapi_id () {
500
  if (current_device >= 0 && current_device < config.nethernets)
501
    config.ethernets[current_device].vapi_id = tempUL;
502
  else {
503
    fprintf (stderr, "ERROR: invalid device number.");
504
    exit (-1);
505
  }
506
}
507
 
508
 
509
 
510 239 markom
/* Read environment from a script file. Does not fail - assumes defaukt configuration instead.
511
   The syntax of script file is:
512
   param = value
513
   section x
514
     data
515
     param = value
516
   end
517
 
518
   Example:
519
   section mc
520
     memory_table_file = sim.mem
521
     enable = 1
522
     POC = 0x47892344
523
   end
524
 
525
 */
526
 
527
void read_script_file (char *filename)
528
{
529 263 markom
  FILE *f;
530
  unsigned long memory_needed = 0;
531
  char *home = getenv("HOME");
532
  char ctmp[STR_SIZE];
533
  int local = 1;
534
  int section = 0;
535 239 markom
 
536 263 markom
  sprintf(ctmp, "%s/.or1k/%s", home, filename);
537
  if ((f = fopen (filename, "rt")) != NULL
538
      || home != NULL && !(local = 0) && (f = fopen (ctmp, "rt")) != NULL) {
539
    unsigned long start, length;
540
    char type[STR_SIZE];
541
    int nparam;
542
    int rd, wd;
543 308 markom
    if (config.sim.verbose)
544
      printf ("Reading script file from '%s':\n", local ? filename : ctmp);
545 239 markom
    while (!feof(f)) {
546
      char param[STR_SIZE];
547
      if (fscanf(f, "%s ", &param) != 1) break;
548
      /* Is this a sections? */
549
      if (strcmp (param, "section") == 0) {
550
        int i;
551
        section = 0;
552
        if (fscanf (f, "%s\n", &param) != 1) {
553
          fprintf (stderr, "%s: ERROR: Section name required.\n", local ? filename : ctmp);
554
          exit (-1);
555
        }
556 294 markom
        for (i = 1; i < sizeof(sections) / sizeof(struct section); i++)
557 261 markom
          if (strcmp (sections[i].name, param) == 0) {
558 239 markom
            section = i;
559
            break;
560
          }
561
        if (!section) {
562
          fprintf (stderr, "%s: WARNING: Unknown section: %s; ignoring.\n", local ? filename : ctmp, param);
563
          /* just skip section */
564
          while (fscanf (f, "%s\n", &param) != 1 && strcmp (param, "end"));
565
        }
566
      } else if (strcmp (param, "end") == 0) {
567
        section = 0;
568 264 markom
      } else if (strncmp (param, "/*", 2) == 0) {
569 261 markom
        char c0 = 0, c1 = 0;
570 264 markom
        while (c0 != '*' || c1 != '/') {
571 261 markom
          c0 = c1;
572
          c1 = fgetc(f);
573
          if (feof(f)) {
574
            fprintf (stderr, "%s: ERROR: Comment reached EOF.\n", local ? filename : ctmp);
575
            exit (-1);
576
          }
577
        }
578 239 markom
      } else {
579
        int i, found = -1;
580
        for (i = 0; i < sizeof(config_params)/sizeof(struct config_params); i++)
581
          if (config_params[i].section == section && strcmp (config_params[i].name, param) == 0) {
582
            found = i;
583
            break;
584
          }
585
        if (found < 0) {
586
          fprintf (stderr, "%s: WARNING: Invalid parameter: %s; ignoring.\n", local ? filename : ctmp, param);
587 294 markom
          while (fgetc(f) != '\n' || feof(f));
588 239 markom
          continue;
589
        }
590
 
591
        /* Parse parameter value */
592
        {
593 294 markom
          if (config_params[found].type[0])
594
            if(fscanf_ex (f, config_params[found].type, config_params[found].addr))
595
              exit (1);
596 239 markom
        }
597 262 markom
        if (config_params[found].func)
598
          config_params[found].func();
599 239 markom
      }
600
    }
601 263 markom
    fclose (f);
602 308 markom
  } else
603
    if (config.sim.verbose)
604
      fprintf (stderr, "WARNING: Cannot read script file from '%s',\nneither '%s'; assuming standard configuration.\n", filename, ctmp);
605 103 lampret
 
606 263 markom
  /* Initialize memory table.  */
607
  sim_read_memory_table (config.memory.memory_table_file);
608 7 jrydberg
}

powered by: WebSVN 2.1.0

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