root / target-microblaze / mmu.c @ ab9adc88
History | View | Annotate | Download (8.9 kB)
1 | afeeceb0 | Edgar E. Iglesias | /*
|
---|---|---|---|
2 | afeeceb0 | Edgar E. Iglesias | * Microblaze MMU emulation for qemu.
|
3 | afeeceb0 | Edgar E. Iglesias | *
|
4 | afeeceb0 | Edgar E. Iglesias | * Copyright (c) 2009 Edgar E. Iglesias
|
5 | afeeceb0 | Edgar E. Iglesias | *
|
6 | afeeceb0 | Edgar E. Iglesias | * This library is free software; you can redistribute it and/or
|
7 | afeeceb0 | Edgar E. Iglesias | * modify it under the terms of the GNU Lesser General Public
|
8 | afeeceb0 | Edgar E. Iglesias | * License as published by the Free Software Foundation; either
|
9 | afeeceb0 | Edgar E. Iglesias | * version 2 of the License, or (at your option) any later version.
|
10 | afeeceb0 | Edgar E. Iglesias | *
|
11 | afeeceb0 | Edgar E. Iglesias | * This library is distributed in the hope that it will be useful,
|
12 | afeeceb0 | Edgar E. Iglesias | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 | afeeceb0 | Edgar E. Iglesias | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14 | afeeceb0 | Edgar E. Iglesias | * Lesser General Public License for more details.
|
15 | afeeceb0 | Edgar E. Iglesias | *
|
16 | afeeceb0 | Edgar E. Iglesias | * You should have received a copy of the GNU Lesser General Public
|
17 | 8167ee88 | Blue Swirl | * License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
18 | afeeceb0 | Edgar E. Iglesias | */
|
19 | afeeceb0 | Edgar E. Iglesias | #include <stdio.h> |
20 | afeeceb0 | Edgar E. Iglesias | #include <stdlib.h> |
21 | afeeceb0 | Edgar E. Iglesias | #include <assert.h> |
22 | afeeceb0 | Edgar E. Iglesias | |
23 | afeeceb0 | Edgar E. Iglesias | #include "config.h" |
24 | afeeceb0 | Edgar E. Iglesias | #include "cpu.h" |
25 | afeeceb0 | Edgar E. Iglesias | #include "exec-all.h" |
26 | afeeceb0 | Edgar E. Iglesias | |
27 | afeeceb0 | Edgar E. Iglesias | #define D(x)
|
28 | afeeceb0 | Edgar E. Iglesias | |
29 | afeeceb0 | Edgar E. Iglesias | static unsigned int tlb_decode_size(unsigned int f) |
30 | afeeceb0 | Edgar E. Iglesias | { |
31 | afeeceb0 | Edgar E. Iglesias | static const unsigned int sizes[] = { |
32 | afeeceb0 | Edgar E. Iglesias | 1 * 1024, 4 * 1024, 16 * 1024, 64 * 1024, 256 * 1024, |
33 | afeeceb0 | Edgar E. Iglesias | 1 * 1024 * 1024, 4 * 1024 * 1024, 16 * 1024 * 1024 |
34 | afeeceb0 | Edgar E. Iglesias | }; |
35 | afeeceb0 | Edgar E. Iglesias | assert(f < ARRAY_SIZE(sizes)); |
36 | afeeceb0 | Edgar E. Iglesias | return sizes[f];
|
37 | afeeceb0 | Edgar E. Iglesias | } |
38 | afeeceb0 | Edgar E. Iglesias | |
39 | 6b2fce90 | Edgar E. Iglesias | static void mmu_flush_idx(CPUState *env, unsigned int idx) |
40 | afeeceb0 | Edgar E. Iglesias | { |
41 | afeeceb0 | Edgar E. Iglesias | struct microblaze_mmu *mmu = &env->mmu;
|
42 | afeeceb0 | Edgar E. Iglesias | unsigned int tlb_size; |
43 | afeeceb0 | Edgar E. Iglesias | uint32_t tlb_tag, end, t; |
44 | afeeceb0 | Edgar E. Iglesias | |
45 | afeeceb0 | Edgar E. Iglesias | t = mmu->rams[RAM_TAG][idx]; |
46 | afeeceb0 | Edgar E. Iglesias | if (!(t & TLB_VALID))
|
47 | afeeceb0 | Edgar E. Iglesias | return;
|
48 | afeeceb0 | Edgar E. Iglesias | |
49 | afeeceb0 | Edgar E. Iglesias | tlb_tag = t & TLB_EPN_MASK; |
50 | afeeceb0 | Edgar E. Iglesias | tlb_size = tlb_decode_size((t & TLB_PAGESZ_MASK) >> 7);
|
51 | afeeceb0 | Edgar E. Iglesias | end = tlb_tag + tlb_size; |
52 | afeeceb0 | Edgar E. Iglesias | |
53 | afeeceb0 | Edgar E. Iglesias | while (tlb_tag < end) {
|
54 | afeeceb0 | Edgar E. Iglesias | tlb_flush_page(env, tlb_tag); |
55 | afeeceb0 | Edgar E. Iglesias | tlb_tag += TARGET_PAGE_SIZE; |
56 | afeeceb0 | Edgar E. Iglesias | } |
57 | afeeceb0 | Edgar E. Iglesias | } |
58 | afeeceb0 | Edgar E. Iglesias | |
59 | afeeceb0 | Edgar E. Iglesias | static void mmu_change_pid(CPUState *env, unsigned int newpid) |
60 | afeeceb0 | Edgar E. Iglesias | { |
61 | afeeceb0 | Edgar E. Iglesias | struct microblaze_mmu *mmu = &env->mmu;
|
62 | afeeceb0 | Edgar E. Iglesias | unsigned int i; |
63 | 183aa454 | Blue Swirl | uint32_t t; |
64 | afeeceb0 | Edgar E. Iglesias | |
65 | afeeceb0 | Edgar E. Iglesias | if (newpid & ~0xff) |
66 | afeeceb0 | Edgar E. Iglesias | qemu_log("Illegal rpid=%x\n", newpid);
|
67 | afeeceb0 | Edgar E. Iglesias | |
68 | afeeceb0 | Edgar E. Iglesias | for (i = 0; i < ARRAY_SIZE(mmu->rams[RAM_TAG]); i++) { |
69 | afeeceb0 | Edgar E. Iglesias | /* Lookup and decode. */
|
70 | afeeceb0 | Edgar E. Iglesias | t = mmu->rams[RAM_TAG][i]; |
71 | afeeceb0 | Edgar E. Iglesias | if (t & TLB_VALID) {
|
72 | afeeceb0 | Edgar E. Iglesias | if (mmu->tids[i] && ((mmu->regs[MMU_R_PID] & 0xff) == mmu->tids[i])) |
73 | afeeceb0 | Edgar E. Iglesias | mmu_flush_idx(env, i); |
74 | afeeceb0 | Edgar E. Iglesias | } |
75 | afeeceb0 | Edgar E. Iglesias | } |
76 | afeeceb0 | Edgar E. Iglesias | } |
77 | afeeceb0 | Edgar E. Iglesias | |
78 | afeeceb0 | Edgar E. Iglesias | /* rw - 0 = read, 1 = write, 2 = fetch. */
|
79 | afeeceb0 | Edgar E. Iglesias | unsigned int mmu_translate(struct microblaze_mmu *mmu, |
80 | afeeceb0 | Edgar E. Iglesias | struct microblaze_mmu_lookup *lu,
|
81 | afeeceb0 | Edgar E. Iglesias | target_ulong vaddr, int rw, int mmu_idx) |
82 | afeeceb0 | Edgar E. Iglesias | { |
83 | afeeceb0 | Edgar E. Iglesias | unsigned int i, hit = 0; |
84 | afeeceb0 | Edgar E. Iglesias | unsigned int tlb_ex = 0, tlb_wr = 0, tlb_zsel; |
85 | afeeceb0 | Edgar E. Iglesias | unsigned int tlb_size; |
86 | afeeceb0 | Edgar E. Iglesias | uint32_t tlb_tag, tlb_rpn, mask, t0; |
87 | afeeceb0 | Edgar E. Iglesias | |
88 | afeeceb0 | Edgar E. Iglesias | lu->err = ERR_MISS; |
89 | afeeceb0 | Edgar E. Iglesias | for (i = 0; i < ARRAY_SIZE(mmu->rams[RAM_TAG]); i++) { |
90 | afeeceb0 | Edgar E. Iglesias | uint32_t t, d; |
91 | afeeceb0 | Edgar E. Iglesias | |
92 | afeeceb0 | Edgar E. Iglesias | /* Lookup and decode. */
|
93 | afeeceb0 | Edgar E. Iglesias | t = mmu->rams[RAM_TAG][i]; |
94 | afeeceb0 | Edgar E. Iglesias | D(qemu_log("TLB %d valid=%d\n", i, t & TLB_VALID));
|
95 | afeeceb0 | Edgar E. Iglesias | if (t & TLB_VALID) {
|
96 | afeeceb0 | Edgar E. Iglesias | tlb_size = tlb_decode_size((t & TLB_PAGESZ_MASK) >> 7);
|
97 | afeeceb0 | Edgar E. Iglesias | if (tlb_size < TARGET_PAGE_SIZE) {
|
98 | afeeceb0 | Edgar E. Iglesias | qemu_log("%d pages not supported\n", tlb_size);
|
99 | afeeceb0 | Edgar E. Iglesias | abort(); |
100 | afeeceb0 | Edgar E. Iglesias | } |
101 | afeeceb0 | Edgar E. Iglesias | |
102 | afeeceb0 | Edgar E. Iglesias | mask = ~(tlb_size - 1);
|
103 | afeeceb0 | Edgar E. Iglesias | tlb_tag = t & TLB_EPN_MASK; |
104 | afeeceb0 | Edgar E. Iglesias | if ((vaddr & mask) != (tlb_tag & mask)) {
|
105 | afeeceb0 | Edgar E. Iglesias | D(qemu_log("TLB %d vaddr=%x != tag=%x\n",
|
106 | afeeceb0 | Edgar E. Iglesias | i, vaddr & mask, tlb_tag & mask)); |
107 | afeeceb0 | Edgar E. Iglesias | continue;
|
108 | afeeceb0 | Edgar E. Iglesias | } |
109 | afeeceb0 | Edgar E. Iglesias | if (mmu->tids[i]
|
110 | afeeceb0 | Edgar E. Iglesias | && ((mmu->regs[MMU_R_PID] & 0xff) != mmu->tids[i])) {
|
111 | afeeceb0 | Edgar E. Iglesias | D(qemu_log("TLB %d pid=%x != tid=%x\n",
|
112 | afeeceb0 | Edgar E. Iglesias | i, mmu->regs[MMU_R_PID], mmu->tids[i])); |
113 | afeeceb0 | Edgar E. Iglesias | continue;
|
114 | afeeceb0 | Edgar E. Iglesias | } |
115 | afeeceb0 | Edgar E. Iglesias | |
116 | afeeceb0 | Edgar E. Iglesias | /* Bring in the data part. */
|
117 | afeeceb0 | Edgar E. Iglesias | d = mmu->rams[RAM_DATA][i]; |
118 | afeeceb0 | Edgar E. Iglesias | tlb_ex = d & TLB_EX; |
119 | afeeceb0 | Edgar E. Iglesias | tlb_wr = d & TLB_WR; |
120 | afeeceb0 | Edgar E. Iglesias | |
121 | afeeceb0 | Edgar E. Iglesias | /* Now lets see if there is a zone that overrides the protbits. */
|
122 | afeeceb0 | Edgar E. Iglesias | tlb_zsel = (d >> 4) & 0xf; |
123 | afeeceb0 | Edgar E. Iglesias | t0 = mmu->regs[MMU_R_ZPR] >> (30 - (tlb_zsel * 2)); |
124 | afeeceb0 | Edgar E. Iglesias | t0 &= 0x3;
|
125 | 3c50a71f | Edgar E. Iglesias | |
126 | 3c50a71f | Edgar E. Iglesias | if (tlb_zsel > mmu->c_mmu_zones) {
|
127 | 3c50a71f | Edgar E. Iglesias | qemu_log("tlb zone select out of range! %d\n", tlb_zsel);
|
128 | 3c50a71f | Edgar E. Iglesias | t0 = 1; /* Ignore. */ |
129 | 3c50a71f | Edgar E. Iglesias | } |
130 | 3c50a71f | Edgar E. Iglesias | |
131 | 3c50a71f | Edgar E. Iglesias | if (mmu->c_mmu == 1) { |
132 | 3c50a71f | Edgar E. Iglesias | t0 = 1; /* Zones are disabled. */ |
133 | 3c50a71f | Edgar E. Iglesias | } |
134 | 3c50a71f | Edgar E. Iglesias | |
135 | afeeceb0 | Edgar E. Iglesias | switch (t0) {
|
136 | afeeceb0 | Edgar E. Iglesias | case 0: |
137 | afeeceb0 | Edgar E. Iglesias | if (mmu_idx == MMU_USER_IDX)
|
138 | afeeceb0 | Edgar E. Iglesias | continue;
|
139 | afeeceb0 | Edgar E. Iglesias | break;
|
140 | afeeceb0 | Edgar E. Iglesias | case 2: |
141 | afeeceb0 | Edgar E. Iglesias | if (mmu_idx != MMU_USER_IDX) {
|
142 | afeeceb0 | Edgar E. Iglesias | tlb_ex = 1;
|
143 | afeeceb0 | Edgar E. Iglesias | tlb_wr = 1;
|
144 | afeeceb0 | Edgar E. Iglesias | } |
145 | afeeceb0 | Edgar E. Iglesias | break;
|
146 | afeeceb0 | Edgar E. Iglesias | case 3: |
147 | afeeceb0 | Edgar E. Iglesias | tlb_ex = 1;
|
148 | afeeceb0 | Edgar E. Iglesias | tlb_wr = 1;
|
149 | afeeceb0 | Edgar E. Iglesias | break;
|
150 | 3c50a71f | Edgar E. Iglesias | default: break; |
151 | afeeceb0 | Edgar E. Iglesias | } |
152 | afeeceb0 | Edgar E. Iglesias | |
153 | afeeceb0 | Edgar E. Iglesias | lu->err = ERR_PROT; |
154 | afeeceb0 | Edgar E. Iglesias | lu->prot = PAGE_READ; |
155 | afeeceb0 | Edgar E. Iglesias | if (tlb_wr)
|
156 | afeeceb0 | Edgar E. Iglesias | lu->prot |= PAGE_WRITE; |
157 | afeeceb0 | Edgar E. Iglesias | else if (rw == 1) |
158 | afeeceb0 | Edgar E. Iglesias | goto done;
|
159 | afeeceb0 | Edgar E. Iglesias | if (tlb_ex)
|
160 | afeeceb0 | Edgar E. Iglesias | lu->prot |=PAGE_EXEC; |
161 | afeeceb0 | Edgar E. Iglesias | else if (rw == 2) { |
162 | afeeceb0 | Edgar E. Iglesias | goto done;
|
163 | afeeceb0 | Edgar E. Iglesias | } |
164 | afeeceb0 | Edgar E. Iglesias | |
165 | afeeceb0 | Edgar E. Iglesias | tlb_rpn = d & TLB_RPN_MASK; |
166 | afeeceb0 | Edgar E. Iglesias | |
167 | afeeceb0 | Edgar E. Iglesias | lu->vaddr = tlb_tag; |
168 | afeeceb0 | Edgar E. Iglesias | lu->paddr = tlb_rpn; |
169 | afeeceb0 | Edgar E. Iglesias | lu->size = tlb_size; |
170 | afeeceb0 | Edgar E. Iglesias | lu->err = ERR_HIT; |
171 | afeeceb0 | Edgar E. Iglesias | lu->idx = i; |
172 | afeeceb0 | Edgar E. Iglesias | hit = 1;
|
173 | afeeceb0 | Edgar E. Iglesias | goto done;
|
174 | afeeceb0 | Edgar E. Iglesias | } |
175 | afeeceb0 | Edgar E. Iglesias | } |
176 | afeeceb0 | Edgar E. Iglesias | done:
|
177 | afeeceb0 | Edgar E. Iglesias | D(qemu_log("MMU vaddr=%x rw=%d tlb_wr=%d tlb_ex=%d hit=%d\n",
|
178 | afeeceb0 | Edgar E. Iglesias | vaddr, rw, tlb_wr, tlb_ex, hit)); |
179 | afeeceb0 | Edgar E. Iglesias | return hit;
|
180 | afeeceb0 | Edgar E. Iglesias | } |
181 | afeeceb0 | Edgar E. Iglesias | |
182 | afeeceb0 | Edgar E. Iglesias | /* Writes/reads to the MMU's special regs end up here. */
|
183 | afeeceb0 | Edgar E. Iglesias | uint32_t mmu_read(CPUState *env, uint32_t rn) |
184 | afeeceb0 | Edgar E. Iglesias | { |
185 | afeeceb0 | Edgar E. Iglesias | unsigned int i; |
186 | afeeceb0 | Edgar E. Iglesias | uint32_t r; |
187 | afeeceb0 | Edgar E. Iglesias | |
188 | 3c50a71f | Edgar E. Iglesias | if (env->mmu.c_mmu < 2 || !env->mmu.c_mmu_tlb_access) { |
189 | 3c50a71f | Edgar E. Iglesias | qemu_log("MMU access on MMU-less system\n");
|
190 | 3c50a71f | Edgar E. Iglesias | return 0; |
191 | 3c50a71f | Edgar E. Iglesias | } |
192 | 3c50a71f | Edgar E. Iglesias | |
193 | afeeceb0 | Edgar E. Iglesias | switch (rn) {
|
194 | afeeceb0 | Edgar E. Iglesias | /* Reads to HI/LO trig reads from the mmu rams. */
|
195 | afeeceb0 | Edgar E. Iglesias | case MMU_R_TLBLO:
|
196 | afeeceb0 | Edgar E. Iglesias | case MMU_R_TLBHI:
|
197 | 3c50a71f | Edgar E. Iglesias | if (!(env->mmu.c_mmu_tlb_access & 1)) { |
198 | 3c50a71f | Edgar E. Iglesias | qemu_log("Invalid access to MMU reg %d\n", rn);
|
199 | 3c50a71f | Edgar E. Iglesias | return 0; |
200 | 3c50a71f | Edgar E. Iglesias | } |
201 | 3c50a71f | Edgar E. Iglesias | |
202 | afeeceb0 | Edgar E. Iglesias | i = env->mmu.regs[MMU_R_TLBX] & 0xff;
|
203 | afeeceb0 | Edgar E. Iglesias | r = env->mmu.rams[rn & 1][i];
|
204 | afeeceb0 | Edgar E. Iglesias | if (rn == MMU_R_TLBHI)
|
205 | afeeceb0 | Edgar E. Iglesias | env->mmu.regs[MMU_R_PID] = env->mmu.tids[i]; |
206 | afeeceb0 | Edgar E. Iglesias | break;
|
207 | 3c50a71f | Edgar E. Iglesias | case MMU_R_PID:
|
208 | 3c50a71f | Edgar E. Iglesias | case MMU_R_ZPR:
|
209 | 3c50a71f | Edgar E. Iglesias | if (!(env->mmu.c_mmu_tlb_access & 1)) { |
210 | 3c50a71f | Edgar E. Iglesias | qemu_log("Invalid access to MMU reg %d\n", rn);
|
211 | 3c50a71f | Edgar E. Iglesias | return 0; |
212 | 3c50a71f | Edgar E. Iglesias | } |
213 | 3c50a71f | Edgar E. Iglesias | r = env->mmu.regs[rn]; |
214 | 3c50a71f | Edgar E. Iglesias | break;
|
215 | afeeceb0 | Edgar E. Iglesias | default:
|
216 | afeeceb0 | Edgar E. Iglesias | r = env->mmu.regs[rn]; |
217 | afeeceb0 | Edgar E. Iglesias | break;
|
218 | afeeceb0 | Edgar E. Iglesias | } |
219 | afeeceb0 | Edgar E. Iglesias | D(qemu_log("%s rn=%d=%x\n", __func__, rn, r));
|
220 | afeeceb0 | Edgar E. Iglesias | return r;
|
221 | afeeceb0 | Edgar E. Iglesias | } |
222 | afeeceb0 | Edgar E. Iglesias | |
223 | afeeceb0 | Edgar E. Iglesias | void mmu_write(CPUState *env, uint32_t rn, uint32_t v)
|
224 | afeeceb0 | Edgar E. Iglesias | { |
225 | afeeceb0 | Edgar E. Iglesias | unsigned int i; |
226 | afeeceb0 | Edgar E. Iglesias | D(qemu_log("%s rn=%d=%x old=%x\n", __func__, rn, v, env->mmu.regs[rn]));
|
227 | afeeceb0 | Edgar E. Iglesias | |
228 | 3c50a71f | Edgar E. Iglesias | if (env->mmu.c_mmu < 2 || !env->mmu.c_mmu_tlb_access) { |
229 | 3c50a71f | Edgar E. Iglesias | qemu_log("MMU access on MMU-less system\n");
|
230 | 3c50a71f | Edgar E. Iglesias | return;
|
231 | 3c50a71f | Edgar E. Iglesias | } |
232 | 3c50a71f | Edgar E. Iglesias | |
233 | afeeceb0 | Edgar E. Iglesias | switch (rn) {
|
234 | afeeceb0 | Edgar E. Iglesias | /* Writes to HI/LO trig writes to the mmu rams. */
|
235 | afeeceb0 | Edgar E. Iglesias | case MMU_R_TLBLO:
|
236 | afeeceb0 | Edgar E. Iglesias | case MMU_R_TLBHI:
|
237 | afeeceb0 | Edgar E. Iglesias | i = env->mmu.regs[MMU_R_TLBX] & 0xff;
|
238 | afeeceb0 | Edgar E. Iglesias | if (rn == MMU_R_TLBHI) {
|
239 | afeeceb0 | Edgar E. Iglesias | if (i < 3 && !(v & TLB_VALID) && qemu_loglevel_mask(~0)) |
240 | afeeceb0 | Edgar E. Iglesias | qemu_log("invalidating index %x at pc=%x\n",
|
241 | afeeceb0 | Edgar E. Iglesias | i, env->sregs[SR_PC]); |
242 | afeeceb0 | Edgar E. Iglesias | env->mmu.tids[i] = env->mmu.regs[MMU_R_PID] & 0xff;
|
243 | afeeceb0 | Edgar E. Iglesias | mmu_flush_idx(env, i); |
244 | afeeceb0 | Edgar E. Iglesias | } |
245 | afeeceb0 | Edgar E. Iglesias | env->mmu.rams[rn & 1][i] = v;
|
246 | afeeceb0 | Edgar E. Iglesias | |
247 | afeeceb0 | Edgar E. Iglesias | D(qemu_log("%s ram[%d][%d]=%x\n", __func__, rn & 1, i, v)); |
248 | afeeceb0 | Edgar E. Iglesias | break;
|
249 | afeeceb0 | Edgar E. Iglesias | case MMU_R_ZPR:
|
250 | 3c50a71f | Edgar E. Iglesias | if (env->mmu.c_mmu_tlb_access <= 1) { |
251 | 3c50a71f | Edgar E. Iglesias | qemu_log("Invalid access to MMU reg %d\n", rn);
|
252 | 3c50a71f | Edgar E. Iglesias | return;
|
253 | 3c50a71f | Edgar E. Iglesias | } |
254 | 3c50a71f | Edgar E. Iglesias | |
255 | d0f3654f | Edgar E. Iglesias | /* Changes to the zone protection reg flush the QEMU TLB.
|
256 | d0f3654f | Edgar E. Iglesias | Fortunately, these are very uncommon. */
|
257 | d0f3654f | Edgar E. Iglesias | if (v != env->mmu.regs[rn]) {
|
258 | d0f3654f | Edgar E. Iglesias | tlb_flush(env, 1);
|
259 | d0f3654f | Edgar E. Iglesias | } |
260 | d0f3654f | Edgar E. Iglesias | env->mmu.regs[rn] = v; |
261 | d0f3654f | Edgar E. Iglesias | break;
|
262 | afeeceb0 | Edgar E. Iglesias | case MMU_R_PID:
|
263 | 3c50a71f | Edgar E. Iglesias | if (env->mmu.c_mmu_tlb_access <= 1) { |
264 | 3c50a71f | Edgar E. Iglesias | qemu_log("Invalid access to MMU reg %d\n", rn);
|
265 | 3c50a71f | Edgar E. Iglesias | return;
|
266 | 3c50a71f | Edgar E. Iglesias | } |
267 | 3c50a71f | Edgar E. Iglesias | |
268 | afeeceb0 | Edgar E. Iglesias | if (v != env->mmu.regs[rn]) {
|
269 | afeeceb0 | Edgar E. Iglesias | mmu_change_pid(env, v); |
270 | afeeceb0 | Edgar E. Iglesias | env->mmu.regs[rn] = v; |
271 | afeeceb0 | Edgar E. Iglesias | } |
272 | afeeceb0 | Edgar E. Iglesias | break;
|
273 | afeeceb0 | Edgar E. Iglesias | case MMU_R_TLBSX:
|
274 | afeeceb0 | Edgar E. Iglesias | { |
275 | afeeceb0 | Edgar E. Iglesias | struct microblaze_mmu_lookup lu;
|
276 | afeeceb0 | Edgar E. Iglesias | int hit;
|
277 | 3c50a71f | Edgar E. Iglesias | |
278 | 3c50a71f | Edgar E. Iglesias | if (env->mmu.c_mmu_tlb_access <= 1) { |
279 | 3c50a71f | Edgar E. Iglesias | qemu_log("Invalid access to MMU reg %d\n", rn);
|
280 | 3c50a71f | Edgar E. Iglesias | return;
|
281 | 3c50a71f | Edgar E. Iglesias | } |
282 | 3c50a71f | Edgar E. Iglesias | |
283 | afeeceb0 | Edgar E. Iglesias | hit = mmu_translate(&env->mmu, &lu, |
284 | afeeceb0 | Edgar E. Iglesias | v & TLB_EPN_MASK, 0, cpu_mmu_index(env));
|
285 | afeeceb0 | Edgar E. Iglesias | if (hit) {
|
286 | afeeceb0 | Edgar E. Iglesias | env->mmu.regs[MMU_R_TLBX] = lu.idx; |
287 | afeeceb0 | Edgar E. Iglesias | } else
|
288 | afeeceb0 | Edgar E. Iglesias | env->mmu.regs[MMU_R_TLBX] |= 0x80000000;
|
289 | afeeceb0 | Edgar E. Iglesias | break;
|
290 | afeeceb0 | Edgar E. Iglesias | } |
291 | afeeceb0 | Edgar E. Iglesias | default:
|
292 | afeeceb0 | Edgar E. Iglesias | env->mmu.regs[rn] = v; |
293 | afeeceb0 | Edgar E. Iglesias | break;
|
294 | afeeceb0 | Edgar E. Iglesias | } |
295 | afeeceb0 | Edgar E. Iglesias | } |
296 | afeeceb0 | Edgar E. Iglesias | |
297 | afeeceb0 | Edgar E. Iglesias | void mmu_init(struct microblaze_mmu *mmu) |
298 | afeeceb0 | Edgar E. Iglesias | { |
299 | 3c50a71f | Edgar E. Iglesias | int i;
|
300 | 3c50a71f | Edgar E. Iglesias | for (i = 0; i < ARRAY_SIZE(mmu->regs); i++) { |
301 | 3c50a71f | Edgar E. Iglesias | mmu->regs[i] = 0;
|
302 | 3c50a71f | Edgar E. Iglesias | } |
303 | afeeceb0 | Edgar E. Iglesias | } |