]> git.proxmox.com Git - mirror_qemu.git/blame - target-xtensa/op_helper.c
Drop obsolete nographic timer
[mirror_qemu.git] / target-xtensa / op_helper.c
CommitLineData
2328826b
MF
1/*
2 * Copyright (c) 2011, Max Filippov, Open Source and Linux Lab.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the Open Source and Linux Lab nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28#include "cpu.h"
29#include "dyngen-exec.h"
dedc5eae 30#include "helpers.h"
3580ecad 31#include "host-utils.h"
2328826b 32
5b4e481b
MF
33static void do_unaligned_access(target_ulong addr, int is_write, int is_user,
34 void *retaddr);
35
36#define ALIGNED_ONLY
2328826b
MF
37#define MMUSUFFIX _mmu
38
39#define SHIFT 0
40#include "softmmu_template.h"
41
42#define SHIFT 1
43#include "softmmu_template.h"
44
45#define SHIFT 2
46#include "softmmu_template.h"
47
48#define SHIFT 3
49#include "softmmu_template.h"
50
5b4e481b
MF
51static void do_restore_state(void *pc_ptr)
52{
53 TranslationBlock *tb;
54 uint32_t pc = (uint32_t)(intptr_t)pc_ptr;
55
56 tb = tb_find_pc(pc);
57 if (tb) {
58 cpu_restore_state(tb, env, pc);
59 }
60}
61
62static void do_unaligned_access(target_ulong addr, int is_write, int is_user,
63 void *retaddr)
64{
65 if (xtensa_option_enabled(env->config, XTENSA_OPTION_UNALIGNED_EXCEPTION) &&
66 !xtensa_option_enabled(env->config, XTENSA_OPTION_HW_ALIGNMENT)) {
67 do_restore_state(retaddr);
68 HELPER(exception_cause_vaddr)(
69 env->pc, LOAD_STORE_ALIGNMENT_CAUSE, addr);
70 }
71}
72
bccd9ec5
BS
73void tlb_fill(CPUState *env1, target_ulong vaddr, int is_write, int mmu_idx,
74 void *retaddr)
2328826b 75{
b67ea0cd
MF
76 CPUState *saved_env = env;
77
bccd9ec5 78 env = env1;
b67ea0cd
MF
79 {
80 uint32_t paddr;
81 uint32_t page_size;
82 unsigned access;
83 int ret = xtensa_get_physical_addr(env, vaddr, is_write, mmu_idx,
84 &paddr, &page_size, &access);
85
86 qemu_log("%s(%08x, %d, %d) -> %08x, ret = %d\n", __func__,
87 vaddr, is_write, mmu_idx, paddr, ret);
88
89 if (ret == 0) {
90 tlb_set_page(env,
91 vaddr & TARGET_PAGE_MASK,
92 paddr & TARGET_PAGE_MASK,
93 access, mmu_idx, page_size);
94 } else {
95 do_restore_state(retaddr);
96 HELPER(exception_cause_vaddr)(env->pc, ret, vaddr);
97 }
98 }
99 env = saved_env;
2328826b 100}
dedc5eae
MF
101
102void HELPER(exception)(uint32_t excp)
103{
104 env->exception_index = excp;
105 cpu_loop_exit(env);
106}
3580ecad 107
40643d7c
MF
108void HELPER(exception_cause)(uint32_t pc, uint32_t cause)
109{
110 uint32_t vector;
111
112 env->pc = pc;
113 if (env->sregs[PS] & PS_EXCM) {
114 if (env->config->ndepc) {
115 env->sregs[DEPC] = pc;
116 } else {
117 env->sregs[EPC1] = pc;
118 }
119 vector = EXC_DOUBLE;
120 } else {
121 env->sregs[EPC1] = pc;
122 vector = (env->sregs[PS] & PS_UM) ? EXC_USER : EXC_KERNEL;
123 }
124
125 env->sregs[EXCCAUSE] = cause;
126 env->sregs[PS] |= PS_EXCM;
127
128 HELPER(exception)(vector);
129}
130
131void HELPER(exception_cause_vaddr)(uint32_t pc, uint32_t cause, uint32_t vaddr)
132{
133 env->sregs[EXCVADDR] = vaddr;
134 HELPER(exception_cause)(pc, cause);
135}
136
3580ecad
MF
137uint32_t HELPER(nsa)(uint32_t v)
138{
139 if (v & 0x80000000) {
140 v = ~v;
141 }
142 return v ? clz32(v) - 1 : 31;
143}
144
145uint32_t HELPER(nsau)(uint32_t v)
146{
147 return v ? clz32(v) : 32;
148}
553e44f9
MF
149
150static void copy_window_from_phys(CPUState *env,
151 uint32_t window, uint32_t phys, uint32_t n)
152{
153 assert(phys < env->config->nareg);
154 if (phys + n <= env->config->nareg) {
155 memcpy(env->regs + window, env->phys_regs + phys,
156 n * sizeof(uint32_t));
157 } else {
158 uint32_t n1 = env->config->nareg - phys;
159 memcpy(env->regs + window, env->phys_regs + phys,
160 n1 * sizeof(uint32_t));
161 memcpy(env->regs + window + n1, env->phys_regs,
162 (n - n1) * sizeof(uint32_t));
163 }
164}
165
166static void copy_phys_from_window(CPUState *env,
167 uint32_t phys, uint32_t window, uint32_t n)
168{
169 assert(phys < env->config->nareg);
170 if (phys + n <= env->config->nareg) {
171 memcpy(env->phys_regs + phys, env->regs + window,
172 n * sizeof(uint32_t));
173 } else {
174 uint32_t n1 = env->config->nareg - phys;
175 memcpy(env->phys_regs + phys, env->regs + window,
176 n1 * sizeof(uint32_t));
177 memcpy(env->phys_regs, env->regs + window + n1,
178 (n - n1) * sizeof(uint32_t));
179 }
180}
181
182
183static inline unsigned windowbase_bound(unsigned a, const CPUState *env)
184{
185 return a & (env->config->nareg / 4 - 1);
186}
187
188static inline unsigned windowstart_bit(unsigned a, const CPUState *env)
189{
190 return 1 << windowbase_bound(a, env);
191}
192
193void xtensa_sync_window_from_phys(CPUState *env)
194{
195 copy_window_from_phys(env, 0, env->sregs[WINDOW_BASE] * 4, 16);
196}
197
198void xtensa_sync_phys_from_window(CPUState *env)
199{
200 copy_phys_from_window(env, env->sregs[WINDOW_BASE] * 4, 0, 16);
201}
202
203static void rotate_window_abs(uint32_t position)
204{
205 xtensa_sync_phys_from_window(env);
206 env->sregs[WINDOW_BASE] = windowbase_bound(position, env);
207 xtensa_sync_window_from_phys(env);
208}
209
210static void rotate_window(uint32_t delta)
211{
212 rotate_window_abs(env->sregs[WINDOW_BASE] + delta);
213}
214
215void HELPER(wsr_windowbase)(uint32_t v)
216{
217 rotate_window_abs(v);
218}
219
220void HELPER(entry)(uint32_t pc, uint32_t s, uint32_t imm)
221{
222 int callinc = (env->sregs[PS] & PS_CALLINC) >> PS_CALLINC_SHIFT;
223 if (s > 3 || ((env->sregs[PS] & (PS_WOE | PS_EXCM)) ^ PS_WOE) != 0) {
224 qemu_log("Illegal entry instruction(pc = %08x), PS = %08x\n",
225 pc, env->sregs[PS]);
226 HELPER(exception_cause)(pc, ILLEGAL_INSTRUCTION_CAUSE);
227 } else {
228 env->regs[(callinc << 2) | (s & 3)] = env->regs[s] - (imm << 3);
229 rotate_window(callinc);
230 env->sregs[WINDOW_START] |=
231 windowstart_bit(env->sregs[WINDOW_BASE], env);
232 }
233}
234
235void HELPER(window_check)(uint32_t pc, uint32_t w)
236{
237 uint32_t windowbase = windowbase_bound(env->sregs[WINDOW_BASE], env);
238 uint32_t windowstart = env->sregs[WINDOW_START];
239 uint32_t m, n;
240
241 if ((env->sregs[PS] & (PS_WOE | PS_EXCM)) ^ PS_WOE) {
242 return;
243 }
244
245 for (n = 1; ; ++n) {
246 if (n > w) {
247 return;
248 }
249 if (windowstart & windowstart_bit(windowbase + n, env)) {
250 break;
251 }
252 }
253
254 m = windowbase_bound(windowbase + n, env);
255 rotate_window(n);
256 env->sregs[PS] = (env->sregs[PS] & ~PS_OWB) |
257 (windowbase << PS_OWB_SHIFT) | PS_EXCM;
258 env->sregs[EPC1] = env->pc = pc;
259
260 if (windowstart & windowstart_bit(m + 1, env)) {
261 HELPER(exception)(EXC_WINDOW_OVERFLOW4);
262 } else if (windowstart & windowstart_bit(m + 2, env)) {
263 HELPER(exception)(EXC_WINDOW_OVERFLOW8);
264 } else {
265 HELPER(exception)(EXC_WINDOW_OVERFLOW12);
266 }
267}
268
269uint32_t HELPER(retw)(uint32_t pc)
270{
271 int n = (env->regs[0] >> 30) & 0x3;
272 int m = 0;
273 uint32_t windowbase = windowbase_bound(env->sregs[WINDOW_BASE], env);
274 uint32_t windowstart = env->sregs[WINDOW_START];
275 uint32_t ret_pc = 0;
276
277 if (windowstart & windowstart_bit(windowbase - 1, env)) {
278 m = 1;
279 } else if (windowstart & windowstart_bit(windowbase - 2, env)) {
280 m = 2;
281 } else if (windowstart & windowstart_bit(windowbase - 3, env)) {
282 m = 3;
283 }
284
285 if (n == 0 || (m != 0 && m != n) ||
286 ((env->sregs[PS] & (PS_WOE | PS_EXCM)) ^ PS_WOE) != 0) {
287 qemu_log("Illegal retw instruction(pc = %08x), "
288 "PS = %08x, m = %d, n = %d\n",
289 pc, env->sregs[PS], m, n);
290 HELPER(exception_cause)(pc, ILLEGAL_INSTRUCTION_CAUSE);
291 } else {
292 int owb = windowbase;
293
294 ret_pc = (pc & 0xc0000000) | (env->regs[0] & 0x3fffffff);
295
296 rotate_window(-n);
297 if (windowstart & windowstart_bit(env->sregs[WINDOW_BASE], env)) {
298 env->sregs[WINDOW_START] &= ~windowstart_bit(owb, env);
299 } else {
300 /* window underflow */
301 env->sregs[PS] = (env->sregs[PS] & ~PS_OWB) |
302 (windowbase << PS_OWB_SHIFT) | PS_EXCM;
303 env->sregs[EPC1] = env->pc = pc;
304
305 if (n == 1) {
306 HELPER(exception)(EXC_WINDOW_UNDERFLOW4);
307 } else if (n == 2) {
308 HELPER(exception)(EXC_WINDOW_UNDERFLOW8);
309 } else if (n == 3) {
310 HELPER(exception)(EXC_WINDOW_UNDERFLOW12);
311 }
312 }
313 }
314 return ret_pc;
315}
316
317void HELPER(rotw)(uint32_t imm4)
318{
319 rotate_window(imm4);
320}
321
322void HELPER(restore_owb)(void)
323{
324 rotate_window_abs((env->sregs[PS] & PS_OWB) >> PS_OWB_SHIFT);
325}
326
327void HELPER(movsp)(uint32_t pc)
328{
329 if ((env->sregs[WINDOW_START] &
330 (windowstart_bit(env->sregs[WINDOW_BASE] - 3, env) |
331 windowstart_bit(env->sregs[WINDOW_BASE] - 2, env) |
332 windowstart_bit(env->sregs[WINDOW_BASE] - 1, env))) == 0) {
333 HELPER(exception_cause)(pc, ALLOCA_CAUSE);
334 }
335}
336
797d780b
MF
337void HELPER(wsr_lbeg)(uint32_t v)
338{
339 if (env->sregs[LBEG] != v) {
340 tb_invalidate_phys_page_range(
341 env->sregs[LEND] - 1, env->sregs[LEND], 0);
342 env->sregs[LBEG] = v;
343 }
344}
345
346void HELPER(wsr_lend)(uint32_t v)
347{
348 if (env->sregs[LEND] != v) {
349 tb_invalidate_phys_page_range(
350 env->sregs[LEND] - 1, env->sregs[LEND], 0);
351 env->sregs[LEND] = v;
352 tb_invalidate_phys_page_range(
353 env->sregs[LEND] - 1, env->sregs[LEND], 0);
354 }
355}
356
553e44f9
MF
357void HELPER(dump_state)(void)
358{
359 cpu_dump_state(env, stderr, fprintf, 0);
360}
b994e91b
MF
361
362void HELPER(waiti)(uint32_t pc, uint32_t intlevel)
363{
364 env->pc = pc;
365 env->sregs[PS] = (env->sregs[PS] & ~PS_INTLEVEL) |
366 (intlevel << PS_INTLEVEL_SHIFT);
367 check_interrupts(env);
368 if (env->pending_irq_level) {
369 cpu_loop_exit(env);
370 return;
371 }
372
373 if (xtensa_option_enabled(env->config, XTENSA_OPTION_TIMER_INTERRUPT)) {
374 int i;
375 uint32_t wake_ccount = env->sregs[CCOUNT] - 1;
376
377 for (i = 0; i < env->config->nccompare; ++i) {
378 if (env->sregs[CCOMPARE + i] - env->sregs[CCOUNT] <
379 wake_ccount - env->sregs[CCOUNT]) {
380 wake_ccount = env->sregs[CCOMPARE + i];
381 }
382 }
383 env->wake_ccount = wake_ccount;
384 qemu_mod_timer(env->ccompare_timer, qemu_get_clock_ns(vm_clock) +
385 muldiv64(wake_ccount - env->sregs[CCOUNT],
386 1000000, env->config->clock_freq_khz));
387 }
388 env->halt_clock = qemu_get_clock_ns(vm_clock);
389 env->halted = 1;
390 HELPER(exception)(EXCP_HLT);
391}
392
393void HELPER(timer_irq)(uint32_t id, uint32_t active)
394{
395 xtensa_timer_irq(env, id, active);
396}
397
398void HELPER(advance_ccount)(uint32_t d)
399{
400 xtensa_advance_ccount(env, d);
401}
402
403void HELPER(check_interrupts)(CPUState *env)
404{
405 check_interrupts(env);
406}
b67ea0cd
MF
407
408void HELPER(wsr_rasid)(uint32_t v)
409{
410 v = (v & 0xffffff00) | 0x1;
411 if (v != env->sregs[RASID]) {
412 env->sregs[RASID] = v;
413 tlb_flush(env, 1);
414 }
415}
416
417static uint32_t get_page_size(const CPUState *env, bool dtlb, uint32_t way)
418{
419 uint32_t tlbcfg = env->sregs[dtlb ? DTLBCFG : ITLBCFG];
420
421 switch (way) {
422 case 4:
423 return (tlbcfg >> 16) & 0x3;
424
425 case 5:
426 return (tlbcfg >> 20) & 0x1;
427
428 case 6:
429 return (tlbcfg >> 24) & 0x1;
430
431 default:
432 return 0;
433 }
434}
435
436/*!
437 * Get bit mask for the virtual address bits translated by the TLB way
438 */
439uint32_t xtensa_tlb_get_addr_mask(const CPUState *env, bool dtlb, uint32_t way)
440{
441 if (xtensa_option_enabled(env->config, XTENSA_OPTION_MMU)) {
442 bool varway56 = dtlb ?
443 env->config->dtlb.varway56 :
444 env->config->itlb.varway56;
445
446 switch (way) {
447 case 4:
448 return 0xfff00000 << get_page_size(env, dtlb, way) * 2;
449
450 case 5:
451 if (varway56) {
452 return 0xf8000000 << get_page_size(env, dtlb, way);
453 } else {
454 return 0xf8000000;
455 }
456
457 case 6:
458 if (varway56) {
459 return 0xf0000000 << (1 - get_page_size(env, dtlb, way));
460 } else {
461 return 0xf0000000;
462 }
463
464 default:
465 return 0xfffff000;
466 }
467 } else {
468 return REGION_PAGE_MASK;
469 }
470}
471
472/*!
473 * Get bit mask for the 'VPN without index' field.
474 * See ISA, 4.6.5.6, data format for RxTLB0
475 */
476static uint32_t get_vpn_mask(const CPUState *env, bool dtlb, uint32_t way)
477{
478 if (way < 4) {
479 bool is32 = (dtlb ?
480 env->config->dtlb.nrefillentries :
481 env->config->itlb.nrefillentries) == 32;
482 return is32 ? 0xffff8000 : 0xffffc000;
483 } else if (way == 4) {
484 return xtensa_tlb_get_addr_mask(env, dtlb, way) << 2;
485 } else if (way <= 6) {
486 uint32_t mask = xtensa_tlb_get_addr_mask(env, dtlb, way);
487 bool varway56 = dtlb ?
488 env->config->dtlb.varway56 :
489 env->config->itlb.varway56;
490
491 if (varway56) {
492 return mask << (way == 5 ? 2 : 3);
493 } else {
494 return mask << 1;
495 }
496 } else {
497 return 0xfffff000;
498 }
499}
500
501/*!
502 * Split virtual address into VPN (with index) and entry index
503 * for the given TLB way
504 */
505void split_tlb_entry_spec_way(const CPUState *env, uint32_t v, bool dtlb,
506 uint32_t *vpn, uint32_t wi, uint32_t *ei)
507{
508 bool varway56 = dtlb ?
509 env->config->dtlb.varway56 :
510 env->config->itlb.varway56;
511
512 if (!dtlb) {
513 wi &= 7;
514 }
515
516 if (wi < 4) {
517 bool is32 = (dtlb ?
518 env->config->dtlb.nrefillentries :
519 env->config->itlb.nrefillentries) == 32;
520 *ei = (v >> 12) & (is32 ? 0x7 : 0x3);
521 } else {
522 switch (wi) {
523 case 4:
524 {
525 uint32_t eibase = 20 + get_page_size(env, dtlb, wi) * 2;
526 *ei = (v >> eibase) & 0x3;
527 }
528 break;
529
530 case 5:
531 if (varway56) {
532 uint32_t eibase = 27 + get_page_size(env, dtlb, wi);
533 *ei = (v >> eibase) & 0x3;
534 } else {
535 *ei = (v >> 27) & 0x1;
536 }
537 break;
538
539 case 6:
540 if (varway56) {
541 uint32_t eibase = 29 - get_page_size(env, dtlb, wi);
542 *ei = (v >> eibase) & 0x7;
543 } else {
544 *ei = (v >> 28) & 0x1;
545 }
546 break;
547
548 default:
549 *ei = 0;
550 break;
551 }
552 }
553 *vpn = v & xtensa_tlb_get_addr_mask(env, dtlb, wi);
554}
555
556/*!
557 * Split TLB address into TLB way, entry index and VPN (with index).
558 * See ISA, 4.6.5.5 - 4.6.5.8 for the TLB addressing format
559 */
560static void split_tlb_entry_spec(uint32_t v, bool dtlb,
561 uint32_t *vpn, uint32_t *wi, uint32_t *ei)
562{
563 if (xtensa_option_enabled(env->config, XTENSA_OPTION_MMU)) {
564 *wi = v & (dtlb ? 0xf : 0x7);
565 split_tlb_entry_spec_way(env, v, dtlb, vpn, *wi, ei);
566 } else {
567 *vpn = v & REGION_PAGE_MASK;
568 *wi = 0;
569 *ei = (v >> 29) & 0x7;
570 }
571}
572
573static xtensa_tlb_entry *get_tlb_entry(uint32_t v, bool dtlb, uint32_t *pwi)
574{
575 uint32_t vpn;
576 uint32_t wi;
577 uint32_t ei;
578
579 split_tlb_entry_spec(v, dtlb, &vpn, &wi, &ei);
580 if (pwi) {
581 *pwi = wi;
582 }
583 return xtensa_tlb_get_entry(env, dtlb, wi, ei);
584}
585
586uint32_t HELPER(rtlb0)(uint32_t v, uint32_t dtlb)
587{
588 if (xtensa_option_enabled(env->config, XTENSA_OPTION_MMU)) {
589 uint32_t wi;
590 const xtensa_tlb_entry *entry = get_tlb_entry(v, dtlb, &wi);
591 return (entry->vaddr & get_vpn_mask(env, dtlb, wi)) | entry->asid;
592 } else {
593 return v & REGION_PAGE_MASK;
594 }
595}
596
597uint32_t HELPER(rtlb1)(uint32_t v, uint32_t dtlb)
598{
599 const xtensa_tlb_entry *entry = get_tlb_entry(v, dtlb, NULL);
600 return entry->paddr | entry->attr;
601}
602
603void HELPER(itlb)(uint32_t v, uint32_t dtlb)
604{
605 if (xtensa_option_enabled(env->config, XTENSA_OPTION_MMU)) {
606 uint32_t wi;
607 xtensa_tlb_entry *entry = get_tlb_entry(v, dtlb, &wi);
608 if (entry->variable && entry->asid) {
609 tlb_flush_page(env, entry->vaddr);
610 entry->asid = 0;
611 }
612 }
613}
614
615uint32_t HELPER(ptlb)(uint32_t v, uint32_t dtlb)
616{
617 if (xtensa_option_enabled(env->config, XTENSA_OPTION_MMU)) {
618 uint32_t wi;
619 uint32_t ei;
620 uint8_t ring;
621 int res = xtensa_tlb_lookup(env, v, dtlb, &wi, &ei, &ring);
622
623 switch (res) {
624 case 0:
625 if (ring >= xtensa_get_ring(env)) {
626 return (v & 0xfffff000) | wi | (dtlb ? 0x10 : 0x8);
627 }
628 break;
629
630 case INST_TLB_MULTI_HIT_CAUSE:
631 case LOAD_STORE_TLB_MULTI_HIT_CAUSE:
632 HELPER(exception_cause_vaddr)(env->pc, res, v);
633 break;
634 }
635 return 0;
636 } else {
637 return (v & REGION_PAGE_MASK) | 0x1;
638 }
639}
640
641void xtensa_tlb_set_entry(CPUState *env, bool dtlb,
642 unsigned wi, unsigned ei, uint32_t vpn, uint32_t pte)
643{
644 xtensa_tlb_entry *entry = xtensa_tlb_get_entry(env, dtlb, wi, ei);
645
646 if (xtensa_option_enabled(env->config, XTENSA_OPTION_MMU)) {
647 if (entry->variable) {
648 if (entry->asid) {
649 tlb_flush_page(env, entry->vaddr);
650 }
651 entry->vaddr = vpn;
652 entry->paddr = pte & xtensa_tlb_get_addr_mask(env, dtlb, wi);
653 entry->asid = (env->sregs[RASID] >> ((pte >> 1) & 0x18)) & 0xff;
654 entry->attr = pte & 0xf;
655 } else {
656 qemu_log("%s %d, %d, %d trying to set immutable entry\n",
657 __func__, dtlb, wi, ei);
658 }
659 } else {
660 tlb_flush_page(env, entry->vaddr);
661 if (xtensa_option_enabled(env->config,
662 XTENSA_OPTION_REGION_TRANSLATION)) {
663 entry->paddr = pte & REGION_PAGE_MASK;
664 }
665 entry->attr = pte & 0xf;
666 }
667}
668
669void HELPER(wtlb)(uint32_t p, uint32_t v, uint32_t dtlb)
670{
671 uint32_t vpn;
672 uint32_t wi;
673 uint32_t ei;
674 split_tlb_entry_spec(v, dtlb, &vpn, &wi, &ei);
675 xtensa_tlb_set_entry(env, dtlb, wi, ei, vpn, p);
676}