Commit e16c53fabbc3eea32be2837c08c8d4180429b2b8
1 parent
8351d2d4
assembly soft MMU defines on i386
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@524 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
150 additions
and
0 deletions
softmmu_header.h
... | ... | @@ -74,6 +74,152 @@ DATA_TYPE REGPARM(1) glue(glue(__ld, SUFFIX), MMUSUFFIX)(unsigned long addr, |
74 | 74 | int is_user); |
75 | 75 | void REGPARM(2) glue(glue(__st, SUFFIX), MMUSUFFIX)(unsigned long addr, DATA_TYPE v, int is_user); |
76 | 76 | |
77 | +#if (DATA_SIZE <= 4) && defined(__i386__) && (ACCESS_TYPE <= 1) && defined(ASM_SOFTMMU) | |
78 | + | |
79 | +static inline RES_TYPE glue(glue(ld, USUFFIX), MEMSUFFIX)(void *ptr) | |
80 | +{ | |
81 | + int res; | |
82 | + | |
83 | + asm volatile ("movl %1, %%edx\n" | |
84 | + "movl %1, %%eax\n" | |
85 | + "shrl %3, %%edx\n" | |
86 | + "andl %4, %%eax\n" | |
87 | + "andl %2, %%edx\n" | |
88 | + "leal %5(%%edx, %%ebp), %%edx\n" | |
89 | + "cmpl (%%edx), %%eax\n" | |
90 | + "movl %1, %%eax\n" | |
91 | + "je 1f\n" | |
92 | + "pushl %6\n" | |
93 | + "call %7\n" | |
94 | + "popl %%edx\n" | |
95 | + "movl %%eax, %0\n" | |
96 | + "jmp 2f\n" | |
97 | + "1:\n" | |
98 | + "addl 4(%%edx), %%eax\n" | |
99 | +#if DATA_SIZE == 1 | |
100 | + "movzbl (%%eax), %0\n" | |
101 | +#elif DATA_SIZE == 2 | |
102 | + "movzwl (%%eax), %0\n" | |
103 | +#elif DATA_SIZE == 4 | |
104 | + "movl (%%eax), %0\n" | |
105 | +#else | |
106 | +#error unsupported size | |
107 | +#endif | |
108 | + "2:\n" | |
109 | + : "=r" (res) | |
110 | + : "r" (ptr), | |
111 | + "i" ((CPU_TLB_SIZE - 1) << 3), | |
112 | + "i" (TARGET_PAGE_BITS - 3), | |
113 | + "i" (TARGET_PAGE_MASK | (DATA_SIZE - 1)), | |
114 | + "m" (*(uint32_t *)offsetof(CPUState, tlb_read[CPU_MEM_INDEX][0].address)), | |
115 | + "i" (CPU_MEM_INDEX), | |
116 | + "m" (*(uint8_t *)&glue(glue(__ld, SUFFIX), MMUSUFFIX)) | |
117 | + : "%eax", "%ecx", "%edx", "memory", "cc"); | |
118 | + return res; | |
119 | +} | |
120 | + | |
121 | +#if DATA_SIZE <= 2 | |
122 | +static inline int glue(glue(lds, SUFFIX), MEMSUFFIX)(void *ptr) | |
123 | +{ | |
124 | + int res; | |
125 | + | |
126 | + asm volatile ("movl %1, %%edx\n" | |
127 | + "movl %1, %%eax\n" | |
128 | + "shrl %3, %%edx\n" | |
129 | + "andl %4, %%eax\n" | |
130 | + "andl %2, %%edx\n" | |
131 | + "leal %5(%%edx, %%ebp), %%edx\n" | |
132 | + "cmpl (%%edx), %%eax\n" | |
133 | + "movl %1, %%eax\n" | |
134 | + "je 1f\n" | |
135 | + "pushl %6\n" | |
136 | + "call %7\n" | |
137 | + "popl %%edx\n" | |
138 | +#if DATA_SIZE == 1 | |
139 | + "movsbl %%al, %0\n" | |
140 | +#elif DATA_SIZE == 2 | |
141 | + "movswl %%ax, %0\n" | |
142 | +#else | |
143 | +#error unsupported size | |
144 | +#endif | |
145 | + "jmp 2f\n" | |
146 | + "1:\n" | |
147 | + "addl 4(%%edx), %%eax\n" | |
148 | +#if DATA_SIZE == 1 | |
149 | + "movsbl (%%eax), %0\n" | |
150 | +#elif DATA_SIZE == 2 | |
151 | + "movswl (%%eax), %0\n" | |
152 | +#else | |
153 | +#error unsupported size | |
154 | +#endif | |
155 | + "2:\n" | |
156 | + : "=r" (res) | |
157 | + : "r" (ptr), | |
158 | + "i" ((CPU_TLB_SIZE - 1) << 3), | |
159 | + "i" (TARGET_PAGE_BITS - 3), | |
160 | + "i" (TARGET_PAGE_MASK | (DATA_SIZE - 1)), | |
161 | + "m" (*(uint32_t *)offsetof(CPUState, tlb_read[CPU_MEM_INDEX][0].address)), | |
162 | + "i" (CPU_MEM_INDEX), | |
163 | + "m" (*(uint8_t *)&glue(glue(__ld, SUFFIX), MMUSUFFIX)) | |
164 | + : "%eax", "%ecx", "%edx", "memory", "cc"); | |
165 | + return res; | |
166 | +} | |
167 | +#endif | |
168 | + | |
169 | +static inline void glue(glue(st, SUFFIX), MEMSUFFIX)(void *ptr, RES_TYPE v) | |
170 | +{ | |
171 | + asm volatile ("movl %0, %%edx\n" | |
172 | + "movl %0, %%eax\n" | |
173 | + "shrl %3, %%edx\n" | |
174 | + "andl %4, %%eax\n" | |
175 | + "andl %2, %%edx\n" | |
176 | + "leal %5(%%edx, %%ebp), %%edx\n" | |
177 | + "cmpl (%%edx), %%eax\n" | |
178 | + "movl %0, %%eax\n" | |
179 | + "je 1f\n" | |
180 | +#if DATA_SIZE == 1 | |
181 | + "movzbl %b1, %%edx\n" | |
182 | +#elif DATA_SIZE == 2 | |
183 | + "movzwl %w1, %%edx\n" | |
184 | +#elif DATA_SIZE == 4 | |
185 | + "movl %1, %%edx\n" | |
186 | +#else | |
187 | +#error unsupported size | |
188 | +#endif | |
189 | + "pushl %6\n" | |
190 | + "call %7\n" | |
191 | + "popl %%eax\n" | |
192 | + "jmp 2f\n" | |
193 | + "1:\n" | |
194 | + "addl 4(%%edx), %%eax\n" | |
195 | +#if DATA_SIZE == 1 | |
196 | + "movb %b1, (%%eax)\n" | |
197 | +#elif DATA_SIZE == 2 | |
198 | + "movw %w1, (%%eax)\n" | |
199 | +#elif DATA_SIZE == 4 | |
200 | + "movl %1, (%%eax)\n" | |
201 | +#else | |
202 | +#error unsupported size | |
203 | +#endif | |
204 | + "2:\n" | |
205 | + : | |
206 | + : "r" (ptr), | |
207 | +/* NOTE: 'q' would be needed as constraint, but we could not use it | |
208 | + with T1 ! */ | |
209 | + "r" (v), | |
210 | + "i" ((CPU_TLB_SIZE - 1) << 3), | |
211 | + "i" (TARGET_PAGE_BITS - 3), | |
212 | + "i" (TARGET_PAGE_MASK | (DATA_SIZE - 1)), | |
213 | + "m" (*(uint32_t *)offsetof(CPUState, tlb_write[CPU_MEM_INDEX][0].address)), | |
214 | + "i" (CPU_MEM_INDEX), | |
215 | + "m" (*(uint8_t *)&glue(glue(__st, SUFFIX), MMUSUFFIX)) | |
216 | + : "%eax", "%ecx", "%edx", "memory", "cc"); | |
217 | +} | |
218 | + | |
219 | +#else | |
220 | + | |
221 | +/* generic load/store macros */ | |
222 | + | |
77 | 223 | static inline RES_TYPE glue(glue(ld, USUFFIX), MEMSUFFIX)(void *ptr) |
78 | 224 | { |
79 | 225 | int index; |
... | ... | @@ -115,6 +261,8 @@ static inline int glue(glue(lds, SUFFIX), MEMSUFFIX)(void *ptr) |
115 | 261 | } |
116 | 262 | #endif |
117 | 263 | |
264 | +/* generic store macro */ | |
265 | + | |
118 | 266 | static inline void glue(glue(st, SUFFIX), MEMSUFFIX)(void *ptr, RES_TYPE v) |
119 | 267 | { |
120 | 268 | int index; |
... | ... | @@ -133,6 +281,8 @@ static inline void glue(glue(st, SUFFIX), MEMSUFFIX)(void *ptr, RES_TYPE v) |
133 | 281 | } |
134 | 282 | } |
135 | 283 | |
284 | +#endif | |
285 | + | |
136 | 286 | #undef RES_TYPE |
137 | 287 | #undef DATA_TYPE |
138 | 288 | #undef DATA_STYPE | ... | ... |