Initial cut of the open ath9k htc firmware.
[open-ath9k-htc-firmware.git] / target_firmware / magpie_fw_dev / target / inc / adf_os_defer.h
1 /**
2  * @ingroup adf_os_public
3  * @file adf_os_defer.h
4  * This file abstracts deferred execution contexts.
5  */
6
7 #ifndef __ADF_OS_DEFER_H
8 #define __ADF_OS_DEFER_H
9
10 #include <adf_os_types.h>
11 #include <adf_os_defer_pvt.h>
12
13 /**
14  * TODO This implements work queues (worker threads, kernel threads etc.).
15  * Note that there is no cancel on a scheduled work. You cannot free a work 
16  * item if its queued. You cannot know if a work item is queued or not unless
17  * its running, whence you know its not queued.
18  *
19  * so if, say, a module is asked to unload itself, how exactly will it make
20  * sure that the work's not queued, for OS'es that dont provide such a 
21  * mechanism??
22  */
23
24 /**
25  * @brief Representation of a work queue.
26  */ 
27 typedef __adf_os_work_t     adf_os_work_t;
28
29 /**
30  * @brief Representation of a bottom half.
31  */ 
32 typedef __adf_os_bh_t       adf_os_bh_t;
33
34
35
36 /**
37  * @brief This initiallizes the Bottom half deferred handler
38  * 
39  * @param[in] hdl   OS handle
40  * @param[in] bh    bottom instance
41  * @param[in] func  deferred function to run at bottom half interrupt
42  *                  context.
43  * @param[in] arg   argument for the deferred function
44  */
45 static inline void 
46 adf_os_init_bh(adf_os_handle_t  hdl, adf_os_bh_t  *bh,
47                adf_os_defer_fn_t  func,void  *arg)
48 {
49     __adf_os_init_bh(hdl, bh, func, arg);
50 }
51
52
53 /**
54  * @brief schedule a bottom half (DPC)
55  * 
56  * @param[in] hdl   OS handle
57  * @param[in] bh    bottom instance
58  */
59 static inline void 
60 adf_os_sched_bh(adf_os_handle_t hdl, adf_os_bh_t *bh)
61 {
62     __adf_os_sched_bh(hdl, bh);
63 }
64
65 /**
66  * @brief disable the bh (synchronous)
67  * 
68  * @param[in] hdl   OS handle
69  * @param[in] bh    bottom instance
70  */
71 static inline void 
72 adf_os_disable_bh(adf_os_handle_t hdl, adf_os_bh_t *bh)
73 {
74     __adf_os_disable_bh(hdl,bh);
75 }
76
77 /*********************Non-Interrupt Context deferred Execution***************/
78
79 /**
80  * @brief allocate a work/task queue, This runs in non-interrupt
81  *        context, so can be preempted by H/W & S/W intr
82  * 
83  * @param[in] hdl   OS handle
84  * @param[in] work  work instance
85  * @param[in] func  deferred function to run at bottom half non-interrupt
86  *                  context.
87  * @param[in] arg   argument for the deferred function
88  */
89 static inline void 
90 adf_os_init_work(adf_os_handle_t hdl, adf_os_work_t  *work,
91                  adf_os_defer_fn_t  func, void  *arg)
92 {
93     __adf_os_init_work(hdl, work, func, arg);
94 }
95
96 /**
97  * @brief Schedule a deferred task on non-interrupt context
98  * 
99  * @param[in] hdl   OS handle
100  * @param[in] work  work instance
101  */
102 static inline void 
103 adf_os_sched_work(adf_os_handle_t  hdl, adf_os_work_t   *work)
104 {
105     __adf_os_sched_work(hdl, work);
106 }
107
108 /**
109  *@brief disable the deferred task (synchronous)
110  *
111  *@param[in] hdl    OS handle
112  *@param[in] work   work instance
113  */
114 static inline void 
115 adf_os_disable_work(adf_os_handle_t hdl, adf_os_work_t *work) 
116 {
117     __adf_os_disable_work(hdl, work);
118 }
119
120
121 /**
122  * XXX API to specify processor while scheduling a bh => only on vista
123  */
124
125
126 #endif /*_ADF_OS_DEFER_H*/