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

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gdb/] [gdb-6.8/] [sim/] [m32c/] [cpu.h] - Blame information for rev 26

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 26 jlechner
/* cpu.h --- declarations for the M32C core.
2
 
3
Copyright (C) 2005, 2007, 2008 Free Software Foundation, Inc.
4
Contributed by Red Hat, Inc.
5
 
6
This file is part of the GNU simulators.
7
 
8
This program is free software; you can redistribute it and/or modify
9
it under the terms of the GNU General Public License as published by
10
the Free Software Foundation; either version 3 of the License, or
11
(at your option) any later version.
12
 
13
This program is distributed in the hope that it will be useful,
14
but WITHOUT ANY WARRANTY; without even the implied warranty of
15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
GNU General Public License for more details.
17
 
18
You should have received a copy of the GNU General Public License
19
along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
20
 
21
 
22
extern int verbose;
23
extern int trace;
24
extern int enable_counting;
25
 
26
typedef unsigned char QI;
27
typedef unsigned short HI;
28
typedef unsigned long SI;
29
typedef unsigned long long DI;
30
 
31
#define CPU_R8C         0x11
32
#define CPU_M16C        0x12
33
#define CPU_M32CM       0x23
34
#define CPU_M32C        0x24
35
extern int m32c_cpu;
36
void m32c_set_cpu (int cpu);
37
 
38
#define A16 (m32c_cpu & 0x10)
39
#define A24 (m32c_cpu & 0x20)
40
 
41
typedef struct
42
{
43
  HI r_r0;
44
  HI r_r2;
45
  HI r_r1;
46
  HI r_r3;
47
  SI r_a0;
48
  SI r_a1;
49
  SI r_sb;
50
  SI r_fb;
51
} reg_bank_type;
52
 
53
typedef struct
54
{
55
  reg_bank_type r[2];
56
  QI r_intbh;
57
  HI r_intbl;
58
  SI r_usp;
59
  SI r_isp;
60
  SI r_pc;
61
  HI r_flags;
62
} regs_type;
63
 
64
extern regs_type regs;
65
extern int addr_mask;
66
extern int membus_mask;
67
 
68
#define FLAGBIT_C       0x0001
69
#define FLAGBIT_D       0x0002
70
#define FLAGBIT_Z       0x0004
71
#define FLAGBIT_S       0x0008
72
#define FLAGBIT_B       0x0010
73
#define FLAGBIT_O       0x0020
74
#define FLAGBIT_I       0x0040
75
#define FLAGBIT_U       0x0080
76
 
77
#define REG_BANK (regs.r_flags & FLAG_B ? 1 : 0)
78
 
79
typedef enum
80
{
81
  mem,
82
  r0, r0h, r0l,
83
  r1, r1h, r1l,
84
  r2, r2r0,
85
  r3, r3r1,
86
  r3r1r2r0,
87
  r3r2r1r0,
88
  a0,
89
  a1, a1a0,
90
  sb, fb,
91
  intb, intbl, intbh,
92
  sp, usp, isp, pc, flags,
93
  num_regs
94
} reg_id;
95
 
96
extern char *reg_names[];
97
extern int reg_bytes[];
98
 
99
extern unsigned int b2mask[];
100
extern unsigned int b2signbit[];
101
extern int b2maxsigned[];
102
extern int b2minsigned[];
103
 
104
void init_regs (void);
105
void stack_heap_stats (void);
106
void set_pointer_width (int bytes);
107
unsigned int get_reg (reg_id id);
108
DI get_reg_ll (reg_id id);
109
void put_reg (reg_id id, unsigned int value);
110
void put_reg_ll (reg_id id, DI value);
111
 
112
void set_flags (int mask, int newbits);
113
void set_oszc (int value, int bytes, int c);
114
void set_szc (int value, int bytes, int c);
115
void set_osz (int value, int bytes);
116
void set_sz (int value, int bytes);
117
void set_zc (int z, int c);
118
void set_c (int c);
119
 
120
const char *bits (int v, int b);
121
 
122
typedef struct
123
{
124
  QI bytes;
125
  QI mem;
126
  HI mask;
127
  union
128
  {
129
    unsigned int addr;
130
    reg_id reg;
131
  } u;
132
} srcdest;
133
 
134
void decode_indirect (int src_indirect, int dest_indirect);
135
void decode_index (int src_addend, int dest_addend);
136
 
137
/* r8c */
138
srcdest decode_srcdest4 (int destcode, int bw);
139
srcdest decode_dest3 (int destcode, int bw);
140
srcdest decode_src2 (int srccode, int bw, int d);
141
srcdest decode_dest1 (int destcode, int bw);
142
srcdest decode_jumpdest (int destcode, int w);
143
srcdest decode_cr (int crcode);
144
srcdest decode_cr_b (int crcode, int bank);
145
#define CR_B_DCT0       0
146
#define CR_B_INTB       1
147
#define CR_B_DMA0       2
148
 
