1 /* Copyright (C) 1995-2018 Free Software Foundation, Inc.
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.
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.
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/>. */
18 #include "gdb/callback.h"
19 #include "gdb/remote-sim.h"
20 #include <sim-config.h>
23 #if HOST_BYTE_ORDER == BIG_ENDIAN
24 #define HOST_BIG_ENDIAN
27 #define HOST_LITTLE_ENDIAN
33 /* Maximum events in event queue */
36 /* Maximum # of floating point queue */
39 /* Maximum # of breakpoints */
47 /* type definitions */
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 */
56 typedef uint64_t uint64
; /* 64-bit unsigned int */
57 typedef int64_t int64
; /* 64-bit signed int */
61 float64 fd
[16]; /* FPU registers */
62 #ifdef HOST_LITTLE_ENDIAN
71 uint32 fpq
[FPUQN
* 2];
78 uint32 fpu_pres
; /* FPU present (0 = No, 1 = Yes) */
80 uint32 psr
; /* IU registers */
86 uint32 asr17
; /* Single vector trapping */
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 */
99 uint32 bpts
[BPT_MAX
]; /* Breakpoints */
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 */
106 uint32 histlen
; /* Trace history management */
108 struct histype
*histbuf
;
109 float32 freq
; /* Simulated processor frequency */
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 */
126 uint32 ildreg
; /* Destination of last load instruction */
127 uint64 ildtime
; /* Last time point for load dependency */
129 int rett_err
; /* IU in jmpl/restore error state (Rev.0) */
142 struct evcell
*freeq
;
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);
168 extern int memory_iread (uint32 addr
, uint32
*data
, int32
*ws
);
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
,
179 extern struct pstate sregs
;
180 extern void set_regi (struct pstate
*sregs
, int32 reg
,
182 extern void get_regi (struct pstate
*sregs
, int32 reg
, char *buf
);
183 extern int exec_cmd (struct pstate
*sregs
, const char *cmd
);
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);
189 struct disassemble_info
;
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);
201 extern int bfd_load (const char *fname
);
202 extern double get_time (void);
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
);
211 extern int run_sim (struct pstate
*sregs
,
212 uint64 icount
, int dis
);
215 extern int get_accex (void);
216 extern void clear_accex (void);
217 extern void set_fsr (uint32 fsr
);
220 extern void usage (void);
221 extern void gen_help (void);