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 335

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 332 markom
 
89
  /* Tick timer */
90
  config.tick.enabled = 0;
91 269 markom
 
92 262 markom
  /* Old */
93 326 lampret
  config.dc.tagtype = PHYSICAL/*VIRTUAL*/;
94
  config.ic.tagtype = PHYSICAL/*VIRTUAL*/;
95 239 markom
  config.clkcycle_ns = 4; /* 4 for 4ns (250MHz) */
96 103 lampret
}
97
 
98
int parse_args(int argc, char *argv[])
99
{
100 239 markom
  unsigned long val;
101
 
102
  argv++; argc--;
103
  while (argc) {
104
    if (argc && (*argv[0] != '-')) {
105
      config.filename = argv[0];
106
      argc--;
107
      argv++;
108 242 markom
    } else
109 263 markom
    if (strcmp(*argv, "-f") == 0 || strcmp(*argv, "--file") == 0) {
110
      argv++; argc--;
111
      config.script_file = argv[0];
112
      argv++; argc--;
113
    } else
114
    if (strcmp(*argv, "--nosrv") == 0) {  /* (CZ) */
115 269 markom
      config.debug.gdb_enabled = 0;
116 239 markom
      argv++; argc--;
117
    } else
118 263 markom
    if (strcmp(*argv, "--srv") == 0) {  /* (CZ) */
119 239 markom
      char *s;
120
      if(!--argc)
121
        return 1;
122 269 markom
      config.debug.enabled = 1;
123
      config.debug.gdb_enabled = 0;
124
      config.debug.server_port = strtol(*(++argv),&s,10);
125 239 markom
      if(*s)
126
        return 1;
127
      argv++; argc--;
128
    } else
129
    if (strcmp(*argv, "-i") == 0) {
130 264 markom
      config.sim.iprompt = 1;
131 239 markom
      argv++; argc--;
132
    } else
133
    if (strcmp(*argv, "-v") == 0) {
134
      version();
135
      exit(0);
136
    } else
137 263 markom
    if (strcmp(*argv, "--profile") == 0) {
138 264 markom
      config.sim.profile = 1;
139 239 markom
      argv++; argc--;
140
    } else {
141
      printf("Unknown option: %s\n", *argv);
142
      return 1;
143
    }
144
  }
145
 
146
  if (!argc)
147
    return 0;
148
 
149
  return 0;
150
}
151 123 markom
 
152 294 markom
#define CNV(x) ((isblank(x) || (x) == 0) ? ' ' : (x))
153
 
154
/* Substitute for less powerful fscanf */
155
int fscanf_ex (FILE *f, char *fmt, void *buf) {
156
  char tmp[STR_SIZE];
157
  char ch;
158
  int i = 0;
159
  while (*fmt) {
160
    switch (*fmt) {
161
      case '%':
162
        while(*fmt != 0 && !isalpha (*fmt))
163
          tmp[i++] = *(fmt++);
164
        tmp[i++] = *(fmt++);
165
        if (tmp[i - 1] == 's') {
166
          char *cbuf = (char *)buf;
167
          i = 0;
168
          while (ch = fgetc (f), isblank(ch))
169
            if (feof (f)) return 1;
170
          ungetc (ch, f);
171
          while ((*(cbuf++) = ch = fgetc (f), CNV(ch) ) != *fmt) {
172
            if (feof (f)) return 1;
173
            if (++i >= STR_SIZE) {
174
              fprintf (stderr, "ERROR: string too long.\n");
175
              return 1;
176
            }
177
          }
178
          *(--cbuf) = 0;
179
          fmt++;
180
        } else {
181
          tmp[i++] = 0;
182
          fscanf (f, tmp, buf);
183
        }
184
        break;
185
      default:
186
        while ((ch = fgetc (f)) != *fmt) {
187
          if (!isblank (ch))
188
            fprintf (stderr, "WARNING: unexpected char '%c' (expecting '%c')\n", ch, *fmt);
189
          if (feof (f)) return 1;
190
        }
191
        fmt++;
192
        break;
193
    }
194
  }
195
  return 0;
196
}
197
 
