Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
wolfevent.h
00001 /* wolfevent.h 00002 * 00003 * Copyright (C) 2006-2017 wolfSSL Inc. 00004 * 00005 * This file is part of wolfSSL. 00006 * 00007 * wolfSSL is free software; you can redistribute it and/or modify 00008 * it under the terms of the GNU General Public License as published by 00009 * the Free Software Foundation; either version 2 of the License, or 00010 * (at your option) any later version. 00011 * 00012 * wolfSSL is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU General Public License 00018 * along with this program; if not, write to the Free Software 00019 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA 00020 */ 00021 00022 #ifndef _WOLF_EVENT_H_ 00023 #define _WOLF_EVENT_H_ 00024 00025 #ifdef __cplusplus 00026 extern "C" { 00027 #endif 00028 00029 #ifndef SINGLE_THREADED 00030 #include <wolfcrypt/wc_port.h> 00031 #endif 00032 00033 typedef struct WOLF_EVENT WOLF_EVENT; 00034 typedef unsigned short WOLF_EVENT_FLAG; 00035 00036 typedef enum WOLF_EVENT_TYPE { 00037 WOLF_EVENT_TYPE_NONE, 00038 #ifdef WOLFSSL_ASYNC_CRYPT 00039 WOLF_EVENT_TYPE_ASYNC_WOLFSSL, /* context is WOLFSSL* */ 00040 WOLF_EVENT_TYPE_ASYNC_WOLFCRYPT, /* context is WC_ASYNC_DEV */ 00041 WOLF_EVENT_TYPE_ASYNC_FIRST = WOLF_EVENT_TYPE_ASYNC_WOLFSSL, 00042 WOLF_EVENT_TYPE_ASYNC_LAST = WOLF_EVENT_TYPE_ASYNC_WOLFCRYPT, 00043 #endif /* WOLFSSL_ASYNC_CRYPT */ 00044 } WOLF_EVENT_TYPE; 00045 00046 typedef enum WOLF_EVENT_STATE { 00047 WOLF_EVENT_STATE_READY, 00048 WOLF_EVENT_STATE_PENDING, 00049 WOLF_EVENT_STATE_DONE, 00050 } WOLF_EVENT_STATE; 00051 00052 struct WOLF_EVENT { 00053 /* double linked list */ 00054 WOLF_EVENT* next; 00055 WOLF_EVENT* prev; 00056 00057 void* context; 00058 union { 00059 void* ptr; 00060 #ifdef WOLFSSL_ASYNC_CRYPT 00061 struct WC_ASYNC_DEV* async; 00062 #endif 00063 } dev; 00064 #ifdef HAVE_CAVIUM 00065 word64 reqId; 00066 #ifdef WOLFSSL_NITROX_DEBUG 00067 word32 pendCount; 00068 #endif 00069 #endif 00070 #ifndef WC_NO_ASYNC_THREADING 00071 pthread_t threadId; 00072 #endif 00073 int ret; /* Async return code */ 00074 unsigned int flags; 00075 WOLF_EVENT_TYPE type; 00076 WOLF_EVENT_STATE state; 00077 }; 00078 00079 enum WOLF_POLL_FLAGS { 00080 WOLF_POLL_FLAG_CHECK_HW = 0x01, 00081 }; 00082 00083 typedef struct { 00084 WOLF_EVENT* head; /* head of queue */ 00085 WOLF_EVENT* tail; /* tail of queue */ 00086 #ifndef SINGLE_THREADED 00087 wolfSSL_Mutex lock; /* queue lock */ 00088 #endif 00089 int count; 00090 } WOLF_EVENT_QUEUE; 00091 00092 00093 #ifdef HAVE_WOLF_EVENT 00094 00095 /* Event */ 00096 WOLFSSL_API int wolfEvent_Init(WOLF_EVENT* event, WOLF_EVENT_TYPE type, void* context); 00097 WOLFSSL_API int wolfEvent_Poll(WOLF_EVENT* event, WOLF_EVENT_FLAG flags); 00098 00099 /* Event Queue */ 00100 WOLFSSL_API int wolfEventQueue_Init(WOLF_EVENT_QUEUE* queue); 00101 WOLFSSL_API int wolfEventQueue_Push(WOLF_EVENT_QUEUE* queue, WOLF_EVENT* event); 00102 WOLFSSL_API int wolfEventQueue_Pop(WOLF_EVENT_QUEUE* queue, WOLF_EVENT** event); 00103 WOLFSSL_API int wolfEventQueue_Poll(WOLF_EVENT_QUEUE* queue, void* context_filter, 00104 WOLF_EVENT** events, int maxEvents, WOLF_EVENT_FLAG flags, int* eventCount); 00105 WOLFSSL_API int wolfEventQueue_Count(WOLF_EVENT_QUEUE* queue); 00106 WOLFSSL_API void wolfEventQueue_Free(WOLF_EVENT_QUEUE* queue); 00107 00108 /* the queue mutex must be locked prior to calling these */ 00109 WOLFSSL_API int wolfEventQueue_Add(WOLF_EVENT_QUEUE* queue, WOLF_EVENT* event); 00110 WOLFSSL_API int wolfEventQueue_Remove(WOLF_EVENT_QUEUE* queue, WOLF_EVENT* event); 00111 00112 00113 #endif /* HAVE_WOLF_EVENT */ 00114 00115 00116 #ifdef __cplusplus 00117 } /* extern "C" */ 00118 #endif 00119 00120 #endif /* _WOLF_EVENT_H_ */ 00121
Generated on Tue Jul 12 2022 16:58:12 by
1.7.2