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 #ifndef BIT
18 #define BIT(x) (1 << (x))
19 #endif
20
21 #define BIT0 0x00000001
22 #define BIT1 0x00000002
23 #define BIT2 0x00000004
24 #define BIT3 0x00000008
25 #define BIT4 0x00000010
26 #define BIT5 0x00000020
27 #define BIT6 0x00000040
28 #define BIT7 0x00000080
29 #define BIT8 0x00000100
30 #define BIT9 0x00000200
31 #define BIT10 0x00000400
32 #define BIT11 0x00000800
33 #define BIT12 0x00001000
34 #define BIT13 0x00002000
35 #define BIT14 0x00004000
36 #define BIT15 0x00008000
37 #define BIT16 0x00010000
38 #define BIT17 0x00020000
39 #define BIT18 0x00040000
40 #define BIT19 0x00080000
41 #define BIT20 0x00100000
42 #define BIT21 0x00200000
43 #define BIT22 0x00400000
44 #define BIT23 0x00800000
45 #define BIT24 0x01000000
46 #define BIT25 0x02000000
47 #define BIT26 0x04000000
48 #define BIT27 0x08000000
49 #define BIT28 0x10000000
50 #define BIT29 0x20000000
51 #define BIT30 0x40000000
52 #define BIT31 0x80000000
53 #define BIT32 0x0100000000
54 #define BIT33 0x0200000000
55 #define BIT34 0x0400000000
56 #define BIT35 0x0800000000
57 #define BIT36 0x1000000000
58
59 extern int RTW_STATUS_CODE(int error_code);
60
61 void *_rtw_zmalloc(u32 sz);
62 void *_rtw_malloc(u32 sz);
63 void _kfree(u8 *pbuf, u32 sz);
64
65 struct sk_buff *_rtw_skb_alloc(u32 sz);
66 struct sk_buff *_rtw_skb_copy(const struct sk_buff *skb);
67 int _rtw_netif_rx(struct net_device *ndev, struct sk_buff *skb);
68
69 #define rtw_malloc(sz) _rtw_malloc((sz))
70 #define rtw_zmalloc(sz) _rtw_zmalloc((sz))
71
72 #define rtw_skb_alloc(size) _rtw_skb_alloc((size))
73 #define rtw_skb_alloc_f(size, mstat_f) _rtw_skb_alloc((size))
74 #define rtw_skb_copy(skb) _rtw_skb_copy((skb))
75 #define rtw_skb_copy_f(skb, mstat_f) _rtw_skb_copy((skb))
76 #define rtw_netif_rx(ndev, skb) _rtw_netif_rx(ndev, skb)
77
78 extern void _rtw_init_queue(struct __queue *pqueue);
79
thread_enter(char * name)80 static inline void thread_enter(char *name)
81 {
82 allow_signal(SIGTERM);
83 }
84
flush_signals_thread(void)85 static inline void flush_signals_thread(void)
86 {
87 if (signal_pending(current))
88 {
89 flush_signals(current);
90 }
91 }
92
93 #define rtw_warn_on(condition) WARN_ON(condition)
94
rtw_bug_check(void * parg1,void * parg2,void * parg3,void * parg4)95 static inline int rtw_bug_check(void *parg1, void *parg2, void *parg3, void *parg4)
96 {
97 int ret = true;
98
99 return ret;
100
101 }
102
103 #define _RND(sz, r) ((((sz)+((r)-1))/(r))*(r))
104
105 #ifndef MAC_ARG
106 #define MAC_ARG(x) (x)
107 #endif
108
109 extern void rtw_free_netdev(struct net_device * netdev);
110
111 /* Macros for handling unaligned memory accesses */
112
113 void rtw_buf_free(u8 **buf, u32 *buf_len);
114 void rtw_buf_update(u8 **buf, u32 *buf_len, u8 *src, u32 src_len);
115
116 struct rtw_cbuf {
117 u32 write;
118 u32 read;
119 u32 size;
120 void *bufs[0];
121 };
122
123 bool rtw_cbuf_full(struct rtw_cbuf *cbuf);
124 bool rtw_cbuf_empty(struct rtw_cbuf *cbuf);
125 bool rtw_cbuf_push(struct rtw_cbuf *cbuf, void *buf);
126 void *rtw_cbuf_pop(struct rtw_cbuf *cbuf);
127 struct rtw_cbuf *rtw_cbuf_alloc(u32 size);
128
129 /* String handler */
130 /*
131 * Write formatted output to sized buffer
132 */
133 #define rtw_sprintf(buf, size, format, arg...) snprintf(buf, size, format, ##arg)
134
135 #endif
136