]> git.proxmox.com Git - qemu.git/blob - target-cris/op_helper.c
701c835be1d61fb8644aa666e8946b347745ed5a
[qemu.git] / target-cris / op_helper.c
1 /*
2 * CRIS helper routines
3 *
4 * Copyright (c) 2007 AXIS Communications
5 * Written by Edgar E. Iglesias
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */
21
22 #include <assert.h>
23 #include "exec.h"
24 #include "mmu.h"
25
26 #define MMUSUFFIX _mmu
27 #ifdef __s390__
28 # define GETPC() ((void*)((unsigned long)__builtin_return_address(0) & 0x7fffffffUL))
29 #else
30 # define GETPC() (__builtin_return_address(0))
31 #endif
32
33 #define SHIFT 0
34 #include "softmmu_template.h"
35
36 #define SHIFT 1
37 #include "softmmu_template.h"
38
39 #define SHIFT 2
40 #include "softmmu_template.h"
41
42 #define SHIFT 3
43 #include "softmmu_template.h"
44
45 #define D(x)
46
47 /* Try to fill the TLB and return an exception if error. If retaddr is
48 NULL, it means that the function was called in C code (i.e. not
49 from generated code or from helper.c) */
50 /* XXX: fix it to restore all registers */
51 void tlb_fill (target_ulong addr, int is_write, int mmu_idx, void *retaddr)
52 {
53 TranslationBlock *tb;
54 CPUState *saved_env;
55 unsigned long pc;
56 int ret;
57
58 /* XXX: hack to restore env in all cases, even if not called from
59 generated code */
60 saved_env = env;
61 env = cpu_single_env;
62 ret = cpu_cris_handle_mmu_fault(env, addr, is_write, mmu_idx, 1);
63 if (__builtin_expect(ret, 0)) {
64 if (retaddr) {
65 /* now we have a real cpu fault */
66 pc = (unsigned long)retaddr;
67 tb = tb_find_pc(pc);
68 if (tb) {
69 /* the PC is inside the translated code. It means that we have
70 a virtual CPU fault */
71 cpu_restore_state(tb, env, pc, NULL);
72 }
73 }
74 cpu_loop_exit();
75 }
76 env = saved_env;
77 }
78
79 void helper_tlb_update(uint32_t T0)
80 {
81 #if !defined(CONFIG_USER_ONLY)
82 uint32_t vaddr;
83
84 vaddr = cris_mmu_tlb_latest_update(env, T0);
85 D(printf("flush vaddr %x\n", vaddr));
86 tlb_flush_page(env, vaddr);
87 #endif
88 }
89
90 void do_unassigned_access(target_phys_addr_t addr, int is_write, int is_exec,
91 int is_asi)
92 {
93 D(printf("%s addr=%x w=%d ex=%d asi=%d\n",
94 __func__, addr, is_write, is_exec, is_asi));
95 }