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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gdb-7.1/] [sim/] [common/] [gentmap.c] - Blame information for rev 842

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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