1 /* This file is part of the program psim.
3 Copyright (C) 1994-1995, 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"
27 #define unsigned_N XCONCAT2(unsigned_,N)
29 #define T2H_N XCONCAT2(T2H_,N)
31 #define H2T_N XCONCAT2(H2T_,N)
35 XCONCAT2(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
);
42 unsigned_N val
= XCONCAT2(core_map_read_
,N
)(map
->read
, ra
, processor
, cia
);
43 if (WITH_MON
& MONITOR_LOAD_STORE_UNIT
)
44 mon_read(ea
, ra
, sizeof(unsigned_N
), processor
, cia
);
45 TRACE(trace_load_store
, ("load cia=0x%x ea=0x%x N=%d val=0x%x\n",
46 cia
, ea
, sizeof(unsigned_N
), val
));
50 switch (CURRENT_ALIGNMENT
) {
51 case STRICT_ALIGNMENT
:
52 alignment_interrupt(processor
, cia
, ea
);
54 case NONSTRICT_ALIGNMENT
:
57 if (vm_data_map_read_buffer(map
, &val
, ea
, sizeof(unsigned_N
))
58 != sizeof(unsigned_N
))
59 alignment_interrupt(processor
, cia
, ea
);
61 if (WITH_MON
& MONITOR_LOAD_STORE_UNIT
) {
63 unsigned ra
= vm_real_data_addr(map
, ea
, 1, processor
, cia
);
64 mon_read(ea
, ra
, sizeof(unsigned_N
), processor
, cia
);
66 TRACE(trace_load_store
, ("load cia=0x%x ea=0x%x N=%d data=0x%x\n",
67 cia
, ea
, sizeof(unsigned_N
), val
));
71 error("unknown alignment support\n");
78 XCONCAT2(vm_data_map_write_
,N
)(vm_data_map
*map
,
84 if ((ea
& (sizeof(unsigned_N
)-1)) == 0) {
85 unsigned ra
= vm_real_data_addr(map
, ea
, 0/*is-read?*/, processor
, cia
);
86 XCONCAT2(core_map_write_
,N
)(map
->write
, ra
, val
, processor
, cia
);
87 if (WITH_MON
& MONITOR_LOAD_STORE_UNIT
)
88 mon_write(ea
, ra
, sizeof(unsigned_N
), processor
, cia
);
89 TRACE(trace_load_store
, ("store cia=0x%x ea=0x%x N=%d val=0x%x\n",
90 cia
, ea
, sizeof(unsigned_N
), val
));
93 switch (CURRENT_ALIGNMENT
) {
94 case STRICT_ALIGNMENT
:
95 alignment_interrupt(processor
, cia
, ea
);
97 case NONSTRICT_ALIGNMENT
:
99 unsigned_N data
= H2T_N(val
);
100 if (vm_data_map_write_buffer(map
, &data
, ea
, sizeof(unsigned_N
), 0)
101 != sizeof(unsigned_N
))
102 alignment_interrupt(processor
, cia
, ea
);
103 if (WITH_MON
& MONITOR_LOAD_STORE_UNIT
) {
105 unsigned ra
= vm_real_data_addr(map
, ea
, 1, processor
, cia
);
106 mon_write(ea
, ra
, sizeof(unsigned_N
), processor
, cia
);
108 TRACE(trace_load_store
, ("store cia=0x%x ea=0x%x N=%d val=0x%x\n",
109 cia
, ea
, sizeof(unsigned_N
), val
));
113 error("unknown alignment support\n");