198 239 markom
void print_config()
199
{
200
  printf("Machine initialization...\n");
201
  if (testsprbits(SPR_UPR, SPR_UPR_DCP))
202
    printf("Data cache tag: %s\n", config.dc.tagtype == VIRTUAL ? "virtual" : "physical");
203
  else
204
    printf("No data cache.\n");
205
  if (testsprbits(SPR_UPR, SPR_UPR_ICP))
206
    printf("Insn cache tag: %s\n", config.ic.tagtype == VIRTUAL ? "virtual" : "physical");
207
  else
208
    printf("No instruction cache.\n");
209 264 markom
  /*if (config.cpu.bpb_sim)
210 239 markom
    printf("BPB simulation on.\n");
211
  else
212
    printf("BPB simulation off.\n");
213 264 markom
  if (config.cpu.btic_sim)
214 239 markom
    printf("BTIC simulation on.\n");
215
  else
216 264 markom
    printf("BTIC simulation off.\n");*/
217 239 markom
  printf("Clock cycle: %d ns\n", config.clkcycle_ns);
218
 
219 264 markom
  if (config.sim.debug)
220 239 markom
    printf("simdebug on, ");
221
  else
222
    printf("simdebug off, ");
223 264 markom
  if (config.sim.iprompt)
224 239 markom
    printf("interactive prompt on\n");
225
  else
226
    printf("interactive prompt off\n");
227
}
228 123 markom
 
229 261 markom
void change_device ();
230
void end_device ();
231
void uart_baseaddr ();
232
void uart_rxfile ();
233
void uart_txfile ();
234
void uart_jitter ();
235 333 markom
void uart_irq ();
236 320 erez
void uart_vapi_id ();
237 261 markom
void dma_baseaddr ();
238
void dma_irq ();
239 320 erez
void dma_vapi_id ();
240 262 markom
void memory_type ();
241 306 markom
void eth_baseaddr ();
242
void eth_dma ();
243 310 markom
void eth_rx_channel ();
244
void eth_tx_channel ();
245
void eth_rxfile ();
246
void eth_txfile ();
247 320 erez
void eth_vapi_id ();
248 123 markom
 
249 305 markom
unsigned long tempL;
250
unsigned long tempUL;
251
char tempS[STR_SIZE];
252 123 markom
 
253 305 markom
#define CPF_SUBSECTION 1
254
#define CPF_SUBFIELD   2
255
 
256 261 markom
struct section {
257
  char *name;
258
  int flags;
259
} sections[] = {
260 332 markom
  {"",       0},  /* 0  */
261 261 markom
  {"mc",     0},
262
  {"uart",   0},
263 262 markom
  {"dma",    0},
264 263 markom
  {"memory", 0},
265 264 markom
  {"cpu",    0},
266 269 markom
  {"sim",    0},
267 293 markom
  {"debug",  0},
268 304 markom
  {"VAPI",   0},
269 332 markom
  {"ethernet",0},
270
  {"tick",   0}   /* 10 */
271 239 markom
};
272
 
273 305 markom
/* *INDENT-OFF* */
274 261 markom
 
