a0d359239c0a630710f48b7ff6d3974a446a05b1
[open-ath9k-htc-firmware.git] / target_firmware / magpie_fw_dev / target / adf / adf_os_defer_pvt.h
1 #ifndef __ADF_OS_DEFER_PVT_H
2 #define __ADF_OS_DEFER_PVT_H
3
4 #include <adf_os_types.h>
5 #include <cmnos_api.h>
6 #include "Magpie_api.h"
7
8 /*
9  * Because the real function taked an extra int :(
10  */
11 typedef struct {
12     adf_os_defer_fn_t  caller_fn;
13     void             *caller_arg;
14 }__adf_os_defer_ctx_t;
15
16 /*
17  * wrapper around the real task func
18  */
19 typedef struct {
20     //struct task          tsk;
21     __adf_os_defer_ctx_t ctx;
22 }__adf_os_defer_t;
23
24 //typedef __adf_os_defer_t    __adf_os_bh_t;
25 typedef A_tasklet_t         __adf_os_bh_t;
26 typedef __adf_os_defer_t    __adf_os_work_t;
27
28 /*
29  * wrapper function
30  */
31 extern void __adf_os_defer_func(void *arg, int pending);
32
33 /**
34  * @brief initiallize the defer function (work or bh)
35  * 
36  * @param defer
37  * @param func
38  * @param arg
39  */
40 static inline void __adf_os_init_defer(__adf_os_defer_t  *defer,
41                                        adf_os_defer_fn_t    func, 
42                                        void              *arg)
43 {
44     defer->ctx.caller_fn  = func;
45     defer->ctx.caller_arg = arg;
46
47     //TASK_INIT(&defer->tsk, 0, __adf_os_defer_func, &defer->ctx);
48 }
49
50 static inline void __adf_os_init_work(adf_os_handle_t  hdl,
51                                                                           __adf_os_work_t       *work,
52                                                                           adf_os_defer_fn_t     func,
53                                                                           void                          *arg)
54 {
55         __adf_os_init_defer(work, func, arg);
56 }
57
58 static inline void      __adf_os_init_bh(adf_os_handle_t  hdl,
59                                                                          __adf_os_bh_t          *bh,
60                                                                          adf_os_defer_fn_t      func,
61                                                                          void                           *arg)
62 {
63         //__adf_os_init_defer(bh, func, arg);
64         A_TASKLET_INIT_TASK(func, arg, bh);
65 }
66 static inline void __adf_os_sched_work(adf_os_handle_t  hdl, 
67                                        __adf_os_work_t  * work)
68 {
69     //taskqueue_enqueue(taskqueue_thread, &work->tsk);
70 }
71 static inline void __adf_os_disable_work(adf_os_handle_t  hdl, 
72                                          __adf_os_work_t  * work)
73 {
74     //taskqueue_drain(taskqueue_thread, &work->tsk);
75 }
76
77 static inline void __adf_os_sched_bh(adf_os_handle_t  hdl, 
78                                        __adf_os_bh_t  * bh)
79 {
80     A_TASKLET_SCHEDULE(bh);
81 }
82
83 static inline void __adf_os_disable_bh(adf_os_handle_t  hdl, 
84                                        __adf_os_bh_t  * bh)
85 {
86     A_TASKLET_DISABLE(bh);
87 }
88
89 #endif