]>
Commit | Line | Data |
---|---|---|
69163fbb RH |
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 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 | ||
e2e5e114 | 20 | #include "qemu/osdep.h" |
69163fbb | 21 | #include "cpu.h" |
63c91552 | 22 | #include "exec/exec-all.h" |
2ef6175a | 23 | #include "exec/helper-proto.h" |
54d31236 | 24 | #include "sysemu/runstate.h" |
9c17d615 | 25 | #include "sysemu/sysemu.h" |
1de7afc9 | 26 | #include "qemu/timer.h" |
69163fbb RH |
27 | |
28 | ||
29 | uint64_t helper_load_pcc(CPUAlphaState *env) | |
30 | { | |
31 | #ifndef CONFIG_USER_ONLY | |
32 | /* In system mode we have access to a decent high-resolution clock. | |
33 | In order to make OS-level time accounting work with the RPCC, | |
34 | present it with a well-timed clock fixed at 250MHz. */ | |
35 | return (((uint64_t)env->pcc_ofs << 32) | |
bc72ad67 | 36 | | (uint32_t)(qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) >> 2)); |
69163fbb | 37 | #else |
bc72ad67 | 38 | /* In user-mode, QEMU_CLOCK_VIRTUAL doesn't exist. Just pass through the host cpu |
69163fbb | 39 | clock ticks. Also, don't bother taking PCC_OFS into account. */ |
4a7428c5 | 40 | return (uint32_t)cpu_get_host_ticks(); |
69163fbb RH |
41 | #endif |
42 | } | |
43 | ||
44 | /* PALcode support special instructions */ | |
45 | #ifndef CONFIG_USER_ONLY | |
69163fbb RH |
46 | void helper_tbia(CPUAlphaState *env) |
47 | { | |
1c7ad260 | 48 | tlb_flush(env_cpu(env)); |
69163fbb RH |
49 | } |
50 | ||
51 | void helper_tbis(CPUAlphaState *env, uint64_t p) | |
52 | { | |
1c7ad260 | 53 | tlb_flush_page(env_cpu(env), p); |
69163fbb RH |
54 | } |
55 | ||
a9ead832 RH |
56 | void helper_tb_flush(CPUAlphaState *env) |
57 | { | |
1c7ad260 | 58 | tb_flush(env_cpu(env)); |
a9ead832 RH |
59 | } |
60 | ||
69163fbb RH |
61 | void helper_halt(uint64_t restart) |
62 | { | |
63 | if (restart) { | |
cf83f140 | 64 | qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET); |
69163fbb | 65 | } else { |
cf83f140 | 66 | qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN); |
69163fbb RH |
67 | } |
68 | } | |
69 | ||
19e0cbb8 RH |
70 | uint64_t helper_get_vmtime(void) |
71 | { | |
bc72ad67 | 72 | return qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); |
19e0cbb8 RH |
73 | } |
74 | ||
75 | uint64_t helper_get_walltime(void) | |
69163fbb | 76 | { |
884f17c2 | 77 | return qemu_clock_get_ns(rtc_clock); |
69163fbb RH |
78 | } |
79 | ||
80 | void helper_set_alarm(CPUAlphaState *env, uint64_t expire) | |
81 | { | |
1c7ad260 | 82 | AlphaCPU *cpu = env_archcpu(env); |
c9245853 | 83 | |
69163fbb RH |
84 | if (expire) { |
85 | env->alarm_expire = expire; | |
bc72ad67 | 86 | timer_mod(cpu->alarm_timer, expire); |
69163fbb | 87 | } else { |
bc72ad67 | 88 | timer_del(cpu->alarm_timer); |
69163fbb RH |
89 | } |
90 | } | |
ba96394e | 91 | |
69163fbb | 92 | #endif /* CONFIG_USER_ONLY */ |