xref: /qemu/target/ppc/user_only_helper.c (revision 0d75590d919454be322f21d55494b8937651fc86)
1cc8eae8aSDavid Gibson /*
2cc8eae8aSDavid Gibson  *  PowerPC MMU stub handling for user mode emulation
3cc8eae8aSDavid Gibson  *
4cc8eae8aSDavid Gibson  *  Copyright (c) 2003-2007 Jocelyn Mayer
5cc8eae8aSDavid Gibson  *  Copyright (c) 2013 David Gibson, IBM Corporation.
6cc8eae8aSDavid Gibson  *
7cc8eae8aSDavid Gibson  * This library is free software; you can redistribute it and/or
8cc8eae8aSDavid Gibson  * modify it under the terms of the GNU Lesser General Public
9cc8eae8aSDavid Gibson  * License as published by the Free Software Foundation; either
10cc8eae8aSDavid Gibson  * version 2 of the License, or (at your option) any later version.
11cc8eae8aSDavid Gibson  *
12cc8eae8aSDavid Gibson  * This library is distributed in the hope that it will be useful,
13cc8eae8aSDavid Gibson  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14cc8eae8aSDavid Gibson  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15cc8eae8aSDavid Gibson  * Lesser General Public License for more details.
16cc8eae8aSDavid Gibson  *
17cc8eae8aSDavid Gibson  * You should have received a copy of the GNU Lesser General Public
18cc8eae8aSDavid Gibson  * License along with this library; if not, see <http://www.gnu.org/licenses/>.
19cc8eae8aSDavid Gibson  */
20cc8eae8aSDavid Gibson 
210d75590dSPeter Maydell #include "qemu/osdep.h"
22cc8eae8aSDavid Gibson #include "cpu.h"
23cc8eae8aSDavid Gibson 
247510454eSAndreas Färber int ppc_cpu_handle_mmu_fault(CPUState *cs, vaddr address, int rw,
25cc8eae8aSDavid Gibson                              int mmu_idx)
26cc8eae8aSDavid Gibson {
277510454eSAndreas Färber     PowerPCCPU *cpu = POWERPC_CPU(cs);
287510454eSAndreas Färber     CPUPPCState *env = &cpu->env;
29cc8eae8aSDavid Gibson     int exception, error_code;
30cc8eae8aSDavid Gibson 
31cc8eae8aSDavid Gibson     if (rw == 2) {
32cc8eae8aSDavid Gibson         exception = POWERPC_EXCP_ISI;
33cc8eae8aSDavid Gibson         error_code = 0x40000000;
34cc8eae8aSDavid Gibson     } else {
35cc8eae8aSDavid Gibson         exception = POWERPC_EXCP_DSI;
36cc8eae8aSDavid Gibson         error_code = 0x40000000;
37cc8eae8aSDavid Gibson         if (rw) {
38cc8eae8aSDavid Gibson             error_code |= 0x02000000;
39cc8eae8aSDavid Gibson         }
40cc8eae8aSDavid Gibson         env->spr[SPR_DAR] = address;
41cc8eae8aSDavid Gibson         env->spr[SPR_DSISR] = error_code;
42cc8eae8aSDavid Gibson     }
4327103424SAndreas Färber     cs->exception_index = exception;
44cc8eae8aSDavid Gibson     env->error_code = error_code;
45cc8eae8aSDavid Gibson 
46cc8eae8aSDavid Gibson     return 1;
47cc8eae8aSDavid Gibson }
48