KallistiOS git master
Independent SDK for the Sega Dreamcast
Loading...
Searching...
No Matches
rtc.h
Go to the documentation of this file.
1/* KallistiOS ##version##
2
3 arch/dreamcast/include/arch/rtc.h
4 Copyright (C) 2000, 2001 Megan Potter
5 Copyright (C) 2023, 2024 Falco Girgis
6 Copyright (C) 2026 Paul Cercueil
7
8*/
9
10/** \file arch/rtc.h
11 \brief Low-level real-time clock functionality.
12 \ingroup rtc
13
14 This file contains functions for interacting with the real-time clock in the
15 Dreamcast. Generally, you should prefer interacting with the higher level
16 standard C functions, like time(), rather than these when simply needing
17 to fetch the current system time.
18
19 \sa dc/wdt.h
20
21 \author Megan Potter
22 \author Falco Girgis
23*/
24
25/* Keep this include above the macro guards */
26#include <kos/rtc.h>
27
28#ifndef __ARCH_RTC_H
29#define __ARCH_RTC_H
30
31#include <kos/cdefs.h>
32__BEGIN_DECLS
33
34#include <time.h>
35
36/* Notes:
37 The RTC that is used by the DC is located on the AICA rather than SH4,
38 presumably for power-efficiency reasons. Because of this, accessing
39 it requires a trip over the G2 BUS, which is notoriously slow.
40
41 Internally, the RTC's date/time is maintained using a 32-bit counter
42 with an epoch of January 1, 1950 00:00. Because of this, the Dreamcast's
43 Y2K and the last timestamp it can represent before rolling over is
44 February 06 2086 06:28:15.
45*/
46
47extern time_t dc_boot_time;
48
49time_t arch_rtc_unix_secs(void);
50int arch_rtc_set_unix_secs(time_t time);
51
52static inline time_t arch_rtc_boot_time(void) {
53 return dc_boot_time;
54}
55
56static inline int arch_rtc_init(void) {
57 dc_boot_time = arch_rtc_unix_secs();
58 return 0;
59}
60
61static inline void arch_rtc_shutdown(void) {
62}
63
64__END_DECLS
65
66#endif /* __ARCH_RTC_H */
67
Various common macros used throughout the codebase.
Low-level real-time clock functionality.
KOS-implementation of select C11 and POSIX extensions.