1 #ifndef __LWP_WATCHDOG_H__
2 #define __LWP_WATCHDOG_H__
9 #define TB_BUS_CLOCK 243000000u
10 #define TB_CORE_CLOCK 729000000u
12 #define TB_BUS_CLOCK 162000000u
13 #define TB_CORE_CLOCK 486000000u
15 #define TB_TIMER_CLOCK (TB_BUS_CLOCK/4000) //4th of the bus frequency
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)
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
32 #define ticks_to_cycles(ticks) ((u32)(((u64)(ticks)*(u64)((TB_CORE_CLOCK*2)/TB_TIMER_CLOCK))/2))
33 #define ticks_to_secs(ticks) ((u32)((u64)(ticks)/(u64)(TB_TIMER_CLOCK*1000)))
34 #define ticks_to_millisecs(ticks) ((u32)((u64)(ticks)/(u64)(TB_TIMER_CLOCK)))
35 #define ticks_to_microsecs(ticks) ((u32)(((u64)(ticks)*8)/(u64)(TB_TIMER_CLOCK/125)))
36 #define ticks_to_nanosecs(ticks) ((u32)(((u64)(ticks)*8000)/(u64)(TB_TIMER_CLOCK/125)))
38 #define secs_to_ticks(sec) ((u64)(sec)*(TB_TIMER_CLOCK*1000))
39 #define millisecs_to_ticks(msec) ((u64)(msec)*(TB_TIMER_CLOCK))
40 #define microsecs_to_ticks(usec) (((u64)(usec)*(TB_TIMER_CLOCK/125))/8)
41 #define nanosecs_to_ticks(nsec) (((u64)(nsec)*(TB_TIMER_CLOCK/125))/8000)
43 #define diff_ticks(tick0,tick1) (((u64)(tick1)<(u64)(tick0))?((u64)-1-(u64)(tick0)+(u64)(tick1)):((u64)(tick1)-(u64)(tick0)))
45 #define LWP_WD_INACTIVE 0
46 #define LWP_WD_INSERTED 1
47 #define LWP_WD_ACTIVE 2
48 #define LWP_WD_REMOVE 3
50 #define LWP_WD_FORWARD 0
51 #define LWP_WD_BACKWARD 1
53 #define LWP_WD_NOTIMEOUT 0
55 #define LWP_WD_ABS(x) ((s64)(x)>0?(s64)(x):-((s64)(x)))
61 extern vu32 _wd_sync_level
;
62 extern vu32 _wd_sync_count
;
63 extern u32 _wd_ticks_since_boot
;
65 extern lwp_queue _wd_ticks_queue
;
69 extern void settime(u64
);
71 u32
diff_sec(u64 start
,u64 end
);
72 u32
diff_msec(u64 start
,u64 end
);
73 u32
diff_usec(u64 start
,u64 end
);
74 u32
diff_nsec(u64 start
,u64 end
);
76 typedef void (*wd_service_routine
)(void *);
78 typedef struct _wdcntrl
{
84 wd_service_routine routine
;
88 void __lwp_watchdog_init();
89 void __lwp_watchdog_settimer(wd_cntrl
*wd
);
90 void __lwp_wd_insert(lwp_queue
*header
,wd_cntrl
*wd
);
91 u32
__lwp_wd_remove(lwp_queue
*header
,wd_cntrl
*wd
);
92 void __lwp_wd_tickle(lwp_queue
*queue
);
93 void __lwp_wd_adjust(lwp_queue
*queue
,u32 dir
,s64 interval
);
95 #ifdef LIBOGC_INTERNAL
96 #include <libogc/lwp_watchdog.inl>