1 /******************************************************************************
2 *
3 * Copyright(c) 2019 - 2020 Realtek Corporation.
4 *
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.
8 *
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
12 * more details.
13 *
14 *****************************************************************************/
15 #ifndef _PLTFM_OPS_MACOS_H_
16 #define _PLTFM_OPS_MACOS_H_
17
_os_strsep(char ** s,const char * ct)18 static __inline char *_os_strsep(char **s, const char *ct)
19 {
20 return NULL;
21 }
_os_sscanf(const char * buf,const char * fmt,...)22 static __inline int _os_sscanf(const char *buf, const char *fmt, ...)
23 {
24 return 0;
25 }
_os_strcmp(const char * s1,const char * s2)26 static __inline int _os_strcmp(const char *s1, const char *s2)
27 {
28 return 0;
29 }
_os_strncmp(const char * s1,const char * s2,size_t n)30 static __inline int _os_strncmp(const char *s1, const char *s2, size_t n)
31 {
32 return 0;
33 }
_os_strcpy(char * dest,const char * src)34 static __inline char *_os_strcpy(char *dest, const char *src)
35 {
36 return NULL;
37 }
_os_strncpy(char * dest,const char * src,size_t n)38 static inline char *_os_strncpy(char *dest, const char *src, size_t n)
39 {
40 return NULL;
41 }
_os_strchr(const char * s,int c)42 static __inline char *_os_strchr(const char *s, int c)
43 {
44 while (*s != (char)c)
45 if (*s++ == '\0')
46 return NULL;
47 return (char *)s;
48 }
_os_snprintf(char * str,size_t size,const char * format,...)49 static __inline int _os_snprintf(char *str, size_t size, const char *format, ...)
50 {
51 return 0;
52 }
53
_os_strlen(u8 * buf)54 static __inline u32 _os_strlen(u8 *buf)
55 {
56 return 0;
57 }
_os_delay_ms(void * h,u32 ms)58 static __inline void _os_delay_ms(void *h, u32 ms)
59 {
60 }
_os_delay_us(void * h,u32 us)61 static __inline void _os_delay_us(void *h, u32 us)
62 {
63 }
_os_sleep_ms(void * h,u32 ms)64 static __inline void _os_sleep_ms(void *h, u32 ms)
65 {
66 }
_os_sleep_us(void * h,u32 us)67 static __inline void _os_sleep_us(void *h, u32 us)
68 {
69 }
_os_get_cur_time_us(void)70 static inline u32 _os_get_cur_time_us(void)
71 {
72 return 0;
73 }
_os_get_cur_time_ms(void)74 static inline u32 _os_get_cur_time_ms(void)
75 {
76 return 0;
77 }
78
_os_modular64(u64 x,u64 y)79 static inline u64 _os_modular64(u64 x, u64 y)
80 {
81 return x % y;
82 }
_os_division64(u64 x,u64 y)83 static inline u64 _os_division64(u64 x, u64 y)
84 {
85 return x / y;
86 }
87
88 #ifdef CONFIG_PCI_HCI
_os_cache_inv(void * d,_dma * bus_addr_l,_dma * bus_addr_h,u32 buf_sz,u8 direction)89 static inline void _os_cache_inv(void *d, _dma *bus_addr_l, _dma *bus_addr_h,
90 u32 buf_sz, u8 direction)
91 {
92 }
_os_cache_wback(void * d,_dma * bus_addr_l,_dma * bus_addr_h,u32 buf_sz,u8 direction)93 static inline void _os_cache_wback(void *d, _dma *bus_addr_l,
94 _dma *bus_addr_h, u32 buf_sz, u8 direction)
95 {
96 }
97
98 /* txbd, rxbd, wd */
_os_shmem_alloc(void * d,_dma * bus_addr_l,_dma * bus_addr_h,u32 buf_sz,u8 cache,u8 direction,void ** os_rsvd)99 static inline void *_os_shmem_alloc(void *d, _dma *bus_addr_l,
100 _dma *bus_addr_h, u32 buf_sz,
101 u8 cache, u8 direction, void **os_rsvd)
102 {
103 return NULL;
104 }
_os_shmem_free(void * d,u8 * vir_addr,_dma * bus_addr_l,_dma * bus_addr_h,u32 buf_sz,u8 cache,u8 direction,void * os_rsvd)105 static inline void _os_shmem_free(void *d, u8 *vir_addr, _dma *bus_addr_l,
106 _dma *bus_addr_h, u32 buf_sz,
107 u8 cache, u8 direction, void *os_rsvd)
108 {
109 return NULL;
110 }
111 #endif
112
_os_pkt_buf_unmap_rx(void * d,_dma bus_addr_l,_dma bus_addr_h,u32 buf_sz)113 static inline void *_os_pkt_buf_unmap_rx(void *d, _dma bus_addr_l, _dma bus_addr_h, u32 buf_sz)
114 {
115 return NULL;
116 }
117
_os_pkt_buf_map_rx(void * d,_dma * bus_addr_l,_dma * bus_addr_h,u32 buf_sz,void * os_priv)118 static inline void *_os_pkt_buf_map_rx(void *d, _dma *bus_addr_l, _dma *bus_addr_h,
119 u32 buf_sz, void *os_priv)
120 {
121 return NULL;
122 }
123
_os_pkt_buf_alloc_rx(void * d,_dma * bus_addr_l,_dma * bus_addr_h,u32 buf_sz,void ** os_priv)124 static inline void *_os_pkt_buf_alloc_rx(void *d, _dma *bus_addr_l, _dma *bus_addr_h,
125 u32 buf_sz, void **os_priv)
126 {
127 return NULL;
128 }
_os_pkt_buf_free_rx(void * d,u8 * vir_addr,_dma bus_addr_l,_dma bus_addr_h,u32 buf_sz,void * os_priv)129 static inline u8 *_os_pkt_buf_free_rx(void *d, u8 *vir_addr, _dma bus_addr_l,
130 _dma bus_addr_h, u32 buf_sz, void *os_priv)
131 {
132 return NULL;
133 }
134
135 /* phl pre-alloc network layer buffer */
_os_alloc_netbuf(void * d,u32 buf_sz,void ** os_priv)136 static inline void * _os_alloc_netbuf(void *d, u32 buf_sz, void **os_priv)
137 {
138 return NULL; // windows never do this.
139 }
140
141 /* Free netbuf for error case. (ex. drop rx-reorder packet) */
_os_free_netbuf(void * d,u8 * vir_addr,u32 buf_sz,void * os_priv)142 static inline void _os_free_netbuf(void *d, u8 *vir_addr, u32 buf_sz, void *os_priv)
143 {
144 }
145
_os_mem_alloc(void * h,u32 buf_sz)146 static __inline void *_os_mem_alloc(void *h, u32 buf_sz)
147 {
148 return NULL;
149 }
150
_os_mem_free(void * h,void * buf,u32 buf_sz)151 static __inline void _os_mem_free(void *h, void *buf, u32 buf_sz)
152 {
153 }
154 /*physically contiguous memory if the buffer will be accessed by a DMA device*/
_os_kmem_alloc(void * h,u32 buf_sz)155 static inline void *_os_kmem_alloc(void *h, u32 buf_sz)
156 {
157 return NULL;
158 }
159
160 /*physically contiguous memory if the buffer will be accessed by a DMA device*/
_os_kmem_free(void * h,void * buf,u32 buf_sz)161 static inline void _os_kmem_free(void *h, void *buf, u32 buf_sz)
162 {
163 }
_os_mem_set(void * h,void * buf,s8 value,u32 size)164 static __inline void _os_mem_set(void *h, void *buf, s8 value, u32 size)
165 {
166 }
_os_mem_cpy(void * h,void * dest,void * src,u32 size)167 static __inline void _os_mem_cpy(void *h, void *dest, void *src, u32 size)
168 {
169 }
_os_mem_cmp(void * h,void * ptr1,void * ptr2,u32 size)170 static __inline int _os_mem_cmp(void *h, void *ptr1, void *ptr2, u32 size)
171 {
172 return 0;
173 }
_os_init_timer(void * h,_os_timer * timer,void (* call_back_func)(void * context),void * context,const char * sz_id)174 static __inline void _os_init_timer(void *h, _os_timer *timer,
175 void (*call_back_func)(void *context), void *context,
176 const char *sz_id)
177 {
178 }
179
_os_set_timer(void * h,_os_timer * timer,u32 ms_delay)180 static __inline void _os_set_timer(void *h, _os_timer *timer, u32 ms_delay)
181 {
182 }
183
_os_cancel_timer(void * h,_os_timer * timer)184 static __inline void _os_cancel_timer(void *h, _os_timer *timer)
185 {
186 }
_os_cancel_timer_async(void * d,_os_timer * timer)187 static inline void _os_cancel_timer_async(void *d, _os_timer *timer)
188 {
189 }
190
_os_release_timer(void * h,_os_timer * timer)191 static __inline void _os_release_timer(void *h, _os_timer *timer)
192 {
193
194 }
_os_mutex_init(void * h,_os_mutex * mutex)195 static __inline void _os_mutex_init(void *h, _os_mutex *mutex)
196 {
197 }
198
_os_mutex_deinit(void * h,_os_mutex * mutex)199 static __inline void _os_mutex_deinit(void *h, _os_mutex *mutex)
200 {
201 }
202
_os_mutex_lock(void * h,_os_mutex * mutex)203 static __inline void _os_mutex_lock(void *h, _os_mutex *mutex)
204 {
205 }
206
_os_mutex_unlock(void * h,_os_mutex * mutex)207 static __inline void _os_mutex_unlock(void *h, _os_mutex *mutex)
208 {
209 }
210
_os_sema_init(void * h,_os_sema * sema,int int_cnt)211 static inline void _os_sema_init(void *h, _os_sema *sema, int int_cnt)
212 {
213 }
214
_os_sema_free(void * h,_os_sema * sema)215 static inline void _os_sema_free(void *h, _os_sema *sema)
216 {
217 }
218
_os_sema_up(void * h,_os_sema * sema)219 static inline void _os_sema_up(void *h, _os_sema *sema)
220 {
221 }
222
_os_sema_down(void * h,_os_sema * sema)223 static inline u8 _os_sema_down(void *h, _os_sema *sema)
224 {
225 return 0; //success
226 }
227
_os_spinlock_init(void * d,_os_lock * plock)228 static __inline void _os_spinlock_init(void *d, _os_lock *plock)
229 {
230 }
_os_spinlock_free(void * d,_os_lock * plock)231 static __inline void _os_spinlock_free(void *d, _os_lock *plock)
232 {
233 }
_os_spinlock(void * d,_os_lock * plock,enum lock_type type,_os_spinlockfg * flags)234 static inline void _os_spinlock(void *d, _os_lock *plock,
235 enum lock_type type, _os_spinlockfg *flags)
236 {
237 }
238
_os_spinunlock(void * d,_os_lock * plock,enum lock_type type,_os_spinlockfg * flags)239 static inline void _os_spinunlock(void *d, _os_lock *plock,
240 enum lock_type type, _os_spinlockfg *flags)
241 {
242 }
243
244 /* event */
_os_event_init(void * h,_os_event * event)245 static __inline void _os_event_init(void *h, _os_event *event)
246 {
247 }
_os_event_free(void * h,_os_event * event)248 static __inline void _os_event_free(void *h, _os_event *event)
249 {
250 }
_os_event_reset(void * h,_os_event * event)251 static __inline void _os_event_reset(void *h, _os_event *event)
252 {
253 }
_os_event_set(void * h,_os_event * event)254 static __inline void _os_event_set(void *h, _os_event *event)
255 {
256 }
257
258 /*
259 * m_sec
260 * == 0 : wait for completion
261 * > 0 : wait for timeout or completion
262 * return value
263 * 0:timeout
264 * otherwise:success
265 */
_os_event_wait(void * h,_os_event * event,u32 m_sec)266 static __inline int _os_event_wait(void *h, _os_event *event, u32 m_sec)
267 {
268 return 0;
269 }
270
_os_test_and_clear_bit(int nr,unsigned long * addr)271 static inline int _os_test_and_clear_bit(int nr, unsigned long *addr)
272 {
273 /*UNDO*/
274 return 0;
275 }
_os_test_and_set_bit(int nr,unsigned long * addr)276 static inline int _os_test_and_set_bit(int nr, unsigned long *addr)
277 {
278 /*UNDO*/
279 return 1;
280 }
281 /* Atomic integer operations */
_os_atomic_set(void * d,_os_atomic * v,int i)282 static __inline void _os_atomic_set(void *d, _os_atomic *v, int i)
283 {
284 }
285
_os_atomic_read(void * d,_os_atomic * v)286 static __inline int _os_atomic_read(void *d, _os_atomic *v)
287 {
288 return 0;
289 }
290
_os_atomic_add(void * d,_os_atomic * v,int i)291 static __inline void _os_atomic_add(void *d, _os_atomic *v, int i)
292 {
293 }
_os_atomic_sub(void * d,_os_atomic * v,int i)294 static __inline void _os_atomic_sub(void *d, _os_atomic *v, int i)
295 {
296 }
297
_os_atomic_inc(void * d,_os_atomic * v)298 static __inline void _os_atomic_inc(void *d, _os_atomic *v)
299 {
300 }
301
_os_atomic_dec(void * d,_os_atomic * v)302 static __inline void _os_atomic_dec(void *d, _os_atomic *v)
303 {
304 }
305
_os_atomic_add_return(void * d,_os_atomic * v,int i)306 static __inline int _os_atomic_add_return(void *d, _os_atomic *v, int i)
307 {
308 return 0;
309 }
310
_os_atomic_sub_return(void * d,_os_atomic * v,int i)311 static __inline int _os_atomic_sub_return(void *d, _os_atomic *v, int i)
312 {
313 return 0;
314 }
315
_os_atomic_inc_return(void * d,_os_atomic * v)316 static __inline int _os_atomic_inc_return(void *d, _os_atomic *v)
317 {
318 return 0;
319 }
320
_os_atomic_dec_return(void * d,_os_atomic * v)321 static __inline int _os_atomic_dec_return(void *d, _os_atomic *v)
322 {
323 return 0;
324 }
325 /*
326 static __inline bool _os_atomic_inc_unless(void *d, _os_atomic *v, int u)
327 {
328 return 0;
329 }
330 */
_os_tasklet_init(void * drv_priv,_os_tasklet * task,void (* call_back_func)(void * context),void * context)331 static inline u8 _os_tasklet_init(void *drv_priv, _os_tasklet *task,
332 void (*call_back_func)(void* context), void *context)
333 {
334 return 0;
335 }
_os_tasklet_deinit(void * drv_priv,_os_tasklet * task)336 static inline u8 _os_tasklet_deinit(void *drv_priv, _os_tasklet *task)
337 {
338 return 0;
339 }
_os_tasklet_schedule(void * drv_priv,_os_tasklet * task)340 static inline u8 _os_tasklet_schedule(void *drv_priv, _os_tasklet *task)
341 {
342 return 0;
343 }
344
_os_thread_init(void * drv_priv,_os_thread * thread,int (* call_back_func)(void * context),void * context,const char namefmt[])345 static __inline u8 _os_thread_init( void *drv_priv, _os_thread *thread,
346 int (*call_back_func)(void * context),
347 void *context,
348 const char namefmt[])
349 {
350 return RTW_PHL_STATUS_FAILURE;
351 }
_os_thread_deinit(void * drv_priv,_os_thread * thread)352 static __inline u8 _os_thread_deinit(void *drv_priv, _os_thread *thread)
353 {
354 return RTW_PHL_STATUS_FAILURE;
355 }
_os_thread_schedule(void * drv_priv,_os_thread * thread)356 static __inline enum rtw_phl_status _os_thread_schedule(void *drv_priv, _os_thread *thread)
357 {
358 return RTW_PHL_STATUS_FAILURE;
359 }
_os_thread_stop(void * drv_priv,_os_thread * thread)360 static inline void _os_thread_stop(void *drv_priv, _os_thread *thread)
361 {
362 }
_os_thread_check_stop(void * drv_priv,_os_thread * thread)363 static inline int _os_thread_check_stop(void *drv_priv, _os_thread *thread)
364 {
365 return 1;
366 }
_os_thread_wait_stop(void * drv_priv,_os_thread * thread)367 static inline int _os_thread_wait_stop(void *drv_priv, _os_thread *thread)
368 {
369 return RTW_PHL_STATUS_SUCCESS;
370 }
371
372 #if 0 /* TODO */
373 static inline _os_thread _os_thread_start(int (*threadfn)(void *data),
374 void *data, const char namefmt[])
375 {
376 return 0;
377 }
378 static inline bool _os_thread_stop(_os_thread th)
379 {
380 return 0;
381 }
382 static inline void _os_thread_wait_stop(void)
383 {
384 }
385 static inline int _os_thread_check_stop(void)
386 {
387 return 0;
388 }
389 #endif
390
_os_workitem_init(void * drv_priv,_os_workitem * workitem,void (* call_back_func)(void * context),void * context)391 static inline u8 _os_workitem_init(void *drv_priv, _os_workitem *workitem,
392 void (*call_back_func)(void* context), void *context)
393 {
394 return 0;
395 }
_os_workitem_schedule(void * drv_priv,_os_workitem * workitem)396 static inline u8 _os_workitem_schedule(void *drv_priv, _os_workitem *workitem)
397 {
398 return 0;
399 }
_os_workitem_deinit(void * drv_priv,_os_workitem * workitem)400 static inline u8 _os_workitem_deinit(void *drv_priv, _os_workitem *workitem)
401 {
402 return 0;
403 }
404
405 /* File Operation */
_os_read_file(const char * path,u8 * buf,u32 sz)406 static inline u32 _os_read_file(const char *path, u8 *buf, u32 sz)
407 {
408 /* OS Dependent API */
409 return 0;
410 }
411
412 #ifdef CONFIG_PCI_HCI
_os_read8_pcie(void * h,u32 addr)413 static __inline u8 _os_read8_pcie(void *h, u32 addr)
414 {
415 return 0;
416 }
_os_read16_pcie(void * h,u32 addr)417 static __inline u16 _os_read16_pcie(void *h, u32 addr)
418 {
419 return 0;
420
421 }
_os_read32_pcie(void * h,u32 addr)422 static __inline u32 _os_read32_pcie(void *h, u32 addr)
423 {
424 return 0;
425 }
426
_os_write8_pcie(void * h,u32 addr,u8 val)427 static __inline u32 _os_write8_pcie(void *h, u32 addr, u8 val)
428 {
429 return 0;
430 }
_os_write16_pcie(void * h,u32 addr,u16 val)431 static __inline u32 _os_write16_pcie(void *h, u32 addr, u16 val)
432 {
433 return 0;
434 }
_os_write32_pcie(void * h,u32 addr,u32 val)435 static __inline u32 _os_write32_pcie(void *h, u32 addr, u32 val)
436 {
437 return 0;
438 }
439 #endif/*#ifdef CONFIG_PCI_HCI*/
440
441 #ifdef CONFIG_USB_HCI
_os_usbctrl_vendorreq(void * h,u8 request,u16 value,u16 index,void * pdata,u16 len,u8 requesttype)442 static __inline u32 _os_usbctrl_vendorreq(void *h, u8 request, u16 value,
443 u16 index, void *pdata, u16 len, u8 requesttype)
444 {
445 return 0;
446 }
447
os_usb_tx(void * h,u8 * tx_buf_ptr,u8 bulk_id,u32 len,u8 * pkt_data_buf)448 static inline int os_usb_tx(void *h, u8 *tx_buf_ptr,
449 u8 bulk_id, u32 len, u8 *pkt_data_buf)
450 {
451 return 1;
452 }
453
454 #endif /*CONFIG_USB_HCI*/
455
456 #ifdef CONFIG_SDIO_HCI
_os_sdio_cmd52_r8(void * d,u32 offset)457 static __inline u8 _os_sdio_cmd52_r8(void *d, u32 offset)
458 {
459 return 0;
460 }
461
_os_sdio_cmd53_r8(void * d,u32 offset)462 static __inline u8 _os_sdio_cmd53_r8(void *d, u32 offset)
463 {
464 return 0;
465 }
466
_os_sdio_cmd53_r16(void * d,u32 offset)467 static __inline u16 _os_sdio_cmd53_r16(void *d, u32 offset)
468 {
469 return 0;
470 }
471
_os_sdio_cmd53_r32(void * d,u32 offset)472 static __inline u32 _os_sdio_cmd53_r32(void *d, u32 offset)
473 {
474 return 0;
475 }
476
_os_sdio_cmd53_rn(void * d,u32 offset,u32 size,u8 * data)477 static __inline u8 _os_sdio_cmd53_rn(void *d, u32 offset, u32 size, u8 *data)
478 {
479 return 0;
480 }
481
_os_sdio_cmd53_r(void * d,u32 offset,u32 size,u8 * data)482 static __inline u8 _os_sdio_cmd53_r(void *d, u32 offset, u32 size, u8 *data)
483 {
484 /* TODO: implement read RX FIFO */
485 return 0;
486 }
487
_os_sdio_cmd52_w8(void * d,u32 offset,u8 val)488 static __inline void _os_sdio_cmd52_w8(void *d, u32 offset, u8 val)
489 {
490 }
491
_os_sdio_cmd53_w8(void * d,u32 offset,u8 val)492 static __inline void _os_sdio_cmd53_w8(void *d, u32 offset, u8 val)
493 {
494 }
495
_os_sdio_cmd53_w16(void * d,u32 offset,u16 val)496 static __inline void _os_sdio_cmd53_w16(void *d, u32 offset, u16 val)
497 {
498 }
499
_os_sdio_cmd53_w32(void * d,u32 offset,u32 val)500 static __inline void _os_sdio_cmd53_w32(void *d, u32 offset, u32 val)
501 {
502 }
503
_os_sdio_cmd53_wn(void * d,u32 offset,u32 size,u8 * data)504 static __inline void _os_sdio_cmd53_wn(void *d, u32 offset, u32 size, u8 *data)
505 {
506 }
507
_os_sdio_cmd53_w(void * d,u32 offset,u32 size,u8 * data)508 static __inline void _os_sdio_cmd53_w(void *d, u32 offset, u32 size, u8 *data)
509 {
510 }
511
_os_sdio_f0_read(void * d,u32 addr,void * buf,size_t len)512 static __inline u8 _os_sdio_f0_read(void *d, u32 addr, void *buf, size_t len)
513 {
514 return 0;
515 }
516
_os_sdio_read_cia_r8(void * d,u32 addr)517 static __inline u8 _os_sdio_read_cia_r8(void *d, u32 addr)
518 {
519 return 0;
520 }
521 #endif /*CONFIG_SDIO_HCI*/
522
523 /* temp os dependency */
524
525 /* can delete if osdep ready */
526
527
528 #endif /*_PLTFM_OPS_MACOS_H_*/
529