root/drivers/staging/rtl8723bs/include/osdep_service.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. thread_enter
  2. flush_signals_thread
  3. rtw_bug_check
  4. _RND4
  5. _RND8

   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 /* flags used for rtw_mstat_update() */
  62 enum mstat_f {
  63         /* type: 0x00ff */
  64         MSTAT_TYPE_VIR = 0x00,
  65         MSTAT_TYPE_PHY = 0x01,
  66         MSTAT_TYPE_SKB = 0x02,
  67         MSTAT_TYPE_USB = 0x03,
  68         MSTAT_TYPE_MAX = 0x04,
  69 
  70         /* func: 0xff00 */
  71         MSTAT_FUNC_UNSPECIFIED = 0x00<<8,
  72         MSTAT_FUNC_IO = 0x01<<8,
  73         MSTAT_FUNC_TX_IO = 0x02<<8,
  74         MSTAT_FUNC_RX_IO = 0x03<<8,
  75         MSTAT_FUNC_TX = 0x04<<8,
  76         MSTAT_FUNC_RX = 0x05<<8,
  77         MSTAT_FUNC_MAX = 0x06<<8,
  78 };
  79 
  80 #define mstat_tf_idx(flags) ((flags)&0xff)
  81 #define mstat_ff_idx(flags) (((flags)&0xff00) >> 8)
  82 
  83 typedef enum mstat_status{
  84         MSTAT_ALLOC_SUCCESS = 0,
  85         MSTAT_ALLOC_FAIL,
  86         MSTAT_FREE
  87 } MSTAT_STATUS;
  88 
  89 #define rtw_mstat_update(flag, status, sz) do {} while (0)
  90 #define rtw_mstat_dump(sel) do {} while (0)
  91 void *_rtw_zmalloc(u32 sz);
  92 void *_rtw_malloc(u32 sz);
  93 void _kfree(u8 *pbuf, u32 sz);
  94 
  95 struct sk_buff *_rtw_skb_alloc(u32 sz);
  96 struct sk_buff *_rtw_skb_copy(const struct sk_buff *skb);
  97 struct sk_buff *_rtw_skb_clone(struct sk_buff *skb);
  98 int _rtw_netif_rx(_nic_hdl ndev, struct sk_buff *skb);
  99 
 100 #define rtw_malloc(sz)                  _rtw_malloc((sz))
 101 #define rtw_zmalloc(sz)                 _rtw_zmalloc((sz))
 102 
 103 #define rtw_skb_alloc(size) _rtw_skb_alloc((size))
 104 #define rtw_skb_alloc_f(size, mstat_f)  _rtw_skb_alloc((size))
 105 #define rtw_skb_copy(skb)       _rtw_skb_copy((skb))
 106 #define rtw_skb_clone(skb)      _rtw_skb_clone((skb))
 107 #define rtw_skb_copy_f(skb, mstat_f)    _rtw_skb_copy((skb))
 108 #define rtw_skb_clone_f(skb, mstat_f)   _rtw_skb_clone((skb))
 109 #define rtw_netif_rx(ndev, skb) _rtw_netif_rx(ndev, skb)
 110 
 111 extern void _rtw_init_queue(struct __queue      *pqueue);
 112 
 113 static inline void thread_enter(char *name)
 114 {
 115         allow_signal(SIGTERM);
 116 }
 117 
 118 static inline void flush_signals_thread(void)
 119 {
 120         if (signal_pending (current))
 121         {
 122                 flush_signals(current);
 123         }
 124 }
 125 
 126 #define rtw_warn_on(condition) WARN_ON(condition)
 127 
 128 static inline int rtw_bug_check(void *parg1, void *parg2, void *parg3, void *parg4)
 129 {
 130         int ret = true;
 131 
 132         return ret;
 133 
 134 }
 135 
 136 #define _RND(sz, r) ((((sz)+((r)-1))/(r))*(r))
 137 #define RND4(x) (((x >> 2) + (((x & 3) == 0) ?  0: 1)) << 2)
 138 
 139 static inline u32 _RND4(u32 sz)
 140 {
 141 
 142         u32 val;
 143 
 144         val = ((sz >> 2) + ((sz & 3) ? 1: 0)) << 2;
 145 
 146         return val;
 147 
 148 }
 149 
 150 static inline u32 _RND8(u32 sz)
 151 {
 152 
 153         u32 val;
 154 
 155         val = ((sz >> 3) + ((sz & 7) ? 1: 0)) << 3;
 156 
 157         return val;
 158 
 159 }
 160 
 161 #ifndef MAC_FMT
 162 #define MAC_FMT "%pM"
 163 #endif
 164 #ifndef MAC_ARG
 165 #define MAC_ARG(x) (x)
 166 #endif
 167 
 168 
 169 #ifdef CONFIG_AP_WOWLAN
 170 extern void rtw_softap_lock_suspend(void);
 171 extern void rtw_softap_unlock_suspend(void);
 172 #endif
 173 
 174 /* File operation APIs, just for linux now */
 175 extern int rtw_is_file_readable(char *path);
 176 extern int rtw_retrive_from_file(char *path, u8 *buf, u32 sz);
 177 
 178 extern void rtw_free_netdev(struct net_device * netdev);
 179 
 180 
 181 /* Macros for handling unaligned memory accesses */
 182 
 183 #define RTW_GET_BE16(a) ((u16) (((a)[0] << 8) | (a)[1]))
 184 #define RTW_PUT_BE16(a, val)                    \
 185         do {                                    \
 186                 (a)[0] = ((u16) (val)) >> 8;    \
 187                 (a)[1] = ((u16) (val)) & 0xff;  \
 188         } while (0)
 189 
 190 #define RTW_GET_LE16(a) ((u16) (((a)[1] << 8) | (a)[0]))
 191 #define RTW_PUT_LE16(a, val)                    \
 192         do {                                    \
 193                 (a)[1] = ((u16) (val)) >> 8;    \
 194                 (a)[0] = ((u16) (val)) & 0xff;  \
 195         } while (0)
 196 
 197 #define RTW_GET_BE24(a) ((((u32) (a)[0]) << 16) | (((u32) (a)[1]) << 8) | \
 198                          ((u32) (a)[2]))
 199 #define RTW_PUT_BE24(a, val)                                    \
 200         do {                                                    \
 201                 (a)[0] = (u8) ((((u32) (val)) >> 16) & 0xff);   \
 202                 (a)[1] = (u8) ((((u32) (val)) >> 8) & 0xff);    \
 203                 (a)[2] = (u8) (((u32) (val)) & 0xff);           \
 204         } while (0)
 205 
 206 #define RTW_GET_BE32(a) ((((u32) (a)[0]) << 24) | (((u32) (a)[1]) << 16) | \
 207                          (((u32) (a)[2]) << 8) | ((u32) (a)[3]))
 208 #define RTW_PUT_BE32(a, val)                                    \
 209         do {                                                    \
 210                 (a)[0] = (u8) ((((u32) (val)) >> 24) & 0xff);   \
 211                 (a)[1] = (u8) ((((u32) (val)) >> 16) & 0xff);   \
 212                 (a)[2] = (u8) ((((u32) (val)) >> 8) & 0xff);    \
 213                 (a)[3] = (u8) (((u32) (val)) & 0xff);           \
 214         } while (0)
 215 
 216 #define RTW_GET_LE32(a) ((((u32) (a)[3]) << 24) | (((u32) (a)[2]) << 16) | \
 217                          (((u32) (a)[1]) << 8) | ((u32) (a)[0]))
 218 #define RTW_PUT_LE32(a, val)                                    \
 219         do {                                                    \
 220                 (a)[3] = (u8) ((((u32) (val)) >> 24) & 0xff);   \
 221                 (a)[2] = (u8) ((((u32) (val)) >> 16) & 0xff);   \
 222                 (a)[1] = (u8) ((((u32) (val)) >> 8) & 0xff);    \
 223                 (a)[0] = (u8) (((u32) (val)) & 0xff);           \
 224         } while (0)
 225 
 226 #define RTW_GET_BE64(a) ((((u64) (a)[0]) << 56) | (((u64) (a)[1]) << 48) | \
 227                          (((u64) (a)[2]) << 40) | (((u64) (a)[3]) << 32) | \
 228                          (((u64) (a)[4]) << 24) | (((u64) (a)[5]) << 16) | \
 229                          (((u64) (a)[6]) << 8) | ((u64) (a)[7]))
 230 #define RTW_PUT_BE64(a, val)                            \
 231         do {                                            \
 232                 (a)[0] = (u8) (((u64) (val)) >> 56);    \
 233                 (a)[1] = (u8) (((u64) (val)) >> 48);    \
 234                 (a)[2] = (u8) (((u64) (val)) >> 40);    \
 235                 (a)[3] = (u8) (((u64) (val)) >> 32);    \
 236                 (a)[4] = (u8) (((u64) (val)) >> 24);    \
 237                 (a)[5] = (u8) (((u64) (val)) >> 16);    \
 238                 (a)[6] = (u8) (((u64) (val)) >> 8);     \
 239                 (a)[7] = (u8) (((u64) (val)) & 0xff);   \
 240         } while (0)
 241 
 242 #define RTW_GET_LE64(a) ((((u64) (a)[7]) << 56) | (((u64) (a)[6]) << 48) | \
 243                          (((u64) (a)[5]) << 40) | (((u64) (a)[4]) << 32) | \
 244                          (((u64) (a)[3]) << 24) | (((u64) (a)[2]) << 16) | \
 245                          (((u64) (a)[1]) << 8) | ((u64) (a)[0]))
 246 
 247 void rtw_buf_free(u8 **buf, u32 *buf_len);
 248 void rtw_buf_update(u8 **buf, u32 *buf_len, u8 *src, u32 src_len);
 249 
 250 struct rtw_cbuf {
 251         u32 write;
 252         u32 read;
 253         u32 size;
 254         void *bufs[0];
 255 };
 256 
 257 bool rtw_cbuf_full(struct rtw_cbuf *cbuf);
 258 bool rtw_cbuf_empty(struct rtw_cbuf *cbuf);
 259 bool rtw_cbuf_push(struct rtw_cbuf *cbuf, void *buf);
 260 void *rtw_cbuf_pop(struct rtw_cbuf *cbuf);
 261 struct rtw_cbuf *rtw_cbuf_alloc(u32 size);
 262 
 263 /*  String handler */
 264 /*
 265  * Write formatted output to sized buffer
 266  */
 267 #define rtw_sprintf(buf, size, format, arg...)  snprintf(buf, size, format, ##arg)
 268 
 269 #endif

/* [<][>][^][v][top][bottom][index][help] */