]>
Commit | Line | Data |
---|---|---|
a983c8f0 MM |
1 | /* This file is part of the program psim. |
2 | ||
3 | Copyright (C) 1994-1995, Andrew Cagney <[email protected]> | |
4 | ||
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. | |
9 | ||
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. | |
14 | ||
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. | |
18 | ||
19 | */ | |
20 | ||
21 | ||
22 | #ifndef N | |
23 | #error "N must be #defined" | |
24 | #endif | |
25 | ||
26 | #undef unsigned_N | |
27 | #define unsigned_N XCONCAT2(unsigned_,N) | |
28 | #undef T2H_N | |
29 | #define T2H_N XCONCAT2(T2H_,N) | |
30 | #undef H2T_N | |
31 | #define H2T_N XCONCAT2(H2T_,N) | |
32 | ||
33 | ||
34 | INLINE_VM unsigned_N | |
35 | XCONCAT2(vm_data_map_read_,N)(vm_data_map *map, | |
36 | unsigned_word ea, | |
37 | cpu *processor, | |
38 | unsigned_word cia) | |
39 | { | |
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)); | |
47 | return val; | |
48 | } | |
49 | else { | |
50 | switch (CURRENT_ALIGNMENT) { | |
51 | case STRICT_ALIGNMENT: | |
52 | alignment_interrupt(processor, cia, ea); | |
53 | return 0; | |
54 | case NONSTRICT_ALIGNMENT: | |
55 | { | |
a983c8f0 MM |
56 | unsigned_N val; |
57 | if (vm_data_map_read_buffer(map, &val, ea, sizeof(unsigned_N)) | |
58 | != sizeof(unsigned_N)) | |
59 | alignment_interrupt(processor, cia, ea); | |
60 | val = T2H_N(val); | |
61 | if (WITH_MON & MONITOR_LOAD_STORE_UNIT) { | |
62 | /* YUCK */ | |
63 | unsigned ra = vm_real_data_addr(map, ea, 1, processor, cia); | |
64 | mon_read(ea, ra, sizeof(unsigned_N), processor, cia); | |
65 | } | |
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)); | |
68 | return val; | |
69 | } | |
70 | default: | |
71 | error("unknown alignment support\n"); | |
72 | return 0; | |
73 | } | |
74 | } | |
75 | } | |
76 | ||
77 | INLINE_VM void | |
78 | XCONCAT2(vm_data_map_write_,N)(vm_data_map *map, | |
79 | unsigned_word ea, | |
80 | unsigned_N val, | |
81 | cpu *processor, | |
82 | unsigned_word cia) | |
83 | { | |
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)); | |
91 | } | |
92 | else { | |
93 | switch (CURRENT_ALIGNMENT) { | |
94 | case STRICT_ALIGNMENT: | |
95 | alignment_interrupt(processor, cia, ea); | |
96 | break; | |
97 | case NONSTRICT_ALIGNMENT: | |
98 | { | |
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) { | |
104 | /* YUCK */ | |
105 | unsigned ra = vm_real_data_addr(map, ea, 1, processor, cia); | |
106 | mon_write(ea, ra, sizeof(unsigned_N), processor, cia); | |
107 | } | |
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)); | |
110 | } | |
111 | break; | |
112 | default: | |
113 | error("unknown alignment support\n"); | |
114 | } | |
115 | } | |
116 | } |