39 #include "simplelink.h"
41 #ifndef __SIMPLELINK_TRACE_H__
42 #define __SIMPLELINK_TRACE_H__
53 #define SL_SYNC_SCAN_THRESHOLD (( _u32 )2000)
56 #define _SlDrvAssert(line ) { while(1); }
58 #define _SlDrvAssert( ) { _SlDriverHandleError(SL_DEVICE_DRIVER_ASSERT_ERROR_EVENT, 0, 0); }
61 #define _SL_ASSERT(expr) { if(!(expr)){ \
64 #define _SL_ERROR(expr, error) { if(!(expr)){return (error); } }
66 #define SL_HANDLING_ASSERT 2
67 #define SL_HANDLING_ERROR 1
68 #define SL_HANDLING_NONE 0
74 #define SL_SELF_COND_HANDLING SL_HANDLING_ERROR
75 #define SL_PROTOCOL_HANDLING SL_HANDLING_ERROR
76 #define SL_DRV_RET_CODE_HANDLING SL_HANDLING_ERROR
77 #define SL_NWP_IF_HANDLING SL_HANDLING_ERROR
78 #define SL_OSI_RET_OK_HANDLING SL_HANDLING_ERROR
79 #define SL_MALLOC_OK_HANDLING SL_HANDLING_ERROR
80 #define SL_USER_ARGS_HANDLING SL_HANDLING_ERROR
81 #define SL_ERR_IN_PROGRESS_HANDLING SL_HANDLING_ERROR
85 #define SL_SELF_COND_HANDLING SL_HANDLING_NONE
86 #define SL_PROTOCOL_HANDLING SL_HANDLING_NONE
87 #define SL_DRV_RET_CODE_HANDLING SL_HANDLING_NONE
88 #define SL_NWP_IF_HANDLING SL_HANDLING_NONE
89 #define SL_OSI_RET_OK_HANDLING SL_HANDLING_NONE
90 #define SL_MALLOC_OK_HANDLING SL_HANDLING_NONE
91 #define SL_USER_ARGS_HANDLING SL_HANDLING_NONE
92 #define SL_ERR_IN_PROGRESS_HANDLING SL_HANDLING_NONE
96 #if (SL_ERR_IN_PROGRESS_HANDLING == SL_HANDLING_ERROR)
97 #define VERIFY_NO_ERROR_HANDLING_IN_PROGRESS() { \
98 if ( g_bDeviceRestartIsRequired == (_u8)TRUE) return SL_API_ABORTED; }
100 #define VERIFY_NO_ERROR_HANDLING_IN_PROGRESS()
102 #if (SL_DRV_RET_CODE_HANDLING == SL_HANDLING_ASSERT)
103 #define VERIFY_RET_OK(Func) {_SlReturnVal_t _RetVal = (Func); _SL_ASSERT((_SlReturnVal_t)SL_OS_RET_CODE_OK == _RetVal)}
104 #elif (SL_DRV_RET_CODE_HANDLING == SL_HANDLING_ERROR)
105 #define VERIFY_RET_OK(Func) {_SlReturnVal_t _RetVal = (Func); if (SL_OS_RET_CODE_OK != _RetVal) return _RetVal;}
107 #define VERIFY_RET_OK(Func) (Func);
110 #if (SL_PROTOCOL_HANDLING == SL_HANDLING_ASSERT)
111 #define VERIFY_PROTOCOL(expr) _SL_ASSERT(expr)
112 #elif (SL_PROTOCOL_HANDLING == SL_HANDLING_ERROR)
113 #define VERIFY_PROTOCOL(expr) _SL_ERROR(expr, SL_RET_CODE_PROTOCOL_ERROR)
115 #define VERIFY_PROTOCOL(expr)
118 #if (defined(PROTECT_SOCKET_ASYNC_RESP) && (SL_SELF_COND_HANDLING == SL_HANDLING_ASSERT))
119 #define VERIFY_SOCKET_CB(expr) _SL_ASSERT(expr)
120 #elif (defined(PROTECT_SOCKET_ASYNC_RESP) && (SL_SELF_COND_HANDLING == SL_HANDLING_ERROR))
121 #define VERIFY_SOCKET_CB(expr) _SL_ERROR(expr, SL_RET_CODE_SELF_ERROR)
123 #define VERIFY_SOCKET_CB(expr)
126 #if (SL_NWP_IF_HANDLING == SL_HANDLING_ASSERT)
127 #define NWP_IF_WRITE_CHECK(fd,pBuff,len) { _i16 RetSize, ExpSize = (_i16)(len); RetSize = sl_IfWrite((fd),(pBuff),ExpSize); _SL_ASSERT(ExpSize == RetSize)}
128 #define NWP_IF_READ_CHECK(fd,pBuff,len) { _i16 RetSize, ExpSize = (_i16)(len); RetSize = sl_IfRead((fd),(pBuff),ExpSize); _SL_ASSERT(ExpSize == RetSize)}
129 #elif (SL_NWP_IF_HANDLING == SL_HANDLING_ERROR)
130 #define NWP_IF_WRITE_CHECK(fd,pBuff,len) { _SL_ERROR((len == sl_IfWrite((fd),(pBuff),(len))), SL_RET_CODE_NWP_IF_ERROR);}
131 #define NWP_IF_READ_CHECK(fd,pBuff,len) { _SL_ERROR((len == sl_IfRead((fd),(pBuff),(len))), SL_RET_CODE_NWP_IF_ERROR);}
133 #define NWP_IF_WRITE_CHECK(fd,pBuff,len) { sl_IfWrite((fd),(pBuff),(len));}
134 #define NWP_IF_READ_CHECK(fd,pBuff,len) { sl_IfRead((fd),(pBuff),(len));}
137 #if (SL_OSI_RET_OK_HANDLING == SL_HANDLING_ASSERT)
138 #define OSI_RET_OK_CHECK(Func) {_SlReturnVal_t _RetVal = (Func); _SL_ASSERT((_SlReturnVal_t)SL_OS_RET_CODE_OK == _RetVal)}
139 #elif (SL_OSI_RET_OK_HANDLING == SL_HANDLING_ERROR)
140 #define OSI_RET_OK_CHECK(Func) {_SlReturnVal_t _RetVal = (Func); if (SL_OS_RET_CODE_OK != _RetVal) return _RetVal;}
142 #define OSI_RET_OK_CHECK(Func) (Func);
145 #if (SL_MALLOC_OK_HANDLING == SL_HANDLING_ASSERT)
146 #define MALLOC_OK_CHECK(Ptr) _SL_ASSERT(NULL != Ptr)
147 #elif (SL_MALLOC_OK_HANDLING == SL_HANDLING_ERROR)
148 #define MALLOC_OK_CHECK(Ptr) _SL_ERROR((NULL != Ptr), SL_RET_CODE_MALLOC_ERROR)
150 #define MALLOC_OK_CHECK(Ptr)
153 #ifdef SL_INC_ARG_CHECK
155 #if (SL_USER_ARGS_HANDLING == SL_HANDLING_ASSERT)
156 #define ARG_CHECK_PTR(Ptr) _SL_ASSERT(NULL != Ptr)
157 #elif (SL_USER_ARGS_HANDLING == SL_HANDLING_ERROR)
158 #define ARG_CHECK_PTR(Ptr) _SL_ERROR((NULL != Ptr), SL_RET_CODE_INVALID_INPUT)
160 #define ARG_CHECK_PTR(Ptr)
164 #define ARG_CHECK_PTR(Ptr)
168 #ifdef SL_DBG_TRACE_ENABLE
169 #define SL_TRACE0(level,msg_id,str) printf(str)
170 #define SL_TRACE1(level,msg_id,str,p1) printf(str,(p1))
171 #define SL_TRACE2(level,msg_id,str,p1,p2) printf(str,(p1),(p2))
172 #define SL_TRACE3(level,msg_id,str,p1,p2,p3) printf(str,(p1),(p2),(p3))
173 #define SL_TRACE4(level,msg_id,str,p1,p2,p3,p4) printf(str,(p1),(p2),(p3),(p4))
174 #define SL_ERROR_TRACE(msg_id,str) printf(str)
175 #define SL_ERROR_TRACE1(msg_id,str,p1) printf(str,(p1))
176 #define SL_ERROR_TRACE2(msg_id,str,p1,p2) printf(str,(p1),(p2))
177 #define SL_ERROR_TRACE3(msg_id,str,p1,p2,p3) printf(str,(p1),(p2),(p3))
178 #define SL_ERROR_TRACE4(msg_id,str,p1,p2,p3,p4) printf(str,(p1),(p2),(p3),(p4))
179 #define SL_TRACE_FLUSH()
181 #define SL_TRACE0(level,msg_id,str)
182 #define SL_TRACE1(level,msg_id,str,p1)
183 #define SL_TRACE2(level,msg_id,str,p1,p2)
184 #define SL_TRACE3(level,msg_id,str,p1,p2,p3)
185 #define SL_TRACE4(level,msg_id,str,p1,p2,p3,p4)
186 #define SL_ERROR_TRACE(msg_id,str)
187 #define SL_ERROR_TRACE1(msg_id,str,p1)
188 #define SL_ERROR_TRACE2(msg_id,str,p1,p2)
189 #define SL_ERROR_TRACE3(msg_id,str,p1,p2,p3)
190 #define SL_ERROR_TRACE4(msg_id,str,p1,p2,p3,p4)
191 #define SL_TRACE_FLUSH()
195 #ifdef SL_DBG_CNT_ENABLE
196 #define _SL_DBG_CNT_INC(Cnt) g_DbgCnt. ## Cnt++
197 #define _SL_DBG_SYNC_LOG(index,value) {if(index < SL_DBG_SYNC_LOG_SIZE){*(_u32 *)&g_DbgCnt.SyncLog[index] = *(_u32 *)(value);}}
200 #define _SL_DBG_CNT_INC(Cnt)
201 #define _SL_DBG_SYNC_LOG(index,value)
204 #define SL_DBG_LEVEL_1 1
205 #define SL_DBG_LEVEL_2 2
206 #define SL_DBG_LEVEL_3 4
207 #define SL_DBG_LEVEL_MASK (SL_DBG_LEVEL_2|SL_DBG_LEVEL_3)
209 #define SL_INCLUDE_DBG_FUNC(Name) ((Name ## _DBG_LEVEL) & SL_DBG_LEVEL_MASK)
211 #define _SlDrvPrintStat_DBG_LEVEL SL_DBG_LEVEL_3
212 #define _SlDrvOtherFunc_DBG_LEVEL SL_DBG_LEVEL_1