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