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