xref: /haiku/src/system/kernel/arch/riscv64/arch_real_time_clock.cpp (revision 3d4afef9cba2f328e238089d4609d00d4b1524f3)
1 /*
2  * Copyright 2021 Haiku, Inc. All rights reserved.
3  * Distributed under the terms of the MIT License.
4  */
5 
6 #include <arch/real_time_clock.h>
7 #include <boot/kernel_args.h>
8 
9 #include <real_time_clock.h>
10 #include <real_time_data.h>
11 
12 #include <Htif.h>
13 
14 
15 status_t
16 arch_rtc_init(kernel_args *args, struct real_time_data *data)
17 {
18 /*
19 	data->arch_data.system_time_conversion_factor
20 		= (1LL << 32) * 1000000LL / args->arch_args.timerFrequency;
21 
22 	dprintf("timerFrequency: %" B_PRIu64 "\n",
23 		args->arch_args.timerFrequency);
24 	dprintf("system_time_conversion_factor: %" B_PRIu64 "\n",
25 		data->arch_data.system_time_conversion_factor);
26 */
27 	return B_OK;
28 }
29 
30 
31 uint32
32 arch_rtc_get_hw_time(void)
33 {
34 	return (uint32)(HtifCmd(2, 0, 0) / 1000000);
35 }
36 
37 
38 void
39 arch_rtc_set_hw_time(uint32 seconds)
40 {
41 }
42 
43 
44 void
45 arch_rtc_set_system_time_offset(struct real_time_data *data, bigtime_t offset)
46 {
47 	atomic_set64(&data->arch_data.system_time_offset, offset);
48 }
49 
50 
51 bigtime_t
52 arch_rtc_get_system_time_offset(struct real_time_data *data)
53 {
54 	return atomic_get64(&data->arch_data.system_time_offset);
55 }
56