1 /* 2 * Copyright 2017-2018,2021 NXP 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef PHOSAL_QUEUE_H_ 18 #define PHOSAL_QUEUE_H_ 19 20 #include "phOsal_Posix.h" 21 22 #ifdef __cplusplus 23 extern "C" { /* Assume C declarations for C++ */ 24 #endif /* __cplusplus */ 25 26 typedef enum phOsal_eQueueOverwriteMode { 27 PHOSAL_QUEUE_NO_OVERWRITE, 28 PHOSAL_QUEUE_OVERWRITE_OLDEST, 29 PHOSAL_QUEUE_OVERWRITE_NEWEST 30 } phOsal_eQueueOverwriteMode_t; 31 32 typedef struct phOsal_QueueCreateParams_tag { 33 void* memHdl; 34 void* (*MemAllocCb)(void* memHdl, uint32_t Size); 35 int (*MemFreeCb)(void* memHdl, void* ptrToMem); 36 uint32_t wQLength; 37 phOsal_eQueueOverwriteMode_t eOverwriteMode; 38 39 } phOsal_QueueCreateParams_t; 40 41 /** 42 * \ingroup grp_osal_lib 43 * \brief creates queue 44 * 45 * This function creates resources for handling queue 46 * \param[out] pvQueueHandle Queue Handle to be filled 47 * \param[in] psQueueCreatePrms structure contatinng params to create 48 * linkedlist \retval #OSALSTATUS_SUCCESS OSAL LIB Queue created successfully 49 * \retval #OSALSTATUS_FAILED OSAL LIB failed to create queue 50 * 51 */ 52 extern OSALSTATUS phOsal_QueueCreate( 53 void** pvQueueHandle, phOsal_QueueCreateParams_t* psQueueCreatePrms); 54 /** 55 * \ingroup grp_osal_lib 56 * \brief Destroys queue 57 * 58 * This function destroys resources used for handling queue 59 * \param[out] pvQueueHandle Queue Handle to be filled 60 * \retval #OSALSTATUS_SUCCESS OSAL LIB Queue created successfully 61 * \retval #OSALSTATUS_FAILED OSAL LIB failed to create queue 62 * 63 */ 64 extern OSALSTATUS phOsal_QueueDestroy(void* pvQueueHandle); 65 66 /** 67 * \ingroup grp_osal_lib 68 * \brief Inserts object into queue 69 * 70 * This function inserts objects into queue 71 72 * \param[in] pvQueueHandle Queue Handle to be filled 73 * \param[out] pvQueueObj Queue object ot be inserted 74 * \retval #OSALSTATUS_SUCCESS OSAL LIB Queue created successfully 75 * \retval #OSALSTATUS_FAILED OSAL LIB failed to create queue 76 * 77 */ 78 extern OSALSTATUS phOsal_QueuePush(void* pvQueueHandle, void* pvQueueObj, 79 uint32_t u4_time_out_ms); 80 81 /** 82 * \ingroup grp_osal_lib 83 * \brief retrieve objects from queue 84 * 85 * This function retrieves objects from queue 86 * \param[in] pvQueueHandle Queue Handle to be filled 87 * \param[out] ppvQueueObj Queue object pulled 88 * \param[in] u4_time_out_ms time to wait until an object is found in queue 89 * \retval #OSALSTATUS_SUCCESS OSAL LIB Queue Pulled successfully 90 * \retval #OSALSTATUS_FAILED OSAL LIB failed to Pull object from queue 91 * \retval #OSALSTATUS_Q_UNDERFLOW No objects in Q even after timeout 92 */ 93 extern OSALSTATUS phOsal_QueuePull(void* pvQueueHandle, void** ppvQueueObj, 94 uint32_t u4_time_out_ms); 95 96 /** 97 * \ingroup grp_osal_lib 98 * \brief retrieve objects from queue 99 * 100 * This function retrieves objects from queue 101 * \param[in] pvQueueHandle Queue Handle to be filled 102 * \retval #OSALSTATUS_SUCCESS OSAL LIB Queue created successfully 103 * \retval #OSALSTATUS_FAILED OSAL LIB failed to create queue 104 * 105 */ 106 extern OSALSTATUS phOsal_QueueFlush(void* pvQueueHandle); 107 108 #ifdef __cplusplus 109 } /* Assume C declarations for C++ */ 110 #endif /* __cplusplus */ 111 112 #endif /* __PH_OSAL_QUEUE_H__ */ 113