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