275 239 markom
/* Parameter definitions */
276
struct config_params {
277
  int section;
278
  char *name;
279
  char *type;
280 261 markom
  void (*func)();
281
  void *addr;
282 239 markom
} config_params[] = {
283 294 markom
  {1, "enabled",            "=%i",         NULL,          (void *)(&config.mc.enabled)},
284
  {1, "baseaddr",           "=0x%x",       NULL,          (void *)(&config.mc.baseaddr)},
285
  {1, "POC",                "=0x%x",       NULL,          (void *)(&config.mc.POC)},
286 261 markom
 
287 294 markom
  {2, "enabled",            "=%i",         NULL,          (void *)(&config.uarts_enabled)},
288
  {2, "nuarts",             "=%i",         NULL,          (void *)(&config.nuarts)},
289 261 markom
  {2, "device",             "%i",          change_device, (void *)(&tempL)},
290
  {2, "enddevice",          "",            end_device,    NULL},
291 294 markom
  {2, "baseaddr",           "=0x%x",       uart_baseaddr, (void *)(&tempUL)},
292 332 markom
  {2, "irq",                "=%i",         uart_irq,      (void *)(&tempL)},
293 294 markom
  {2, "jitter",             "=%i",         uart_jitter,   (void *)(&tempL)},
294
  {2, "rxfile",             "=\"%s\"",     uart_rxfile,   (void *)(&tempS[0])},
295
  {2, "txfile",             "=\"%s\"",     uart_txfile,   (void *)(&tempS[0])},
296 335 markom
  {2, "vapi_id",            "=0x%x",       uart_vapi_id,  (void *)(&tempUL)},
297 261 markom
 
298 294 markom
  {3, "enabled",            "=%i",         NULL,          (void *)(&config.dmas_enabled)},
299
  {3, "ndmas",              "=%i",         NULL,          (void *)(&config.ndmas)},
300 261 markom
  {3, "device",             "%i",          change_device, (void *)(&tempL)},
301
  {3, "enddevice",          "",            end_device,    NULL},
302 294 markom
  {3, "baseaddr",           "=0x%x",       dma_baseaddr,  (void *)(&tempUL)},
303
  {3, "irq",                "=%i",         dma_baseaddr,  (void *)(&tempL)},
304 335 markom
  {3, "vapi_id",            "=0x%x",       dma_vapi_id,   (void *)(&tempUL)},
305 262 markom
 
306 294 markom
  {4, "memory_table_file",  "=\"%s\"",     NULL,          (void *)(&config.memory.memory_table_file[0])},
307
  {4, "random_seed",        "=%i",         NULL,          (void *)(&config.memory.random_seed)},
308
  {4, "pattern",            "=%i",         NULL,          (void *)(&config.memory.pattern)},
309
  {4, "type",               "=%s ",        memory_type,   (void *)(&tempS[0])},
310 263 markom
 
311 294 markom
  {5, "ver",                "=0x%x",       NULL,          (void *)(&config.cpu.ver)},
312
  {5, "rev",                "=0x%x",       NULL,          (void *)(&config.cpu.rev)},
313
  {5, "upr",                "=0x%x",       NULL,          (void *)(&config.cpu.upr)},
314
  {5, "hazards",            "=%i",         NULL,          (void *)(&config.cpu.hazards)},
315
  {5, "history",            "=%i",         NULL,          (void *)(&config.cpu.history)},
316
  {5, "superscalar",        "=%i",         NULL,          (void *)(&config.cpu.superscalar)},
317
  {5, "dependstats",        "=%i",         NULL,          (void *)(&config.cpu.dependstats)},
318
  {5, "dependency",         "=%i",         NULL,          (void *)(&config.cpu.dependency)},
319
  {5, "slp",                "=%i",         NULL,          (void *)(&config.cpu.slp)},
320
  {5, "bpb",                "=%i",         NULL,          (void *)(&config.cpu.bpb)},
321 304 markom
  {5, "btic",               "=%i",         NULL,          (void *)(&config.cpu.btic)},
322 264 markom
 
323 294 markom
  {6, "debug",              "=%i",         NULL,          (void *)(&config.sim.debug)},
324
  {6, "iprompt",            "=%i",         NULL,          (void *)(&config.sim.iprompt)},
325
  {6, "verbose",            "=%i",         NULL,          (void *)(&config.sim.verbose)},
326
  {6, "profile",            "=%i",         NULL,          (void *)(&config.sim.profile)},
327
  {6, "prof_fn",            "=\"%s\"",     NULL,          (void *)(&config.sim.prof_fn[0])},
328 269 markom
 
329 294 markom
  {6, "exe_log",            "=%i",         NULL,          (void *)(&config.sim.exe_log)},
330
  {6, "exe_log_fn",         "=\"%s\"",     NULL,          (void *)(&config.sim.exe_log_fn[0])},
331 293 markom
 
332 294 markom
  {7, "enabled",            "=%i",         NULL,          (void *)(&config.debug.enabled)},
333
  {7, "gdb_enabled",        "=%i",         NULL,          (void *)(&config.debug.gdb_enabled)},
334
  {7, "server_port",        "=%i",         NULL,          (void *)(&config.debug.server_port)},
335
 
336 306 markom
  {8, "enabled",            "=%i",         NULL,          (void *)(&config.vapi.enabled)},
337 304 markom
  {8, "server_port",        "=%i",         NULL,          (void *)(&config.vapi.server_port)},
338
 
339 306 markom
  {9, "enabled",            "=%i",         NULL,          (void *)(&config.ethernets_enabled)},
340 310 markom
  {9, "nethernets",         "=%i",         NULL,          (void *)(&config.nethernets)},
341 304 markom
  {9, "device",             "%i",          change_device, (void *)(&tempL)},
342
  {9, "enddevice",          "",            end_device,    NULL},
343
  {9, "baseaddr",           "=0x%x",       eth_baseaddr,  (void *)(&tempUL)},
344 310 markom
  {9, "dma",                "=%i",         eth_dma,       (void *)(&tempL)},
345
  {9, "rx_channel",         "=%i",         eth_rx_channel,(void *)(&tempL)},
346
  {9, "tx_channel",         "=%i",         eth_tx_channel,(void *)(&tempL)},
347
  {9, "rxfile",             "=\"%s\"",     eth_rxfile,    (void *)(&tempS[0])},
348 313 markom
  {9, "txfile",             "=\"%s\"",     eth_txfile,    (void *)(&tempS[0])},
349 335 markom
  {9, "vapi_id",            "=0x%x",       eth_vapi_id,   (void *)(&tempUL)},
350 332 markom
 
351
 {10, "enabled",            "=%i",         NULL,          (void *)(&config.tick.enabled)},
352
 {10, "irq",                "=%i",         NULL,          (void *)(&config.tick.irq)},
353 239 markom
};
354
 
