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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gdb-6.8/] [sim/] [ppc/] [registers.c] - Blame information for rev 840

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 24 jeremybenn
/*  This file is part of the program psim.
2
 
3
    Copyright (C) 1994-1995, Andrew Cagney <cagney@highland.com.au>
4
 
5
    This program is free software; you can redistribute it and/or modify
6
    it under the terms of the GNU General Public License as published by
7
    the Free Software Foundation; either version 2 of the License, or
8
    (at your option) any later version.
9
 
10
    This program is distributed in the hope that it will be useful,
11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
    GNU General Public License for more details.
14
 
15
    You should have received a copy of the GNU General Public License
16
    along with this program; if not, write to the Free Software
17
    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
 
19
    */
20
 
21
 
22
#ifndef _REGISTERS_C_
23
#define _REGISTERS_C_
24
 
25
#include <ctype.h>
26
 
27
#include "basics.h"
28
#include "registers.h"
29
 
30
#ifdef HAVE_STDLIB_H
31
#include <stdlib.h>
32
#endif
33
 
34
#ifdef HAVE_STRING_H
35
#include <string.h>
36
#else
37
#ifdef HAVE_STRINGS_H
38
#include <strings.h>
39
#endif
40
#endif
41
 
42
 
43
INLINE_REGISTERS\
44
(void)
45
registers_dump(registers *registers)
46
{
47
  int i;
48
  int j;
49
  for (i = 0; i < 8; i++) {
50
    printf_filtered("GPR %2d:", i*4);
51
    for (j = 0; j < 4; j++) {
52
      printf_filtered(" 0x%08lx", (long)registers->gpr[i*4 + j]);
53
    }
54
    printf_filtered("\n");
55
  }
56
}
57
 
58
STATIC_INLINE_REGISTERS\
59
(sprs)
60
find_spr(const char name[])
61
{
62
  sprs spr;
63
  for (spr = 0; spr < nr_of_sprs; spr++)
64
    if (spr_is_valid(spr)
65
        && !strcmp(name, spr_name(spr))
66
        && spr_index(spr) == spr)
67
      return spr;
68
  return nr_of_sprs;
69
}
70
 
71
STATIC_INLINE_REGISTERS\
72
(int)
73
are_digits(const char *digits)
74
{
75
  while (isdigit(*digits))
76
    digits++;
77
  return *digits == '\0';
78
}
79
 
80
 
81
INLINE_REGISTERS\
82
(register_descriptions)
83
register_description(const char reg[])
84
{
85
  register_descriptions description;
86
 
87
  /* try for a general-purpose integer or floating point register */
88
  if (reg[0] == 'r' && are_digits(reg + 1)) {
89
    description.type = reg_gpr;
90
    description.index = atoi(reg+1);
91
    description.size = sizeof(gpreg);
92
  }
93
  else if (reg[0] == 'f' && are_digits(reg + 1)) {
94
    description.type = reg_fpr;
95
    description.index = atoi(reg+1);
96
    description.size = sizeof(fpreg);
97
  }
98
  else if (!strcmp(reg, "pc") || !strcmp(reg, "nia")) {
99
    description.type = reg_pc;
100
    description.index = 0;
101
    description.size = sizeof(unsigned_word);
102
  }
103
  else if (!strcmp(reg, "sp")) {
104
    description.type = reg_gpr;
105
    description.index = 1;
106
    description.size = sizeof(gpreg);
107
  }
108
  else if (!strcmp(reg, "toc")) {
109
    description.type = reg_gpr;
110
    description.index = 2;
111
    description.size = sizeof(gpreg);
112
  }
113
  else if (!strcmp(reg, "cr") || !strcmp(reg, "cnd")) {
114
    description.type = reg_cr;
115
    description.index = 0;
116
    description.size = sizeof(creg); /* FIXME */
117
  }
118
  else if (!strcmp(reg, "msr") || !strcmp(reg, "ps")) {
119
    description.type = reg_msr;
120
    description.index = 0;
121
    description.size = sizeof(msreg);
122
  }
123
  else if (!strcmp(reg, "fpscr")) {
124
    description.type = reg_fpscr;
125
    description.index = 0;
126
    description.size = sizeof(fpscreg);
127
  }
128
  else if (!strncmp(reg, "sr", 2) && are_digits(reg + 2)) {
129
    description.type = reg_sr;
130
    description.index = atoi(reg+2);
131
    description.size = sizeof(sreg);
132
  }
133
  else if (!strcmp(reg, "cnt")) {
134
    description.type = reg_spr;
135
    description.index = spr_ctr;
136
    description.size = sizeof(spreg);
137
  }
138
  else if (!strcmp(reg, "insns")) {
139
    description.type = reg_insns;
140
    description.index = spr_ctr;
141
    description.size = sizeof(unsigned_word);
142
  }
143
  else if (!strcmp(reg, "stalls")) {
144
    description.type = reg_stalls;
145
    description.index = spr_ctr;
146
    description.size = sizeof(unsigned_word);
147
  }
148
  else if (!strcmp(reg, "cycles")) {
149
    description.type = reg_cycles;
150
    description.index = spr_ctr;
151
    description.size = sizeof(unsigned_word);
152
  }
153
#ifdef WITH_ALTIVEC
154
  else if (reg[0] == 'v' && reg[1] == 'r' && are_digits(reg + 2)) {
155
    description.type = reg_vr;
156
    description.index = atoi(reg+2);
157
    description.size = sizeof(vreg);
158
  }
159
   else if (!strcmp(reg, "vscr")) {
160
    description.type = reg_vscr;
161
    description.index = 0;
162
    description.size = sizeof(vscreg);
163
  }
164
#endif
165
#ifdef WITH_E500
166
  else if (reg[0] == 'e' && reg[1] == 'v' && are_digits(reg + 2)) {
167
    description.type = reg_evr;
168
    description.index = atoi(reg+2);
169
    description.size = sizeof(unsigned64);
170
  }
171
  else if (reg[0] == 'r' && reg[1] == 'h' && are_digits(reg + 2)) {
172
    description.type = reg_gprh;
173
    description.index = atoi(reg+2);
174
    description.size = sizeof(gpreg);
175
  }
176
  else if (!strcmp(reg, "acc")) {
177
    description.type = reg_acc;
178
    description.index = 0;
179
    description.size = sizeof(unsigned64);
180
  }
181
#endif
182
  else {
183
    sprs spr = find_spr(reg);
184
    if (spr != nr_of_sprs) {
185
      description.type = reg_spr;
186
      description.index = spr;
187
      description.size = sizeof(spreg);
188
    }
189
    else {
190
      description.type = reg_invalid;
191
      description.index = 0;
192
      description.size = 0;
193
    }
194
  }
195
  return description;
196
}
197
 
198
#endif /* _REGISTERS_C_ */

powered by: WebSVN 2.1.0

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