xref: /haiku/src/system/libroot/os/arch/riscv64/time.cpp (revision 899e0ef82b5624ace2ccfa5f5a58c8ebee54aaef)
1 /*
2  * Copyright 2006, Ingo Weinhold <bonefish@cs.tu-berlin.de>.
3  * Distributed under the terms of the MIT License.
4  */
5 
6 #include <OS.h>
7 
8 #include <arch_cpu.h>
9 #include <libroot_private.h>
10 #include <real_time_data.h>
11 
12 
13 static struct arch_real_time_data *sRealTimeData;
14 
15 
16 void
17 __arch_init_time(struct real_time_data *data, bool setDefaults)
18 {
19 	sRealTimeData = &data->arch_data;
20 
21 	if (setDefaults)
22 		sRealTimeData->system_time_conversion_factor = 1000000000LL;
23 
24 	__riscv64_setup_system_time(sRealTimeData->system_time_conversion_factor);
25 }
26 
27 
28 bigtime_t
29 __arch_get_system_time_offset(struct real_time_data *data)
30 {
31 	// we don't use atomic_get64 because memory is read-only, maybe
32 	// find another way to lock
33 	return data->arch_data.system_time_offset;
34 }
35