1 /* 2 * Copyright (C) 2015-2017 Alibaba Group Holding Limited 3 */ 4 #ifndef __AOS_OSDEP_SERVICE_H_ 5 #define __AOS_OSDEP_SERVICE_H_ 6 7 #include "dlist.h" 8 #include "aos/kernel.h" 9 #include <k_api.h> 10 // -------------------------------------------- 11 // Platform dependent include file 12 // -------------------------------------------- 13 #if defined(CONFIG_PLATFORM_8195A) 14 #include "platform/platform_stdlib.h" 15 extern VOID RtlUdelayOS(u32 us); 16 #elif defined(CONFIG_PLATFORM_8711B) 17 #include "platform/platform_stdlib.h" 18 #elif defined(CONFIG_PLATFORM_8721D) 19 #include "platform/platform_stdlib.h" 20 #else 21 // other MCU may use standard library 22 #include <string.h> 23 #endif 24 25 #ifndef configTICK_RATE_HZ 26 #define configTICK_RATE_HZ ( ( uint32_t ) 1000 ) 27 #endif 28 29 #define DBG_ERR(fmt, args...) DBG_8195A("\n\r[%s] " fmt, __FUNCTION__, ## args) 30 #if WLAN_INTF_DBG 31 #define DBG_TRACE(fmt, args...) DBG_8195A("\n\r[%s] " fmt, __FUNCTION__, ## args) 32 #define DBG_INFO(fmt, args...) DBG_8195A("\n\r[%s] " fmt, __FUNCTION__, ## args) 33 #else 34 #define DBG_TRACE(fmt, args...) 35 #define DBG_INFO(fmt, args...) 36 #endif 37 38 #define pvPortMalloc aos_malloc 39 #define vPortFree aos_free 40 /* 41 * atomic_read - read atomic variable 42 * @v: pointer of type atomic_t 43 * 44 * Atomically reads the value of @v. Note that the guaranteed 45 * useful range of an atomic_t is only 24 bits. 46 */ 47 #undef atomic_read 48 #define atomic_read(v) ((v)->counter) 49 50 /* 51 * atomic_set - set atomic variable 52 * @v: pointer of type atomic_t 53 * @i: required value 54 * 55 * Atomically sets the value of @v to @i. Note that the guaranteed 56 * useful range of an atomic_t is only 24 bits. 57 */ 58 #undef atomic_set 59 #define atomic_set(v,i) ((v)->counter = (i)) 60 61 #define HALT() do { cli(); for(;;);} while(0) 62 #undef ASSERT 63 #define ASSERT(x) do { \ 64 if((x) == 0){\ 65 DBG_8195A("\n\rAssert(" #x ") failed on line %d in file %s", __LINE__, __FILE__); \ 66 HALT();}\ 67 } while(0) 68 69 #undef DBG_ASSERT 70 #define DBG_ASSERT(x, msg) do { \ 71 if((x) == 0) \ 72 DBG_8195A("\n\r%s, Assert(" #x ") failed on line %d in file %s", msg, __LINE__, __FILE__); \ 73 } while(0) 74 75 76 77 // os types 78 typedef char osdepCHAR; 79 typedef float osdepFLOAT; 80 typedef double osdepDOUBLE; 81 typedef long osdepLONG; 82 typedef short osdepSHORT; 83 typedef unsigned long osdepSTACK_TYPE; 84 typedef long osdepBASE_TYPE; 85 typedef unsigned long osdepTickType; 86 87 88 struct timerHandle{ 89 aos_timer_t timer; 90 char* q_buf; 91 }; 92 93 typedef struct timerHandle* _timerHandle; 94 typedef aos_sem_t _sema; 95 typedef aos_mutex_t _mutex; 96 typedef aos_mutex_t _lock; 97 typedef aos_queue_t _queueHandle; 98 typedef kbuf_queue_t _xqueue; 99 #if 0 100 typedef struct{ 101 aos_queue_t queue; 102 char* q_buf; 103 }_xqueue; 104 #endif 105 typedef struct timer_list _timer; 106 107 typedef struct sk_buff _pkt; 108 typedef unsigned char _buffer; 109 110 struct __queue { 111 struct list_head queue; 112 _lock lock; 113 }; 114 typedef struct __queue _queue; 115 typedef struct list_head _list; 116 typedef u32 _irqL; 117 118 typedef struct {volatile int counter;} atomic_t; 119 #define ATOMIC_T atomic_t 120 121 #define DBG_ERR(fmt, args...) DBG_8195A("\n\r[%s] " fmt, __FUNCTION__, ## args) 122 123 #if CONFIG_PLATFORM_8711B 124 extern u32 random_seed; 125 #endif 126 #endif 127 128 129