sim: v850: convert to sim-cpu
[deliverable/binutils-gdb.git] / sim / erc32 / sis.h
1 /*
2 * This file is part of SIS.
3 *
4 * ERC32SIM, SPARC instruction simulator. Copyright (C) 1995 Jiri Gaisler,
5 * European Space Agency
6 *
7 * This program is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License as published by the Free
9 * Software Foundation; either version 3 of the License, or (at your option)
10 * any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 * more details.
16 *
17 * You should have received a copy of the GNU General Public License along with
18 * this program; if not, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22 #include "config.h"
23 #include "ansidecl.h"
24 #include "gdb/callback.h"
25 #include "gdb/remote-sim.h"
26 #include <sim-config.h>
27 #include <stdint.h>
28
29 #if WITH_HOST_BYTE_ORDER == BIG_ENDIAN
30 #define HOST_BIG_ENDIAN
31 #else
32 #define HOST_LITTLE_ENDIAN
33 #endif
34
35 #define I_ACC_EXC 1
36
37 /* Maximum events in event queue */
38 #define EVENT_MAX 256
39
40 /* Maximum # of floating point queue */
41 #define FPUQN 1
42
43 /* Maximum # of breakpoints */
44 #define BPT_MAX 256
45
46 struct histype {
47 unsigned addr;
48 unsigned time;
49 };
50
51 /* type definitions */
52
53 typedef short int int16; /* 16-bit signed int */
54 typedef unsigned short int uint16; /* 16-bit unsigned int */
55 typedef int int32; /* 32-bit signed int */
56 typedef unsigned int uint32; /* 32-bit unsigned int */
57 typedef float float32; /* 32-bit float */
58 typedef double float64; /* 64-bit float */
59
60 typedef uint64_t uint64; /* 64-bit unsigned int */
61 typedef int64_t int64; /* 64-bit signed int */
62
63 struct pstate {
64
65 float64 fd[16]; /* FPU registers */
66 #ifdef HOST_LITTLE_ENDIAN
67 float32 fs[32];
68 float32 *fdp;
69 #else
70 float32 *fs;
71 #endif
72 int32 *fsi;
73 uint32 fsr;
74 int32 fpstate;
75 uint32 fpq[FPUQN * 2];
76 uint32 fpqn;
77 uint32 ftime;
78 uint32 flrd;
79 uint32 frd;
80 uint32 frs1;
81 uint32 frs2;
82 uint32 fpu_pres; /* FPU present (0 = No, 1 = Yes) */
83
84 uint32 psr; /* IU registers */
85 uint32 tbr;
86 uint32 wim;
87 uint32 g[8];
88 uint32 r[128];
89 uint32 y;
90 uint32 asr17; /* Single vector trapping */
91 uint32 pc, npc;
92
93
94 uint32 trap; /* Current trap type */
95 uint32 annul; /* Instruction annul */
96 uint32 data; /* Loaded data */
97 uint32 inst; /* Current instruction */
98 uint32 asi; /* Current ASI */
99 uint32 err_mode; /* IU error mode */
100 uint32 breakpoint;
101 uint32 bptnum;
102 uint32 bphit;
103 uint32 bpts[BPT_MAX]; /* Breakpoints */
104
105 uint32 ltime; /* Load interlock time */
106 uint32 hold; /* IU hold cycles in current inst */
107 uint32 fhold; /* FPU hold cycles in current inst */
108 uint32 icnt; /* Instruction cycles in curr inst */
109
110 uint32 histlen; /* Trace history management */
111 uint32 histind;
112 struct histype *histbuf;
113 float32 freq; /* Simulated processor frequency */
114
115
116 double tottime;
117 uint64 ninst;
118 uint64 fholdt;
119 uint64 holdt;
120 uint64 icntt;
121 uint64 finst;
122 uint64 simstart;
123 double starttime;
124 uint64 tlimit; /* Simulation time limit */
125 uint64 pwdtime; /* Cycles in power-down mode */
126 uint64 nstore; /* Number of load instructions */
127 uint64 nload; /* Number of store instructions */
128 uint64 nannul; /* Number of annuled instructions */
129 uint64 nbranch; /* Number of branch instructions */
130 uint32 ildreg; /* Destination of last load instruction */
131 uint64 ildtime; /* Last time point for load dependency */
132
133 int rett_err; /* IU in jmpl/restore error state (Rev.0) */
134 int jmpltime;
135 };
136
137 struct evcell {
138 void (*cfunc) ();
139 int32 arg;
140 uint64 time;
141 struct evcell *nxt;
142 };
143
144 struct estate {
145 struct evcell eq;
146 struct evcell *freeq;
147 uint64 simtime;
148 };
149
150 struct irqcell {
151 void (*callback) ();
152 int32 arg;
153 };
154
155
156 #define OK 0
157 #define TIME_OUT 1
158 #define BPT_HIT 2
159 #define ERROR 3
160 #define CTRL_C 4
161
162 /* Prototypes */
163
164 /* erc32.c */
165 extern void init_sim (void);
166 extern void reset (void);
167 extern void error_mode (uint32 pc);
168 extern void sim_halt (void);
169 extern void exit_sim (void);
170 extern void init_stdio (void);
171 extern void restore_stdio (void);
172 extern int memory_iread (uint32 addr, uint32 *data, int32 *ws);
173 extern int memory_read (int32 asi, uint32 addr, uint32 *data,
174 int32 sz, int32 *ws);
175 extern int memory_write (int32 asi, uint32 addr, uint32 *data,
176 int32 sz, int32 *ws);
177 extern int sis_memory_write (uint32 addr,
178 const unsigned char *data, uint32 length);
179 extern int sis_memory_read (uint32 addr, char *data,
180 uint32 length);
181
182 /* func.c */
183 extern struct pstate sregs;
184 extern void set_regi (struct pstate *sregs, int32 reg,
185 uint32 rval);
186 extern void get_regi (struct pstate *sregs, int32 reg, char *buf);
187 extern int exec_cmd (struct pstate *sregs, const char *cmd);
188 extern void reset_stat (struct pstate *sregs);
189 extern void show_stat (struct pstate *sregs);
190 extern void init_bpt (struct pstate *sregs);
191 extern void init_signals (void);
192
193 struct disassemble_info;
194 extern void dis_mem (uint32 addr, uint32 len,
195 struct disassemble_info *info);
196 extern void event (void (*cfunc) (), int32 arg, uint64 delta);
197 extern void set_int (int32 level, void (*callback) (), int32 arg);
198 extern void advance_time (struct pstate *sregs);
199 extern uint32 now (void);
200 extern int wait_for_irq (void);
201 extern int check_bpt (struct pstate *sregs);
202 extern void reset_all (void);
203 extern void sys_reset (void);
204 extern void sys_halt (void);
205 extern int bfd_load (const char *fname);
206 extern double get_time (void);
207
208 /* exec.c */
209 extern int dispatch_instruction (struct pstate *sregs);
210 extern int execute_trap (struct pstate *sregs);
211 extern int check_interrupts (struct pstate *sregs);
212 extern void init_regs (struct pstate *sregs);
213
214 /* interf.c */
215 extern int run_sim (struct pstate *sregs,
216 uint64 icount, int dis);
217
218 /* float.c */
219 extern int get_accex (void);
220 extern void clear_accex (void);
221 extern void set_fsr (uint32 fsr);
222
223 /* help.c */
224 extern void usage (void);
225 extern void gen_help (void);
This page took 0.039209 seconds and 4 git commands to generate.