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