1f46bdd1cSAxel Dörfler/*
26a0f39daSAxel Dörfler * Copyright 2006-2007, Axel D��rfler, axeld@pinc-software.de. All rights reserved.
3f46bdd1cSAxel Dörfler * Copyright 2003, Jeff Ward, jeff@r2d2.stcloudstate.edu. All rights reserved.
4f46bdd1cSAxel Dörfler *
5f46bdd1cSAxel Dörfler * Distributed under the terms of the MIT License.
6f46bdd1cSAxel Dörfler */
72218f79eSAxel Dörfler#ifndef _KERNEL_REAL_TIME_CLOCK_H
82218f79eSAxel Dörfler#define _KERNEL_REAL_TIME_CLOCK_H
92218f79eSAxel Dörfler
102218f79eSAxel Dörfler
112218f79eSAxel Dörfler#include <KernelExport.h>
122218f79eSAxel Dörfler
13d9a5e605SIngo Weinhold#include <time.h>
14d9a5e605SIngo Weinhold
15d9a5e605SIngo Weinhold
16e0ea55e0SOliver Tappestruct kernel_args;
17e0ea55e0SOliver Tappe
18e0ea55e0SOliver Tappe
196a0f39daSAxel Dörfler#define RTC_EPOCH_BASE_YEAR	1970
202218f79eSAxel Dörfler
21a34e8cc3SAxel Dörfler#ifdef __cplusplus
22a34e8cc3SAxel Dörflerextern "C" {
23a34e8cc3SAxel Dörfler#endif
242218f79eSAxel Dörfler
2524df6592SIngo Weinholdvoid set_real_time_clock_usecs(bigtime_t currentTime);
2624df6592SIngo Weinhold
27e0ea55e0SOliver Tappestatus_t rtc_init(struct kernel_args *args);
289b50999cSJérôme Duvalbigtime_t rtc_boot_time(void);
299b50999cSJérôme Duval	// Returns the time at which the system was booted in microseconds since Jan 1, 1970 UTC.
30a34e8cc3SAxel Dörfler
31d9a5e605SIngo Weinhold// Both functions use the passed struct tm only partially
32d9a5e605SIngo Weinhold// (no tm_wday, tm_yday, tm_isdst).
33d9a5e605SIngo Weinholduint32 rtc_tm_to_secs(const struct tm *t);
34d9a5e605SIngo Weinholdvoid rtc_secs_to_tm(uint32 seconds, struct tm *t);
35d9a5e605SIngo Weinhold
366bb7a098SOliver Tappeuint32 get_timezone_offset(void);
37e0ea55e0SOliver Tappe
380d96fb11SAxel Dörflerbigtime_t _user_system_time(void);
3924df6592SIngo Weinholdstatus_t _user_set_real_time_clock(bigtime_t time);
40dbe1e23aSOliver Tappestatus_t _user_set_timezone(int32 timezoneOffset, const char *name,
41dbe1e23aSOliver Tappe			size_t nameLength);
42dbe1e23aSOliver Tappestatus_t _user_get_timezone(int32 *_timezoneOffset, char* name,
43dbe1e23aSOliver Tappe			size_t nameLength);
4496ac47e3SOliver Tappestatus_t _user_set_real_time_clock_is_gmt(bool isGMT);
4596ac47e3SOliver Tappestatus_t _user_get_real_time_clock_is_gmt(bool *_isGMT);
469699c529SAxel Dörfler
47a34e8cc3SAxel Dörfler#ifdef __cplusplus
48a34e8cc3SAxel Dörfler}
49a34e8cc3SAxel Dörfler#endif
502218f79eSAxel Dörfler
512218f79eSAxel Dörfler#endif /* _KERNEL_REAL_TIME_CLOCK_H */
52