1fcf5ef2aSThomas Huth /* 2fcf5ef2aSThomas Huth * Helpers for system instructions. 3fcf5ef2aSThomas Huth * 4fcf5ef2aSThomas Huth * Copyright (c) 2007 Jocelyn Mayer 5fcf5ef2aSThomas Huth * 6fcf5ef2aSThomas Huth * This library is free software; you can redistribute it and/or 7fcf5ef2aSThomas Huth * modify it under the terms of the GNU Lesser General Public 8fcf5ef2aSThomas Huth * License as published by the Free Software Foundation; either 9d6ea4236SChetan Pant * version 2.1 of the License, or (at your option) any later version. 10fcf5ef2aSThomas Huth * 11fcf5ef2aSThomas Huth * This library is distributed in the hope that it will be useful, 12fcf5ef2aSThomas Huth * but WITHOUT ANY WARRANTY; without even the implied warranty of 13fcf5ef2aSThomas Huth * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14fcf5ef2aSThomas Huth * Lesser General Public License for more details. 15fcf5ef2aSThomas Huth * 16fcf5ef2aSThomas Huth * You should have received a copy of the GNU Lesser General Public 17fcf5ef2aSThomas Huth * License along with this library; if not, see <http://www.gnu.org/licenses/>. 18fcf5ef2aSThomas Huth */ 19fcf5ef2aSThomas Huth 20fcf5ef2aSThomas Huth #include "qemu/osdep.h" 21fcf5ef2aSThomas Huth #include "cpu.h" 22fcf5ef2aSThomas Huth #include "exec/exec-all.h" 23*548c9609SAlex Bennée #include "exec/tb-flush.h" 24fcf5ef2aSThomas Huth #include "exec/helper-proto.h" 2554d31236SMarkus Armbruster #include "sysemu/runstate.h" 26fcf5ef2aSThomas Huth #include "sysemu/sysemu.h" 27fcf5ef2aSThomas Huth #include "qemu/timer.h" 28fcf5ef2aSThomas Huth 29fcf5ef2aSThomas Huth 30fcf5ef2aSThomas Huth /* PALcode support special instructions */ helper_tbia(CPUAlphaState * env)31fcf5ef2aSThomas Huthvoid helper_tbia(CPUAlphaState *env) 32fcf5ef2aSThomas Huth { 331c7ad260SRichard Henderson tlb_flush(env_cpu(env)); 34fcf5ef2aSThomas Huth } 35fcf5ef2aSThomas Huth helper_tbis(CPUAlphaState * env,uint64_t p)36fcf5ef2aSThomas Huthvoid helper_tbis(CPUAlphaState *env, uint64_t p) 37fcf5ef2aSThomas Huth { 381c7ad260SRichard Henderson tlb_flush_page(env_cpu(env), p); 39fcf5ef2aSThomas Huth } 40fcf5ef2aSThomas Huth helper_tb_flush(CPUAlphaState * env)41fcf5ef2aSThomas Huthvoid helper_tb_flush(CPUAlphaState *env) 42fcf5ef2aSThomas Huth { 431c7ad260SRichard Henderson tb_flush(env_cpu(env)); 44fcf5ef2aSThomas Huth } 45fcf5ef2aSThomas Huth helper_halt(uint64_t restart)46fcf5ef2aSThomas Huthvoid helper_halt(uint64_t restart) 47fcf5ef2aSThomas Huth { 48fcf5ef2aSThomas Huth if (restart) { 49cf83f140SEric Blake qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET); 50fcf5ef2aSThomas Huth } else { 51cf83f140SEric Blake qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN); 52fcf5ef2aSThomas Huth } 53fcf5ef2aSThomas Huth } 54fcf5ef2aSThomas Huth helper_get_vmtime(void)55fcf5ef2aSThomas Huthuint64_t helper_get_vmtime(void) 56fcf5ef2aSThomas Huth { 57fcf5ef2aSThomas Huth return qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); 58fcf5ef2aSThomas Huth } 59fcf5ef2aSThomas Huth helper_get_walltime(void)60fcf5ef2aSThomas Huthuint64_t helper_get_walltime(void) 61fcf5ef2aSThomas Huth { 62fcf5ef2aSThomas Huth return qemu_clock_get_ns(rtc_clock); 63fcf5ef2aSThomas Huth } 64fcf5ef2aSThomas Huth helper_set_alarm(CPUAlphaState * env,uint64_t expire)65fcf5ef2aSThomas Huthvoid helper_set_alarm(CPUAlphaState *env, uint64_t expire) 66fcf5ef2aSThomas Huth { 671c7ad260SRichard Henderson AlphaCPU *cpu = env_archcpu(env); 68fcf5ef2aSThomas Huth 69fcf5ef2aSThomas Huth if (expire) { 70fcf5ef2aSThomas Huth env->alarm_expire = expire; 71fcf5ef2aSThomas Huth timer_mod(cpu->alarm_timer, expire); 72fcf5ef2aSThomas Huth } else { 73fcf5ef2aSThomas Huth timer_del(cpu->alarm_timer); 74fcf5ef2aSThomas Huth } 75fcf5ef2aSThomas Huth } 76