Update sim copyright headers from GPLv2-or-later to GPLv3-or-later.
[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, write to the Free Software Foundation, Inc., 675
19 * Mass Ave, Cambridge, MA 02139, USA.
20 *
21 */
22
23 #include "config.h"
24 #include "ansidecl.h"
25 #include "gdb/callback.h"
26 #include "gdb/remote-sim.h"
27
28 #include "end.h"
29
30 #define I_ACC_EXC 1
31
32 /* Maximum events in event queue */
33 #define EVENT_MAX 256
34
35 /* Maximum # of floating point queue */
36 #define FPUQN 1
37
38 /* Maximum # of breakpoints */
39 #define BPT_MAX 256
40
41 struct histype {
42 unsigned addr;
43 unsigned time;
44 };
45
46 /* type definitions */
47
48 typedef short int int16; /* 16-bit signed int */
49 typedef unsigned short int uint16; /* 16-bit unsigned int */
50 typedef int int32; /* 32-bit signed int */
51 typedef unsigned int uint32; /* 32-bit unsigned int */
52 typedef float float32; /* 32-bit float */
53 typedef double float64; /* 64-bit float */
54
55 /* FIXME: what about host compilers that don't support 64-bit ints? */
56 typedef unsigned long long uint64; /* 64-bit unsigned int */
57 typedef long long int64; /* 64-bit signed int */
58
59 #define UINT64_MAX 18446744073709551615ULL
60
61 struct pstate {
62
63 float64 fd[16]; /* FPU registers */
64 #ifdef HOST_LITTLE_ENDIAN_FLOAT
65 float32 fs[32];
66 float32 *fdp;
67 #else
68 float32 *fs;
69 #endif
70 int32 *fsi;
71 uint32 fsr;
72 int32 fpstate;
73 uint32 fpq[FPUQN * 2];
74 uint32 fpqn;
75 uint32 ftime;
76 uint32 flrd;
77 uint32 frd;
78 uint32 frs1;
79 uint32 frs2;
80 uint32 fpu_pres; /* FPU present (0 = No, 1 = Yes) */
81
82 uint32 psr; /* IU registers */
83 uint32 tbr;
84 uint32 wim;
85 uint32 g[8];
86 uint32 r[128];
87 uint32 y;
88 uint32 asr17; /* Single vector trapping */
89 uint32 pc, npc;
90
91
92 uint32 trap; /* Current trap type */
93 uint32 annul; /* Instruction annul */
94 uint32 data; /* Loaded data */
95 uint32 inst; /* Current instruction */
96 uint32 asi; /* Current ASI */
97 uint32 err_mode; /* IU error mode */
98 uint32 breakpoint;
99 uint32 bptnum;
100 uint32 bphit;
101 uint32 bpts[BPT_MAX]; /* Breakpoints */
102
103 uint32 ltime; /* Load interlock time */
104 uint32 hold; /* IU hold cycles in current inst */
105 uint32 fhold; /* FPU hold cycles in current inst */
106 uint32 icnt; /* Instruction cycles in curr inst */
107
108 uint32 histlen; /* Trace history management */
109 uint32 histind;
110 struct histype *histbuf;
111 float32 freq; /* Simulated processor frequency */
112
113
114 uint64 tottime;
115 uint64 ninst;
116 uint64 fholdt;
117 uint64 holdt;
118 uint64 icntt;
119 uint64 finst;
120 uint64 simstart;
121 uint64 starttime;
122 uint64 tlimit; /* Simulation time limit */
123 uint64 pwdtime; /* Cycles in power-down mode */
124 uint64 nstore; /* Number of load instructions */
125 uint64 nload; /* Number of store instructions */
126 uint64 nannul; /* Number of annuled instructions */
127 uint64 nbranch; /* Number of branch instructions */
128 uint32 ildreg; /* Destination of last load instruction */
129 uint64 ildtime; /* Last time point for load dependency */
130
131 int rett_err; /* IU in jmpl/restore error state (Rev.0) */
132 int jmpltime;
133 };
134
135 struct evcell {
136 void (*cfunc) ();
137 int32 arg;
138 uint64 time;
139 struct evcell *nxt;
140 };
141
142 struct estate {
143 struct evcell eq;
144 struct evcell *freeq;
145 uint64 simtime;
146 };
147
148 struct irqcell {
149 void (*callback) ();
150 int32 arg;
151 };
152
153
154 #define OK 0
155 #define TIME_OUT 1
156 #define BPT_HIT 2
157 #define ERROR 3
158 #define CTRL_C 4
159
160 /* Prototypes */
161
162 /* erc32.c */
163 extern void init_sim PARAMS ((void));
164 extern void reset PARAMS ((void));
165 extern void error_mode PARAMS ((uint32 pc));
166 extern void sim_halt PARAMS ((void));
167 extern void exit_sim PARAMS ((void));
168 extern void init_stdio PARAMS ((void));
169 extern void restore_stdio PARAMS ((void));
170 extern int memory_read PARAMS ((int32 asi, uint32 addr, uint32 *data,
171 int32 sz, int32 *ws));
172 extern int memory_write PARAMS ((int32 asi, uint32 addr, uint32 *data,
173 int32 sz, int32 *ws));
174 extern int sis_memory_write PARAMS ((uint32 addr,
175 const unsigned char *data, uint32 length));
176 extern int sis_memory_read PARAMS ((uint32 addr, char *data,
177 uint32 length));
178
179 /* func.c */
180 extern void set_regi PARAMS ((struct pstate *sregs, int32 reg,
181 uint32 rval));
182 extern void get_regi PARAMS ((struct pstate *sregs, int32 reg, char *buf));
183 extern int exec_cmd PARAMS ((struct pstate *sregs, char *cmd));
184 extern void reset_stat PARAMS ((struct pstate *sregs));
185 extern void show_stat PARAMS ((struct pstate *sregs));
186 extern void init_bpt PARAMS ((struct pstate *sregs));
187 extern void init_signals PARAMS ((void));
188
189 struct disassemble_info;
190 extern void dis_mem PARAMS ((uint32 addr, uint32 len,
191 struct disassemble_info *info));
192 extern void event PARAMS ((void (*cfunc) (), int32 arg, uint64 delta));
193 extern void set_int PARAMS ((int32 level, void (*callback) (), int32 arg));
194 extern void advance_time PARAMS ((struct pstate *sregs));
195 extern uint32 now PARAMS ((void));
196 extern int wait_for_irq PARAMS ((void));
197 extern int check_bpt PARAMS ((struct pstate *sregs));
198 extern void reset_all PARAMS ((void));
199 extern void sys_reset PARAMS ((void));
200 extern void sys_halt PARAMS ((void));
201 extern int bfd_load PARAMS ((char *fname));
202
203 /* exec.c */
204 extern int dispatch_instruction PARAMS ((struct pstate *sregs));
205 extern int execute_trap PARAMS ((struct pstate *sregs));
206 extern int check_interrupts PARAMS ((struct pstate *sregs));
207 extern void init_regs PARAMS ((struct pstate *sregs));
208
209 /* interf.c */
210 extern int run_sim PARAMS ((struct pstate *sregs,
211 uint64 icount, int dis));
212
213 /* float.c */
214 extern int get_accex PARAMS ((void));
215 extern void clear_accex PARAMS ((void));
216 extern void set_fsr PARAMS ((uint32 fsr));
217
218 /* help.c */
219 extern void usage PARAMS ((void));
220 extern void gen_help PARAMS ((void));