149
/* m32c */
150
srcdest decode_dest23 (int ddd, int dd, int bytes);
151
srcdest decode_src23 (int sss, int ss, int bytes);
152
srcdest decode_src3 (int sss, int bytes);
153
srcdest decode_dest2 (int dd, int bytes);
154
 
155
srcdest widen_sd (srcdest sd);
156
srcdest reg_sd (reg_id reg);
157
 
158
/* Mask has the one appropriate bit set.  */
159
srcdest decode_bit (int destcode);
160
srcdest decode_bit11 (int op0);
161
int get_bit (srcdest sd);
162
void put_bit (srcdest sd, int val);
163
int get_bit2 (srcdest sd, int bit);
164
void put_bit2 (srcdest sd, int bit, int val);
165
 
166
int get_src (srcdest sd);
167
void put_dest (srcdest sd, int value);
168
 
169
int condition_true (int cond_id);
170
 
171
#define FLAG(f) (regs.r_flags & f ? 1 : 0)
172
#define FLAG_C  FLAG(FLAGBIT_C)
173
#define FLAG_D  FLAG(FLAGBIT_D)
174
#define FLAG_Z  FLAG(FLAGBIT_Z)
175
#define FLAG_S  FLAG(FLAGBIT_S)
176
#define FLAG_B  FLAG(FLAGBIT_B)
177
#define FLAG_O  FLAG(FLAGBIT_O)
178
#define FLAG_I  FLAG(FLAGBIT_I)
179
#define FLAG_U  FLAG(FLAGBIT_U)
180
 
181
/* Instruction step return codes.
182
   Suppose one of the decode_* functions below returns a value R:
183
   - If M32C_STEPPED (R), then the single-step completed normally.
184
   - If M32C_HIT_BREAK (R), then the program hit a breakpoint.
185
   - If M32C_EXITED (R), then the program has done an 'exit' system
186
     call, and the exit code is M32C_EXIT_STATUS (R).
187
   - If M32C_STOPPED (R), then a signal (number M32C_STOP_SIG (R)) was
188
     generated.
189
 
190
   For building step return codes:
191
   - M32C_MAKE_STEPPED is the return code for finishing a normal step.
192
   - M32C_MAKE_HIT_BREAK is the return code for hitting a breakpoint.
193
   - M32C_MAKE_EXITED (C) is the return code for exiting with status C.
194
   - M32C_MAKE_STOPPED (S) is the return code for stopping on signal S.  */
195
#define M32C_MAKE_STEPPED()   (0)
196
#define M32C_MAKE_HIT_BREAK() (1)
197
#define M32C_MAKE_EXITED(c)   (((int) (c) << 8) + 2)
198
#define M32C_MAKE_STOPPED(s)  (((int) (s) << 8) + 3)
199
 
200
#define M32C_STEPPED(r)       ((r) == M32C_MAKE_STEPPED ())
201
#define M32C_HIT_BREAK(r)     ((r) == M32C_MAKE_HIT_BREAK ())
202
#define M32C_EXITED(r)        (((r) & 0xff) == 2)
203
#define M32C_EXIT_STATUS(r)   ((r) >> 8)
204
#define M32C_STOPPED(r)       (((r) & 0xff) == 3)
205
#define M32C_STOP_SIG(r)      ((r) >> 8)
206
 
207
/* The step result for the current step.  Global to allow
208
   communication between the stepping function and the system
209
   calls.  */
210
extern int step_result;
211
 
212
/* Used to detect heap/stack collisions */
213
extern unsigned int heaptop;
214
extern unsigned int heapbottom;
215
 
216
/* Points to one of the below functions, set by m32c_load().  */
217
extern int (*decode_opcode) ();
218
 
219
extern int decode_r8c ();
220
extern int decode_m32c ();
221
 
222
extern void trace_register_changes ();

powered by: WebSVN 2.1.0

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