Commit | Line | Data |
---|---|---|
dec38dac MM |
1 | /* This file is part of the program psim. |
2 | ||
3 | Copyright (C) 1994-1995, Andrew Cagney <cagney@highland.com.au> | |
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 | ||
93fac324 | 26 | /* NOTE: see end of file for #undef of these macros */ |
dec38dac | 27 | #define unsigned_N XCONCAT2(unsigned_,N) |
dec38dac | 28 | #define T2H_N XCONCAT2(T2H_,N) |
dec38dac MM |
29 | #define H2T_N XCONCAT2(H2T_,N) |
30 | ||
93fac324 MM |
31 | #define core_map_read_N XCONCAT2(core_map_read_,N) |
32 | #define core_map_write_N XCONCAT2(core_map_write_,N) | |
dec38dac | 33 | |
93fac324 MM |
34 | unsigned_N INLINE_CORE |
35 | core_map_read_N(core_map *map, | |
36 | unsigned_word addr, | |
37 | cpu *processor, | |
38 | unsigned_word cia) | |
dec38dac MM |
39 | { |
40 | core_mapping *mapping = core_map_find_mapping(map, | |
41 | addr, | |
42 | sizeof(unsigned_N), | |
43 | processor, | |
44 | cia, | |
45 | 1); /*abort*/ | |
93fac324 | 46 | if (WITH_CALLBACK_MEMORY && mapping->device != NULL) { |
dec38dac | 47 | unsigned_N data; |
93fac324 MM |
48 | if (device_io_read_buffer(mapping->device, |
49 | &data, | |
50 | mapping->space, | |
51 | addr - mapping->base, | |
52 | sizeof(unsigned_N), /* nr_bytes */ | |
53 | processor, | |
54 | cia) != sizeof(unsigned_N)) | |
dec38dac MM |
55 | error("core_read_,N() reader should not fail\n"); |
56 | return T2H_N(data); | |
57 | } | |
58 | else | |
59 | return T2H_N(*(unsigned_N*)core_translate(mapping, addr)); | |
60 | } | |
61 | ||
62 | ||
63 | ||
93fac324 MM |
64 | void INLINE_CORE |
65 | core_map_write_N(core_map *map, | |
66 | unsigned_word addr, | |
67 | unsigned_N val, | |
68 | cpu *processor, | |
69 | unsigned_word cia) | |
dec38dac MM |
70 | { |
71 | core_mapping *mapping = core_map_find_mapping(map, | |
72 | addr, | |
73 | sizeof(unsigned_N), | |
74 | processor, | |
75 | cia, | |
76 | 1); /*abort*/ | |
93fac324 | 77 | if (WITH_CALLBACK_MEMORY && mapping->device != NULL) { |
dec38dac | 78 | unsigned_N data = H2T_N(val); |
93fac324 MM |
79 | if (device_io_write_buffer(mapping->device, |
80 | &data, | |
81 | mapping->space, | |
82 | addr - mapping->base, | |
83 | sizeof(unsigned_N), /* nr_bytes */ | |
84 | processor, | |
85 | cia) != sizeof(unsigned_N)) | |
dec38dac MM |
86 | error("core_read_,N() writer should not fail\n"); |
87 | } | |
88 | else | |
89 | *(unsigned_N*)core_translate(mapping, addr) = H2T_N(val); | |
90 | } | |
91 | ||
93fac324 MM |
92 | /* NOTE: see start of file for #define of these macros */ |
93 | #undef unsigned_N | |
94 | #undef T2H_N | |
95 | #undef H2T_N | |
96 | #undef core_map_read_N | |
97 | #undef core_map_write_N |