]>
git.proxmox.com Git - mirror_qemu.git/blob - target-alpha/op_helper.c
2 * Alpha emulation cpu micro-operations helpers for qemu.
4 * Copyright (c) 2007 Jocelyn Mayer
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.
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.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
21 #include "dyngen-exec.h"
22 #include "host-utils.h"
23 #include "softfloat.h"
26 #include "qemu-timer.h"
28 /*****************************************************************************/
29 /* Exceptions processing helpers */
31 uint64_t helper_load_pcc (void)
33 #ifndef CONFIG_USER_ONLY
34 /* In system mode we have access to a decent high-resolution clock.
35 In order to make OS-level time accounting work with the RPCC,
36 present it with a well-timed clock fixed at 250MHz. */
37 return (((uint64_t)env
->pcc_ofs
<< 32)
38 | (uint32_t)(qemu_get_clock_ns(vm_clock
) >> 2));
40 /* In user-mode, vm_clock doesn't exist. Just pass through the host cpu
41 clock ticks. Also, don't bother taking PCC_OFS into account. */
42 return (uint32_t)cpu_get_real_ticks();
46 /* PALcode support special instructions */
47 #if !defined (CONFIG_USER_ONLY)
48 void helper_hw_ret (uint64_t a
)
55 swap_shadow_regs(env
);
59 void helper_tbia(void)
64 void helper_tbis(uint64_t p
)
66 tlb_flush_page(env
, p
);
69 void helper_halt(uint64_t restart
)
72 qemu_system_reset_request();
74 qemu_system_shutdown_request();
78 uint64_t helper_get_time(void)
80 return qemu_get_clock_ns(rtc_clock
);
83 void helper_set_alarm(uint64_t expire
)
86 env
->alarm_expire
= expire
;
87 qemu_mod_timer(env
->alarm_timer
, expire
);
89 qemu_del_timer(env
->alarm_timer
);
94 /*****************************************************************************/
96 #if !defined (CONFIG_USER_ONLY)
97 uint64_t helper_ldl_phys(uint64_t p
)
99 return (int32_t)ldl_phys(p
);
102 uint64_t helper_ldq_phys(uint64_t p
)
107 uint64_t helper_ldl_l_phys(uint64_t p
)
110 return env
->lock_value
= (int32_t)ldl_phys(p
);
113 uint64_t helper_ldq_l_phys(uint64_t p
)
116 return env
->lock_value
= ldl_phys(p
);
119 void helper_stl_phys(uint64_t p
, uint64_t v
)
124 void helper_stq_phys(uint64_t p
, uint64_t v
)
129 uint64_t helper_stl_c_phys(uint64_t p
, uint64_t v
)
133 if (p
== env
->lock_addr
) {
134 int32_t old
= ldl_phys(p
);
135 if (old
== (int32_t)env
->lock_value
) {
145 uint64_t helper_stq_c_phys(uint64_t p
, uint64_t v
)
149 if (p
== env
->lock_addr
) {
150 uint64_t old
= ldq_phys(p
);
151 if (old
== env
->lock_value
) {
161 static void QEMU_NORETURN
do_unaligned_access(target_ulong addr
, int is_write
,
162 int is_user
, void *retaddr
)
167 do_restore_state(env
, retaddr
);
172 env
->trap_arg0
= addr
;
173 env
->trap_arg1
= insn
>> 26; /* opcode */
174 env
->trap_arg2
= (insn
>> 21) & 31; /* dest regno */
175 env
->exception_index
= EXCP_UNALIGN
;
180 void QEMU_NORETURN
cpu_unassigned_access(CPUAlphaState
*env1
,
181 target_phys_addr_t addr
, int is_write
,
182 int is_exec
, int unused
, int size
)
185 env
->trap_arg0
= addr
;
186 env
->trap_arg1
= is_write
;
187 dynamic_excp(env1
, GETPC(), EXCP_MCHK
, 0);
190 #include "softmmu_exec.h"
192 #define MMUSUFFIX _mmu
196 #include "softmmu_template.h"
199 #include "softmmu_template.h"
202 #include "softmmu_template.h"
205 #include "softmmu_template.h"
207 /* try to fill the TLB and return an exception if error. If retaddr is
208 NULL, it means that the function was called in C code (i.e. not
209 from generated code or from helper.c) */
210 /* XXX: fix it to restore all registers */
211 void tlb_fill(CPUAlphaState
*env1
, target_ulong addr
, int is_write
, int mmu_idx
,
214 CPUAlphaState
*saved_env
;
219 ret
= cpu_alpha_handle_mmu_fault(env
, addr
, is_write
, mmu_idx
);
220 if (unlikely(ret
!= 0)) {
221 do_restore_state(env
, retaddr
);
222 /* Exception index and error code are already set */