Add a number of per-simulator options: hostendian, endian, inline, warnings.
[external/binutils.git] / sim / common / sim-n-core.h
1 /*  This file is part of the program psim.
2
3     Copyright (C) 1994-1997, 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
26 /* NOTE: see end of file for #undef of these macros */
27 #define unsigned_N XCONCAT2(unsigned_,N)
28 #define T2H_N XCONCAT2(T2H_,N)
29 #define H2T_N XCONCAT2(H2T_,N)
30
31 #define core_map_read_N XCONCAT2(core_map_read_,N)
32 #define core_map_write_N XCONCAT2(core_map_write_,N)
33
34
35 INLINE_SIM_CORE(unsigned_N)
36 core_map_read_N(engine *system,
37                 core_maps map,
38                 unsigned_word addr)
39 {
40   core_mapping *mapping = core_map_find_mapping(system, map,
41                                                 addr,
42                                                 sizeof(unsigned_N),
43                                                 1); /*abort*/
44 #if (WITH_DEVICES)
45   if (WITH_CALLBACK_MEMORY && mapping->device != NULL) {
46     unsigned_N data;
47     if (device_io_read_buffer(mapping->device,
48                               &data,
49                               mapping->space,
50                               addr,
51                               sizeof(unsigned_N)) != sizeof(unsigned_N))
52       device_error(mapping->device, "internal error - core_read_N() - io_read_buffer should not fail");
53     return T2H_N(data);
54   }
55   else
56 #endif
57     return T2H_N(*(unsigned_N*)core_translate(mapping, addr));
58 }
59
60
61
62 INLINE_SIM_CORE(void)
63 core_map_write_N(engine *system,
64                  core_maps map,
65                  unsigned_word addr,
66                  unsigned_N val)
67 {
68   core_mapping *mapping = core_map_find_mapping(system, map,
69                                                 addr,
70                                                 sizeof(unsigned_N),
71                                                 1); /*abort*/
72 #if (WITH_DEVICES)
73   if (WITH_CALLBACK_MEMORY && mapping->device != NULL) {
74     unsigned_N data = H2T_N(val);
75     if (device_io_write_buffer(mapping->device,
76                                &data,
77                                mapping->space,
78                                addr,
79                                sizeof(unsigned_N), /* nr_bytes */
80                                processor,
81                                cia) != sizeof(unsigned_N))
82       device_error(mapping->device, "internal error - core_write_N() - io_write_buffer should not fail");
83   }
84   else
85 #endif
86     *(unsigned_N*)core_translate(mapping, addr) = H2T_N(val);
87 }
88
89
90 /* NOTE: see start of file for #define of these macros */
91 #undef unsigned_N
92 #undef T2H_N
93 #undef H2T_N
94 #undef core_map_read_N
95 #undef core_map_write_N