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:
58 if (vm_data_map_read_buffer(map, &val, ea, sizeof(unsigned_N))
59 != sizeof(unsigned_N))
60 alignment_interrupt(processor, cia, ea);
62 if (WITH_MON & MONITOR_LOAD_STORE_UNIT) {
64 unsigned ra = vm_real_data_addr(map, ea, 1, processor, cia);
65 mon_read(ea, ra, sizeof(unsigned_N), processor, cia);
67 TRACE(trace_load_store, ("load cia=0x%x ea=0x%x N=%d data=0x%x\n",
68 cia, ea, sizeof(unsigned_N), val));
72 error("unknown alignment support\n");
79 XCONCAT2(vm_data_map_write_,N)(vm_data_map *map,
85 if ((ea & (sizeof(unsigned_N)-1)) == 0) {
86 unsigned ra = vm_real_data_addr(map, ea, 0/*is-read?*/, processor, cia);
87 XCONCAT2(core_map_write_,N)(map->write, ra, val, processor, cia);
88 if (WITH_MON & MONITOR_LOAD_STORE_UNIT)
89 mon_write(ea, ra, sizeof(unsigned_N), processor, cia);
90 TRACE(trace_load_store, ("store cia=0x%x ea=0x%x N=%d val=0x%x\n",
91 cia, ea, sizeof(unsigned_N), val));
94 switch (CURRENT_ALIGNMENT) {
95 case STRICT_ALIGNMENT:
96 alignment_interrupt(processor, cia, ea);
98 case NONSTRICT_ALIGNMENT:
100 unsigned_N data = H2T_N(val);
101 if (vm_data_map_write_buffer(map, &data, ea, sizeof(unsigned_N), 0)
102 != sizeof(unsigned_N))
103 alignment_interrupt(processor, cia, ea);
104 if (WITH_MON & MONITOR_LOAD_STORE_UNIT) {
106 unsigned ra = vm_real_data_addr(map, ea, 1, processor, cia);
107 mon_write(ea, ra, sizeof(unsigned_N), processor, cia);
109 TRACE(trace_load_store, ("store cia=0x%x ea=0x%x N=%d val=0x%x\n",
110 cia, ea, sizeof(unsigned_N), val));
114 error("unknown alignment support\n");