Statistics
| Branch: | Revision:

root / target-ppc / user_only_helper.c @ dc364f4c

History | View | Annotate | Download (1.4 kB)

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