Richard Henderson | 69163fb | 2012-03-24 09:51:12 -0700 | [diff] [blame] | 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 | |
| 20 | #include "cpu.h" |
Richard Henderson | 2ef6175 | 2014-04-07 22:31:41 -0700 | [diff] [blame] | 21 | #include "exec/helper-proto.h" |
Paolo Bonzini | 9c17d61 | 2012-12-17 18:20:04 +0100 | [diff] [blame] | 22 | #include "sysemu/sysemu.h" |
Paolo Bonzini | 1de7afc | 2012-12-17 18:20:00 +0100 | [diff] [blame] | 23 | #include "qemu/timer.h" |
Richard Henderson | 69163fb | 2012-03-24 09:51:12 -0700 | [diff] [blame] | 24 | |
| 25 | |
| 26 | uint64_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 Bligh | bc72ad6 | 2013-08-21 16:03:08 +0100 | [diff] [blame] | 33 | | (uint32_t)(qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) >> 2)); |
Richard Henderson | 69163fb | 2012-03-24 09:51:12 -0700 | [diff] [blame] | 34 | #else |
Alex Bligh | bc72ad6 | 2013-08-21 16:03:08 +0100 | [diff] [blame] | 35 | /* In user-mode, QEMU_CLOCK_VIRTUAL doesn't exist. Just pass through the host cpu |
Richard Henderson | 69163fb | 2012-03-24 09:51:12 -0700 | [diff] [blame] | 36 | clock ticks. Also, don't bother taking PCC_OFS into account. */ |
Christopher Covington | 4a7428c | 2015-09-25 10:42:21 -0400 | [diff] [blame] | 37 | return (uint32_t)cpu_get_host_ticks(); |
Richard Henderson | 69163fb | 2012-03-24 09:51:12 -0700 | [diff] [blame] | 38 | #endif |
| 39 | } |
| 40 | |
| 41 | /* PALcode support special instructions */ |
| 42 | #ifndef CONFIG_USER_ONLY |
Richard Henderson | 69163fb | 2012-03-24 09:51:12 -0700 | [diff] [blame] | 43 | void helper_tbia(CPUAlphaState *env) |
| 44 | { |
Andreas Färber | 00c8cb0 | 2013-09-04 02:19:44 +0200 | [diff] [blame] | 45 | tlb_flush(CPU(alpha_env_get_cpu(env)), 1); |
Richard Henderson | 69163fb | 2012-03-24 09:51:12 -0700 | [diff] [blame] | 46 | } |
| 47 | |
| 48 | void helper_tbis(CPUAlphaState *env, uint64_t p) |
| 49 | { |
Andreas Färber | 31b030d | 2013-09-04 01:29:02 +0200 | [diff] [blame] | 50 | tlb_flush_page(CPU(alpha_env_get_cpu(env)), p); |
Richard Henderson | 69163fb | 2012-03-24 09:51:12 -0700 | [diff] [blame] | 51 | } |
| 52 | |
Richard Henderson | a9ead83 | 2013-07-26 12:00:32 -1000 | [diff] [blame] | 53 | void helper_tb_flush(CPUAlphaState *env) |
| 54 | { |
Peter Crosthwaite | bbd77c1 | 2015-06-23 19:31:15 -0700 | [diff] [blame] | 55 | tb_flush(CPU(alpha_env_get_cpu(env))); |
Richard Henderson | a9ead83 | 2013-07-26 12:00:32 -1000 | [diff] [blame] | 56 | } |
| 57 | |
Richard Henderson | 69163fb | 2012-03-24 09:51:12 -0700 | [diff] [blame] | 58 | void 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 Henderson | 19e0cbb | 2013-07-16 06:45:57 -0700 | [diff] [blame] | 67 | uint64_t helper_get_vmtime(void) |
| 68 | { |
Alex Bligh | bc72ad6 | 2013-08-21 16:03:08 +0100 | [diff] [blame] | 69 | return qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); |
Richard Henderson | 19e0cbb | 2013-07-16 06:45:57 -0700 | [diff] [blame] | 70 | } |
| 71 | |
| 72 | uint64_t helper_get_walltime(void) |
Richard Henderson | 69163fb | 2012-03-24 09:51:12 -0700 | [diff] [blame] | 73 | { |
Alex Bligh | 884f17c | 2013-08-21 16:03:04 +0100 | [diff] [blame] | 74 | return qemu_clock_get_ns(rtc_clock); |
Richard Henderson | 69163fb | 2012-03-24 09:51:12 -0700 | [diff] [blame] | 75 | } |
| 76 | |
| 77 | void helper_set_alarm(CPUAlphaState *env, uint64_t expire) |
| 78 | { |
Andreas Färber | c924585 | 2012-10-31 02:41:11 +0100 | [diff] [blame] | 79 | AlphaCPU *cpu = alpha_env_get_cpu(env); |
| 80 | |
Richard Henderson | 69163fb | 2012-03-24 09:51:12 -0700 | [diff] [blame] | 81 | if (expire) { |
| 82 | env->alarm_expire = expire; |
Alex Bligh | bc72ad6 | 2013-08-21 16:03:08 +0100 | [diff] [blame] | 83 | timer_mod(cpu->alarm_timer, expire); |
Richard Henderson | 69163fb | 2012-03-24 09:51:12 -0700 | [diff] [blame] | 84 | } else { |
Alex Bligh | bc72ad6 | 2013-08-21 16:03:08 +0100 | [diff] [blame] | 85 | timer_del(cpu->alarm_timer); |
Richard Henderson | 69163fb | 2012-03-24 09:51:12 -0700 | [diff] [blame] | 86 | } |
| 87 | } |
Richard Henderson | ba96394 | 2013-07-26 11:22:21 -1000 | [diff] [blame] | 88 | |
Richard Henderson | 69163fb | 2012-03-24 09:51:12 -0700 | [diff] [blame] | 89 | #endif /* CONFIG_USER_ONLY */ |