Statistics
| Branch: | Revision:

root / target-openrisc / interrupt_helper.c @ bdf7ae5b

History | View | Annotate | Download (1.8 kB)

1 b6a71ef7 Jia Liu
/*
2 b6a71ef7 Jia Liu
 * OpenRISC interrupt helper routines
3 b6a71ef7 Jia Liu
 *
4 b6a71ef7 Jia Liu
 * Copyright (c) 2011-2012 Jia Liu <proljc@gmail.com>
5 b6a71ef7 Jia Liu
 *                         Feng Gao <gf91597@gmail.com>
6 b6a71ef7 Jia Liu
 *
7 b6a71ef7 Jia Liu
 * This library is free software; you can redistribute it and/or
8 b6a71ef7 Jia Liu
 * modify it under the terms of the GNU Lesser General Public
9 b6a71ef7 Jia Liu
 * License as published by the Free Software Foundation; either
10 b6a71ef7 Jia Liu
 * version 2 of the License, or (at your option) any later version.
11 b6a71ef7 Jia Liu
 *
12 b6a71ef7 Jia Liu
 * This library is distributed in the hope that it will be useful,
13 b6a71ef7 Jia Liu
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 b6a71ef7 Jia Liu
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 b6a71ef7 Jia Liu
 * Lesser General Public License for more details.
16 b6a71ef7 Jia Liu
 *
17 b6a71ef7 Jia Liu
 * You should have received a copy of the GNU Lesser General Public
18 b6a71ef7 Jia Liu
 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
19 b6a71ef7 Jia Liu
 */
20 b6a71ef7 Jia Liu
21 b6a71ef7 Jia Liu
#include "cpu.h"
22 b6a71ef7 Jia Liu
#include "helper.h"
23 b6a71ef7 Jia Liu
24 b6a71ef7 Jia Liu
void HELPER(rfe)(CPUOpenRISCState *env)
25 b6a71ef7 Jia Liu
{
26 dd51dc52 Andreas Färber
    OpenRISCCPU *cpu = openrisc_env_get_cpu(env);
27 259186a7 Andreas Färber
    CPUState *cs = CPU(cpu);
28 b6a71ef7 Jia Liu
#ifndef CONFIG_USER_ONLY
29 b6a71ef7 Jia Liu
    int need_flush_tlb = (cpu->env.sr & (SR_SM | SR_IME | SR_DME)) ^
30 b6a71ef7 Jia Liu
                         (cpu->env.esr & (SR_SM | SR_IME | SR_DME));
31 b6a71ef7 Jia Liu
#endif
32 b6a71ef7 Jia Liu
    cpu->env.pc = cpu->env.epcr;
33 b6a71ef7 Jia Liu
    cpu->env.npc = cpu->env.epcr;
34 b6a71ef7 Jia Liu
    cpu->env.sr = cpu->env.esr;
35 b6a71ef7 Jia Liu
36 b6a71ef7 Jia Liu
#ifndef CONFIG_USER_ONLY
37 b6a71ef7 Jia Liu
    if (cpu->env.sr & SR_DME) {
38 b6a71ef7 Jia Liu
        cpu->env.tlb->cpu_openrisc_map_address_data =
39 b6a71ef7 Jia Liu
            &cpu_openrisc_get_phys_data;
40 b6a71ef7 Jia Liu
    } else {
41 b6a71ef7 Jia Liu
        cpu->env.tlb->cpu_openrisc_map_address_data =
42 b6a71ef7 Jia Liu
            &cpu_openrisc_get_phys_nommu;
43 b6a71ef7 Jia Liu
    }
44 b6a71ef7 Jia Liu
45 b6a71ef7 Jia Liu
    if (cpu->env.sr & SR_IME) {
46 b6a71ef7 Jia Liu
        cpu->env.tlb->cpu_openrisc_map_address_code =
47 b6a71ef7 Jia Liu
            &cpu_openrisc_get_phys_code;
48 b6a71ef7 Jia Liu
    } else {
49 b6a71ef7 Jia Liu
        cpu->env.tlb->cpu_openrisc_map_address_code =
50 b6a71ef7 Jia Liu
            &cpu_openrisc_get_phys_nommu;
51 b6a71ef7 Jia Liu
    }
52 b6a71ef7 Jia Liu
53 b6a71ef7 Jia Liu
    if (need_flush_tlb) {
54 b6a71ef7 Jia Liu
        tlb_flush(&cpu->env, 1);
55 b6a71ef7 Jia Liu
    }
56 b6a71ef7 Jia Liu
#endif
57 259186a7 Andreas Färber
    cs->interrupt_request |= CPU_INTERRUPT_EXITTB;
58 b6a71ef7 Jia Liu
}