345
by bellard
Software MMU support (used for memory mapped devices such as VGA) |
1 |
/*
|
2 |
* Software MMU support
|
|
3163
by ths
find -type f | xargs sed -i 's/[\t ]$//g' # on most files |
3 |
*
|
345
by bellard
Software MMU support (used for memory mapped devices such as VGA) |
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, write to the Free Software
|
|
18 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
19 |
*/
|
|
20 |
#define DATA_SIZE (1 << SHIFT)
|
|
21 |
||
22 |
#if DATA_SIZE == 8
|
|
23 |
#define SUFFIX q
|
|
408
by bellard
full softmmu support |
24 |
#define USUFFIX q
|
345
by bellard
Software MMU support (used for memory mapped devices such as VGA) |
25 |
#define DATA_TYPE uint64_t
|
26 |
#elif DATA_SIZE == 4
|
|
27 |
#define SUFFIX l
|
|
408
by bellard
full softmmu support |
28 |
#define USUFFIX l
|
345
by bellard
Software MMU support (used for memory mapped devices such as VGA) |
29 |
#define DATA_TYPE uint32_t
|
30 |
#elif DATA_SIZE == 2
|
|
31 |
#define SUFFIX w
|
|
408
by bellard
full softmmu support |
32 |
#define USUFFIX uw
|
345
by bellard
Software MMU support (used for memory mapped devices such as VGA) |
33 |
#define DATA_TYPE uint16_t
|
34 |
#elif DATA_SIZE == 1
|
|
35 |
#define SUFFIX b
|
|
408
by bellard
full softmmu support |
36 |
#define USUFFIX ub
|
345
by bellard
Software MMU support (used for memory mapped devices such as VGA) |
37 |
#define DATA_TYPE uint8_t
|
38 |
#else
|
|
39 |
#error unsupported data size
|
|
40 |
#endif
|
|
41 |
||
1091
by bellard
removed access_type hack |
42 |
#ifdef SOFTMMU_CODE_ACCESS
|
43 |
#define READ_ACCESS_TYPE 2
|
|
1669
by bellard
PAGE_EXEC support in TLBs |
44 |
#define ADDR_READ addr_code
|
1091
by bellard
removed access_type hack |
45 |
#else
|
46 |
#define READ_ACCESS_TYPE 0
|
|
1669
by bellard
PAGE_EXEC support in TLBs |
47 |
#define ADDR_READ addr_read
|
1091
by bellard
removed access_type hack |
48 |
#endif
|
49 |
||
3163
by ths
find -type f | xargs sed -i 's/[\t ]$//g' # on most files |
50 |
static DATA_TYPE glue(glue(slow_ld, SUFFIX), MMUSUFFIX)(target_ulong addr, |
3374
by j_mayer
Replace is_user variable with mmu_idx in softmmu core, |
51 |
int mmu_idx, |
408
by bellard
full softmmu support |
52 |
void *retaddr); |
3163
by ths
find -type f | xargs sed -i 's/[\t ]$//g' # on most files |
53 |
static inline DATA_TYPE glue(io_read, SUFFIX)(target_phys_addr_t physaddr, |
1184
by bellard
64 bit target support |
54 |
target_ulong tlb_addr) |
345
by bellard
Software MMU support (used for memory mapped devices such as VGA) |
55 |
{
|
56 |
DATA_TYPE res; |
|
57 |
int index; |
|
58 |
||
59 |
index = (tlb_addr >> IO_MEM_SHIFT) & (IO_MEM_NB_ENTRIES - 1); |
|
60 |
#if SHIFT <= 2
|
|
871
by bellard
support for opaque data on memory I/Os |
61 |
res = io_mem_read[index][SHIFT](io_mem_opaque[index], physaddr); |
345
by bellard
Software MMU support (used for memory mapped devices such as VGA) |
62 |
#else
|
63 |
#ifdef TARGET_WORDS_BIGENDIAN
|
|
871
by bellard
support for opaque data on memory I/Os |
64 |
res = (uint64_t)io_mem_read[index][2](io_mem_opaque[index], physaddr) << 32; |
65 |
res |= io_mem_read[index][2](io_mem_opaque[index], physaddr + 4); |
|
345
by bellard
Software MMU support (used for memory mapped devices such as VGA) |
66 |
#else
|
871
by bellard
support for opaque data on memory I/Os |
67 |
res = io_mem_read[index][2](io_mem_opaque[index], physaddr); |
68 |
res |= (uint64_t)io_mem_read[index][2](io_mem_opaque[index], physaddr + 4) << 32; |
|
345
by bellard
Software MMU support (used for memory mapped devices such as VGA) |
69 |
#endif
|
70 |
#endif /* SHIFT > 2 */ |
|
1745
by bellard
added last_io_time field |
71 |
#ifdef USE_KQEMU
|
72 |
env->last_io_time = cpu_get_time_fast(); |
|
73 |
#endif
|
|
345
by bellard
Software MMU support (used for memory mapped devices such as VGA) |
74 |
return res; |
75 |
}
|
|
76 |
||
77 |
/* handle all cases except unaligned access which span two pages */
|
|
1184
by bellard
64 bit target support |
78 |
DATA_TYPE REGPARM(1) glue(glue(__ld, SUFFIX), MMUSUFFIX)(target_ulong addr, |
3374
by j_mayer
Replace is_user variable with mmu_idx in softmmu core, |
79 |
int mmu_idx) |
345
by bellard
Software MMU support (used for memory mapped devices such as VGA) |
80 |
{
|
81 |
DATA_TYPE res; |
|
408
by bellard
full softmmu support |
82 |
int index; |
1184
by bellard
64 bit target support |
83 |
target_ulong tlb_addr; |
1520
by bellard
allow more than 32 bit of physical memory |
84 |
target_phys_addr_t physaddr; |
345
by bellard
Software MMU support (used for memory mapped devices such as VGA) |
85 |
void *retaddr; |
3167
by ths
find -type f | xargs sed -i 's/[\t ]*$//g' # Yes, again. Note the star in the regex. |
86 |
|
345
by bellard
Software MMU support (used for memory mapped devices such as VGA) |
87 |
/* test if there is match for unaligned or IO access */
|
88 |
/* XXX: could done more in memory macro in a non portable way */
|
|
89 |
index = (addr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1); |
|
90 |
redo: |
|
3374
by j_mayer
Replace is_user variable with mmu_idx in softmmu core, |
91 |
tlb_addr = env->tlb_table[mmu_idx][index].ADDR_READ; |
345
by bellard
Software MMU support (used for memory mapped devices such as VGA) |
92 |
if ((addr & TARGET_PAGE_MASK) == (tlb_addr & (TARGET_PAGE_MASK | TLB_INVALID_MASK))) { |
3374
by j_mayer
Replace is_user variable with mmu_idx in softmmu core, |
93 |
physaddr = addr + env->tlb_table[mmu_idx][index].addend; |
345
by bellard
Software MMU support (used for memory mapped devices such as VGA) |
94 |
if (tlb_addr & ~TARGET_PAGE_MASK) { |
95 |
/* IO access */
|
|
96 |
if ((addr & (DATA_SIZE - 1)) != 0) |
|
97 |
goto do_unaligned_access; |
|
98 |
res = glue(io_read, SUFFIX)(physaddr, tlb_addr); |
|
1652
by bellard
use TARGET_PAGE_SIZE (Paul Brook) |
99 |
} else if (((addr & ~TARGET_PAGE_MASK) + DATA_SIZE - 1) >= TARGET_PAGE_SIZE) { |
345
by bellard
Software MMU support (used for memory mapped devices such as VGA) |
100 |
/* slow unaligned access (it spans two pages or IO) */
|
101 |
do_unaligned_access: |
|
408
by bellard
full softmmu support |
102 |
retaddr = GETPC(); |
1681
by bellard
MIPS unaligned accesses exceptions (Daniel Jacobowitz) |
103 |
#ifdef ALIGNED_ONLY
|
3374
by j_mayer
Replace is_user variable with mmu_idx in softmmu core, |
104 |
do_unaligned_access(addr, READ_ACCESS_TYPE, mmu_idx, retaddr); |
1681
by bellard
MIPS unaligned accesses exceptions (Daniel Jacobowitz) |
105 |
#endif
|
3163
by ths
find -type f | xargs sed -i 's/[\t ]$//g' # on most files |
106 |
res = glue(glue(slow_ld, SUFFIX), MMUSUFFIX)(addr, |
3374
by j_mayer
Replace is_user variable with mmu_idx in softmmu core, |
107 |
mmu_idx, retaddr); |
345
by bellard
Software MMU support (used for memory mapped devices such as VGA) |
108 |
} else { |
1681
by bellard
MIPS unaligned accesses exceptions (Daniel Jacobowitz) |
109 |
/* unaligned/aligned access in the same page */
|
110 |
#ifdef ALIGNED_ONLY
|
|
111 |
if ((addr & (DATA_SIZE - 1)) != 0) { |
|
112 |
retaddr = GETPC(); |
|
3374
by j_mayer
Replace is_user variable with mmu_idx in softmmu core, |
113 |
do_unaligned_access(addr, READ_ACCESS_TYPE, mmu_idx, retaddr); |
1681
by bellard
MIPS unaligned accesses exceptions (Daniel Jacobowitz) |
114 |
}
|
115 |
#endif
|
|
1520
by bellard
allow more than 32 bit of physical memory |
116 |
res = glue(glue(ld, USUFFIX), _raw)((uint8_t *)(long)physaddr); |
345
by bellard
Software MMU support (used for memory mapped devices such as VGA) |
117 |
}
|
118 |
} else { |
|
119 |
/* the page is not in the TLB : fill it */
|
|
408
by bellard
full softmmu support |
120 |
retaddr = GETPC(); |
1681
by bellard
MIPS unaligned accesses exceptions (Daniel Jacobowitz) |
121 |
#ifdef ALIGNED_ONLY
|
122 |
if ((addr & (DATA_SIZE - 1)) != 0) |
|
3374
by j_mayer
Replace is_user variable with mmu_idx in softmmu core, |
123 |
do_unaligned_access(addr, READ_ACCESS_TYPE, mmu_idx, retaddr); |
1681
by bellard
MIPS unaligned accesses exceptions (Daniel Jacobowitz) |
124 |
#endif
|
3374
by j_mayer
Replace is_user variable with mmu_idx in softmmu core, |
125 |
tlb_fill(addr, READ_ACCESS_TYPE, mmu_idx, retaddr); |
345
by bellard
Software MMU support (used for memory mapped devices such as VGA) |
126 |
goto redo; |
127 |
}
|
|
128 |
return res; |
|
129 |
}
|
|
130 |
||
131 |
/* handle all unaligned cases */
|
|
3163
by ths
find -type f | xargs sed -i 's/[\t ]$//g' # on most files |
132 |
static DATA_TYPE glue(glue(slow_ld, SUFFIX), MMUSUFFIX)(target_ulong addr, |
3374
by j_mayer
Replace is_user variable with mmu_idx in softmmu core, |
133 |
int mmu_idx, |
408
by bellard
full softmmu support |
134 |
void *retaddr) |
345
by bellard
Software MMU support (used for memory mapped devices such as VGA) |
135 |
{
|
136 |
DATA_TYPE res, res1, res2; |
|
408
by bellard
full softmmu support |
137 |
int index, shift; |
1520
by bellard
allow more than 32 bit of physical memory |
138 |
target_phys_addr_t physaddr; |
1184
by bellard
64 bit target support |
139 |
target_ulong tlb_addr, addr1, addr2; |
345
by bellard
Software MMU support (used for memory mapped devices such as VGA) |
140 |
|
141 |
index = (addr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1); |
|
142 |
redo: |
|
3374
by j_mayer
Replace is_user variable with mmu_idx in softmmu core, |
143 |
tlb_addr = env->tlb_table[mmu_idx][index].ADDR_READ; |
345
by bellard
Software MMU support (used for memory mapped devices such as VGA) |
144 |
if ((addr & TARGET_PAGE_MASK) == (tlb_addr & (TARGET_PAGE_MASK | TLB_INVALID_MASK))) { |
3374
by j_mayer
Replace is_user variable with mmu_idx in softmmu core, |
145 |
physaddr = addr + env->tlb_table[mmu_idx][index].addend; |
345
by bellard
Software MMU support (used for memory mapped devices such as VGA) |
146 |
if (tlb_addr & ~TARGET_PAGE_MASK) { |
147 |
/* IO access */
|
|
148 |
if ((addr & (DATA_SIZE - 1)) != 0) |
|
149 |
goto do_unaligned_access; |
|
150 |
res = glue(io_read, SUFFIX)(physaddr, tlb_addr); |
|
1652
by bellard
use TARGET_PAGE_SIZE (Paul Brook) |
151 |
} else if (((addr & ~TARGET_PAGE_MASK) + DATA_SIZE - 1) >= TARGET_PAGE_SIZE) { |
345
by bellard
Software MMU support (used for memory mapped devices such as VGA) |
152 |
do_unaligned_access: |
153 |
/* slow unaligned access (it spans two pages) */
|
|
154 |
addr1 = addr & ~(DATA_SIZE - 1); |
|
155 |
addr2 = addr1 + DATA_SIZE; |
|
3163
by ths
find -type f | xargs sed -i 's/[\t ]$//g' # on most files |
156 |
res1 = glue(glue(slow_ld, SUFFIX), MMUSUFFIX)(addr1, |
3374
by j_mayer
Replace is_user variable with mmu_idx in softmmu core, |
157 |
mmu_idx, retaddr); |
3163
by ths
find -type f | xargs sed -i 's/[\t ]$//g' # on most files |
158 |
res2 = glue(glue(slow_ld, SUFFIX), MMUSUFFIX)(addr2, |
3374
by j_mayer
Replace is_user variable with mmu_idx in softmmu core, |
159 |
mmu_idx, retaddr); |
345
by bellard
Software MMU support (used for memory mapped devices such as VGA) |
160 |
shift = (addr & (DATA_SIZE - 1)) * 8; |
161 |
#ifdef TARGET_WORDS_BIGENDIAN
|
|
162 |
res = (res1 << shift) | (res2 >> ((DATA_SIZE * 8) - shift)); |
|
163 |
#else
|
|
164 |
res = (res1 >> shift) | (res2 << ((DATA_SIZE * 8) - shift)); |
|
165 |
#endif
|
|
553
by bellard
cast to return type |
166 |
res = (DATA_TYPE)res; |
345
by bellard
Software MMU support (used for memory mapped devices such as VGA) |
167 |
} else { |
168 |
/* unaligned/aligned access in the same page */
|
|
1520
by bellard
allow more than 32 bit of physical memory |
169 |
res = glue(glue(ld, USUFFIX), _raw)((uint8_t *)(long)physaddr); |
345
by bellard
Software MMU support (used for memory mapped devices such as VGA) |
170 |
}
|
171 |
} else { |
|
172 |
/* the page is not in the TLB : fill it */
|
|
3374
by j_mayer
Replace is_user variable with mmu_idx in softmmu core, |
173 |
tlb_fill(addr, READ_ACCESS_TYPE, mmu_idx, retaddr); |
345
by bellard
Software MMU support (used for memory mapped devices such as VGA) |
174 |
goto redo; |
175 |
}
|
|
176 |
return res; |
|
177 |
}
|
|
178 |
||
1091
by bellard
removed access_type hack |
179 |
#ifndef SOFTMMU_CODE_ACCESS
|
180 |
||
3163
by ths
find -type f | xargs sed -i 's/[\t ]$//g' # on most files |
181 |
static void glue(glue(slow_st, SUFFIX), MMUSUFFIX)(target_ulong addr, |
182 |
DATA_TYPE val, |
|
3374
by j_mayer
Replace is_user variable with mmu_idx in softmmu core, |
183 |
int mmu_idx, |
1091
by bellard
removed access_type hack |
184 |
void *retaddr); |
185 |
||
3163
by ths
find -type f | xargs sed -i 's/[\t ]$//g' # on most files |
186 |
static inline void glue(io_write, SUFFIX)(target_phys_addr_t physaddr, |
1091
by bellard
removed access_type hack |
187 |
DATA_TYPE val, |
1184
by bellard
64 bit target support |
188 |
target_ulong tlb_addr, |
1091
by bellard
removed access_type hack |
189 |
void *retaddr) |
190 |
{
|
|
191 |
int index; |
|
192 |
||
193 |
index = (tlb_addr >> IO_MEM_SHIFT) & (IO_MEM_NB_ENTRIES - 1); |
|
194 |
env->mem_write_vaddr = tlb_addr; |
|
195 |
env->mem_write_pc = (unsigned long)retaddr; |
|
196 |
#if SHIFT <= 2
|
|
197 |
io_mem_write[index][SHIFT](io_mem_opaque[index], physaddr, val); |
|
198 |
#else
|
|
199 |
#ifdef TARGET_WORDS_BIGENDIAN
|
|
200 |
io_mem_write[index][2](io_mem_opaque[index], physaddr, val >> 32); |
|
201 |
io_mem_write[index][2](io_mem_opaque[index], physaddr + 4, val); |
|
202 |
#else
|
|
203 |
io_mem_write[index][2](io_mem_opaque[index], physaddr, val); |
|
204 |
io_mem_write[index][2](io_mem_opaque[index], physaddr + 4, val >> 32); |
|
205 |
#endif
|
|
206 |
#endif /* SHIFT > 2 */ |
|
1745
by bellard
added last_io_time field |
207 |
#ifdef USE_KQEMU
|
208 |
env->last_io_time = cpu_get_time_fast(); |
|
209 |
#endif
|
|
1091
by bellard
removed access_type hack |
210 |
}
|
345
by bellard
Software MMU support (used for memory mapped devices such as VGA) |
211 |
|
3163
by ths
find -type f | xargs sed -i 's/[\t ]$//g' # on most files |
212 |
void REGPARM(2) glue(glue(__st, SUFFIX), MMUSUFFIX)(target_ulong addr, |
408
by bellard
full softmmu support |
213 |
DATA_TYPE val, |
3374
by j_mayer
Replace is_user variable with mmu_idx in softmmu core, |
214 |
int mmu_idx) |
345
by bellard
Software MMU support (used for memory mapped devices such as VGA) |
215 |
{
|
1520
by bellard
allow more than 32 bit of physical memory |
216 |
target_phys_addr_t physaddr; |
1184
by bellard
64 bit target support |
217 |
target_ulong tlb_addr; |
345
by bellard
Software MMU support (used for memory mapped devices such as VGA) |
218 |
void *retaddr; |
408
by bellard
full softmmu support |
219 |
int index; |
3167
by ths
find -type f | xargs sed -i 's/[\t ]*$//g' # Yes, again. Note the star in the regex. |
220 |
|
345
by bellard
Software MMU support (used for memory mapped devices such as VGA) |
221 |
index = (addr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1); |
222 |
redo: |
|
3374
by j_mayer
Replace is_user variable with mmu_idx in softmmu core, |
223 |
tlb_addr = env->tlb_table[mmu_idx][index].addr_write; |
345
by bellard
Software MMU support (used for memory mapped devices such as VGA) |
224 |
if ((addr & TARGET_PAGE_MASK) == (tlb_addr & (TARGET_PAGE_MASK | TLB_INVALID_MASK))) { |
3374
by j_mayer
Replace is_user variable with mmu_idx in softmmu core, |
225 |
physaddr = addr + env->tlb_table[mmu_idx][index].addend; |
345
by bellard
Software MMU support (used for memory mapped devices such as VGA) |
226 |
if (tlb_addr & ~TARGET_PAGE_MASK) { |
227 |
/* IO access */
|
|
228 |
if ((addr & (DATA_SIZE - 1)) != 0) |
|
229 |
goto do_unaligned_access; |
|
742
by bellard
precise self modifying code support |
230 |
retaddr = GETPC(); |
231 |
glue(io_write, SUFFIX)(physaddr, val, tlb_addr, retaddr); |
|
1652
by bellard
use TARGET_PAGE_SIZE (Paul Brook) |
232 |
} else if (((addr & ~TARGET_PAGE_MASK) + DATA_SIZE - 1) >= TARGET_PAGE_SIZE) { |
345
by bellard
Software MMU support (used for memory mapped devices such as VGA) |
233 |
do_unaligned_access: |
408
by bellard
full softmmu support |
234 |
retaddr = GETPC(); |
1681
by bellard
MIPS unaligned accesses exceptions (Daniel Jacobowitz) |
235 |
#ifdef ALIGNED_ONLY
|
3374
by j_mayer
Replace is_user variable with mmu_idx in softmmu core, |
236 |
do_unaligned_access(addr, 1, mmu_idx, retaddr); |
1681
by bellard
MIPS unaligned accesses exceptions (Daniel Jacobowitz) |
237 |
#endif
|
3163
by ths
find -type f | xargs sed -i 's/[\t ]$//g' # on most files |
238 |
glue(glue(slow_st, SUFFIX), MMUSUFFIX)(addr, val, |
3374
by j_mayer
Replace is_user variable with mmu_idx in softmmu core, |
239 |
mmu_idx, retaddr); |
345
by bellard
Software MMU support (used for memory mapped devices such as VGA) |
240 |
} else { |
241 |
/* aligned/unaligned access in the same page */
|
|
1681
by bellard
MIPS unaligned accesses exceptions (Daniel Jacobowitz) |
242 |
#ifdef ALIGNED_ONLY
|
243 |
if ((addr & (DATA_SIZE - 1)) != 0) { |
|
244 |
retaddr = GETPC(); |
|
3374
by j_mayer
Replace is_user variable with mmu_idx in softmmu core, |
245 |
do_unaligned_access(addr, 1, mmu_idx, retaddr); |
1681
by bellard
MIPS unaligned accesses exceptions (Daniel Jacobowitz) |
246 |
}
|
247 |
#endif
|
|
1520
by bellard
allow more than 32 bit of physical memory |
248 |
glue(glue(st, SUFFIX), _raw)((uint8_t *)(long)physaddr, val); |
345
by bellard
Software MMU support (used for memory mapped devices such as VGA) |
249 |
}
|
250 |
} else { |
|
251 |
/* the page is not in the TLB : fill it */
|
|
408
by bellard
full softmmu support |
252 |
retaddr = GETPC(); |
1681
by bellard
MIPS unaligned accesses exceptions (Daniel Jacobowitz) |
253 |
#ifdef ALIGNED_ONLY
|
254 |
if ((addr & (DATA_SIZE - 1)) != 0) |
|
3374
by j_mayer
Replace is_user variable with mmu_idx in softmmu core, |
255 |
do_unaligned_access(addr, 1, mmu_idx, retaddr); |
1681
by bellard
MIPS unaligned accesses exceptions (Daniel Jacobowitz) |
256 |
#endif
|
3374
by j_mayer
Replace is_user variable with mmu_idx in softmmu core, |
257 |
tlb_fill(addr, 1, mmu_idx, retaddr); |
345
by bellard
Software MMU support (used for memory mapped devices such as VGA) |
258 |
goto redo; |
259 |
}
|
|
260 |
}
|
|
261 |
||
262 |
/* handles all unaligned cases */
|
|
3163
by ths
find -type f | xargs sed -i 's/[\t ]$//g' # on most files |
263 |
static void glue(glue(slow_st, SUFFIX), MMUSUFFIX)(target_ulong addr, |
408
by bellard
full softmmu support |
264 |
DATA_TYPE val, |
3374
by j_mayer
Replace is_user variable with mmu_idx in softmmu core, |
265 |
int mmu_idx, |
408
by bellard
full softmmu support |
266 |
void *retaddr) |
345
by bellard
Software MMU support (used for memory mapped devices such as VGA) |
267 |
{
|
1520
by bellard
allow more than 32 bit of physical memory |
268 |
target_phys_addr_t physaddr; |
1184
by bellard
64 bit target support |
269 |
target_ulong tlb_addr; |
408
by bellard
full softmmu support |
270 |
int index, i; |
345
by bellard
Software MMU support (used for memory mapped devices such as VGA) |
271 |
|
272 |
index = (addr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1); |
|
273 |
redo: |
|
3374
by j_mayer
Replace is_user variable with mmu_idx in softmmu core, |
274 |
tlb_addr = env->tlb_table[mmu_idx][index].addr_write; |
345
by bellard
Software MMU support (used for memory mapped devices such as VGA) |
275 |
if ((addr & TARGET_PAGE_MASK) == (tlb_addr & (TARGET_PAGE_MASK | TLB_INVALID_MASK))) { |
3374
by j_mayer
Replace is_user variable with mmu_idx in softmmu core, |
276 |
physaddr = addr + env->tlb_table[mmu_idx][index].addend; |
345
by bellard
Software MMU support (used for memory mapped devices such as VGA) |
277 |
if (tlb_addr & ~TARGET_PAGE_MASK) { |
278 |
/* IO access */
|
|
279 |
if ((addr & (DATA_SIZE - 1)) != 0) |
|
280 |
goto do_unaligned_access; |
|
742
by bellard
precise self modifying code support |
281 |
glue(io_write, SUFFIX)(physaddr, val, tlb_addr, retaddr); |
1652
by bellard
use TARGET_PAGE_SIZE (Paul Brook) |
282 |
} else if (((addr & ~TARGET_PAGE_MASK) + DATA_SIZE - 1) >= TARGET_PAGE_SIZE) { |
345
by bellard
Software MMU support (used for memory mapped devices such as VGA) |
283 |
do_unaligned_access: |
284 |
/* XXX: not efficient, but simple */
|
|
3659
by balrog
Don't compare '\0' against pointers. |
285 |
/* Note: relies on the fact that tlb_fill() does not remove the
|
286 |
* previous page from the TLB cache. */
|
|
3655
by balrog
Check permissions for the last byte first in unaligned slow_st accesses (patch from TeLeMan). |
287 |
for(i = DATA_SIZE - 1; i >= 0; i--) { |
345
by bellard
Software MMU support (used for memory mapped devices such as VGA) |
288 |
#ifdef TARGET_WORDS_BIGENDIAN
|
3163
by ths
find -type f | xargs sed -i 's/[\t ]$//g' # on most files |
289 |
glue(slow_stb, MMUSUFFIX)(addr + i, val >> (((DATA_SIZE - 1) * 8) - (i * 8)), |
3374
by j_mayer
Replace is_user variable with mmu_idx in softmmu core, |
290 |
mmu_idx, retaddr); |
345
by bellard
Software MMU support (used for memory mapped devices such as VGA) |
291 |
#else
|
3163
by ths
find -type f | xargs sed -i 's/[\t ]$//g' # on most files |
292 |
glue(slow_stb, MMUSUFFIX)(addr + i, val >> (i * 8), |
3374
by j_mayer
Replace is_user variable with mmu_idx in softmmu core, |
293 |
mmu_idx, retaddr); |
345
by bellard
Software MMU support (used for memory mapped devices such as VGA) |
294 |
#endif
|
295 |
}
|
|
296 |
} else { |
|
297 |
/* aligned/unaligned access in the same page */
|
|
1520
by bellard
allow more than 32 bit of physical memory |
298 |
glue(glue(st, SUFFIX), _raw)((uint8_t *)(long)physaddr, val); |
345
by bellard
Software MMU support (used for memory mapped devices such as VGA) |
299 |
}
|
300 |
} else { |
|
301 |
/* the page is not in the TLB : fill it */
|
|
3374
by j_mayer
Replace is_user variable with mmu_idx in softmmu core, |
302 |
tlb_fill(addr, 1, mmu_idx, retaddr); |
345
by bellard
Software MMU support (used for memory mapped devices such as VGA) |
303 |
goto redo; |
304 |
}
|
|
305 |
}
|
|
306 |
||
1091
by bellard
removed access_type hack |
307 |
#endif /* !defined(SOFTMMU_CODE_ACCESS) */ |
308 |
||
309 |
#undef READ_ACCESS_TYPE
|
|
345
by bellard
Software MMU support (used for memory mapped devices such as VGA) |
310 |
#undef SHIFT
|
311 |
#undef DATA_TYPE
|
|
312 |
#undef SUFFIX
|
|
408
by bellard
full softmmu support |
313 |
#undef USUFFIX
|
345
by bellard
Software MMU support (used for memory mapped devices such as VGA) |
314 |
#undef DATA_SIZE
|
1669
by bellard
PAGE_EXEC support in TLBs |
315 |
#undef ADDR_READ
|