VirtualBox

source: vbox/trunk/src/recompiler/softmmu_header.h@ 64696

最後變更 在這個檔案從64696是 42601,由 vboxsync 提交於 12 年 前

REM: Initial changes to make it work (seemingly) with MinGW-w64.

  • 屬性 svn:eol-style 設為 native
檔案大小: 5.3 KB
 
1/*
2 * Software MMU support
3 *
4 * Copyright (c) 2003 Fabrice Bellard
5 *
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.
10 *
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.
15 *
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/>.
18 */
19
20/*
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.
27 */
28
29#if DATA_SIZE == 8
30#define SUFFIX q
31#define USUFFIX q
32#define DATA_TYPE uint64_t
33#elif DATA_SIZE == 4
34#define SUFFIX l
35#define USUFFIX l
36#define DATA_TYPE uint32_t
37#elif DATA_SIZE == 2
38#define SUFFIX w
39#define USUFFIX uw
40#define DATA_TYPE uint16_t
41#define DATA_STYPE int16_t
42#elif DATA_SIZE == 1
43#define SUFFIX b
44#define USUFFIX ub
45#define DATA_TYPE uint8_t
46#define DATA_STYPE int8_t
47#else
48#error unsupported data size
49#endif
50
51#if ACCESS_TYPE < (NB_MMU_MODES)
52
53#define CPU_MMU_INDEX ACCESS_TYPE
54#define MMUSUFFIX _mmu
55
56#elif ACCESS_TYPE == (NB_MMU_MODES)
57
58#define CPU_MMU_INDEX (cpu_mmu_index(env))
59#define MMUSUFFIX _mmu
60
61#elif ACCESS_TYPE == (NB_MMU_MODES + 1)
62
63#define CPU_MMU_INDEX (cpu_mmu_index(env))
64#define MMUSUFFIX _cmmu
65
66#else
67#error invalid ACCESS_TYPE
68#endif
69
70#if DATA_SIZE == 8
71#define RES_TYPE uint64_t
72#else
73#define RES_TYPE uint32_t
74#endif
75
76#if ACCESS_TYPE == (NB_MMU_MODES + 1)
77#define ADDR_READ addr_code
78#else
79#define ADDR_READ addr_read
80#endif
81
82/* generic load/store macros */
83
84static inline RES_TYPE glue(glue(ld, USUFFIX), MEMSUFFIX)(target_ulong ptr)
85{
86 int page_index;
87 RES_TYPE res;
88 target_ulong addr;
89 uintptr_t physaddr;
90 int mmu_idx;
91
92 addr = 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);
98 } else {
99 physaddr = addr + env->tlb_table[mmu_idx][page_index].addend;
100 res = glue(glue(ld, USUFFIX), _raw)((uint8_t *)physaddr);
101 }
102 return res;
103}
104
105#if DATA_SIZE <= 2
106static inline int glue(glue(lds, SUFFIX), MEMSUFFIX)(target_ulong ptr)
107{
108 int res, page_index;
109 target_ulong addr;
110 uintptr_t physaddr;
111 int mmu_idx;
112
113 addr = 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);
119 } else {
120 physaddr = addr + env->tlb_table[mmu_idx][page_index].addend;
121 res = glue(glue(lds, SUFFIX), _raw)((uint8_t *)physaddr);
122 }
123 return res;
124}
125#endif
126
127#if ACCESS_TYPE != (NB_MMU_MODES + 1)
128
129/* generic store macro */
130
131static inline void glue(glue(st, SUFFIX), MEMSUFFIX)(target_ulong ptr, RES_TYPE v)
132{
133 int page_index;
134 target_ulong addr;
135 uintptr_t physaddr;
136 int mmu_idx;
137
138 addr = ptr;
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);
144 } else {
145 physaddr = addr + env->tlb_table[mmu_idx][page_index].addend;
146 glue(glue(st, SUFFIX), _raw)((uint8_t *)physaddr, v);
147 }
148}
149
150#endif /* ACCESS_TYPE != (NB_MMU_MODES + 1) */
151
152#if ACCESS_TYPE != (NB_MMU_MODES + 1)
153
154#if DATA_SIZE == 8
155static inline float64 glue(ldfq, MEMSUFFIX)(target_ulong ptr)
156{
157 union {
158 float64 d;
159 uint64_t i;
160 } u;
161 u.i = glue(ldq, MEMSUFFIX)(ptr);
162 return u.d;
163}
164
165static inline void glue(stfq, MEMSUFFIX)(target_ulong ptr, float64 v)
166{
167 union {
168 float64 d;
169 uint64_t i;
170 } u;
171 u.d = v;
172 glue(stq, MEMSUFFIX)(ptr, u.i);
173}
174#endif /* DATA_SIZE == 8 */
175
176#if DATA_SIZE == 4
177static inline float32 glue(ldfl, MEMSUFFIX)(target_ulong ptr)
178{
179 union {
180 float32 f;
181 uint32_t i;
182 } u;
183 u.i = glue(ldl, MEMSUFFIX)(ptr);
184 return u.f;
185}
186
187static inline void glue(stfl, MEMSUFFIX)(target_ulong ptr, float32 v)
188{
189 union {
190 float32 f;
191 uint32_t i;
192 } u;
193 u.f = v;
194 glue(stl, MEMSUFFIX)(ptr, u.i);
195}
196#endif /* DATA_SIZE == 4 */
197
198#endif /* ACCESS_TYPE != (NB_MMU_MODES + 1) */
199
200#undef RES_TYPE
201#undef DATA_TYPE
202#undef DATA_STYPE
203#undef SUFFIX
204#undef USUFFIX
205#undef DATA_SIZE
206#undef CPU_MMU_INDEX
207#undef MMUSUFFIX
208#undef ADDR_READ
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette