2 * Copyright 2002-2009, Axel Dörfler, axeld@pinc-software.de.
3 * Distributed under the terms of the MIT License.
12 #include <FindDirectory.h>
15 #include <commpage_defs.h>
16 #include <errno_private.h>
17 #include <libroot_private.h>
18 #include <real_time_data.h>
19 #include <user_timer_defs.h>
23 static struct real_time_data
* sRealTimeData
;
27 __init_time(addr_t commPageTable
)
29 sRealTimeData
= (struct real_time_data
*)
30 (((addr_t
*)commPageTable
)[COMMPAGE_ENTRY_REAL_TIME_DATA
]
33 __arch_init_time(sRealTimeData
, false);
38 __get_system_time_offset()
40 return __arch_get_system_time_offset(sRealTimeData
);
44 // #pragma mark - public API
50 return (__arch_get_system_time_offset(sRealTimeData
) + system_time())
56 real_time_clock_usecs(void)
58 return __arch_get_system_time_offset(sRealTimeData
) + system_time();
63 set_real_time_clock(unsigned long secs
)
65 _kern_set_real_time_clock((bigtime_t
)secs
* 1000000);
70 set_timezone(const char* /*timezone*/)
72 /* There's nothing we can do here, since we no longer support named
75 * TODO: should we keep this around for compatibility or get rid of it?
82 set_alarm(bigtime_t when
, uint32 mode
)
84 // prepare the values to be passed to the kernel
85 bigtime_t interval
= 0;
86 uint32 flags
= B_RELATIVE_TIMEOUT
;
88 if (when
== B_INFINITE_TIMEOUT
) {
89 when
= B_INFINITE_TIMEOUT
;
92 case B_PERIODIC_ALARM
:
95 case B_ONE_SHOT_ABSOLUTE_ALARM
:
96 flags
= B_ABSOLUTE_TIMEOUT
;
98 case B_ONE_SHOT_RELATIVE_ALARM
:
105 user_timer_info oldInfo
;
106 status_t error
= _kern_set_timer(USER_TIMER_REAL_TIME_ID
, find_thread(NULL
),
107 when
, interval
, flags
, &oldInfo
);
111 // A remaining time of B_INFINITE_TIMEOUT means not scheduled.
112 return oldInfo
.remaining_time
!= B_INFINITE_TIMEOUT
113 ? oldInfo
.remaining_time
: 0;