master
c 74 lines 1.82 KB
Raw
1 /*
2 * Helpers for system instructions.
3 *
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.1 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
17 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #include "qemu/osdep.h"
21 #include "cpu.h"
22 #include "exec/cputlb.h"
23 #include "exec/helper-proto.h"
24 #include "system/runstate.h"
25 #include "system/system.h"
26 #include "qemu/timer.h"
27
28
29 /* PALcode support special instructions */
30 void helper_tbia(CPUAlphaState *env)
31 {
32 tlb_flush(env_cpu(env));
33 }
34
35 void helper_tbis(CPUAlphaState *env, uint64_t p)
36 {
37 tlb_flush_page(env_cpu(env), p);
38 }
39
40 void helper_halt(uint64_t restart)
41 {
42 if (restart) {
43 qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET);
44 } else {
45 qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN);
46 }
47 }
48
49 uint64_t helper_get_vmtime(void)
50 {
51 return qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
52 }
53
54 uint64_t helper_get_walltime(void)
55 {
56 return qemu_clock_get_ns(rtc_clock);
57 }
58
59 void helper_set_alarm(CPUAlphaState *env, uint64_t expire)
60 {
61 AlphaCPU *cpu = env_archcpu(env);
62
63 if (expire) {
64 env->alarm_expire = expire;
65 timer_mod(cpu->alarm_timer, expire);
66 } else {
67 timer_del(cpu->alarm_timer);
68 }
69 }
70
71 uint64_t HELPER(whami)(CPUAlphaState *env)
72 {
73 return env_cpu(env)->cpu_index;
74 }