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 CPU, when non NULL, specifes the single processor that the memory
107 space is to be attached to. (UNIMPLEMENTED).
109 LEVEL specifies the ordering of the memory region. Lower regions
110 are searched first. Within a level, memory regions can not
113 DEVICE, when non NULL, specifies a callback memory space.
114 (UNIMPLEMENTED, see the ppc simulator for an example).
116 MODULO, when the simulator has been configured WITH_MODULO support
117 and is greater than zero, specifies that accesses to the region
118 [ADDR .. ADDR+NR_BYTES) should be mapped onto the sub region [ADDR
119 .. ADDR+MODULO). The modulo value must be a power of two.
121 OPTIONAL_BUFFER, when non NULL, specifies the buffer to use for
122 data read & written to the region. Normally a more efficient
123 internal structure is used. It is assumed that buffer is allocated
124 such that the byte alignmed of OPTIONAL_BUFFER matches ADDR vis
125 (OPTIONAL_BUFFER % 8) == (ADDR % 8)) */
128 (void) sim_core_attach
135 address_word nr_bytes
,
138 void *optional_buffer
);
141 /* Delete a memory space within the core.
146 (void) sim_core_detach
154 /* Variable sized read/write
156 Transfer a variable sized block of raw data between the host and
157 target. Should any problems occure, the number of bytes
158 successfully transfered is returned.
160 No host/target byte endian conversion is performed. No xor-endian
161 conversion is performed.
163 If CPU argument, when non NULL, specifies the processor specific
164 address map that is to be used in the transfer. */
168 (unsigned) sim_core_read_buffer
177 (unsigned) sim_core_write_buffer
187 /* Configure the core's XOR endian transfer mode. Only applicable
188 when WITH_XOR_ENDIAN is enabled.
190 Targets suporting XOR endian, shall notify the core of any changes
191 in state via this call.
193 The CPU argument, when non NULL, specifes the single processor that
194 the xor-endian configuration is to be applied to. */
197 (void) sim_core_set_xor\
203 /* XOR version of variable sized read/write.
205 Transfer a variable sized block of raw data between the host and
206 target. Should any problems occure, the number of bytes
207 successfully transfered is returned.
209 No host/target byte endian conversion is performed. If applicable
210 (WITH_XOR_ENDIAN and xor-endian set), xor-endian conversion *is*
213 If CPU argument, when non NULL, specifies the processor specific
214 address map that is to be used in the transfer. */
217 (unsigned) sim_core_xor_read_buffer
226 (unsigned) sim_core_xor_write_buffer
236 /* Fixed sized, processor oriented, read/write.
238 Transfer a fixed amout of memory between the host and target. The
239 data transfered is translated from/to host to/from target byte
240 order (including xor endian). Should the transfer fail, the
241 operation shall abort (no return).
243 The aligned alternative makes the assumption that that the address
244 is N byte aligned (no alignment checks are made).
246 The unaligned alternative checks the address for correct byte
247 alignment. Action, as defined by WITH_ALIGNMENT, being taken
248 should the check fail.
250 Misaligned xor-endian accesses are broken into a sequence of
251 transfers each <= WITH_XOR_ENDIAN bytes */
254 #define DECLARE_SIM_CORE_WRITE_N(ALIGNMENT,N) \
256 (void) sim_core_write_##ALIGNMENT##_##N \
263 DECLARE_SIM_CORE_WRITE_N(aligned
,1)
264 DECLARE_SIM_CORE_WRITE_N(aligned
,2)
265 DECLARE_SIM_CORE_WRITE_N(aligned
,4)
266 DECLARE_SIM_CORE_WRITE_N(aligned
,8)
267 DECLARE_SIM_CORE_WRITE_N(aligned
,16)
269 DECLARE_SIM_CORE_WRITE_N(unaligned
,1)
270 DECLARE_SIM_CORE_WRITE_N(unaligned
,2)
271 DECLARE_SIM_CORE_WRITE_N(unaligned
,4)
272 DECLARE_SIM_CORE_WRITE_N(unaligned
,8)
273 DECLARE_SIM_CORE_WRITE_N(unaligned
,16)
276 #define sim_core_write_1 sim_core_write_aligned_1
277 #define sim_core_write_2 sim_core_write_aligned_2
278 #define sim_core_write_4 sim_core_write_aligned_4
279 #define sim_core_write_8 sim_core_write_aligned_8
280 #define sim_core_write_16 sim_core_write_aligned_16
282 #define sim_core_write_unaligned_word XCONCAT2(sim_core_write_unaligned_,WITH_TARGET_WORD_BITSIZE)
283 #define sim_core_write_aligned_word XCONCAT2(sim_core_write_aligned_,WITH_TARGET_WORD_BITSIZE)
284 #define sim_core_write_word XCONCAT2(sim_core_write_,WITH_TARGET_WORD_BITSIZE)
286 #undef DECLARE_SIM_CORE_WRITE_N
289 #define DECLARE_SIM_CORE_READ_N(ALIGNMENT,N) \
291 (unsigned_##N) sim_core_read_##ALIGNMENT##_##N \
297 DECLARE_SIM_CORE_READ_N(aligned
,1)
298 DECLARE_SIM_CORE_READ_N(aligned
,2)
299 DECLARE_SIM_CORE_READ_N(aligned
,4)
300 DECLARE_SIM_CORE_READ_N(aligned
,8)
301 DECLARE_SIM_CORE_READ_N(aligned
,16)
303 DECLARE_SIM_CORE_READ_N(unaligned
,1)
304 DECLARE_SIM_CORE_READ_N(unaligned
,2)
305 DECLARE_SIM_CORE_READ_N(unaligned
,4)
306 DECLARE_SIM_CORE_READ_N(unaligned
,8)
307 DECLARE_SIM_CORE_READ_N(unaligned
,16)
309 #define sim_core_read_1 sim_core_read_aligned_1
310 #define sim_core_read_2 sim_core_read_aligned_2
311 #define sim_core_read_4 sim_core_read_aligned_4
312 #define sim_core_read_8 sim_core_read_aligned_8
313 #define sim_core_read_16 sim_core_read_aligned_16
315 #define sim_core_read_unaligned_word XCONCAT2(sim_core_read_unaligned_,WITH_TARGET_WORD_BITSIZE)
316 #define sim_core_read_aligned_word XCONCAT2(sim_core_read_aligned_,WITH_TARGET_WORD_BITSIZE)
317 #define sim_core_read_word XCONCAT2(sim_core_read_,WITH_TARGET_WORD_BITSIZE)
319 #undef DECLARE_SIM_CORE_READ_N