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.
Fork of wolfSSL by
wolfevent.h
00001 /* wolfevent.h 00002 * 00003 * Copyright (C) 2006-2016 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 <wolfssl/wolfcrypt/wc_port.h> 00031 #endif 00032 #ifdef HAVE_CAVIUM 00033 #include <wolfssl/wolfcrypt/port/cavium/cavium_nitrox.h> 00034 #endif 00035 00036 #ifndef WOLFSSL_WOLFSSL_TYPE_DEFINED 00037 #define WOLFSSL_WOLFSSL_TYPE_DEFINED 00038 typedef struct WOLFSSL WOLFSSL; 00039 #endif 00040 typedef struct WOLF_EVENT WOLF_EVENT; 00041 #ifndef WOLFSSL_WOLFSSL_CTX_TYPE_DEFINED 00042 #define WOLFSSL_WOLFSSL_CTX_TYPE_DEFINED 00043 typedef struct WOLFSSL_CTX WOLFSSL_CTX; 00044 #endif 00045 00046 typedef unsigned short WOLF_EVENT_FLAG; 00047 00048 typedef enum WOLF_EVENT_TYPE { 00049 WOLF_EVENT_TYPE_NONE, 00050 #ifdef WOLFSSL_ASYNC_CRYPT 00051 WOLF_EVENT_TYPE_ASYNC_WOLFSSL, /* context is WOLFSSL* */ 00052 WOLF_EVENT_TYPE_ASYNC_WOLFCRYPT, /* context is WC_ASYNC_DEV */ 00053 WOLF_EVENT_TYPE_ASYNC_FIRST = WOLF_EVENT_TYPE_ASYNC_WOLFSSL, 00054 WOLF_EVENT_TYPE_ASYNC_LAST = WOLF_EVENT_TYPE_ASYNC_WOLFCRYPT, 00055 #endif /* WOLFSSL_ASYNC_CRYPT */ 00056 } WOLF_EVENT_TYPE; 00057 00058 struct WOLF_EVENT { 00059 /* double linked list */ 00060 WOLF_EVENT* next; 00061 WOLF_EVENT* prev; 00062 00063 void* context; 00064 union { 00065 void* ptr; 00066 #ifdef WOLFSSL_ASYNC_CRYPT 00067 struct WC_ASYNC_DEV* async; 00068 #endif 00069 } dev; 00070 #ifdef HAVE_CAVIUM 00071 CavReqId reqId; 00072 #endif 00073 int ret; /* Async return code */ 00074 unsigned int flags; 00075 WOLF_EVENT_TYPE type; 00076 00077 /* event flags */ 00078 WOLF_EVENT_FLAG pending:1; 00079 WOLF_EVENT_FLAG done:1; 00080 /* Future event flags can go here */ 00081 }; 00082 00083 enum WOLF_POLL_FLAGS { 00084 WOLF_POLL_FLAG_CHECK_HW = 0x01, 00085 }; 00086 00087 typedef struct { 00088 WOLF_EVENT* head; /* head of queue */ 00089 WOLF_EVENT* tail; /* tail of queue */ 00090 #ifndef SINGLE_THREADED 00091 wolfSSL_Mutex lock; /* queue lock */ 00092 #endif 00093 int count; 00094 } WOLF_EVENT_QUEUE; 00095 00096 00097 #ifdef HAVE_WOLF_EVENT 00098 00099 /* Event */ 00100 WOLFSSL_API int wolfEvent_Init(WOLF_EVENT* event, WOLF_EVENT_TYPE type, void* context); 00101 WOLFSSL_API int wolfEvent_Poll(WOLF_EVENT* event, WOLF_EVENT_FLAG flags); 00102 00103 /* Event Queue */ 00104 WOLFSSL_API int wolfEventQueue_Init(WOLF_EVENT_QUEUE* queue); 00105 WOLFSSL_API int wolfEventQueue_Push(WOLF_EVENT_QUEUE* queue, WOLF_EVENT* event); 00106 WOLFSSL_API int wolfEventQueue_Pop(WOLF_EVENT_QUEUE* queue, WOLF_EVENT** event); 00107 WOLFSSL_API int wolfEventQueue_Poll(WOLF_EVENT_QUEUE* queue, void* context_filter, 00108 WOLF_EVENT** events, int maxEvents, WOLF_EVENT_FLAG flags, int* eventCount); 00109 WOLFSSL_API int wolfEventQueue_Count(WOLF_EVENT_QUEUE* queue); 00110 WOLFSSL_API void wolfEventQueue_Free(WOLF_EVENT_QUEUE* queue); 00111 00112 /* the queue mutex must be locked prior to calling these */ 00113 WOLFSSL_API int wolfEventQueue_Add(WOLF_EVENT_QUEUE* queue, WOLF_EVENT* event); 00114 WOLFSSL_API int wolfEventQueue_Remove(WOLF_EVENT_QUEUE* queue, WOLF_EVENT* event); 00115 00116 00117 #endif /* HAVE_WOLF_EVENT */ 00118 00119 00120 #ifdef __cplusplus 00121 } /* extern "C" */ 00122 #endif 00123 00124 #endif /* _WOLF_EVENT_H_ */ 00125
Generated on Tue Jul 12 2022 23:31:02 by
1.7.2
