1 /* This file is part of the program psim.
3 Copyright (C) 1994-1997, Andrew Cagney <cagney@highland.com.au>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26 /* core signals (error conditions) */
29 sim_core_unmapped_signal
,
30 sim_core_unaligned_signal
,
34 /* define SIM_CORE_SIGNAL to catch these signals - see sim-core.c for
41 typedef struct _sim_core_mapping sim_core_mapping
;
42 struct _sim_core_mapping
{
48 unsigned_word nr_bytes
;
58 sim_core_mapping
*next
;
61 typedef struct _sim_core_map sim_core_map
;
62 struct _sim_core_map
{
63 sim_core_mapping
*first
;
74 typedef struct _sim_core_common
{
75 sim_core_map map
[nr_sim_core_maps
];
79 /* Main core structure */
81 typedef struct _sim_core sim_core
;
83 sim_core_common common
;
84 address_word byte_xor
; /* apply xor universally */
88 /* Per CPU distributed component of the core. At present this is
89 mostly a clone of the global core data structure. */
91 typedef struct _sim_cpu_core
{
92 sim_core_common common
;
93 address_word
xor[WITH_XOR_ENDIAN
+ 1]; /* +1 to avoid zero-sized array */
97 /* Install the "core" module. */
100 (SIM_RC
) sim_core_install (SIM_DESC sd
);
104 /* Create a memory space within the core.
106 The CPU option (when non NULL) specifes the single processor that
107 the memory space is to be attached to. (UNIMPLEMENTED).
112 (void) sim_core_attach
119 address_word nr_bytes
,
120 unsigned modulo
, /* Power of two, zero for none. */
122 void *optional_buffer
);
124 /* Delete a memory space within the core.
129 (void) sim_core_detach
137 /* Variable sized read/write
139 Transfer a variable sized block of raw data between the host and
140 target. Should any problems occure, the number of bytes
141 successfully transfered is returned.
143 No host/target byte endian conversion is performed. No xor-endian
144 conversion is performed.
146 If CPU argument, when non NULL, specifies the processor specific
147 address map that is to be used in the transfer. */
151 (unsigned) sim_core_read_buffer
160 (unsigned) sim_core_write_buffer
170 /* Configure the core's XOR endian transfer mode. Only applicable
171 when WITH_XOR_ENDIAN is enabled.
173 Targets suporting XOR endian, shall notify the core of any changes
174 in state via this call.
176 The CPU argument, when non NULL, specifes the single processor that
177 the xor-endian configuration is to be applied to. */
180 (void) sim_core_set_xor\
186 /* XOR version of variable sized read/write.
188 Transfer a variable sized block of raw data between the host and
189 target. Should any problems occure, the number of bytes
190 successfully transfered is returned.
192 No host/target byte endian conversion is performed. If applicable
193 (WITH_XOR_ENDIAN and xor-endian set), xor-endian conversion *is*
196 If CPU argument, when non NULL, specifies the processor specific
197 address map that is to be used in the transfer. */
200 (unsigned) sim_core_xor_read_buffer
209 (unsigned) sim_core_xor_write_buffer
219 /* Fixed sized, processor oriented, read/write.
221 Transfer a fixed amout of memory between the host and target. The
222 data transfered is translated from/to host to/from target byte
223 order (including xor endian). Should the transfer fail, the
224 operation shall abort (no return).
226 The aligned alternative makes the assumption that that the address
227 is N byte aligned (no alignment checks are made).
229 The unaligned alternative checks the address for correct byte
230 alignment. Action, as defined by WITH_ALIGNMENT, being taken
231 should the check fail.
233 Misaligned xor-endian accesses are broken into a sequence of
234 transfers each <= WITH_XOR_ENDIAN bytes */
237 #define DECLARE_SIM_CORE_WRITE_N(ALIGNMENT,N) \
239 (void) sim_core_write_##ALIGNMENT##_##N \
246 DECLARE_SIM_CORE_WRITE_N(aligned
,1)
247 DECLARE_SIM_CORE_WRITE_N(aligned
,2)
248 DECLARE_SIM_CORE_WRITE_N(aligned
,4)
249 DECLARE_SIM_CORE_WRITE_N(aligned
,8)
250 DECLARE_SIM_CORE_WRITE_N(aligned
,word
)
252 DECLARE_SIM_CORE_WRITE_N(unaligned
,1)
253 DECLARE_SIM_CORE_WRITE_N(unaligned
,2)
254 DECLARE_SIM_CORE_WRITE_N(unaligned
,4)
255 DECLARE_SIM_CORE_WRITE_N(unaligned
,8)
256 DECLARE_SIM_CORE_WRITE_N(unaligned
,word
)
258 #define sim_core_write_1 sim_core_write_aligned_1
259 #define sim_core_write_2 sim_core_write_aligned_2
260 #define sim_core_write_4 sim_core_write_aligned_4
261 #define sim_core_write_8 sim_core_write_aligned_8
263 #undef DECLARE_SIM_CORE_WRITE_N
266 #define DECLARE_SIM_CORE_READ_N(ALIGNMENT,N) \
268 (unsigned_##N) sim_core_read_##ALIGNMENT##_##N \
274 DECLARE_SIM_CORE_READ_N(aligned
,1)
275 DECLARE_SIM_CORE_READ_N(aligned
,2)
276 DECLARE_SIM_CORE_READ_N(aligned
,4)
277 DECLARE_SIM_CORE_READ_N(aligned
,8)
278 DECLARE_SIM_CORE_READ_N(aligned
,word
)
280 DECLARE_SIM_CORE_READ_N(unaligned
,1)
281 DECLARE_SIM_CORE_READ_N(unaligned
,2)
282 DECLARE_SIM_CORE_READ_N(unaligned
,4)
283 DECLARE_SIM_CORE_READ_N(unaligned
,8)
284 DECLARE_SIM_CORE_READ_N(unaligned
,word
)
286 #define sim_core_read_1 sim_core_read_aligned_1
287 #define sim_core_read_2 sim_core_read_aligned_2
288 #define sim_core_read_4 sim_core_read_aligned_4
289 #define sim_core_read_8 sim_core_read_aligned_8
291 #undef DECLARE_SIM_CORE_READ_N