1 /*------------------------------------------------------------------------------------------------*/
2 /* UNICENS V2.1.0-3491 */
3 /* Copyright (c) 2017 Microchip Technology Germany II GmbH & Co. KG. */
5 /* This program is free software: you can redistribute it and/or modify */
6 /* it under the terms of the GNU General Public License as published by */
7 /* the Free Software Foundation, either version 2 of the License, or */
8 /* (at your option) any later version. */
10 /* This program is distributed in the hope that it will be useful, */
11 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
12 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
13 /* GNU General Public License for more details. */
15 /* You should have received a copy of the GNU General Public License */
16 /* along with this program. If not, see <http://www.gnu.org/licenses/>. */
18 /* You may also obtain this software under a propriety license from Microchip. */
19 /* Please contact Microchip for further information. */
20 /*------------------------------------------------------------------------------------------------*/
24 * \brief Internal header file of Application Message Pools
26 * \cond UCS_INTERNAL_DOC
27 * \addtogroup G_AMSPOOL
34 /*------------------------------------------------------------------------------------------------*/
36 /*------------------------------------------------------------------------------------------------*/
37 #include "ucs_ams_pb.h"
39 #include "ucs_amsallocator.h"
46 /*------------------------------------------------------------------------------------------------*/
48 /*------------------------------------------------------------------------------------------------*/
49 /*! \brief Class members of AMS Pool */
50 typedef struct CAmsMsgPool_
52 Ams_MemAllocator_t *allocator_ptr; /*!< \brief Interface to memory allocator */
53 Ucs_AmsRx_Msg_t *rx_rsvd_msg_ptr; /*!< \brief Pre-allocated Rx message or NULL if no
54 * reserved message is available */
55 Ucs_AmsRx_Msg_t *rx_rsvd_msg_ref; /*!< \brief Stores the reference of the reserved message
56 * to identify it and restore the
57 * \c rx_rsvd_msg_ptr. */
58 CSubject tx_freed_subject; /*!< \brief Allows to observe freed Tx message event */
59 CSubject rx_freed_subject; /*!< \brief Allows to observe freed Rx message event */
60 bool tx_notify_freed; /*!< \brief Is \c true when to notify the next Tx freed object */
61 bool rx_notify_freed; /*!< \brief Is \c true when to notify the next Rx freed object */
62 bool terminated; /*!< \brief Is \c true if a cleanup was done. Helps to release the
63 * pre-allocated message after the first cleanup attempt. */
64 void *ucs_user_ptr; /*!< \brief User reference that needs to be passed in every callback function */
68 /*------------------------------------------------------------------------------------------------*/
70 /*------------------------------------------------------------------------------------------------*/
71 extern void Amsp_Ctor(CAmsMsgPool *self, Ams_MemAllocator_t *mem_allocator_ptr, void *ucs_user_ptr);
72 extern void Amsp_Cleanup(CAmsMsgPool *self);
74 extern void Amsp_AssignTxFreedObs(CAmsMsgPool *self, CObserver *observer_ptr);
75 extern Ucs_AmsTx_Msg_t* Amsp_AllocTxObj(CAmsMsgPool *self, uint16_t payload_sz);
77 extern void Amsp_AssignRxFreedObs(CAmsMsgPool *self, CObserver *observer_ptr);
78 extern Ucs_AmsRx_Msg_t* Amsp_AllocRxObj(CAmsMsgPool *self, uint16_t payload_sz);
79 extern Ucs_AmsRx_Msg_t* Amsp_AllocRxRsvd(CAmsMsgPool *self);
80 extern bool Amsp_AllocRxPayload(CAmsMsgPool *self, uint16_t payload_sz, Ucs_AmsRx_Msg_t* msg_ptr);
81 extern void Amsp_FreeRxObj(CAmsMsgPool *self, Ucs_AmsRx_Msg_t* msg_ptr);
82 extern void Amsp_FreeRxPayload(CAmsMsgPool *self, Ucs_AmsRx_Msg_t* msg_ptr);
88 #endif /* UCS_AMSPOOL_H */
95 /*------------------------------------------------------------------------------------------------*/
97 /*------------------------------------------------------------------------------------------------*/