4 * Copyright (c) 2003 Fabrice Bellard
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
21 * Oracle LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
22 * other than GPL or LGPL is available it will apply instead, Oracle elects to use only
23 * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
24 * a choice of LGPL license versions is made available with the language indicating
25 * that LGPLv2 or any later version may be used, or where a choice of which version
26 * of the LGPL is applied is otherwise unspecified.
32 #define DATA_TYPE uint64_t
36 #define DATA_TYPE uint32_t
40 #define DATA_TYPE uint16_t
41 #define DATA_STYPE int16_t
45 #define DATA_TYPE uint8_t
46 #define DATA_STYPE int8_t
48 #error unsupported data size
51 #if ACCESS_TYPE < (NB_MMU_MODES)
53 #define CPU_MMU_INDEX ACCESS_TYPE
54 #define MMUSUFFIX _mmu
56 #elif ACCESS_TYPE == (NB_MMU_MODES)
58 #define CPU_MMU_INDEX (cpu_mmu_index(env))
59 #define MMUSUFFIX _mmu
61 #elif ACCESS_TYPE == (NB_MMU_MODES + 1)
63 #define CPU_MMU_INDEX (cpu_mmu_index(env))
64 #define MMUSUFFIX _cmmu
67 #error invalid ACCESS_TYPE
71 #define RES_TYPE uint64_t
73 #define RES_TYPE uint32_t
76 #if ACCESS_TYPE == (NB_MMU_MODES + 1)
77 #define ADDR_READ addr_code
79 #define ADDR_READ addr_read
82 /* generic load/store macros */
84 static inline RES_TYPE
glue(glue(ld
, USUFFIX
), MEMSUFFIX
)(target_ulong ptr
)
93 page_index
= (addr
>> TARGET_PAGE_BITS
) & (CPU_TLB_SIZE
- 1);
94 mmu_idx
= CPU_MMU_INDEX
;
95 if (unlikely(env
->tlb_table
[mmu_idx
][page_index
].ADDR_READ
!=
96 (addr
& (TARGET_PAGE_MASK
| (DATA_SIZE
- 1))))) {
97 res
= glue(glue(__ld
, SUFFIX
), MMUSUFFIX
)(addr
, mmu_idx
);
99 physaddr
= addr
+ env
->tlb_table
[mmu_idx
][page_index
].addend
;
100 res
= glue(glue(ld
, USUFFIX
), _raw
)((uint8_t *)physaddr
);
106 static inline int glue(glue(lds
, SUFFIX
), MEMSUFFIX
)(target_ulong ptr
)
114 page_index
= (addr
>> TARGET_PAGE_BITS
) & (CPU_TLB_SIZE
- 1);
115 mmu_idx
= CPU_MMU_INDEX
;
116 if (unlikely(env
->tlb_table
[mmu_idx
][page_index
].ADDR_READ
!=
117 (addr
& (TARGET_PAGE_MASK
| (DATA_SIZE
- 1))))) {
118 res
= (DATA_STYPE
)glue(glue(__ld
, SUFFIX
), MMUSUFFIX
)(addr
, mmu_idx
);
120 physaddr
= addr
+ env
->tlb_table
[mmu_idx
][page_index
].addend
;
121 res
= glue(glue(lds
, SUFFIX
), _raw
)((uint8_t *)physaddr
);
127 #if ACCESS_TYPE != (NB_MMU_MODES + 1)
129 /* generic store macro */
131 static inline void glue(glue(st
, SUFFIX
), MEMSUFFIX
)(target_ulong ptr
, RES_TYPE v
)
139 page_index
= (addr
>> TARGET_PAGE_BITS
) & (CPU_TLB_SIZE
- 1);
140 mmu_idx
= CPU_MMU_INDEX
;
141 if (unlikely(env
->tlb_table
[mmu_idx
][page_index
].addr_write
!=
142 (addr
& (TARGET_PAGE_MASK
| (DATA_SIZE
- 1))))) {
143 glue(glue(__st
, SUFFIX
), MMUSUFFIX
)(addr
, v
, mmu_idx
);
145 physaddr
= addr
+ env
->tlb_table
[mmu_idx
][page_index
].addend
;
146 glue(glue(st
, SUFFIX
), _raw
)((uint8_t *)physaddr
, v
);
150 #endif /* ACCESS_TYPE != (NB_MMU_MODES + 1) */
152 #if ACCESS_TYPE != (NB_MMU_MODES + 1)
155 static inline float64
glue(ldfq
, MEMSUFFIX
)(target_ulong ptr
)
161 u
.i
= glue(ldq
, MEMSUFFIX
)(ptr
);
165 static inline void glue(stfq
, MEMSUFFIX
)(target_ulong ptr
, float64 v
)
172 glue(stq
, MEMSUFFIX
)(ptr
, u
.i
);
174 #endif /* DATA_SIZE == 8 */
177 static inline float32
glue(ldfl
, MEMSUFFIX
)(target_ulong ptr
)
183 u
.i
= glue(ldl
, MEMSUFFIX
)(ptr
);
187 static inline void glue(stfl
, MEMSUFFIX
)(target_ulong ptr
, float32 v
)
194 glue(stl
, MEMSUFFIX
)(ptr
, u
.i
);
196 #endif /* DATA_SIZE == 4 */
198 #endif /* ACCESS_TYPE != (NB_MMU_MODES + 1) */