355 305 markom
/* *INDENT-ON* */
356
 
357 261 markom
int current_device = -1;
358
void change_device () {
359
  current_device = tempL;
360
}
361
 
362
void end_device () {
363
  current_device = -1;
364
}
365
 
366
void uart_baseaddr () {
367
  if (current_device >= 0 && current_device < config.nuarts)
368
    config.uarts[current_device].baseaddr = tempUL;
369
  else {
370
    fprintf (stderr, "ERROR: invalid device number.");
371
    exit (-1);
372
  }
373
}
374
 
375
void uart_jitter () {
376
  if (current_device >= 0 && current_device < config.nuarts)
377
    config.uarts[current_device].jitter = tempL;
378
  else {
379
    fprintf (stderr, "ERROR: invalid device number.");
380
    exit (-1);
381
  }
382
}
383
 
384
void uart_rxfile () {
385
  if (current_device >= 0 && current_device < config.nuarts)
386
    strcpy (config.uarts[current_device].rxfile, tempS);
387
  else {
388
    fprintf (stderr, "ERROR: invalid device number.");
389
    exit (-1);
390
  }
391
}
392
 
393
void uart_txfile () {
394
  if (current_device >= 0 && current_device < config.nuarts)
395
    strcpy (config.uarts[current_device].txfile, tempS);
396
  else {
397
    fprintf (stderr, "ERROR: invalid device number.");
398
    exit (-1);
399
  }
400
}
401
 
402 313 markom
void uart_vapi_id () {
403
  if (current_device >= 0 && current_device < config.nuarts)
404
    config.uarts[current_device].vapi_id = tempUL;
405
  else {
406
    fprintf (stderr, "ERROR: invalid device number.");
407
    exit (-1);
408
  }
409
}
410
 
411 332 markom
void uart_irq () {
412
  if (current_device >= 0 && current_device < config.nuarts)
413
    config.uarts[current_device].irq = tempL;
414
  else {
415
    fprintf (stderr, "ERROR: invalid device number.");
416
    exit (-1);
417
  }
418
}
419
 
