xref: /linux/drivers/staging/rtl8723bs/include/osdep_service.h (revision a5f22b9b139762685810aa5a41fd0181488aea13)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /******************************************************************************
3  *
4  * Copyright(c) 2007 - 2013 Realtek Corporation. All rights reserved.
5  *
6  ******************************************************************************/
7 #ifndef __OSDEP_SERVICE_H_
8 #define __OSDEP_SERVICE_H_
9 
10 
11 #define _FAIL		0
12 #define _SUCCESS	1
13 #define RTW_RX_HANDLED 2
14 
15 #include <osdep_service_linux.h>
16 
17 #define BIT0	0x00000001
18 #define BIT1	0x00000002
19 #define BIT2	0x00000004
20 #define BIT3	0x00000008
21 #define BIT4	0x00000010
22 #define BIT5	0x00000020
23 #define BIT6	0x00000040
24 #define BIT7	0x00000080
25 #define BIT8	0x00000100
26 #define BIT9	0x00000200
27 #define BIT10	0x00000400
28 #define BIT11	0x00000800
29 #define BIT12	0x00001000
30 #define BIT13	0x00002000
31 #define BIT14	0x00004000
32 #define BIT15	0x00008000
33 #define BIT16	0x00010000
34 #define BIT17	0x00020000
35 #define BIT18	0x00040000
36 #define BIT19	0x00080000
37 #define BIT20	0x00100000
38 #define BIT21	0x00200000
39 #define BIT22	0x00400000
40 #define BIT23	0x00800000
41 #define BIT24	0x01000000
42 #define BIT25	0x02000000
43 #define BIT26	0x04000000
44 #define BIT27	0x08000000
45 #define BIT28	0x10000000
46 #define BIT29	0x20000000
47 #define BIT30	0x40000000
48 #define BIT31	0x80000000
49 #define BIT32	0x0100000000
50 #define BIT33	0x0200000000
51 #define BIT34	0x0400000000
52 #define BIT35	0x0800000000
53 #define BIT36	0x1000000000
54 
55 extern int RTW_STATUS_CODE(int error_code);
56 
57 void _kfree(u8 *pbuf, u32 sz);
58 
59 int _rtw_netif_rx(struct net_device *ndev, struct sk_buff *skb);
60 
61 #define rtw_netif_rx(ndev, skb) _rtw_netif_rx(ndev, skb)
62 
63 extern void _rtw_init_queue(struct __queue	*pqueue);
64 
flush_signals_thread(void)65 static inline void flush_signals_thread(void)
66 {
67 	if (signal_pending(current))
68 		flush_signals(current);
69 }
70 
71 #define rtw_warn_on(condition) WARN_ON(condition)
72 
rtw_bug_check(void * parg1,void * parg2,void * parg3,void * parg4)73 static inline int rtw_bug_check(void *parg1, void *parg2, void *parg3, void *parg4)
74 {
75 	int ret = true;
76 
77 	return ret;
78 
79 }
80 
81 #define _RND(sz, r) ((((sz)+((r)-1))/(r))*(r))
82 
83 extern void rtw_free_netdev(struct net_device *netdev);
84 
85 /* Macros for handling unaligned memory accesses */
86 
87 void rtw_buf_free(u8 **buf, u32 *buf_len);
88 void rtw_buf_update(u8 **buf, u32 *buf_len, u8 *src, u32 src_len);
89 
90 struct rtw_cbuf {
91 	u32 write;
92 	u32 read;
93 	u32 size;
94 	void *bufs[];
95 };
96 
97 bool rtw_cbuf_full(struct rtw_cbuf *cbuf);
98 bool rtw_cbuf_empty(struct rtw_cbuf *cbuf);
99 bool rtw_cbuf_push(struct rtw_cbuf *cbuf, void *buf);
100 void *rtw_cbuf_pop(struct rtw_cbuf *cbuf);
101 struct rtw_cbuf *rtw_cbuf_alloc(u32 size);
102 
103 /*  String handler */
104 /*
105  * Write formatted output to sized buffer
106  */
107 #define rtw_sprintf(buf, size, format, arg...)	snprintf(buf, size, format, ##arg)
108 
109 #endif
110