1 /******************************************************************************
3 * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved.
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as
7 * published by the Free Software Foundation.
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
18 * Modifications for inclusion into the Linux staging tree are
19 * Copyright(c) 2010 Larry Finger. All rights reserved.
21 * Contact information:
22 * WLAN FAE <wlanfae@realtek.com>
23 * Larry Finger <Larry.Finger@lwfinger.net>
25 ******************************************************************************/
26 #ifndef __OSDEP_SERVICE_H_
27 #define __OSDEP_SERVICE_H_
32 #include <linux/spinlock.h>
34 #include <linux/interrupt.h>
35 #include <linux/semaphore.h>
36 #include <linux/sched.h>
37 #include <linux/sem.h>
38 #include <linux/netdevice.h>
39 #include <linux/etherdevice.h>
40 #include <net/iw_handler.h>
41 #include <linux/proc_fs.h> /* Necessary because we use the proc fs */
43 #include "basic_types.h"
46 struct list_head queue
;
50 #define _pkt struct sk_buff
51 #define _buffer unsigned char
52 #define thread_exit() complete_and_exit(NULL, 0)
53 #define _workitem struct work_struct
55 #define _init_queue(pqueue) \
57 _init_listhead(&((pqueue)->queue)); \
58 spin_lock_init(&((pqueue)->lock)); \
61 static inline struct list_head
*get_next(struct list_head
*list
)
66 static inline struct list_head
*get_list_head(struct __queue
*queue
)
68 return &(queue
->queue
);
71 #define LIST_CONTAINOR(ptr, type, member) \
72 ((type *)((char *)(ptr)-(SIZE_T)(&((type *)0)->member)))
74 static inline void list_delete(struct list_head
*plist
)
79 static inline void _init_timer(struct timer_list
*ptimer
,
80 struct net_device
*padapter
,
81 void *pfunc
, void *cntx
)
83 ptimer
->function
= pfunc
;
84 ptimer
->data
= (addr_t
)cntx
;
88 static inline void _set_timer(struct timer_list
*ptimer
, u32 delay_time
)
90 mod_timer(ptimer
, (jiffies
+(delay_time
*HZ
/1000)));
93 static inline void _cancel_timer(struct timer_list
*ptimer
, u8
*bcancelled
)
96 *bcancelled
= true; /*true ==1; false==0*/
99 static inline void _init_workitem(_workitem
*pwork
, void *pfunc
, void *cntx
)
101 INIT_WORK(pwork
, pfunc
);
104 static inline void _set_workitem(_workitem
*pwork
)
106 schedule_work(pwork
);
110 #define BIT(x) (1 << (x))
114 For the following list_xxx operations,
115 caller must guarantee the atomic context.
116 Otherwise, there will be racing condition.
118 static inline u32
is_list_empty(struct list_head
*phead
)
120 if (list_empty(phead
))
126 static inline void list_insert_tail(struct list_head
*plist
,
127 struct list_head
*phead
)
129 list_add_tail(plist
, phead
);
132 static inline u32
_down_sema(struct semaphore
*sema
)
134 if (down_interruptible(sema
))
140 static inline void _init_listhead(struct list_head
*list
)
142 INIT_LIST_HEAD(list
);
145 static inline u32
_queue_empty(struct __queue
*pqueue
)
147 return is_list_empty(&(pqueue
->queue
));
150 static inline u32
end_of_queue_search(struct list_head
*head
, struct list_head
*plist
)
158 static inline void sleep_schedulable(int ms
)
162 delta
= (ms
* HZ
) / 1000;/*(ms)*/
165 set_current_state(TASK_INTERRUPTIBLE
);
166 if (schedule_timeout(delta
) != 0)
170 static inline u8
*_malloc(u32 sz
)
172 return kmalloc(sz
, GFP_ATOMIC
);
175 static inline unsigned char _cancel_timer_ex(struct timer_list
*ptimer
)
177 return del_timer(ptimer
);
180 static inline void thread_enter(void *context
)
182 allow_signal(SIGTERM
);
185 static inline void flush_signals_thread(void)
187 if (signal_pending(current
))
188 flush_signals(current
);
191 static inline u32
_RND8(u32 sz
)
193 return ((sz
>> 3) + ((sz
& 7) ? 1 : 0)) << 3;
196 static inline u32
_RND128(u32 sz
)
198 return ((sz
>> 7) + ((sz
& 127) ? 1 : 0)) << 7;
201 static inline u32
_RND256(u32 sz
)
203 return ((sz
>> 8) + ((sz
& 255) ? 1 : 0)) << 8;
206 static inline u32
_RND512(u32 sz
)
208 return ((sz
>> 9) + ((sz
& 511) ? 1 : 0)) << 9;
This page took 0.077256 seconds and 5 git commands to generate.