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