Statistics
| Branch: | Revision:

root / target-cris / op_helper.c @ 273af660

History | View | Annotate | Download (2.4 kB)

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