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 3 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, see <http://www.gnu.org/licenses/>.
22 #error "N must be #defined"
25 /* NOTE: See end of file for #undef */
26 #define unsigned_N XCONCAT2(unsigned_,N)
27 #define T2H_N XCONCAT2(T2H_,N)
28 #define H2T_N XCONCAT2(H2T_,N)
29 #define vm_data_map_read_N XCONCAT2(vm_data_map_read_,N)
30 #define vm_data_map_write_N XCONCAT2(vm_data_map_write_,N)
35 vm_data_map_read_N(vm_data_map
*map
,
40 if ((ea
& (sizeof(unsigned_N
)-1)) == 0) {
41 unsigned ra
= vm_real_data_addr(map
, ea
, 1/*is-read*/, processor
, cia
);
44 ra
^= map
->translation
.xor[sizeof(unsigned_N
) - 1];
45 val
= XCONCAT2(core_map_read_
,N
)(map
->read
, ra
, processor
, cia
);
46 if (WITH_MON
& MONITOR_LOAD_STORE_UNIT
)
47 mon_read(ea
, ra
, sizeof(unsigned_N
), processor
, cia
);
48 TRACE(trace_load_store
, ("load cia=0x%lx ea=0x%lx N=%ld val=0x%lx\n",
49 (long)cia
, (long)ea
, (long)sizeof(unsigned_N
), (long)val
));
53 switch (CURRENT_ALIGNMENT
) {
54 case STRICT_ALIGNMENT
:
55 alignment_interrupt(processor
, cia
, ea
);
57 case NONSTRICT_ALIGNMENT
:
60 if (vm_data_map_read_buffer(map
, &val
, ea
, sizeof(unsigned_N
), processor
, cia
)
61 != sizeof(unsigned_N
)) {
62 cpu_error(processor
, cia
, "misaligned %d byte read to 0x%lx failed",
63 sizeof(unsigned_N
), (unsigned long)ea
);
66 if (WITH_MON
& MONITOR_LOAD_STORE_UNIT
) {
68 unsigned ra
= vm_real_data_addr(map
, ea
, 1, processor
, cia
);
69 mon_read(ea
, ra
, sizeof(unsigned_N
), processor
, cia
);
71 TRACE(trace_load_store
, ("load cia=0x%lx ea=0x%lx N=%ld data=0x%lx\n",
72 (long)cia
, (long)ea
, (long)sizeof(unsigned_N
), (long)val
));
76 error("internal error - vm_data_map_read_N - bad switch");
84 vm_data_map_write_N(vm_data_map
*map
,
90 if ((ea
& (sizeof(unsigned_N
)-1)) == 0) {
91 unsigned ra
= vm_real_data_addr(map
, ea
, 0/*is-read?*/, processor
, cia
);
93 ra
^= map
->translation
.xor[sizeof(unsigned_N
) - 1];
94 XCONCAT2(core_map_write_
,N
)(map
->write
, ra
, val
, processor
, cia
);
95 if (WITH_MON
& MONITOR_LOAD_STORE_UNIT
)
96 mon_write(ea
, ra
, sizeof(unsigned_N
), processor
, cia
);
97 TRACE(trace_load_store
, ("store cia=0x%lx ea=0x%lx N=%ld val=0x%lx\n",
98 (long)cia
, (long)ea
, (long)sizeof(unsigned_N
), (long)val
));
101 switch (CURRENT_ALIGNMENT
) {
102 case STRICT_ALIGNMENT
:
103 alignment_interrupt(processor
, cia
, ea
);
105 case NONSTRICT_ALIGNMENT
:
107 unsigned_N data
= H2T_N(val
);
108 if (vm_data_map_write_buffer(map
, &data
, ea
, sizeof(unsigned_N
), 0, processor
, cia
)
109 != sizeof(unsigned_N
)) {
110 cpu_error(processor
, cia
, "misaligned %d byte write to 0x%lx failed",
111 sizeof(unsigned_N
), (unsigned long)ea
);
113 if (WITH_MON
& MONITOR_LOAD_STORE_UNIT
) {
115 unsigned ra
= vm_real_data_addr(map
, ea
, 1, processor
, cia
);
116 mon_write(ea
, ra
, sizeof(unsigned_N
), processor
, cia
);
118 TRACE(trace_load_store
, ("store cia=0x%lx ea=0x%lx N=%ld val=0x%lx\n",
119 (long)cia
, (long)ea
, (long)sizeof(unsigned_N
), (long)val
));
123 error("internal error - vm_data_map_write_N - bad switch");
128 /* NOTE: see start of file for #define */
132 #undef vm_data_map_read_N
133 #undef vm_data_map_write_N