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