]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - sim/cris/sim-main.h
* cris: New directory, simulator for Axis Communications CRIS
[thirdparty/binutils-gdb.git] / sim / cris / sim-main.h
1 /* Main header for the CRIS simulator, based on the m32r header.
2 Copyright (C) 2004, 2005 Free Software Foundation, Inc.
3 Contributed by Axis Communications.
4
5 This file is part of the GNU simulators.
6
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 of the License, or
10 (at your option) any later version.
11
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.
16
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. */
20
21 /* All FIXME:s present in m32r apply here too; I just refuse to blindly
22 carry them over, as I don't know if they're really things that need
23 fixing. */
24
25 #ifndef SIM_MAIN_H
26 #define SIM_MAIN_H
27
28 #define USING_SIM_BASE_H
29
30 struct _sim_cpu;
31 typedef struct _sim_cpu SIM_CPU;
32
33 #include "symcat.h"
34 #include "sim-basics.h"
35 #include "cgen-types.h"
36 #include "cris-desc.h"
37 #include "cris-opc.h"
38 #include "arch.h"
39
40 /* These must be defined before sim-base.h. */
41 typedef USI sim_cia;
42
43 #define CIA_GET(cpu) CPU_PC_GET (cpu)
44 #define CIA_SET(cpu,val) CPU_PC_SET ((cpu), (val))
45
46 #define SIM_ENGINE_HALT_HOOK(sd, cpu, cia) \
47 do { \
48 if (cpu) /* Null if ctrl-c. */ \
49 sim_pc_set ((cpu), (cia)); \
50 } while (0)
51 #define SIM_ENGINE_RESTART_HOOK(sd, cpu, cia) \
52 do { \
53 sim_pc_set ((cpu), (cia)); \
54 } while (0)
55
56 #include "sim-base.h"
57 #include "cgen-sim.h"
58 #include "cris-sim.h"
59
60 /* For occurrences of ANDIF in decodev32.c. */
61 #include "cgen-ops.h"
62 \f
63 struct cris_sim_mmapped_page {
64 USI addr;
65 struct cris_sim_mmapped_page *prev;
66 };
67
68 struct cris_thread_info {
69 /* Identifier for this thread. */
70 unsigned int threadid;
71
72 /* Identifier for parent thread. */
73 unsigned int parent_threadid;
74
75 /* Signal to send to parent at exit. */
76 int exitsig;
77
78 /* Exit status. */
79 int exitval;
80
81 /* Only as storage to return the "set" value to the "get" method.
82 I'm not sure whether this is useful per-thread. */
83 USI priority;
84
85 struct
86 {
87 USI altstack;
88 USI options;
89
90 char action;
91 char pending;
92 char blocked;
93 char blocked_suspendsave;
94 /* The handler stub unblocks the signal, so we don't need a separate
95 "temporary save" for that. */
96 } sigdata[64];
97
98 /* Register context, swapped with _sim_cpu.cpu_data. */
99 void *cpu_context;
100
101 /* Similar, temporary copy for the state at a signal call. */
102 void *cpu_context_atsignal;
103
104 /* The number of the reading and writing ends of a pipe if waiting for
105 the reader, else 0. */
106 int pipe_read_fd;
107 int pipe_write_fd;
108
109 /* System time at last context switch when this thread ran. */
110 USI last_execution;
111
112 /* Nonzero if we just executed a syscall. */
113 char at_syscall;
114
115 /* Nonzero if any of sigaction[0..64].pending is true. */
116 char sigpending;
117
118 /* Nonzero if in (rt_)sigsuspend call. Cleared at every sighandler
119 call. */
120 char sigsuspended;
121 };
122
123 struct _sim_cpu {
124 /* sim/common cpu base. */
125 sim_cpu_base base;
126
127 /* Static parts of cgen. */
128 CGEN_CPU cgen_cpu;
129
130 CRIS_MISC_PROFILE cris_misc_profile;
131 #define CPU_CRIS_MISC_PROFILE(cpu) (& (cpu)->cris_misc_profile)
132
133 /* Copy of previous data; only valid when emitting trace-data after
134 each insn. */
135 CRIS_MISC_PROFILE cris_prev_misc_profile;
136 #define CPU_CRIS_PREV_MISC_PROFILE(cpu) (& (cpu)->cris_prev_misc_profile)
137
138 /* Simulator environment data. */
139 USI endmem;
140 USI endbrk;
141 USI stack_low;
142 struct cris_sim_mmapped_page *highest_mmapped_page;
143
144 /* Number of syscalls performed or in progress, counting once extra
145 for every time a blocked thread (internally, when threading) polls
146 the (pipe) blockage. By default, this is also a time counter: to
147 minimize performance noise from minor compiler changes,
148 instructions take no time and syscalls always take 1ms. */
149 USI syscalls;
150
151 /* Number of execution contexts minus one. */
152 int m1threads;
153
154 /* Current thread number; index into thread_data when m1threads != 0. */
155 int threadno;
156
157 /* When a new thread is created, it gets a unique number, which we
158 count here. */
159 int max_threadid;
160
161 /* Thread-specific info, for simulator thread support, created at
162 "clone" call. Vector of [threads+1] when m1threads > 0. */
163 struct cris_thread_info *thread_data;
164
165 /* "If CLONE_SIGHAND is set, the calling process and the child pro-
166 cesses share the same table of signal handlers." ... "However, the
167 calling process and child processes still have distinct signal
168 masks and sets of pending signals." See struct cris_thread_info
169 for sigmasks and sigpendings. */
170 USI sighandler[64];
171
172 /* Function for initializing CPU thread context, which varies in size
173 with each CPU model. They should be in some constant parts or
174 initialized in *_init_cpu, but we can't modify that for now. */
175 void* (*make_thread_cpu_data) (SIM_CPU *, void *);
176 size_t thread_cpu_data_size;
177
178 /* CPU-model specific parts go here.
179 Note that in files that don't need to access these pieces WANT_CPU_FOO
180 won't be defined and thus these parts won't appear. This is ok in the
181 sense that things work. It is a source of bugs though.
182 One has to of course be careful to not take the size of this
183 struct and no structure members accessed in non-cpu specific files can
184 go after here. */
185 #if defined (WANT_CPU_CRISV0F)
186 CRISV0F_CPU_DATA cpu_data;
187 #elif defined (WANT_CPU_CRISV3F)
188 CRISV3F_CPU_DATA cpu_data;
189 #elif defined (WANT_CPU_CRISV8F)
190 CRISV8F_CPU_DATA cpu_data;
191 #elif defined (WANT_CPU_CRISV10F)
192 CRISV10F_CPU_DATA cpu_data;
193 #elif defined (WANT_CPU_CRISV32F)
194 CRISV32F_CPU_DATA cpu_data;
195 #else
196 /* Let's assume all cpu_data have the same alignment requirements, so
197 they all are laid out at the same address. Since we can't get the
198 exact definition, we also assume that it has no higher alignment
199 requirements than a vector of, say, 16 pointers. (A single member
200 is often special-cased, and possibly two as well so we don't want
201 that). */
202 union { void *dummy[16]; } cpu_data_placeholder;
203 #endif
204 };
205 \f
206 /* The sim_state struct. */
207
208 struct sim_state {
209 sim_cpu *cpu;
210 #define STATE_CPU(sd, n) (/*&*/ (sd)->cpu)
211
212 CGEN_STATE cgen_state;
213
214 sim_state_base base;
215 };
216 \f
217 /* Misc. */
218
219 /* Catch address exceptions. */
220 extern SIM_CORE_SIGNAL_FN cris_core_signal;
221 #define SIM_CORE_SIGNAL(SD,CPU,CIA,MAP,NR_BYTES,ADDR,TRANSFER,ERROR) \
222 cris_core_signal ((SD), (CPU), (CIA), (MAP), (NR_BYTES), (ADDR), \
223 (TRANSFER), (ERROR))
224
225 /* Default memory size. */
226 #define CRIS_DEFAULT_MEM_SIZE 0x800000 /* 8M */
227
228 extern device cris_devices;
229
230 #endif /* SIM_MAIN_H */