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.
23 #error "N must be #defined"
28 /* NOTE: see end of file for #undef of these macros */
29 #define unsigned_N XCONCAT2(unsigned_,N)
30 #define T2H_N XCONCAT2(T2H_,N)
31 #define H2T_N XCONCAT2(H2T_,N)
33 #define sim_core_read_N XCONCAT2(sim_core_read_,N)
34 #define sim_core_write_N XCONCAT2(sim_core_write_,N)
37 INLINE_SIM_CORE(unsigned_N)
38 sim_core_read_N(SIM_DESC sd,
45 sim_core_mapping *mapping = sim_core_find_mapping (sd, map,
51 if (WITH_CALLBACK_MEMORY && mapping->device != NULL) {
53 if (device_io_read_buffer (mapping->device,
57 sizeof (unsigned_N)) != sizeof (unsigned_N))
58 device_error (mapping->device, "internal error - sim_core_read_N() - io_read_buffer should not fail");
63 val = T2H_N (*(unsigned_N*) sim_core_translate (mapping, addr));
64 if (STATE_CORE (sd)->trace)
65 trace_printf (sd, cpu, "sim-n-core.c:%d: read-%d %s:0x%08lx -> 0x%lx\n",
68 sim_core_map_to_str (map),
77 sim_core_write_N(SIM_DESC sd,
84 sim_core_mapping *mapping = sim_core_find_mapping(sd, map,
90 if (WITH_CALLBACK_MEMORY && mapping->device != NULL) {
91 unsigned_N data = H2T_N (val);
92 if (device_io_write_buffer (mapping->device,
96 sizeof (unsigned_N), /* nr_bytes */
98 cia) != sizeof (unsigned_N))
99 device_error (mapping->device, "internal error - sim_core_write_N() - io_write_buffer should not fail");
103 *(unsigned_N*) sim_core_translate (mapping, addr) = H2T_N (val);
104 if (STATE_CORE (sd)->trace)
105 trace_printf (sd, cpu, "sim-n-core.c:%d: write-%d %s:0x%08lx <- 0x%lx\n",
108 sim_core_map_to_str (map),
109 (unsigned long) addr,
110 (unsigned long) val);
114 /* NOTE: see start of file for #define of these macros */
118 #undef sim_core_read_N
119 #undef sim_core_write_N