1 /* 2 * driver.h - CC31xx/CC32xx Host Driver Implementation 3 * 4 * Copyright (C) 2017 Texas Instruments Incorporated - http://www.ti.com/ 5 * 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 11 * Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer. 13 * 14 * Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in the 16 * documentation and/or other materials provided with the 17 * distribution. 18 * 19 * Neither the name of Texas Instruments Incorporated nor the names of 20 * its contributors may be used to endorse or promote products derived 21 * from this software without specific prior written permission. 22 * 23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 26 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 27 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 28 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 29 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 30 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 31 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 * 35 */ 36 37 #ifndef __DRIVER_INT_H__ 38 #define __DRIVER_INT_H__ 39 40 #ifdef __cplusplus 41 extern "C" { 42 #endif 43 44 #include <ti/drivers/net/wifi/source/protocol.h> 45 46 #define TIMEOUT_STATE_EXPIRY (0) 47 #define TIMEOUT_ONE_MORE_SHOT (1) 48 #define TIMEOUT_STATE_INIT_VAL (2) 49 50 /* Timeouts for the sync objects */ 51 #ifndef SL_DRIVER_TIMEOUT_SHORT 52 #define SL_DRIVER_TIMEOUT_SHORT (10000) /* msec units */ 53 #endif 54 #ifndef SL_DRIVER_TIMEOUT_LONG 55 #define SL_DRIVER_TIMEOUT_LONG (65535) /* msec units */ 56 #endif 57 58 #define INIT_COMPLETE_TIMEOUT SL_DRIVER_TIMEOUT_LONG 59 #define STOP_DEVICE_TIMEOUT SL_DRIVER_TIMEOUT_LONG 60 61 #ifndef SYNC_PATTERN_TIMEOUT_IN_MSEC 62 #define SYNC_PATTERN_TIMEOUT_IN_MSEC (50) /* the sync patttern timeout in milliseconds units */ 63 #endif 64 65 #define GLOBAL_LOCK_FLAGS_NONE (0x0) 66 #define GLOBAL_LOCK_FLAGS_UPDATE_API_IN_PROGRESS (0x1) /* Bit 0 */ 67 #define GLOBAL_LOCK_FLAGS_PROVISIONING_STOP_API (0x2) /* Bit 1*/ 68 #define GLOBAL_LOCK_FLAGS_STARTING_DEVICE (0x4) /* Bit 2 */ 69 /*****************************************************************************/ 70 /* Macro declarations */ 71 /*****************************************************************************/ 72 73 #ifndef CPU_FREQ_IN_MHZ 74 #define CPU_FREQ_IN_MHZ (200) 75 #endif 76 #define USEC_DELAY (50) 77 78 #define SL_DRV_PROTECTION_OBJ_UNLOCK() LOCK_OK_CHECK(_SlDrvProtectionObjUnLock()); 79 #define SL_DRV_PROTECTION_OBJ_LOCK_FOREVER() LOCK_OK_CHECK(_SlDrvProtectionObjLockWaitForever()); 80 #define SL_DRV_OBJ_UNLOCK(pObj) LOCK_OK_CHECK(_SlDrvObjUnLock(pObj)); 81 #define SL_DRV_OBJ_LOCK_FOREVER(pObj) LOCK_OK_CHECK(_SlDrvObjLockWaitForever(pObj)); 82 #define SL_DRV_SYNC_OBJ_SIGNAL(pObj) _SlDrvSyncObjSignal(pObj); 83 #define SL_DRV_SYNC_OBJ_SIGNAL_FROM_IRQ(pObj) sl_SyncObjSignalFromIRQ(pObj); 84 #define SL_DRV_SYNC_OBJ_CLEAR(pObj) sl_SyncObjWait(pObj,SL_OS_NO_WAIT); 85 86 #define SL_DRV_SYNC_OBJ_WAIT_FOREVER(SyncObj) { \ 87 if (SL_API_ABORTED == _SlDrvSyncObjWaitForever(SyncObj)) \ 88 { \ 89 return SL_API_ABORTED; \ 90 } \ 91 } 92 #define SL_DRV_SYNC_OBJ_WAIT_TIMEOUT(SyncObj, timeoutVal, opcode) { \ 93 if (SL_API_ABORTED == _SlDrvSyncObjWaitTimeout(SyncObj, timeoutVal, opcode)) \ 94 { \ 95 _SlDrvReleasePoolObj(g_pCB->FunctionParams.AsyncExt.ActionIndex); \ 96 return SL_API_ABORTED; \ 97 } \ 98 } 99 #define SL_DRV_LOCK_GLOBAL_LOCK_FOREVER(Flags) { \ 100 _SlReturnVal_t retVal; \ 101 \ 102 retVal = _SlDrvObjGlobalLockWaitForever(Flags); \ 103 if (retVal) \ 104 { \ 105 return retVal; \ 106 } \ 107 } 108 109 #define SL_DRV_LOCK_GLOBAL_UNLOCK(bDecrementApiInProgress) { \ 110 _SlReturnVal_t retVal; \ 111 \ 112 retVal = _SlDrvGlobalObjUnLock(bDecrementApiInProgress); \ 113 if (retVal) \ 114 { \ 115 return retVal; \ 116 } \ 117 } 118 119 120 #define SL_IS_RESTART_REQUIRED (g_SlDeviceStatus & _SL_DRV_STATUS_BIT_RESTART_REQUIRED) /* bit 8 indicates restart is required due to fatal error */ 121 #define SL_IS_DEVICE_STARTED (g_SlDeviceStatus & _SL_DRV_STATUS_BIT_DEVICE_STARTED) /* bit 9 indicates device is started */ 122 #define SL_IS_DEVICE_LOCKED (g_SlDeviceStatus & _SL_DEV_STATUS_BIT_LOCKED) /* bits 0-7 devStatus from NWP, bit 2 = device locked */ 123 #define SL_IS_PROVISIONING_ACTIVE (!!(g_SlDeviceStatus & _SL_DEV_STATUS_BIT_PROVISIONING_ACTIVE)) /* bits 0-7 devStatus from NWP, bit 3 = provisioning active */ 124 #define SL_IS_PROVISIONING_INITIATED_BY_USER (!!(g_SlDeviceStatus & _SL_DEV_STATUS_BIT_PROVISIONING_USER_INITIATED)) /* bits 0-7 devStatus from NWP, bit 4 = provisioning initiated by the user */ 125 #define SL_IS_PROVISIONING_API_ALLOWED (!!(g_SlDeviceStatus & _SL_DEV_STATUS_BIT_PROVISIONING_ENABLE_API)) 126 #define SL_IS_DEVICE_STOP_IN_PROGRESS (!!(g_SlDeviceStatus & _SL_DRV_STATUS_BIT_STOP_IN_PROGRESS)) 127 #define SL_IS_DEVICE_START_IN_PROGRESS (!!(g_SlDeviceStatus & _SL_DRV_STATUS_BIT_START_IN_PROGRESS)) 128 129 #define SL_IS_PROVISIONING_IN_PROGRESS (!!(g_SlDeviceStatus & ( _SL_DEV_STATUS_BIT_PROVISIONING_USER_INITIATED | _SL_DEV_STATUS_BIT_PROVISIONING_ACTIVE))) 130 131 #define SL_IS_WLAN_RX_STAT_IN_PROGRESS (g_SlDeviceStatus & _SL_DRV_STATUS_BIT_RX_STAT_IN_PROGRESS) /* bit 13 indicates there is RX-statistics-start in progress */ 132 #define SL_IS_DEVICE_STAT_IN_PROGRESS (g_SlDeviceStatus & _SL_DRV_STATUS_BIT_DEVICE_STAT_IN_PROGRESS) /* bit 14 indicates there is device-statistics-start in progress */ 133 134 135 /* Check the following conditions: 136 1. Device started 137 2. Restart device is not required 138 3. Provisioning is active 139 4. Provisioning was already initiated by the user 140 5. Device is not locked 141 */ 142 #define SL_IS_COMMAND_ALLOWED ((g_SlDeviceStatus & (_SL_DRV_STATUS_BIT_DEVICE_STARTED | \ 143 _SL_DRV_STATUS_BIT_RESTART_REQUIRED | \ 144 _SL_DEV_STATUS_BIT_PROVISIONING_ACTIVE | \ 145 _SL_DEV_STATUS_BIT_PROVISIONING_USER_INITIATED | \ 146 _SL_DRV_STATUS_BIT_STOP_IN_PROGRESS | \ 147 _SL_DEV_STATUS_BIT_LOCKED)) == 0x200) 148 149 #define SL_IS_GLOBAL_LOCK_INIT (g_SlDeviceStatus & _SL_DRV_STATUS_BIT_GLOBAL_LOCK_INIT) 150 #define SL_SET_GLOBAL_LOCK_INIT (g_SlDeviceStatus |= _SL_DRV_STATUS_BIT_GLOBAL_LOCK_INIT) 151 #define SL_UNSET_GLOBAL_LOCK_INIT (g_SlDeviceStatus &= (~ _SL_DRV_STATUS_BIT_GLOBAL_LOCK_INIT)) 152 153 #define SL_SET_RESTART_REQUIRED (g_SlDeviceStatus |= _SL_DRV_STATUS_BIT_RESTART_REQUIRED) /* bit 8 indicates restart is required due to fatal error */ 154 #define SL_UNSET_RESTART_REQUIRED (g_SlDeviceStatus &= (~_SL_DRV_STATUS_BIT_RESTART_REQUIRED)) /* bit 8 indicates restart is required due to fatal error */ 155 #define SL_SET_DEVICE_STARTED (g_SlDeviceStatus |= _SL_DRV_STATUS_BIT_DEVICE_STARTED) /* bit 9 indicates device is started */ 156 #define SL_UNSET_DEVICE_STARTED (g_SlDeviceStatus &= (~_SL_DRV_STATUS_BIT_DEVICE_STARTED)) /* bit 9 indicates device is started */ 157 158 #define SL_SET_DEVICE_STOP_IN_PROGRESS (g_SlDeviceStatus |= _SL_DRV_STATUS_BIT_STOP_IN_PROGRESS) /* bit 10 indicates there is stop in progress */ 159 #define SL_UNSET_DEVICE_STOP_IN_PROGRESS (g_SlDeviceStatus &= (~_SL_DRV_STATUS_BIT_STOP_IN_PROGRESS)) /* bit 10 indicates there is stop in progress */ 160 161 /* Start in progress */ 162 #define SL_SET_DEVICE_START_IN_PROGRESS (g_SlDeviceStatus |= _SL_DRV_STATUS_BIT_START_IN_PROGRESS) /* bit 11 indicates there is start in progress */ 163 #define SL_UNSET_DEVICE_START_IN_PROGRESS (g_SlDeviceStatus &= (~_SL_DRV_STATUS_BIT_START_IN_PROGRESS)) /* bit 11 indicates there is start in progress */ 164 165 /* Statistics flags - Rx stat and device state cannot run in parallel */ 166 167 /* Rx statistics start in progress */ 168 #define SL_SET_WLAN_RX_STAT_IN_PROGRESS (g_SlDeviceStatus |= _SL_DRV_STATUS_BIT_RX_STAT_IN_PROGRESS) /* bit 13 indicates there is RX-statistics-start in progress */ 169 #define SL_UNSET_WLAN_RX_STAT_IN_PROGRESS (g_SlDeviceStatus &= (~_SL_DRV_STATUS_BIT_RX_STAT_IN_PROGRESS)) /* bit 13 indicates there is RX-statistics-start in progress */ 170 171 /* Device statistics start in progress */ 172 #define SL_SET_DEVICE_STAT_IN_PROGRESS (g_SlDeviceStatus |= _SL_DRV_STATUS_BIT_DEVICE_STAT_IN_PROGRESS) /* bit 14 indicates there is device-statistics-start in progress*/ 173 #define SL_UNSET_DEVICE_STAT_IN_PROGRESS (g_SlDeviceStatus &= (~_SL_DRV_STATUS_BIT_DEVICE_STAT_IN_PROGRESS)) /* bit 14 indicates there is device-statistics-start in progress */ 174 175 176 177 178 #define SL_SET_DEVICE_STATUS(x) (g_SlDeviceStatus = ((g_SlDeviceStatus & 0xFF00) | (_u16)x) ) /* bits 0-7 devStatus from NWP */ 179 180 #define _SL_PENDING_RX_MSG(pDriverCB) (RxIrqCnt != (pDriverCB)->RxDoneCnt) 181 182 /*****************************************************************************/ 183 /* Structure/Enum declarations */ 184 /*****************************************************************************/ 185 186 typedef struct _SlSpawnMsgItem_s 187 { 188 _SlSpawnEntryFunc_t AsyncHndlr; 189 _u8 ActionIndex; 190 void *Buffer; 191 struct _SlSpawnMsgItem_s *next; 192 } _SlSpawnMsgItem_t; 193 194 195 typedef struct 196 { 197 _u32 TSPrev; 198 _u32 TSCurr; 199 _u32 DeltaTicks; 200 _u32 DeltaTicksReminder; 201 _i32 Total10MSecUnits; 202 } _SlTimeoutParams_t; 203 204 typedef struct 205 { 206 _u8 *pAsyncMsgBuff; 207 _u8 bInCmdContext; 208 } DeviceEventInfo_t; 209 210 typedef struct 211 { 212 _SlOpcode_t Opcode; 213 _SlArgSize_t TxDescLen; 214 _SlArgSize_t RxDescLen; 215 }_SlCmdCtrl_t; 216 217 typedef struct 218 { 219 _u16 TxPayload1Len; 220 _u16 TxPayload2Len; 221 _i16 RxPayloadLen; 222 _i16 ActualRxPayloadLen; 223 _u8 *pTxPayload1; 224 _u8 *pTxPayload2; 225 _u8 *pRxPayload; 226 }_SlCmdExt_t; 227 228 typedef struct _SlArgsData_t 229 { 230 _u8 *pArgs; 231 _u8 *pData; 232 } _SlArgsData_t; 233 234 typedef struct _SlPoolObj_t 235 { 236 _SlSyncObj_t SyncObj; 237 _u8 *pRespArgs; 238 _u8 ActionID; 239 _u8 AdditionalData; /* use for socketID and one bit which indicate supprt IPV6 or not (1=support, 0 otherwise) */ 240 _u8 NextIndex; 241 } _SlPoolObj_t; 242 243 typedef enum 244 { 245 SOCKET_0, 246 SOCKET_1, 247 SOCKET_2, 248 SOCKET_3, 249 SOCKET_4, 250 SOCKET_5, 251 SOCKET_6, 252 SOCKET_7, 253 SOCKET_8, 254 SOCKET_9, 255 SOCKET_10, 256 SOCKET_11, 257 SOCKET_12, 258 SOCKET_13, 259 SOCKET_14, 260 SOCKET_15, 261 MAX_SOCKET_ENUM_IDX, 262 ACCEPT_ID = MAX_SOCKET_ENUM_IDX, 263 CONNECT_ID, 264 SELECT_ID, 265 GETHOSYBYNAME_ID, 266 GETHOSYBYSERVICE_ID, 267 PING_ID, 268 NETAPP_RECEIVE_ID, 269 START_STOP_ID, 270 NETUTIL_CMD_ID, 271 CLOSE_ID, 272 START_TLS_ID, 273 /**********/ 274 RECV_ID /* Please note!! this member must be the last in this action enum */ 275 }_SlActionID_e; 276 277 typedef struct _SlActionLookup_t 278 { 279 _u8 ActionID; 280 _u16 ActionAsyncOpcode; 281 _SlSpawnEntryFunc_t AsyncEventHandler; 282 283 } _SlActionLookup_t; 284 285 typedef struct 286 { 287 _u8 TxPoolCnt; 288 _u16 MinTxPayloadSize; 289 _SlLockObj_t TxLockObj; 290 _SlSyncObj_t TxSyncObj; 291 }_SlFlowContCB_t; 292 293 typedef enum 294 { 295 RECV_RESP_CLASS, 296 CMD_RESP_CLASS, 297 ASYNC_EVT_CLASS, 298 #if (defined(SL_PLATFORM_MULTI_THREADED) && !defined(slcb_SocketTriggerEventHandler)) 299 MULTI_SELECT_RESP_CLASS, 300 #endif 301 DUMMY_MSG_CLASS 302 }_SlRxMsgClass_e; 303 304 typedef struct 305 { 306 _u8 ActionIndex; 307 _SlSpawnEntryFunc_t AsyncEvtHandler; /* place to write pointer to AsyncEvent handler (calc-ed by Opcode) */ 308 _SlRxMsgClass_e RxMsgClass; /* type of Rx message */ 309 } AsyncExt_t; 310 311 typedef _u8 _SlSd_t; 312 313 typedef struct 314 { 315 _SlCmdCtrl_t *pCmdCtrl; 316 _u8 *pTxRxDescBuff; 317 _SlCmdExt_t *pCmdExt; 318 AsyncExt_t AsyncExt; 319 }_SlFunctionParams_t; 320 321 #if (defined(SL_PLATFORM_MULTI_THREADED) && !defined(slcb_SocketTriggerEventHandler)) 322 323 typedef struct SlSelectEntry_t 324 { 325 SlSelectAsyncResponse_t Response; 326 _u32 TimeStamp; 327 _u16 readlist; 328 _u16 writelist; 329 _i16 ObjIdx; 330 }_SlSelectEntry_t; 331 332 typedef struct _SlMultiSelectCB_t 333 { 334 _u16 readsds; 335 _u16 writesds; 336 _u16 CtrlSockFD; 337 _u8 ActiveSelect; 338 _u8 ActiveWaiters; 339 _BasicResponse_t SelectCmdResp; 340 _SlSyncObj_t SelectSyncObj; 341 _SlLockObj_t SelectLockObj; 342 _SlSelectEntry_t* SelectEntry[MAX_CONCURRENT_ACTIONS]; 343 }_SlMultiSelectCB_t; 344 345 #else 346 347 typedef enum 348 { 349 SOCK_TRIGGER_READY, 350 SOCK_TRIGGER_WAITING_FOR_RESP, 351 SOCK_TRIGGER_RESP_RECEIVED 352 } _SlSockTriggerState_e; 353 354 typedef struct 355 { 356 _SlSockTriggerState_e State; 357 _u8 ObjPoolIdx; 358 } _SlSockTriggerData_t; 359 360 typedef struct 361 { 362 _SlSockTriggerData_t Info; 363 SlSelectAsyncResponse_t Resp; 364 } _SlSockTriggerSelect_t; 365 366 #endif 367 368 typedef struct 369 { 370 _SlFd_t FD; 371 _SlCommandHeader_t TempProtocolHeader; 372 P_INIT_CALLBACK pInitCallback; 373 374 _SlPoolObj_t ObjPool[MAX_CONCURRENT_ACTIONS]; 375 _u8 FreePoolIdx; 376 _u8 PendingPoolIdx; 377 _u8 ActivePoolIdx; 378 _u32 ActiveActionsBitmap; 379 _SlLockObj_t ProtectionLockObj; 380 381 _SlSyncObj_t CmdSyncObj; 382 _u8 WaitForCmdResp; 383 _SlFlowContCB_t FlowContCB; 384 _u8 TxSeqNum; 385 _u8 RxDoneCnt; 386 _u16 SocketNonBlocking; 387 _u16 SocketTXFailure; 388 /* for stack reduction the parameters are globals */ 389 _SlFunctionParams_t FunctionParams; 390 391 _u8 ActionIndex; 392 _i8 ApiInProgressCnt; /* Counts how many APIs are in progress */ 393 394 #if (defined(SL_PLATFORM_MULTI_THREADED) && !defined(slcb_SocketTriggerEventHandler)) 395 /* Multiple Select Control block */ 396 _SlMultiSelectCB_t MultiSelectCB; 397 #endif 398 399 #if defined(slcb_SocketTriggerEventHandler) 400 /* Trigger mode control block */ 401 _SlSockTriggerSelect_t SocketTriggerSelect; 402 #endif 403 404 #ifdef SL_MEMORY_MGMT_DYNAMIC 405 _SlSpawnMsgItem_t *spawnMsgList; 406 #endif 407 _u8 NumOfDeletedSyncObj; 408 }_SlDriverCb_t; 409 410 typedef struct 411 { 412 _SlSpawnEntryFunc_t AsyncHndlr; 413 _u8 ActionIndex; 414 _u8 Buffer[SL_ASYNC_MAX_MSG_LEN]; 415 }_SlAsyncRespBuf_t; 416 417 extern _volatile _u8 RxIrqCnt; 418 419 extern _SlLockObj_t GlobalLockObj; 420 extern _u16 g_SlDeviceStatus; 421 422 extern _SlDriverCb_t* g_pCB; 423 extern P_SL_DEV_PING_CALLBACK pPingCallBackFunc; 424 425 /*****************************************************************************/ 426 /* Function prototypes */ 427 /*****************************************************************************/ 428 extern _SlReturnVal_t _SlDrvDriverCBInit(void); 429 extern _SlReturnVal_t _SlDrvDriverCBDeinit(void); 430 extern _SlReturnVal_t _SlDrvRxIrqHandler(void *pValue); 431 extern _SlReturnVal_t _SlDrvCmdOp(_SlCmdCtrl_t *pCmdCtrl , void* pTxRxDescBuff , _SlCmdExt_t* pCmdExt); 432 extern _SlReturnVal_t _SlDrvCmdSend_noLock(_SlCmdCtrl_t *pCmdCtrl , void* pTxRxDescBuff , _SlCmdExt_t* pCmdExt); 433 extern _SlReturnVal_t _SlDrvCmdSend_noWait(_SlCmdCtrl_t *pCmdCtrl , void* pTxRxDescBuff , _SlCmdExt_t* pCmdExt); 434 extern _SlReturnVal_t _SlDrvCmdSend(_SlCmdCtrl_t *pCmdCtrl , void *pTxRxDescBuff , _SlCmdExt_t *pCmdExt); 435 extern _SlReturnVal_t _SlDrvDataReadOp(_SlSd_t Sd, _SlCmdCtrl_t *pCmdCtrl , void* pTxRxDescBuff , _SlCmdExt_t* pCmdExt); 436 extern _SlReturnVal_t _SlDrvDataWriteOp(_SlSd_t Sd, _SlCmdCtrl_t *pCmdCtrl , void* pTxRxDescBuff , _SlCmdExt_t* pCmdExt); 437 extern _SlReturnVal_t _SlDeviceHandleAsync_InitComplete(void *pVoidBuf); 438 extern _SlReturnVal_t _SlSocketHandleAsync_Connect(void *pVoidBuf); 439 extern _SlReturnVal_t _SlSocketHandleAsync_Close(void *pVoidBuf); 440 extern _SlReturnVal_t _SlDrvGlobalObjUnLock(_u8 bDecrementApiInProgress); 441 extern _SlReturnVal_t _SlDrvObjGlobalLockWaitForever(_u32 Flags); 442 extern _SlReturnVal_t _SlDrvDriverIsApiAllowed(_u16 Silo); 443 extern _SlReturnVal_t _SlDrvMsgReadSpawnCtx(void *pValue); 444 extern void _SlInternalSpawnWaitForEvent(void); 445 extern void _SlDrvSetGlobalLockOwner(_u8 Owner); 446 #if (!defined (SL_PLATFORM_EXTERNAL_SPAWN)) 447 extern _u8 _SlDrvIsSpawnOwnGlobalLock(); 448 #endif 449 extern _SlReturnVal_t _SlDrvBasicCmd(_SlOpcode_t Opcode); 450 extern _SlReturnVal_t _SlSocketHandleAsync_Accept(void *pVoidBuf); 451 extern _SlReturnVal_t _SlNetAppHandleAsync_DnsGetHostByService(void *pVoidBuf); 452 extern _SlReturnVal_t _SlSocketHandleAsync_Select(void *pVoidBuf); 453 extern _SlReturnVal_t _SlSocketHandleAsync_StartTLS(void *pVoidBuf); 454 extern _SlReturnVal_t _SlDrvReleaseAllActivePendingPoolObj(); 455 456 #ifdef slcb_GetTimestamp 457 extern void _SlDrvStartMeasureTimeout(_SlTimeoutParams_t *pTimeoutInfo, _u32 TimeoutInMsec); 458 extern _u8 _SlDrvIsTimeoutExpired(_SlTimeoutParams_t *pTimeoutInfo); 459 extern void _SlDrvSleep(_u16 DurationInMsec); 460 #endif 461 462 #if defined(SL_PLATFORM_MULTI_THREADED) 463 extern void * pthread_self(void); 464 #endif 465 466 extern _SlReturnVal_t _SlNetAppHandleAsync_DnsGetHostByName(void *pVoidBuf); 467 extern _SlReturnVal_t _SlNetAppHandleAsync_DnsGetHostByAddr(void *pVoidBuf); 468 extern _SlReturnVal_t _SlNetAppHandleAsync_PingResponse(void *pVoidBuf); 469 extern _SlReturnVal_t _SlNetAppEventHandler(void* pArgs); 470 471 #if defined(slcb_NetAppHttpServerHdlr) || defined(EXT_LIB_REGISTERED_HTTP_SERVER_EVENTS) 472 extern void _SlDrvDispatchHttpServerEvents(SlNetAppHttpServerEvent_t *slHttpServerEvent, SlNetAppHttpServerResponse_t *slHttpServerResponse); 473 #endif 474 475 #if defined(slcb_NetAppRequestHdlr) || defined(EXT_LIB_REGISTERED_NETAPP_REQUEST_EVENTS) 476 extern void _SlDrvDispatchNetAppRequestEvents(SlNetAppRequest_t *slNetAppRequestEvent, SlNetAppResponse_t *slNetAppResponse); 477 #endif 478 479 extern void _SlDeviceHandleAsync_Stop(void *pVoidBuf); 480 extern void _SlNetUtilHandleAsync_Cmd(void *pVoidBuf); 481 extern _SlReturnVal_t _SlDrvWaitForPoolObj(_u8 ActionID, _u8 SocketID); 482 extern _SlReturnVal_t _SlDrvReleasePoolObj(_u8 pObj); 483 extern void _SlDrvReleaseAllPendingPoolObj(); 484 extern _SlReturnVal_t _SlDrvAlignSize(_u16 msgLen); 485 extern _SlReturnVal_t _SlDrvProtectAsyncRespSetting(_u8 *pAsyncRsp, _SlActionID_e ActionID, _u8 SocketID); 486 extern void _SlNetAppHandleAsync_NetAppReceive(void *pVoidBuf); 487 488 489 extern _SlReturnVal_t _SlDeviceEventHandler(void* pEventInfo); 490 extern _SlReturnVal_t _SlDrvSyncObjWaitForever(_SlSyncObj_t *pSyncObj); 491 extern _SlReturnVal_t _SlDrvObjLockWaitForever(_SlLockObj_t *pLockObj); 492 extern _SlReturnVal_t _SlDrvSyncObjWaitTimeout(_SlSyncObj_t *pSyncObj, 493 _u32 timeoutVal, 494 _u32 asyncEventOpcode); 495 496 extern _SlReturnVal_t _SlDrvSyncObjSignal(_SlSyncObj_t *pSyncObj); 497 extern _SlReturnVal_t _SlDrvObjLock(_SlLockObj_t *pLockObj, _SlTime_t Timeout); 498 extern _SlReturnVal_t _SlDrvProtectionObjLockWaitForever(void); 499 extern _SlReturnVal_t _SlDrvObjUnLock(_SlLockObj_t *pLockObj); 500 extern _SlReturnVal_t _SlDrvProtectionObjUnLock(void); 501 502 extern void _SlDrvMemZero(void* Addr, _u16 size); 503 extern void _SlDrvResetCmdExt(_SlCmdExt_t* pCmdExt); 504 505 extern _i8 _SlDrvIsApiInProgress(void); 506 extern void _SlDrvHandleResetRequest(const void* pIfHdl, _i8* pDevName); 507 extern _SlReturnVal_t _SlDrvWaitForInternalAsyncEvent(_u8 ObjIdx, _u32 Timeout, _SlOpcode_t Opcode); 508 extern _SlReturnVal_t _SlSpawnMsgListInsert(_u16 AsyncEventLen, _u8 *pAsyncBuf); 509 extern _SlReturnVal_t _SlSpawnMsgListProcess(void); 510 extern _u16 _SlSpawnMsgListGetCount(void); 511 extern void _SlDrvHandleFatalError(_u32 errorId, _u32 info1, _u32 info2); 512 extern void _SlDrvHandleAssert(void); 513 extern void _SlFindAndReleasePendingCmd(); 514 515 #define _SL_PROTOCOL_ALIGN_SIZE(msgLen) (((msgLen)+3) & (~3)) 516 #define _SL_IS_PROTOCOL_ALIGNED_SIZE(msgLen) (!((msgLen) & 3)) 517 518 519 #define _SL_PROTOCOL_CALC_LEN(pCmdCtrl,pCmdExt) ((pCmdExt) ? \ 520 (_SL_PROTOCOL_ALIGN_SIZE(pCmdCtrl->TxDescLen) + _SL_PROTOCOL_ALIGN_SIZE(pCmdExt->TxPayload1Len + pCmdExt->TxPayload2Len)) : \ 521 (_SL_PROTOCOL_ALIGN_SIZE(pCmdCtrl->TxDescLen))) 522 523 #ifdef __cplusplus 524 } 525 #endif /* __cplusplus */ 526 527 #endif /* __DRIVER_INT_H__ */ 528