RetroArch
lwp_watchdog.h
Go to the documentation of this file.
1 #ifndef __LWP_WATCHDOG_H__
2 #define __LWP_WATCHDOG_H__
3 
4 #include <gctypes.h>
5 #include "lwp_queue.h"
6 #include <time.h>
7 
8 #if defined(HW_RVL)
9  #define TB_BUS_CLOCK 243000000u
10  #define TB_CORE_CLOCK 729000000u
11 #elif defined(HW_DOL)
12  #define TB_BUS_CLOCK 162000000u
13  #define TB_CORE_CLOCK 486000000u
14 #endif
15 #define TB_TIMER_CLOCK (TB_BUS_CLOCK/4000) //4th of the bus frequency
16 
17 #define TB_SECSPERMIN 60
18 #define TB_MINSPERHR 60
19 #define TB_MONSPERYR 12
20 #define TB_DAYSPERYR 365
21 #define TB_HRSPERDAY 24
22 #define TB_SECSPERDAY (TB_SECSPERMIN*TB_MINSPERHR*TB_HRSPERDAY)
23 #define TB_SECSPERNYR (365*TB_SECSPERDAY)
24 
25 #define TB_MSPERSEC 1000
26 #define TB_USPERSEC 1000000
27 #define TB_NSPERSEC 1000000000
28 #define TB_NSPERMS 1000000
29 #define TB_NSPERUS 1000
30 #define TB_USPERTICK 10000
31 
32 #define ticks_to_cycles(ticks) ((((u64)(ticks)*(u64)((TB_CORE_CLOCK*2)/TB_TIMER_CLOCK))/2))
33 #define ticks_to_secs(ticks) (((u64)(ticks)/(u64)(TB_TIMER_CLOCK*1000)))
34 #define ticks_to_millisecs(ticks) (((u64)(ticks)/(u64)(TB_TIMER_CLOCK)))
35 #define ticks_to_microsecs(ticks) ((((u64)(ticks)*8)/(u64)(TB_TIMER_CLOCK/125)))
36 #define ticks_to_nanosecs(ticks) ((((u64)(ticks)*8000)/(u64)(TB_TIMER_CLOCK/125)))
37 
38 #define tick_microsecs(ticks) ((((u64)(ticks)*8)%(u64)(TB_TIMER_CLOCK/125)))
39 #define tick_nanosecs(ticks) ((((u64)(ticks)*8000)%(u64)(TB_TIMER_CLOCK/125)))
40 
41 
42 #define secs_to_ticks(sec) ((u64)(sec)*(TB_TIMER_CLOCK*1000))
43 #define millisecs_to_ticks(msec) ((u64)(msec)*(TB_TIMER_CLOCK))
44 #define microsecs_to_ticks(usec) (((u64)(usec)*(TB_TIMER_CLOCK/125))/8)
45 #define nanosecs_to_ticks(nsec) (((u64)(nsec)*(TB_TIMER_CLOCK/125))/8000)
46 
47 #define diff_ticks(tick0,tick1) (((u64)(tick1)<(u64)(tick0))?((u64)-1-(u64)(tick0)+(u64)(tick1)):((u64)(tick1)-(u64)(tick0)))
48 
49 #define LWP_WD_INACTIVE 0
50 #define LWP_WD_INSERTED 1
51 #define LWP_WD_ACTIVE 2
52 #define LWP_WD_REMOVE 3
53 
54 #define LWP_WD_FORWARD 0
55 #define LWP_WD_BACKWARD 1
56 
57 #define LWP_WD_NOTIMEOUT 0
58 
59 #define LWP_WD_ABS(x) ((s64)(x)>0?(s64)(x):-((s64)(x)))
60 
61 #ifdef __cplusplus
62 extern "C" {
63 #endif
64 
65 extern vu32 _wd_sync_level;
66 extern vu32 _wd_sync_count;
68 
70 
71 extern u32 gettick();
72 extern u64 gettime();
73 extern void settime(u64);
74 
79 
80 typedef void (*wd_service_routine)(void *);
81 
82 typedef struct _wdcntrl {
89  void *usr_data;
90 } wd_cntrl;
91 
92 void __lwp_watchdog_init();
94 void __lwp_wd_insert(lwp_queue *header,wd_cntrl *wd);
96 void __lwp_wd_tickle(lwp_queue *queue);
97 void __lwp_wd_adjust(lwp_queue *queue,u32 dir,s64 interval);
98 
99 #ifdef LIBOGC_INTERNAL
100 #include <libogc/lwp_watchdog.inl>
101 #endif
102 
103 #ifdef __cplusplus
104  }
105 #endif
106 
107 #endif
u32 __lwp_wd_remove(lwp_queue *header, wd_cntrl *wd)
Definition: lwp_watchdog.c:101
vu32 _wd_sync_level
Definition: lwp_watchdog.c:13
u32 id
Definition: lwp_watchdog.h:85
Definition: lwp_queue.h:21
Data type definitions.
u32 diff_nsec(u64 start, u64 end)
Definition: timesupp.c:99
GLuint start
Definition: glext.h:6292
u32 _wd_ticks_since_boot
Definition: lwp_watchdog.c:15
u64 start
Definition: lwp_watchdog.h:84
u64 fire
Definition: lwp_watchdog.h:87
vu32 _wd_sync_count
Definition: lwp_watchdog.c:14
Definition: lwp_queue.h:16
lwp_queue _wd_ticks_queue
Definition: lwp_watchdog.c:17
typedef void(__stdcall *PFN_DESTRUCTION_CALLBACK)(void *pData)
void __lwp_watchdog_settimer(wd_cntrl *wd)
Definition: lwp_watchdog.h:82
wd_service_routine routine
Definition: lwp_watchdog.h:88
struct _wdcntrl wd_cntrl
u32 diff_sec(u64 start, u64 end)
Definition: timesupp.c:79
u32 diff_msec(u64 start, u64 end)
Definition: timesupp.c:87
void __lwp_watchdog_init()
Definition: lwp_watchdog.c:52
void * usr_data
Definition: lwp_watchdog.h:89
u32 gettick()
void __lwp_wd_tickle(lwp_queue *queue)
Definition: lwp_watchdog.c:130
void __lwp_wd_adjust(lwp_queue *queue, u32 dir, s64 interval)
Definition: lwp_watchdog.c:164
u32 diff_usec(u64 start, u64 end)
Definition: timesupp.c:93
uint64_t u64
64bit unsigned integer
Definition: gctypes.h:20
void settime(u64)
void(* wd_service_routine)(void *)
Definition: lwp_watchdog.h:80
void __lwp_wd_insert(lwp_queue *header, wd_cntrl *wd)
Definition: lwp_watchdog.c:61
u64 gettime()
volatile u32 vu32
32bit unsigned volatile integer
Definition: gctypes.h:29
lwp_node node
Definition: lwp_watchdog.h:83
u32 state
Definition: lwp_watchdog.h:86
GLuint GLuint end
Definition: glext.h:6292
uint32_t u32
32bit unsigned integer
Definition: gctypes.h:19
int64_t s64
64bit signed integer
Definition: gctypes.h:25