Statistics
| Branch: | Revision:

root / target-cris / op_helper.c @ 94cff60a

History | View | Annotate | Download (2.3 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 81fdc5f8 ths
#define GETPC() (__builtin_return_address(0))
27 81fdc5f8 ths
28 81fdc5f8 ths
#define SHIFT 0
29 81fdc5f8 ths
#include "softmmu_template.h"
30 81fdc5f8 ths
31 81fdc5f8 ths
#define SHIFT 1
32 81fdc5f8 ths
#include "softmmu_template.h"
33 81fdc5f8 ths
34 81fdc5f8 ths
#define SHIFT 2
35 81fdc5f8 ths
#include "softmmu_template.h"
36 81fdc5f8 ths
37 81fdc5f8 ths
#define SHIFT 3
38 81fdc5f8 ths
#include "softmmu_template.h"
39 81fdc5f8 ths
40 81fdc5f8 ths
/* Try to fill the TLB and return an exception if error. If retaddr is
41 81fdc5f8 ths
   NULL, it means that the function was called in C code (i.e. not
42 81fdc5f8 ths
   from generated code or from helper.c) */
43 81fdc5f8 ths
/* XXX: fix it to restore all registers */
44 81fdc5f8 ths
void tlb_fill (target_ulong addr, int is_write, int is_user, void *retaddr)
45 81fdc5f8 ths
{
46 81fdc5f8 ths
    TranslationBlock *tb;
47 81fdc5f8 ths
    CPUState *saved_env;
48 81fdc5f8 ths
    target_phys_addr_t pc;
49 81fdc5f8 ths
    int ret;
50 81fdc5f8 ths
51 81fdc5f8 ths
    /* XXX: hack to restore env in all cases, even if not called from
52 81fdc5f8 ths
       generated code */
53 81fdc5f8 ths
    saved_env = env;
54 81fdc5f8 ths
    env = cpu_single_env;
55 81fdc5f8 ths
    ret = cpu_cris_handle_mmu_fault(env, addr, is_write, is_user, 1);
56 81fdc5f8 ths
    if (__builtin_expect(ret, 0)) {
57 81fdc5f8 ths
        if (retaddr) {
58 81fdc5f8 ths
            /* now we have a real cpu fault */
59 81fdc5f8 ths
            pc = (target_phys_addr_t)retaddr;
60 81fdc5f8 ths
            tb = tb_find_pc(pc);
61 81fdc5f8 ths
            if (tb) {
62 81fdc5f8 ths
                /* the PC is inside the translated code. It means that we have
63 81fdc5f8 ths
                   a virtual CPU fault */
64 81fdc5f8 ths
                cpu_restore_state(tb, env, pc, NULL);
65 81fdc5f8 ths
            }
66 81fdc5f8 ths
        }
67 81fdc5f8 ths
        cpu_loop_exit();
68 81fdc5f8 ths
    }
69 81fdc5f8 ths
    env = saved_env;
70 81fdc5f8 ths
}
71 81fdc5f8 ths
72 81fdc5f8 ths
void do_unassigned_access(target_phys_addr_t addr, int is_write, int is_exec,
73 81fdc5f8 ths
                          int is_asi)
74 81fdc5f8 ths
{
75 81fdc5f8 ths
76 81fdc5f8 ths
}