DeepCover Embedded Security in IoT: Public-key Secured Data Paths
Dependencies: MaximInterface
trace.h
00001 /* 00002 * trace.h - CC31xx/CC32xx Host Driver Implementation 00003 * 00004 * Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com/ 00005 * 00006 * 00007 * Redistribution and use in source and binary forms, with or without 00008 * modification, are permitted provided that the following conditions 00009 * are met: 00010 * 00011 * Redistributions of source code must retain the above copyright 00012 * notice, this list of conditions and the following disclaimer. 00013 * 00014 * Redistributions in binary form must reproduce the above copyright 00015 * notice, this list of conditions and the following disclaimer in the 00016 * documentation and/or other materials provided with the 00017 * distribution. 00018 * 00019 * Neither the name of Texas Instruments Incorporated nor the names of 00020 * its contributors may be used to endorse or promote products derived 00021 * from this software without specific prior written permission. 00022 * 00023 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00024 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00025 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 00026 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 00027 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 00028 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 00029 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 00030 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 00031 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00032 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00033 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00034 * 00035 */ 00036 00037 00038 00039 #include "simplelink.h" 00040 00041 #ifndef __SIMPLELINK_TRACE_H__ 00042 #define __SIMPLELINK_TRACE_H__ 00043 00044 00045 #ifdef __cplusplus 00046 extern "C" { 00047 #endif 00048 00049 /*****************************************************************************/ 00050 /* Macro declarations */ 00051 /*****************************************************************************/ 00052 00053 #define SL_SYNC_SCAN_THRESHOLD (( _u32 )2000) 00054 00055 #ifdef SL_TINY_EXT 00056 #define _SlDrvAssert(line ) { while(1); } 00057 #else 00058 #define _SlDrvAssert( ) { _SlDriverHandleError(SL_DEVICE_DRIVER_ASSERT_ERROR_EVENT, 0, 0); } 00059 #endif 00060 00061 #define _SL_ASSERT(expr) { if(!(expr)){ \ 00062 _SlDrvAssert(); } \ 00063 } 00064 #define _SL_ERROR(expr, error) { if(!(expr)){return (error); } } 00065 00066 #define SL_HANDLING_ASSERT 2 00067 #define SL_HANDLING_ERROR 1 00068 #define SL_HANDLING_NONE 0 00069 00070 00071 #ifndef SL_TINY_EXT 00072 00073 #if 1 00074 #define SL_SELF_COND_HANDLING SL_HANDLING_ERROR 00075 #define SL_PROTOCOL_HANDLING SL_HANDLING_ERROR 00076 #define SL_DRV_RET_CODE_HANDLING SL_HANDLING_ERROR 00077 #define SL_NWP_IF_HANDLING SL_HANDLING_ERROR 00078 #define SL_OSI_RET_OK_HANDLING SL_HANDLING_ERROR 00079 #define SL_MALLOC_OK_HANDLING SL_HANDLING_ERROR 00080 #define SL_USER_ARGS_HANDLING SL_HANDLING_ERROR 00081 #define SL_ERR_IN_PROGRESS_HANDLING SL_HANDLING_ERROR 00082 #endif 00083 00084 #else 00085 #define SL_SELF_COND_HANDLING SL_HANDLING_NONE 00086 #define SL_PROTOCOL_HANDLING SL_HANDLING_NONE 00087 #define SL_DRV_RET_CODE_HANDLING SL_HANDLING_NONE 00088 #define SL_NWP_IF_HANDLING SL_HANDLING_NONE 00089 #define SL_OSI_RET_OK_HANDLING SL_HANDLING_NONE 00090 #define SL_MALLOC_OK_HANDLING SL_HANDLING_NONE 00091 #define SL_USER_ARGS_HANDLING SL_HANDLING_NONE 00092 #define SL_ERR_IN_PROGRESS_HANDLING SL_HANDLING_NONE 00093 #endif 00094 00095 00096 #if (SL_ERR_IN_PROGRESS_HANDLING == SL_HANDLING_ERROR) 00097 #define VERIFY_NO_ERROR_HANDLING_IN_PROGRESS() { \ 00098 if ( g_bDeviceRestartIsRequired == (_u8)TRUE) return SL_API_ABORTED; } 00099 #else 00100 #define VERIFY_NO_ERROR_HANDLING_IN_PROGRESS() 00101 #endif 00102 #if (SL_DRV_RET_CODE_HANDLING == SL_HANDLING_ASSERT) 00103 #define VERIFY_RET_OK(Func) {_SlReturnVal_t _RetVal = (Func); _SL_ASSERT((_SlReturnVal_t)SL_OS_RET_CODE_OK == _RetVal)} 00104 #elif (SL_DRV_RET_CODE_HANDLING == SL_HANDLING_ERROR) 00105 #define VERIFY_RET_OK(Func) {_SlReturnVal_t _RetVal = (Func); if (SL_OS_RET_CODE_OK != _RetVal) return _RetVal;} 00106 #else 00107 #define VERIFY_RET_OK(Func) (Func); 00108 #endif 00109 00110 #if (SL_PROTOCOL_HANDLING == SL_HANDLING_ASSERT) 00111 #define VERIFY_PROTOCOL(expr) _SL_ASSERT(expr) 00112 #elif (SL_PROTOCOL_HANDLING == SL_HANDLING_ERROR) 00113 #define VERIFY_PROTOCOL(expr) _SL_ERROR(expr, SL_RET_CODE_PROTOCOL_ERROR) 00114 #else 00115 #define VERIFY_PROTOCOL(expr) 00116 #endif 00117 00118 #if (defined(PROTECT_SOCKET_ASYNC_RESP) && (SL_SELF_COND_HANDLING == SL_HANDLING_ASSERT)) 00119 #define VERIFY_SOCKET_CB(expr) _SL_ASSERT(expr) 00120 #elif (defined(PROTECT_SOCKET_ASYNC_RESP) && (SL_SELF_COND_HANDLING == SL_HANDLING_ERROR)) 00121 #define VERIFY_SOCKET_CB(expr) _SL_ERROR(expr, SL_RET_CODE_SELF_ERROR) 00122 #else 00123 #define VERIFY_SOCKET_CB(expr) 00124 #endif 00125 00126 #if (SL_NWP_IF_HANDLING == SL_HANDLING_ASSERT) 00127 #define NWP_IF_WRITE_CHECK(fd,pBuff,len) { _i16 RetSize, ExpSize = (_i16)(len); RetSize = sl_IfWrite((fd),(pBuff),ExpSize); _SL_ASSERT(ExpSize == RetSize)} 00128 #define NWP_IF_READ_CHECK(fd,pBuff,len) { _i16 RetSize, ExpSize = (_i16)(len); RetSize = sl_IfRead((fd),(pBuff),ExpSize); _SL_ASSERT(ExpSize == RetSize)} 00129 #elif (SL_NWP_IF_HANDLING == SL_HANDLING_ERROR) 00130 #define NWP_IF_WRITE_CHECK(fd,pBuff,len) { _SL_ERROR((len == sl_IfWrite((fd),(pBuff),(len))), SL_RET_CODE_NWP_IF_ERROR);} 00131 #define NWP_IF_READ_CHECK(fd,pBuff,len) { _SL_ERROR((len == sl_IfRead((fd),(pBuff),(len))), SL_RET_CODE_NWP_IF_ERROR);} 00132 #else 00133 #define NWP_IF_WRITE_CHECK(fd,pBuff,len) { sl_IfWrite((fd),(pBuff),(len));} 00134 #define NWP_IF_READ_CHECK(fd,pBuff,len) { sl_IfRead((fd),(pBuff),(len));} 00135 #endif 00136 00137 #if (SL_OSI_RET_OK_HANDLING == SL_HANDLING_ASSERT) 00138 #define OSI_RET_OK_CHECK(Func) {_SlReturnVal_t _RetVal = (Func); _SL_ASSERT((_SlReturnVal_t)SL_OS_RET_CODE_OK == _RetVal)} 00139 #elif (SL_OSI_RET_OK_HANDLING == SL_HANDLING_ERROR) 00140 #define OSI_RET_OK_CHECK(Func) {_SlReturnVal_t _RetVal = (Func); if (SL_OS_RET_CODE_OK != _RetVal) return _RetVal;} 00141 #else 00142 #define OSI_RET_OK_CHECK(Func) (Func); 00143 #endif 00144 00145 #if (SL_MALLOC_OK_HANDLING == SL_HANDLING_ASSERT) 00146 #define MALLOC_OK_CHECK(Ptr) _SL_ASSERT(NULL != Ptr) 00147 #elif (SL_MALLOC_OK_HANDLING == SL_HANDLING_ERROR) 00148 #define MALLOC_OK_CHECK(Ptr) _SL_ERROR((NULL != Ptr), SL_RET_CODE_MALLOC_ERROR) 00149 #else 00150 #define MALLOC_OK_CHECK(Ptr) 00151 #endif 00152 00153 #ifdef SL_INC_ARG_CHECK 00154 00155 #if (SL_USER_ARGS_HANDLING == SL_HANDLING_ASSERT) 00156 #define ARG_CHECK_PTR(Ptr) _SL_ASSERT(NULL != Ptr) 00157 #elif (SL_USER_ARGS_HANDLING == SL_HANDLING_ERROR) 00158 #define ARG_CHECK_PTR(Ptr) _SL_ERROR((NULL != Ptr), SL_RET_CODE_INVALID_INPUT) 00159 #else 00160 #define ARG_CHECK_PTR(Ptr) 00161 #endif 00162 00163 #else 00164 #define ARG_CHECK_PTR(Ptr) 00165 #endif 00166 00167 /*#define SL_DBG_TRACE_ENABLE*/ 00168 #ifdef SL_DBG_TRACE_ENABLE 00169 #define SL_TRACE0(level,msg_id,str) printf(str) 00170 #define SL_TRACE1(level,msg_id,str,p1) printf(str,(p1)) 00171 #define SL_TRACE2(level,msg_id,str,p1,p2) printf(str,(p1),(p2)) 00172 #define SL_TRACE3(level,msg_id,str,p1,p2,p3) printf(str,(p1),(p2),(p3)) 00173 #define SL_TRACE4(level,msg_id,str,p1,p2,p3,p4) printf(str,(p1),(p2),(p3),(p4)) 00174 #define SL_ERROR_TRACE(msg_id,str) printf(str) 00175 #define SL_ERROR_TRACE1(msg_id,str,p1) printf(str,(p1)) 00176 #define SL_ERROR_TRACE2(msg_id,str,p1,p2) printf(str,(p1),(p2)) 00177 #define SL_ERROR_TRACE3(msg_id,str,p1,p2,p3) printf(str,(p1),(p2),(p3)) 00178 #define SL_ERROR_TRACE4(msg_id,str,p1,p2,p3,p4) printf(str,(p1),(p2),(p3),(p4)) 00179 #define SL_TRACE_FLUSH() 00180 #else 00181 #define SL_TRACE0(level,msg_id,str) 00182 #define SL_TRACE1(level,msg_id,str,p1) 00183 #define SL_TRACE2(level,msg_id,str,p1,p2) 00184 #define SL_TRACE3(level,msg_id,str,p1,p2,p3) 00185 #define SL_TRACE4(level,msg_id,str,p1,p2,p3,p4) 00186 #define SL_ERROR_TRACE(msg_id,str) 00187 #define SL_ERROR_TRACE1(msg_id,str,p1) 00188 #define SL_ERROR_TRACE2(msg_id,str,p1,p2) 00189 #define SL_ERROR_TRACE3(msg_id,str,p1,p2,p3) 00190 #define SL_ERROR_TRACE4(msg_id,str,p1,p2,p3,p4) 00191 #define SL_TRACE_FLUSH() 00192 #endif 00193 00194 /* #define SL_DBG_CNT_ENABLE */ 00195 #ifdef SL_DBG_CNT_ENABLE 00196 #define _SL_DBG_CNT_INC(Cnt) g_DbgCnt. ## Cnt++ 00197 #define _SL_DBG_SYNC_LOG(index,value) {if(index < SL_DBG_SYNC_LOG_SIZE){*(_u32 *)&g_DbgCnt.SyncLog[index] = *(_u32 *)(value);}} 00198 00199 #else 00200 #define _SL_DBG_CNT_INC(Cnt) 00201 #define _SL_DBG_SYNC_LOG(index,value) 00202 #endif 00203 00204 #define SL_DBG_LEVEL_1 1 00205 #define SL_DBG_LEVEL_2 2 00206 #define SL_DBG_LEVEL_3 4 00207 #define SL_DBG_LEVEL_MASK (SL_DBG_LEVEL_2|SL_DBG_LEVEL_3) 00208 00209 #define SL_INCLUDE_DBG_FUNC(Name) ((Name ## _DBG_LEVEL) & SL_DBG_LEVEL_MASK) 00210 00211 #define _SlDrvPrintStat_DBG_LEVEL SL_DBG_LEVEL_3 00212 #define _SlDrvOtherFunc_DBG_LEVEL SL_DBG_LEVEL_1 00213 00214 #ifdef __cplusplus 00215 } 00216 #endif 00217 00218 00219 #endif /*__SIMPLELINK_TRACE_H__*/ 00220
Generated on Tue Jul 12 2022 12:06:49 by 1.7.2