1 /* Memory ops header for CGEN-based simlators.
2 Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
3 Contributed by Cygnus Solutions.
5 This file is part of the GNU Simulators.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License along
18 with this program; if not, write to the Free Software Foundation, Inc.,
19 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
24 #ifdef MEMOPS_DEFINE_INLINE
27 #define MEMOPS_INLINE extern inline
30 #if defined (__GNUC__) || defined (MEMOPS_DEFINE_INLINE)
31 #define DECLARE_GETMEM(mode, size) \
33 XCONCAT2 (GETMEM,mode) (SIM_CPU *cpu, ADDR a) \
35 PROFILE_COUNT_READ (cpu, a, XCONCAT2 (MODE_,mode)); \
36 /* Don't read anything into "unaligned" here. Bad name choice. */\
37 return XCONCAT2 (sim_core_read_unaligned_,size) (cpu, NULL_CIA, sim_core_read_map, a); \
40 #define DECLARE_GETMEM(mode, size) \
41 extern mode XCONCAT2 (GETMEM,mode) (SIM_CPU *, ADDR);
44 DECLARE_GETMEM (QI
, 1)
45 DECLARE_GETMEM (UQI
, 1)
46 DECLARE_GETMEM (HI
, 2)
47 DECLARE_GETMEM (UHI
, 2)
48 DECLARE_GETMEM (SI
, 4)
49 DECLARE_GETMEM (USI
, 4)
50 DECLARE_GETMEM (DI
, 8)
51 DECLARE_GETMEM (UDI
, 8)
55 #if defined (__GNUC__) || defined (MEMOPS_DEFINE_INLINE)
56 #define DECLARE_SETMEM(mode, size) \
58 XCONCAT2 (SETMEM,mode) (SIM_CPU *cpu, ADDR a, mode val) \
60 PROFILE_COUNT_WRITE (cpu, a, XCONCAT2 (MODE_,mode)); \
61 /* Don't read anything into "unaligned" here. Bad name choice. */ \
62 XCONCAT2 (sim_core_write_unaligned_,size) (cpu, NULL_CIA, sim_core_write_map, a, val); \
65 #define DECLARE_SETMEM(mode, size) \
66 extern void XCONCAT2 (SETMEM,mode) (SIM_CPU *, ADDR, mode);
69 DECLARE_SETMEM (QI
, 1)
70 DECLARE_SETMEM (UQI
, 1)
71 DECLARE_SETMEM (HI
, 2)
72 DECLARE_SETMEM (UHI
, 2)
73 DECLARE_SETMEM (SI
, 4)
74 DECLARE_SETMEM (USI
, 4)
75 DECLARE_SETMEM (DI
, 8)
76 DECLARE_SETMEM (UDI
, 8)
80 #if defined (__GNUC__) || defined (MEMOPS_DEFINE_INLINE)
81 #define DECLARE_GETIMEM(mode, size) \
83 XCONCAT2 (GETIMEM,mode) (SIM_CPU *cpu, ADDR a) \
85 /*PROFILE_COUNT_READ (cpu, a, XCONCAT2 (MODE_,mode));*/ \
86 /* Don't read anything into "unaligned" here. Bad name choice. */\
87 return XCONCAT2 (sim_core_read_unaligned_,size) (cpu, NULL_CIA, sim_core_execute_map, a); \
90 #define DECLARE_GETIMEM(mode, size) \
91 extern mode XCONCAT2 (GETIMEM,mode) (SIM_CPU *, ADDR);
94 DECLARE_GETIMEM (UQI
, 1)
95 DECLARE_GETIMEM (UHI
, 2)
96 DECLARE_GETIMEM (USI
, 4)
97 DECLARE_GETIMEM (UDI
, 8)
99 #undef DECLARE_GETIMEM
101 /* GETT<mode>: translate target value at P to host value.
102 ??? How inefficient is the current implementation? */
104 #if defined (__GNUC__) || defined (MEMOPS_DEFINE_INLINE)
105 #define DECLARE_GETT(mode, size) \
107 XCONCAT2 (GETT,mode) (unsigned char *p) \
110 memcpy (&tmp, p, sizeof (mode)); \
111 return XCONCAT2 (T2H_,size) (tmp); \
114 #define DECLARE_GETT(mode, size) \
115 extern mode XCONCAT2 (GETT,mode) (unsigned char *);
119 DECLARE_GETT (UQI
, 1)
121 DECLARE_GETT (UHI
, 2)
123 DECLARE_GETT (USI
, 4)
125 DECLARE_GETT (UDI
, 8)
129 /* SETT<mode>: translate host value to target value and store at P.
130 ??? How inefficient is the current implementation? */
132 #if defined (__GNUC__) || defined (MEMOPS_DEFINE_INLINE)
133 #define DECLARE_SETT(mode, size) \
135 XCONCAT2 (SETT,mode) (unsigned char *buf, mode val) \
138 tmp = XCONCAT2 (H2T_,size) (val); \
139 memcpy (buf, &tmp, sizeof (mode)); \
142 #define DECLARE_SETT(mode, size) \
143 extern mode XCONCAT2 (GETT,mode) (unsigned char *, mode);
147 DECLARE_SETT (UQI
, 1)
149 DECLARE_SETT (UHI
, 2)
151 DECLARE_SETT (USI
, 4)
153 DECLARE_SETT (UDI
, 8)
157 #endif /* CGEN_MEM_H */