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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [gdb-5.0/] [sim/] [common/] [gentmap.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 106 markom
/* Generate targ-vals.h and targ-map.c.  */
2
 
3
#include <stdio.h>
4
 
5
struct tdefs {
6
  char *symbol;
7
  int value;
8
};
9
 
10
static struct tdefs sys_tdefs[] = {
11
#define sys_defs
12
#include "targ-vals.def"
13
#undef sys_defs
14
  { 0, 0 }
15
};
16
 
17
static struct tdefs errno_tdefs[] =  {
18
#define errno_defs
19
#include "targ-vals.def"
20
#undef errno_defs
21
  { 0, 0 }
22
};
23
 
24
static struct tdefs open_tdefs[] = {
25
#define open_defs
26
#include "targ-vals.def"
27
#undef open_defs
28
  { 0, 0 }
29
};
30
 
31
static void
32
gen_targ_vals_h ()
33
{
34
  struct tdefs *t;
35
 
36
  printf ("/* Target header values needed by the simulator and gdb.  */\n");
37
  printf ("/* This file is machine generated by gentmap.c.  */\n\n");
38
 
39
  printf ("#ifndef TARG_VALS_H\n");
40
  printf ("#define TARG_VALS_H\n\n");
41
 
42
  printf ("/* syscall values */\n");
43
  for (t = &sys_tdefs[0]; t->symbol; ++t)
44
    printf ("#define TARGET_%s %d\n", t->symbol, t->value);
45
  printf ("\n");
46
 
47
  printf ("/* errno values */\n");
48
  for (t = &errno_tdefs[0]; t->symbol; ++t)
49
    printf ("#define TARGET_%s %d\n", t->symbol, t->value);
50
  printf ("\n");
51
 
52
  printf ("/* open flag values */\n");
53
  for (t = &open_tdefs[0]; t->symbol; ++t)
54
    printf ("#define TARGET_%s 0x%x\n", t->symbol, t->value);
55
  printf ("\n");
56
 
57
  printf ("#endif /* TARG_VALS_H */\n");
58
}
59
 
60
static void
61
gen_targ_map_c ()
62
{
63
  struct tdefs *t;
64
 
65
  printf ("/* Target value mapping utilities needed by the simulator and gdb.  */\n");
66
  printf ("/* This file is machine generated by gentmap.c.  */\n\n");
67
 
68
  printf ("#include <errno.h>\n");
69
  printf ("#include <fcntl.h>\n");
70
  printf ("#include \"ansidecl.h\"\n");
71
  printf ("#include \"callback.h\"\n");
72
  printf ("#include \"targ-vals.h\"\n");
73
  printf ("\n");
74
 
75
  printf ("/* syscall mapping table */\n");
76
  printf ("CB_TARGET_DEFS_MAP cb_init_syscall_map[] = {\n");
77
  for (t = &sys_tdefs[0]; t->symbol; ++t)
78
    {
79
      printf ("#ifdef CB_%s\n", t->symbol);
80
      printf ("  { CB_%s, TARGET_%s },\n", t->symbol, t->symbol);
81
      printf ("#endif\n");
82
    }
83
  printf ("  { -1, -1 }\n");
84
  printf ("};\n\n");
85
 
86
  printf ("/* errno mapping table */\n");
87
  printf ("CB_TARGET_DEFS_MAP cb_init_errno_map[] = {\n");
88
  for (t = &errno_tdefs[0]; t->symbol; ++t)
89
    {
90
      printf ("#ifdef %s\n", t->symbol);
91
      printf ("  { %s, TARGET_%s },\n", t->symbol, t->symbol);
92
      printf ("#endif\n");
93
    }
94
  printf ("  { 0, 0 }\n");
95
  printf ("};\n\n");
96
 
97
  printf ("/* open flags mapping table */\n");
98
  printf ("CB_TARGET_DEFS_MAP cb_init_open_map[] = {\n");
99
  for (t = &open_tdefs[0]; t->symbol; ++t)
100
    {
101
      printf ("#ifdef %s\n", t->symbol);
102
      printf ("  { %s, TARGET_%s },\n", t->symbol, t->symbol);
103
      printf ("#endif\n");
104
    }
105
  printf ("  { -1, -1 }\n");
106
  printf ("};\n\n");
107
}
108
 
109
int
110
main (argc, argv)
111
     int argc;
112
     char *argv[];
113
{
114
  if (argc != 2)
115
    abort ();
116
 
117
  if (strcmp (argv[1], "-h") == 0)
118
    gen_targ_vals_h ();
119
  else if (strcmp (argv[1], "-c") == 0)
120
    gen_targ_map_c ();
121
  else
122
    abort ();
123
 
124
  exit (0);
125
}

powered by: WebSVN 2.1.0

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