1/** 2 * \file 3 * \brief Debug system calls, specific for arm, user-side 4 */ 5 6/* 7 * Copyright (c) 2007, 2008, 2009, 2010, ETH Zurich. 8 * All rights reserved. 9 * 10 * This file is distributed under the terms in the attached LICENSE file. 11 * If you do not find this file, copies can be found by writing to: 12 * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group. 13 */ 14 15#include <barrelfish/barrelfish.h> 16#include <barrelfish/dispatch.h> 17#include <barrelfish/syscall_arch.h> 18#include <barrelfish_kpi/sys_debug.h> 19#include <barrelfish/sys_debug.h> 20#include <stdio.h> 21#include <inttypes.h> 22 23errval_t sys_debug_get_tsc_per_ms(uint64_t *ret) 24{ 25 struct sysret sr = syscall2(SYSCALL_DEBUG, DEBUG_HARDWARE_TIMER_HERTZ_READ); 26 *ret = sr.value / 1000; 27 return sr.error; 28} 29 30errval_t sys_debug_hardware_timer_read(uintptr_t* v) 31{ 32 struct sysret sr 33 = syscall2(SYSCALL_DEBUG, DEBUG_HARDWARE_TIMER_READ); 34 *v = sr.value; 35 return sr.error; 36} 37 38errval_t sys_debug_hardware_timer_hertz_read(uintptr_t* v) 39{ 40 struct sysret sr 41 = syscall2(SYSCALL_DEBUG, DEBUG_HARDWARE_TIMER_HERTZ_READ); 42 *v = sr.value; 43 return sr.error; 44} 45 46errval_t sys_debug_hardware_global_timer_read(uint64_t *ret) 47{ 48 struct sysret sr; 49 50 uint32_t l, h; 51 52 do { 53 h = syscall2(SYSCALL_DEBUG, DEBUG_HARDWARE_GLOBAL_TIMER_HIGH).value; 54 l = syscall2(SYSCALL_DEBUG, DEBUG_HARDWARE_GLOBAL_TIMER_LOW).value; 55 // read high again, in case it changed 56 sr = syscall2(SYSCALL_DEBUG, DEBUG_HARDWARE_GLOBAL_TIMER_HIGH); 57 } while(h != sr.value && err_is_ok(sr.error)); 58 59 if(err_is_ok(sr.error) && ret) { 60 *ret = (((uint64_t) h) << 32) | ((uint32_t) l); 61 } 62 63 return sr.error; 64} 65