blob: 75c96c1c207c7aad339e21d707800ba408de300f [file] [log] [blame]
Richard Henderson69163fb2012-03-24 09:51:12 -07001/*
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
20#include "cpu.h"
Richard Henderson2ef61752014-04-07 22:31:41 -070021#include "exec/helper-proto.h"
Paolo Bonzini9c17d612012-12-17 18:20:04 +010022#include "sysemu/sysemu.h"
Paolo Bonzini1de7afc2012-12-17 18:20:00 +010023#include "qemu/timer.h"
Richard Henderson69163fb2012-03-24 09:51:12 -070024
25
26uint64_t helper_load_pcc(CPUAlphaState *env)
27{
28#ifndef CONFIG_USER_ONLY
29 /* In system mode we have access to a decent high-resolution clock.
30 In order to make OS-level time accounting work with the RPCC,
31 present it with a well-timed clock fixed at 250MHz. */
32 return (((uint64_t)env->pcc_ofs << 32)
Alex Blighbc72ad62013-08-21 16:03:08 +010033 | (uint32_t)(qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) >> 2));
Richard Henderson69163fb2012-03-24 09:51:12 -070034#else
Alex Blighbc72ad62013-08-21 16:03:08 +010035 /* In user-mode, QEMU_CLOCK_VIRTUAL doesn't exist. Just pass through the host cpu
Richard Henderson69163fb2012-03-24 09:51:12 -070036 clock ticks. Also, don't bother taking PCC_OFS into account. */
Christopher Covington4a7428c2015-09-25 10:42:21 -040037 return (uint32_t)cpu_get_host_ticks();
Richard Henderson69163fb2012-03-24 09:51:12 -070038#endif
39}
40
41/* PALcode support special instructions */
42#ifndef CONFIG_USER_ONLY
Richard Henderson69163fb2012-03-24 09:51:12 -070043void helper_tbia(CPUAlphaState *env)
44{
Andreas Färber00c8cb02013-09-04 02:19:44 +020045 tlb_flush(CPU(alpha_env_get_cpu(env)), 1);
Richard Henderson69163fb2012-03-24 09:51:12 -070046}
47
48void helper_tbis(CPUAlphaState *env, uint64_t p)
49{
Andreas Färber31b030d2013-09-04 01:29:02 +020050 tlb_flush_page(CPU(alpha_env_get_cpu(env)), p);
Richard Henderson69163fb2012-03-24 09:51:12 -070051}
52
Richard Hendersona9ead832013-07-26 12:00:32 -100053void helper_tb_flush(CPUAlphaState *env)
54{
Peter Crosthwaitebbd77c12015-06-23 19:31:15 -070055 tb_flush(CPU(alpha_env_get_cpu(env)));
Richard Hendersona9ead832013-07-26 12:00:32 -100056}
57
Richard Henderson69163fb2012-03-24 09:51:12 -070058void helper_halt(uint64_t restart)
59{
60 if (restart) {
61 qemu_system_reset_request();
62 } else {
63 qemu_system_shutdown_request();
64 }
65}
66
Richard Henderson19e0cbb2013-07-16 06:45:57 -070067uint64_t helper_get_vmtime(void)
68{
Alex Blighbc72ad62013-08-21 16:03:08 +010069 return qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
Richard Henderson19e0cbb2013-07-16 06:45:57 -070070}
71
72uint64_t helper_get_walltime(void)
Richard Henderson69163fb2012-03-24 09:51:12 -070073{
Alex Bligh884f17c2013-08-21 16:03:04 +010074 return qemu_clock_get_ns(rtc_clock);
Richard Henderson69163fb2012-03-24 09:51:12 -070075}
76
77void helper_set_alarm(CPUAlphaState *env, uint64_t expire)
78{
Andreas Färberc9245852012-10-31 02:41:11 +010079 AlphaCPU *cpu = alpha_env_get_cpu(env);
80
Richard Henderson69163fb2012-03-24 09:51:12 -070081 if (expire) {
82 env->alarm_expire = expire;
Alex Blighbc72ad62013-08-21 16:03:08 +010083 timer_mod(cpu->alarm_timer, expire);
Richard Henderson69163fb2012-03-24 09:51:12 -070084 } else {
Alex Blighbc72ad62013-08-21 16:03:08 +010085 timer_del(cpu->alarm_timer);
Richard Henderson69163fb2012-03-24 09:51:12 -070086 }
87}
Richard Hendersonba963942013-07-26 11:22:21 -100088
Richard Henderson69163fb2012-03-24 09:51:12 -070089#endif /* CONFIG_USER_ONLY */