Initial cut of the open ath9k htc firmware.
[open-ath9k-htc-firmware.git] / target_firmware / magpie_fw_dev / target / adf / adf_os_timer_pvt.h
1 #ifndef _ADF_OS_TIMER_PVT_H
2 #define _ADF_OS_TIMER_PVT_H
3
4 #include <cmnos_api.h>
5 #include "Magpie_api.h"
6
7
8 typedef struct 
9 {
10         A_timer_t                               *magpie_timer;
11         adf_os_timer_func_t     timer_func;
12 }__adf_os_timer_t;
13
14 //typedef A_timer_t     __adf_os_timer_t;
15
16 void
17 __adf_os_timer_func(A_HANDLE timer_handle, void *arg);
18
19 /* 
20  * Initialize a timer
21  */
22 static inline void
23 __adf_os_timer_init(adf_os_handle_t  hdl, __adf_os_timer_t   *timer,
24                     adf_os_timer_func_t  func, void *arg)
25 {
26     timer->timer_func = func;
27     A_INIT_TIMER(timer->magpie_timer, __adf_os_timer_func, arg);
28 }
29
30 /* 
31  * start a timer 
32  */
33 static inline void
34 __adf_os_timer_start(__adf_os_timer_t *timer, int msec)
35 {
36     A_TIMEOUT_MS(timer->magpie_timer, msec);
37 }
38 /*
39  * Cancel a timer
40  *
41  * Return: TRUE if timer was cancelled and deactived,
42  *         FALSE if timer was cancelled but already got fired.
43  */
44 static inline a_bool_t
45 __adf_os_timer_cancel(__adf_os_timer_t *timer)
46 {
47         A_UNTIMEOUT(timer->magpie_timer);
48         return A_TRUE;
49 }
50
51 /*
52  * XXX Synchronously canel a timer
53  *
54  * Return: TRUE if timer was cancelled and deactived,
55  *         FALSE if timer was cancelled but already got fired.
56  *
57  * Synchronization Rules:
58  * 1. caller must make sure timer function will not use
59  *    adf_os_set_timer to add iteself again.
60  * 2. caller must not hold any lock that timer function
61  *    is likely to hold as well.
62  * 3. It can't be called from interrupt context.
63  */
64 static inline a_bool_t
65 __adf_os_timer_sync_cancel(__adf_os_timer_t *timer)
66 {
67     // @TODO: IS OK??
68     A_UNTIMEOUT(timer->magpie_timer);
69     return A_TRUE;
70 }
71
72
73 #endif