420 261 markom
void dma_baseaddr () {
421
  if (current_device >= 0 && current_device < config.ndmas)
422
    config.dmas[current_device].baseaddr = tempUL;
423
  else {
424
    fprintf (stderr, "ERROR: invalid device number.");
425
    exit (-1);
426
  }
427
}
428
 
429
void dma_irq () {
430
  if (current_device >= 0 && current_device < config.ndmas)
431
    config.dmas[current_device].irq = tempL;
432
  else {
433
    fprintf (stderr, "ERROR: invalid device number.");
434
    exit (-1);
435
  }
436
}
437
 
438 313 markom
void dma_vapi_id () {
439
  if (current_device >= 0 && current_device < config.ndmas)
440
    config.dmas[current_device].vapi_id = tempUL;
441
  else {
442
    fprintf (stderr, "ERROR: invalid device number.");
443
    exit (-1);
444
  }
445
}
446
 
447 262 markom
void memory_type () {
448 269 markom
  if (strcmp (tempS, "unknown") == 0)
449
    config.memory.type = MT_UNKNOWN;
450
  else if (strcmp (tempS, "random") == 0)
451 262 markom
    config.memory.type = MT_RANDOM;
452
  else if (strcmp (tempS, "pattern") == 0)
453
    config.memory.type = MT_PATTERN;
454
  else if (strcmp (tempS, "zero") == 0) {
455
    config.memory.type = MT_PATTERN;
456
    config.memory.pattern = 0;
457
  } else {
458 269 markom
    fprintf (stderr, "ERROR: invalid memory type '%s'.\n", tempS);
459 262 markom
    exit (-1);
460
  }
461
}
462
 
463 304 markom
void eth_baseaddr () {
464
  if (current_device >= 0 && current_device < config.nethernets)
465
    config.ethernets[current_device].baseaddr = tempUL;
466
  else {
467
    fprintf (stderr, "ERROR: invalid device number.");
468
    exit (-1);
469
  }
470
}
471
 
472
void eth_dma () {
473
  if (current_device >= 0 && current_device < config.nethernets)
474 306 markom
    config.ethernets[current_device].dma = tempL;
475 304 markom
  else {
476
    fprintf (stderr, "ERROR: invalid device number.");
477
    exit (-1);
478
  }
479
}
480
 
481 310 markom
void eth_rx_channel () {
482
  if (current_device >= 0 && current_device < config.nethernets)
483
    config.ethernets[current_device].rx_channel = tempL;
484
  else {
485
    fprintf (stderr, "ERROR: invalid device number.");
486
    exit (-1);
487
  }
488
}
489
 
490
void eth_tx_channel () {
491
  if (current_device >= 0 && current_device < config.nethernets)
492
    config.ethernets[current_device].rx_channel = tempL;
493
  else {
494
    fprintf (stderr, "ERROR: invalid device number.");
495
    exit (-1);
496
  }
497
}
498
 
499
void eth_rxfile () {
500
  if (current_device >= 0 && current_device < config.nethernets)
501
    strcpy (config.ethernets[current_device].rxfile, tempS);
502
  else {
503
    fprintf (stderr, "ERROR: invalid device number.");
504
    exit (-1);
505
  }
506
}
507
 
508
void eth_txfile () {
509
  if (current_device >= 0 && current_device < config.nethernets)
510 323 erez
    strcpy (config.ethernets[current_device].txfile, tempS);
511 310 markom
  else {
512
    fprintf (stderr, "ERROR: invalid device number.");
513
    exit (-1);
514
  }
515
}
516
 
517 313 markom
void eth_vapi_id () {
518
  if (current_device >= 0 && current_device < config.nethernets)
519
    config.ethernets[current_device].vapi_id = tempUL;
520
  else {
521
    fprintf (stderr, "ERROR: invalid device number.");
522
    exit (-1);
523
  }
524
}
525
 
526
 
527
 
