root / target-openrisc / interrupt.c @ 45724d6d
History | View | Annotate | Download (2.3 kB)
1 | e67db06e | Jia Liu | /*
|
---|---|---|---|
2 | e67db06e | Jia Liu | * OpenRISC interrupt.
|
3 | e67db06e | Jia Liu | *
|
4 | e67db06e | Jia Liu | * Copyright (c) 2011-2012 Jia Liu <proljc@gmail.com>
|
5 | e67db06e | Jia Liu | *
|
6 | e67db06e | Jia Liu | * This library is free software; you can redistribute it and/or
|
7 | e67db06e | Jia Liu | * modify it under the terms of the GNU Lesser General Public
|
8 | e67db06e | Jia Liu | * License as published by the Free Software Foundation; either
|
9 | e67db06e | Jia Liu | * version 2 of the License, or (at your option) any later version.
|
10 | e67db06e | Jia Liu | *
|
11 | e67db06e | Jia Liu | * This library is distributed in the hope that it will be useful,
|
12 | e67db06e | Jia Liu | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 | e67db06e | Jia Liu | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14 | e67db06e | Jia Liu | * Lesser General Public License for more details.
|
15 | e67db06e | Jia Liu | *
|
16 | e67db06e | Jia Liu | * You should have received a copy of the GNU Lesser General Public
|
17 | e67db06e | Jia Liu | * License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
18 | e67db06e | Jia Liu | */
|
19 | e67db06e | Jia Liu | |
20 | e67db06e | Jia Liu | #include "cpu.h" |
21 | e67db06e | Jia Liu | #include "qemu-common.h" |
22 | e67db06e | Jia Liu | #include "gdbstub.h" |
23 | e67db06e | Jia Liu | #include "host-utils.h" |
24 | e67db06e | Jia Liu | #ifndef CONFIG_USER_ONLY
|
25 | e67db06e | Jia Liu | #include "hw/loader.h" |
26 | e67db06e | Jia Liu | #endif
|
27 | e67db06e | Jia Liu | |
28 | e67db06e | Jia Liu | void do_interrupt(CPUOpenRISCState *env)
|
29 | e67db06e | Jia Liu | { |
30 | b6a71ef7 | Jia Liu | #ifndef CONFIG_USER_ONLY
|
31 | b6a71ef7 | Jia Liu | if (env->flags & D_FLAG) { /* Delay Slot insn */ |
32 | b6a71ef7 | Jia Liu | env->flags &= ~D_FLAG; |
33 | b6a71ef7 | Jia Liu | env->sr |= SR_DSX; |
34 | b6a71ef7 | Jia Liu | if (env->exception_index == EXCP_TICK ||
|
35 | b6a71ef7 | Jia Liu | env->exception_index == EXCP_INT || |
36 | b6a71ef7 | Jia Liu | env->exception_index == EXCP_SYSCALL || |
37 | b6a71ef7 | Jia Liu | env->exception_index == EXCP_FPE) { |
38 | b6a71ef7 | Jia Liu | env->epcr = env->jmp_pc; |
39 | b6a71ef7 | Jia Liu | } else {
|
40 | b6a71ef7 | Jia Liu | env->epcr = env->pc - 4;
|
41 | b6a71ef7 | Jia Liu | } |
42 | b6a71ef7 | Jia Liu | } else {
|
43 | b6a71ef7 | Jia Liu | if (env->exception_index == EXCP_TICK ||
|
44 | b6a71ef7 | Jia Liu | env->exception_index == EXCP_INT || |
45 | b6a71ef7 | Jia Liu | env->exception_index == EXCP_SYSCALL || |
46 | b6a71ef7 | Jia Liu | env->exception_index == EXCP_FPE) { |
47 | b6a71ef7 | Jia Liu | env->epcr = env->npc; |
48 | b6a71ef7 | Jia Liu | } else {
|
49 | b6a71ef7 | Jia Liu | env->epcr = env->pc; |
50 | b6a71ef7 | Jia Liu | } |
51 | b6a71ef7 | Jia Liu | } |
52 | b6a71ef7 | Jia Liu | |
53 | b6a71ef7 | Jia Liu | /* For machine-state changed between user-mode and supervisor mode,
|
54 | b6a71ef7 | Jia Liu | we need flush TLB when we enter&exit EXCP. */
|
55 | b6a71ef7 | Jia Liu | tlb_flush(env, 1);
|
56 | b6a71ef7 | Jia Liu | |
57 | b6a71ef7 | Jia Liu | env->esr = env->sr; |
58 | b6a71ef7 | Jia Liu | env->sr &= ~SR_DME; |
59 | b6a71ef7 | Jia Liu | env->sr &= ~SR_IME; |
60 | b6a71ef7 | Jia Liu | env->sr |= SR_SM; |
61 | b6a71ef7 | Jia Liu | env->sr &= ~SR_IEE; |
62 | b6a71ef7 | Jia Liu | env->sr &= ~SR_TEE; |
63 | b6a71ef7 | Jia Liu | env->tlb->cpu_openrisc_map_address_data = &cpu_openrisc_get_phys_nommu; |
64 | b6a71ef7 | Jia Liu | env->tlb->cpu_openrisc_map_address_code = &cpu_openrisc_get_phys_nommu; |
65 | b6a71ef7 | Jia Liu | |
66 | b6a71ef7 | Jia Liu | if (env->exception_index > 0 && env->exception_index < EXCP_NR) { |
67 | b6a71ef7 | Jia Liu | env->pc = (env->exception_index << 8);
|
68 | b6a71ef7 | Jia Liu | } else {
|
69 | b6a71ef7 | Jia Liu | cpu_abort(env, "Unhandled exception 0x%x\n", env->exception_index);
|
70 | b6a71ef7 | Jia Liu | } |
71 | b6a71ef7 | Jia Liu | #endif
|
72 | b6a71ef7 | Jia Liu | |
73 | b6a71ef7 | Jia Liu | env->exception_index = -1;
|
74 | e67db06e | Jia Liu | } |