]> git.proxmox.com Git - mirror_qemu.git/blame - target-alpha/mem_helper.c
test-qga: Avoid qobject_from_jsonv("%"PRId64)
[mirror_qemu.git] / target-alpha / mem_helper.c
CommitLineData
4c9649a9 1/*
c3082755 2 * Helpers for loads and stores
5fafdf24 3 *
4c9649a9
JM
4 * Copyright (c) 2007 Jocelyn Mayer
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
8167ee88 17 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
4c9649a9
JM
18 */
19
e2e5e114 20#include "qemu/osdep.h"
3e457172 21#include "cpu.h"
2ef6175a 22#include "exec/helper-proto.h"
63c91552 23#include "exec/exec-all.h"
f08b6170 24#include "exec/cpu_ldst.h"
4c9649a9 25
4c9649a9 26/* Softmmu support */
c3082755 27#ifndef CONFIG_USER_ONLY
93e22326 28void alpha_cpu_do_unaligned_access(CPUState *cs, vaddr addr,
b35399bb
SS
29 MMUAccessType access_type,
30 int mmu_idx, uintptr_t retaddr)
5b450407 31{
93e22326
PB
32 AlphaCPU *cpu = ALPHA_CPU(cs);
33 CPUAlphaState *env = &cpu->env;
5b450407
RH
34 uint64_t pc;
35 uint32_t insn;
36
a8a826a3 37 if (retaddr) {
3f38f309 38 cpu_restore_state(cs, retaddr);
a8a826a3 39 }
5b450407
RH
40
41 pc = env->pc;
c3082755 42 insn = cpu_ldl_code(env, pc);
5b450407
RH
43
44 env->trap_arg0 = addr;
45 env->trap_arg1 = insn >> 26; /* opcode */
46 env->trap_arg2 = (insn >> 21) & 31; /* dest regno */
27103424 47 cs->exception_index = EXCP_UNALIGN;
b9f0923e 48 env->error_code = 0;
5638d180 49 cpu_loop_exit(cs);
5b450407
RH
50}
51
c658b94f
AF
52void alpha_cpu_unassigned_access(CPUState *cs, hwaddr addr,
53 bool is_write, bool is_exec, int unused,
54 unsigned size)
5b450407 55{
c658b94f
AF
56 AlphaCPU *cpu = ALPHA_CPU(cs);
57 CPUAlphaState *env = &cpu->env;
58
5b450407 59 env->trap_arg0 = addr;
c658b94f 60 env->trap_arg1 = is_write ? 1 : 0;
ba9c5de5
RH
61 cs->exception_index = EXCP_MCHK;
62 env->error_code = 0;
63
64 /* ??? We should cpu_restore_state to the faulting insn, but this hook
67cc32eb 65 does not have access to the retaddr value from the original helper.
ba9c5de5
RH
66 It's all moot until the QEMU PALcode grows an MCHK handler. */
67
68 cpu_loop_exit(cs);
5b450407
RH
69}
70
4c9649a9
JM
71/* try to fill the TLB and return an exception if error. If retaddr is
72 NULL, it means that the function was called in C code (i.e. not
73 from generated code or from helper.c) */
74/* XXX: fix it to restore all registers */
b35399bb 75void tlb_fill(CPUState *cs, target_ulong addr, MMUAccessType access_type,
20503968 76 int mmu_idx, uintptr_t retaddr)
4c9649a9 77{
4c9649a9
JM
78 int ret;
79
b35399bb 80 ret = alpha_cpu_handle_mmu_fault(cs, addr, access_type, mmu_idx);
2d9671d3 81 if (unlikely(ret != 0)) {
a8a826a3 82 if (retaddr) {
3f38f309 83 cpu_restore_state(cs, retaddr);
a8a826a3 84 }
4c9649a9 85 /* Exception index and error code are already set */
5638d180 86 cpu_loop_exit(cs);
4c9649a9 87 }
4c9649a9 88}
c3082755 89#endif /* CONFIG_USER_ONLY */