4 * Generate inline load/store functions for one MMU mode and data
7 * Generate a store function as well as signed and unsigned loads. For
8 * 32 and 64 bit cases, also generate floating point functions with
11 * Not used directly but included from softmmu_exec.h and exec-all.h.
13 * Copyright (c) 2003 Fabrice Bellard
15 * This library is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU Lesser General Public
17 * License as published by the Free Software Foundation; either
18 * version 2 of the License, or (at your option) any later version.
20 * This library is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23 * Lesser General Public License for more details.
25 * You should have received a copy of the GNU Lesser General Public
26 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
31 #define DATA_TYPE uint64_t
35 #define DATA_TYPE uint32_t
39 #define DATA_TYPE uint16_t
40 #define DATA_STYPE int16_t
44 #define DATA_TYPE uint8_t
45 #define DATA_STYPE int8_t
47 #error unsupported data size
50 #if ACCESS_TYPE < (NB_MMU_MODES)
52 #define CPU_MMU_INDEX ACCESS_TYPE
53 #define MMUSUFFIX _mmu
55 #elif ACCESS_TYPE == (NB_MMU_MODES)
57 #define CPU_MMU_INDEX (cpu_mmu_index(env))
58 #define MMUSUFFIX _mmu
60 #elif ACCESS_TYPE == (NB_MMU_MODES + 1)
62 #define CPU_MMU_INDEX (cpu_mmu_index(env))
63 #define MMUSUFFIX _cmmu
66 #error invalid ACCESS_TYPE
70 #define RES_TYPE uint64_t
72 #define RES_TYPE uint32_t
75 #if ACCESS_TYPE == (NB_MMU_MODES + 1)
76 #define ADDR_READ addr_code
78 #define ADDR_READ addr_read
81 #ifndef CONFIG_TCG_PASS_AREG0
85 #define HELPER_PREFIX __
87 #define ENV_PARAM CPUArchState *env,
89 #define CPU_PREFIX cpu_
90 #define HELPER_PREFIX helper_
93 /* generic load/store macros */
95 static inline RES_TYPE
96 glue(glue(glue(CPU_PREFIX
, ld
), USUFFIX
), MEMSUFFIX
)(ENV_PARAM
102 unsigned long physaddr
;
106 page_index
= (addr
>> TARGET_PAGE_BITS
) & (CPU_TLB_SIZE
- 1);
107 mmu_idx
= CPU_MMU_INDEX
;
108 if (unlikely(env
->tlb_table
[mmu_idx
][page_index
].ADDR_READ
!=
109 (addr
& (TARGET_PAGE_MASK
| (DATA_SIZE
- 1))))) {
110 res
= glue(glue(glue(HELPER_PREFIX
, ld
), SUFFIX
), MMUSUFFIX
)(ENV_VAR
114 physaddr
= addr
+ env
->tlb_table
[mmu_idx
][page_index
].addend
;
115 res
= glue(glue(ld
, USUFFIX
), _raw
)((uint8_t *)physaddr
);
122 glue(glue(glue(CPU_PREFIX
, lds
), SUFFIX
), MEMSUFFIX
)(ENV_PARAM
127 unsigned long physaddr
;
131 page_index
= (addr
>> TARGET_PAGE_BITS
) & (CPU_TLB_SIZE
- 1);
132 mmu_idx
= CPU_MMU_INDEX
;
133 if (unlikely(env
->tlb_table
[mmu_idx
][page_index
].ADDR_READ
!=
134 (addr
& (TARGET_PAGE_MASK
| (DATA_SIZE
- 1))))) {
135 res
= (DATA_STYPE
)glue(glue(glue(HELPER_PREFIX
, ld
), SUFFIX
),
136 MMUSUFFIX
)(ENV_VAR addr
, mmu_idx
);
138 physaddr
= addr
+ env
->tlb_table
[mmu_idx
][page_index
].addend
;
139 res
= glue(glue(lds
, SUFFIX
), _raw
)((uint8_t *)physaddr
);
145 #if ACCESS_TYPE != (NB_MMU_MODES + 1)
147 /* generic store macro */
150 glue(glue(glue(CPU_PREFIX
, st
), SUFFIX
), MEMSUFFIX
)(ENV_PARAM target_ulong ptr
,
155 unsigned long physaddr
;
159 page_index
= (addr
>> TARGET_PAGE_BITS
) & (CPU_TLB_SIZE
- 1);
160 mmu_idx
= CPU_MMU_INDEX
;
161 if (unlikely(env
->tlb_table
[mmu_idx
][page_index
].addr_write
!=
162 (addr
& (TARGET_PAGE_MASK
| (DATA_SIZE
- 1))))) {
163 glue(glue(glue(HELPER_PREFIX
, st
), SUFFIX
), MMUSUFFIX
)(ENV_VAR addr
, v
,
166 physaddr
= addr
+ env
->tlb_table
[mmu_idx
][page_index
].addend
;
167 glue(glue(st
, SUFFIX
), _raw
)((uint8_t *)physaddr
, v
);
171 #endif /* ACCESS_TYPE != (NB_MMU_MODES + 1) */
173 #if ACCESS_TYPE != (NB_MMU_MODES + 1)
176 static inline float64
glue(glue(CPU_PREFIX
, ldfq
), MEMSUFFIX
)(ENV_PARAM
183 u
.i
= glue(glue(CPU_PREFIX
, ldq
), MEMSUFFIX
)(ENV_VAR ptr
);
187 static inline void glue(glue(CPU_PREFIX
, stfq
), MEMSUFFIX
)(ENV_PARAM
196 glue(glue(CPU_PREFIX
, stq
), MEMSUFFIX
)(ENV_VAR ptr
, u
.i
);
198 #endif /* DATA_SIZE == 8 */
201 static inline float32
glue(glue(CPU_PREFIX
, ldfl
), MEMSUFFIX
)(ENV_PARAM
208 u
.i
= glue(glue(CPU_PREFIX
, ldl
), MEMSUFFIX
)(ENV_VAR ptr
);
212 static inline void glue(glue(CPU_PREFIX
, stfl
), MEMSUFFIX
)(ENV_PARAM
221 glue(glue(CPU_PREFIX
, stl
), MEMSUFFIX
)(ENV_VAR ptr
, u
.i
);
223 #endif /* DATA_SIZE == 4 */
225 #endif /* ACCESS_TYPE != (NB_MMU_MODES + 1) */