PS2SDK
PS2 Homebrew Libraries
rtc.c
Go to the documentation of this file.
1 /*
2 # _____ ___ ____ ___ ____
3 # ____| | ____| | | |____|
4 # | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
5 #-----------------------------------------------------------------------
6 # Copyright 2001-2004, ps2dev - http://www.ps2dev.org
7 # Licenced under Academic Free License version 2.0
8 # Review ps2sdk README & LICENSE files for further details.
9 */
10 
16 #include <time.h>
17 #include <stdio.h>
18 #include <stdlib.h>
19 #include "ps2sdkapi.h"
20 #define OSD_CONFIG_NO_LIBCDVD
21 #include "osd_config.h"
22 #include "timer_alarm.h"
23 
24 // The definition for this function is located in ee/rpc/cdvd/src/scmd.c
25 extern time_t ps2time(time_t *t);
26 
27 #ifdef F__libcglue_rtc_data
28 s64 _ps2sdk_rtc_offset_from_busclk = 0;
29 #endif
30 
31 #ifdef F__libcglue_rtc_get_offset_from_busclk
32 s64 _libcglue_rtc_get_offset_from_busclk(void)
33 {
34  return _ps2sdk_rtc_offset_from_busclk;
35 }
36 
37 void _libcglue_rtc_update_impl()
38 {
39  time_t rtc_sec;
40  u32 busclock_sec;
41  u32 busclock_usec;
42 
43  rtc_sec = ps2time(NULL);
44  TimerBusClock2USec(GetTimerSystemTime(), &busclock_sec, &busclock_usec);
45 
46  _ps2sdk_rtc_offset_from_busclk = ((s64)rtc_sec) - ((s64)busclock_sec);
47 }
48 #endif
49 
50 #ifdef F__libcglue_rtc_update
51 void __attribute__((weak)) _libcglue_rtc_update_impl();
52 __attribute__((weak))
53 void _libcglue_rtc_update()
54 {
55  // cppcheck-suppress knownConditionTrueFalse
56  if (&_libcglue_rtc_update_impl)
57  {
58  _libcglue_rtc_update_impl();
59  }
60 }
61 #endif
__attribute__
typedef __attribute__
Definition: tlbfunc.c:60
time.h
stdio.h
osd_config.h
stdlib.h