1 /* 2 * Copyright 2012-2021, Haiku, Inc. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * François Revol <revol@free.fr> 7 */ 8 9 #include <OS.h> 10 11 #include <arch_cpu.h> 12 #include <arch_cpu_defs.h> 13 #include <libroot_private.h> 14 #include <real_time_data.h> 15 16 #ifdef _KERNEL_MODE 17 #include <KernelExport.h> 18 #endif 19 20 21 static uint64_t cv_factor = 0; 22 23 24 extern "C" void 25 __riscv64_setup_system_time(uint64 cv) 26 { 27 cv_factor = cv; 28 } 29 30 31 [[gnu::optimize("omit-frame-pointer")]] bigtime_t 32 system_time() 33 { 34 __uint128_t time = static_cast<__uint128_t>(CpuTime()) * cv_factor; 35 return time >> 32; 36 } 37