1 /* Simulator header for Cpu tools GENerated simulators.
2 Copyright (C) 1996, 1997 Free Software Foundation, Inc.
3 Contributed by Cygnus Support.
5 This file is part of GDB, the GNU debugger.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License along
18 with this program; if not, write to the Free Software Foundation, Inc.,
19 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
24 #define PC (STATE_CPU_CPU (current_state, 0)->pc)
26 /* Execution state. */
28 EXEC_STATE_RUNNING, EXEC_STATE_EXITED,
29 EXEC_STATE_STOPPED, EXEC_STATE_SIGNALLED
33 enum sim_signal_type {
35 SIM_SIGILL, /* illegal insn */
37 SIM_SIGALIGN, /* misaligned memory access */
38 SIM_SIGACCESS, /* tried to read/write memory that's not readable/writable */
39 SIM_SIGXCPU /* cpu limit exceeded */
42 void engine_halt PARAMS ((struct _sim_cpu *, enum exec_state, int));
43 void engine_signal PARAMS ((struct _sim_cpu *, enum sim_signal_type));
45 /* Decode,extract,semantics. */
47 typedef void (EXTRACT_FN) PARAMS ((SIM_CPU *, PCADDR, insn_t, struct argbuf *));
48 /*typedef CIA (SEMANTIC_FN) PARAMS ((SEM_ARG));*/
49 typedef PCADDR (SEMANTIC_FN) PARAMS ((SIM_CPU *, struct argbuf *));
51 typedef void (EXTRACT_CACHE_FN) PARAMS ((SIM_CPU *, PCADDR, insn_t, struct argbuf *));
53 typedef PCADDR (SEMANTIC_CACHE_FN) PARAMS ((SIM_CPU *, struct scache *));
56 /* Using cgen_insn_type requires <cpu>-opc.h. */
57 int /*enum cgen_insn_type*/ insn_type;
58 const struct cgen_insn *opcode;
59 /* FIXME: Perhaps rename these to normal/fast versions to associate them
60 with the normal/fast args to genmloop.sh. */
62 SEMANTIC_FN *semantic;
64 EXTRACT_CACHE_FN *extract_fast;
66 SEMANTIC_CACHE_FN *semantic_fast;
67 #if defined (USE_SEM_SWITCH) && defined (__GNUC__)
72 /* FIXME: length parm to decode() is currently unneeded. */
73 extern DECODE *decode PARAMS ((insn_t /*, int*/));
75 /* Simulator state. */
78 #include "cgen-scache.h"
81 /* ??? Do we *need* to pass state to the semantic routines? */
82 extern SIM_DESC current_state;
84 /* FIXME: Until sim_open creates one. */
85 extern struct sim_state sim_global_state;
87 /* Simulator state. */
90 CGEN_STATE contains addition state information not present in
93 typedef struct cgen_state {
96 #define STATE_ARGV(s) ((s)->cgen_state.argv)
98 #define STATE_ENVP(s) ((s)->cgen_state.envp)
101 /* Additional per-cpu data. */
104 /* Simulator's execution cache. */
107 #endif /* WITH_SCACHE */
109 enum exec_state exec_state;
110 #define CPU_EXEC_STATE(cpu) ((cpu)->cgen_cpu.exec_state)
113 #define CPU_HALT_SIGRC(cpu) ((cpu)->cgen_cpu.halt_sigrc)
115 jmp_buf halt_jmp_buf;
116 #define CPU_HALT_JMP_BUF(cpu) ((cpu)->cgen_cpu.halt_jmp_buf)
119 #define CPU_CPU(c) (& (c)->cgen_cpu.cpu)
120 CPU_PROFILE profile_state;
121 #define CPU_PROFILE_STATE(cpu) (& (cpu)->cgen_cpu.profile_state)
124 /* Various utilities. */
126 int engine_stop (SIM_DESC);
127 void engine_run (SIM_DESC, int, int);
128 void engine_resume (SIM_DESC, int, int);
129 void engine_halt (SIM_CPU *, enum exec_state, int);
130 void engine_signal (SIM_CPU *, enum sim_signal_type);
132 int sim_signal_to_host (int);
135 sim_disassemble_insn (const struct cgen_insn *, const struct argbuf *,
138 #endif /* CGEN_SIM_H */