528 239 markom
/* Read environment from a script file. Does not fail - assumes defaukt configuration instead.
529
   The syntax of script file is:
530
   param = value
531
   section x
532
     data
533
     param = value
534
   end
535
 
536
   Example:
537
   section mc
538
     memory_table_file = sim.mem
539
     enable = 1
540
     POC = 0x47892344
541
   end
542
 
543
 */
544
 
545
void read_script_file (char *filename)
546
{
547 263 markom
  FILE *f;
548
  unsigned long memory_needed = 0;
549
  char *home = getenv("HOME");
550
  char ctmp[STR_SIZE];
551
  int local = 1;
552
  int section = 0;
553 239 markom
 
554 263 markom
  sprintf(ctmp, "%s/.or1k/%s", home, filename);
555
  if ((f = fopen (filename, "rt")) != NULL
556
      || home != NULL && !(local = 0) && (f = fopen (ctmp, "rt")) != NULL) {
557
    unsigned long start, length;
558
    char type[STR_SIZE];
559
    int nparam;
560
    int rd, wd;
561 308 markom
    if (config.sim.verbose)
562
      printf ("Reading script file from '%s':\n", local ? filename : ctmp);
563 239 markom
    while (!feof(f)) {
564
      char param[STR_SIZE];
565
      if (fscanf(f, "%s ", &param) != 1) break;
566
      /* Is this a sections? */
567
      if (strcmp (param, "section") == 0) {
568
        int i;
569
        section = 0;
570
        if (fscanf (f, "%s\n", &param) != 1) {
571
          fprintf (stderr, "%s: ERROR: Section name required.\n", local ? filename : ctmp);
572
          exit (-1);
573
        }
574 294 markom
        for (i = 1; i < sizeof(sections) / sizeof(struct section); i++)
575 261 markom
          if (strcmp (sections[i].name, param) == 0) {
576 239 markom
            section = i;
577
            break;
578
          }
579
        if (!section) {
580
          fprintf (stderr, "%s: WARNING: Unknown section: %s; ignoring.\n", local ? filename : ctmp, param);
581
          /* just skip section */
582
          while (fscanf (f, "%s\n", &param) != 1 && strcmp (param, "end"));
583
        }
584
      } else if (strcmp (param, "end") == 0) {
585
        section = 0;
586 264 markom
      } else if (strncmp (param, "/*", 2) == 0) {
587 261 markom
        char c0 = 0, c1 = 0;
588 264 markom
        while (c0 != '*' || c1 != '/') {
589 261 markom
          c0 = c1;
590
          c1 = fgetc(f);
591
          if (feof(f)) {
592
            fprintf (stderr, "%s: ERROR: Comment reached EOF.\n", local ? filename : ctmp);
593
            exit (-1);
594
          }
595
        }
596 239 markom
      } else {
597
        int i, found = -1;
598
        for (i = 0; i < sizeof(config_params)/sizeof(struct config_params); i++)
599
          if (config_params[i].section == section && strcmp (config_params[i].name, param) == 0) {
600
            found = i;
601
            break;
602
          }
603
        if (found < 0) {
604
          fprintf (stderr, "%s: WARNING: Invalid parameter: %s; ignoring.\n", local ? filename : ctmp, param);
605 294 markom
          while (fgetc(f) != '\n' || feof(f));
606 239 markom
          continue;
607
        }
608
 
609
        /* Parse parameter value */
610
        {
611 294 markom
          if (config_params[found].type[0])
612
            if(fscanf_ex (f, config_params[found].type, config_params[found].addr))
613
              exit (1);
614 239 markom
        }
615 262 markom
        if (config_params[found].func)
616
          config_params[found].func();
617 239 markom
      }
618
    }
619 263 markom
    fclose (f);
620 308 markom
  } else
621
    if (config.sim.verbose)
622
      fprintf (stderr, "WARNING: Cannot read script file from '%s',\nneither '%s'; assuming standard configuration.\n", filename, ctmp);
623 103 lampret
 
624 263 markom
  /* Initialize memory table.  */
625
  sim_read_memory_table (config.memory.memory_table_file);
626 7 jrydberg
}

powered by: WebSVN 2.1.0

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