From 5e48932850f78d3c3fc90ae73982f1ce5ba21e38 Mon Sep 17 00:00:00 2001 From: Giovanni Di Sirio Date: Tue, 3 Oct 2017 13:47:17 +0000 Subject: Objects FIFOs added to the factory. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@10754 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/common/oslib/include/chfactory.h | 54 ++++++++++++++++++++++++++++++++++--- os/common/oslib/include/chfifo.h | 8 +++--- 2 files changed, 55 insertions(+), 7 deletions(-) (limited to 'os/common/oslib/include') diff --git a/os/common/oslib/include/chfactory.h b/os/common/oslib/include/chfactory.h index acb8c79a4..43b389cc4 100644 --- a/os/common/oslib/include/chfactory.h +++ b/os/common/oslib/include/chfactory.h @@ -79,6 +79,13 @@ #define CH_CFG_FACTORY_MAILBOXES TRUE #endif +/** + * @brief Enables factory for objects FIFOs. + */ +#if !defined(CH_CFG_FACTORY_OBJ_FIFOS) || defined(__DOXYGEN__) +#define CH_CFG_FACTORY_OBJ_FIFOS TRUE +#endif + /*===========================================================================*/ /* Derived constants and error checks. */ /*===========================================================================*/ @@ -88,7 +95,8 @@ #define CH_FACTORY_REQUIRES_HEAP \ ((CH_CFG_FACTORY_GENERIC_BUFFERS == TRUE) || \ - (CH_CFG_FACTORY_MAILBOXES == TRUE)) + (CH_CFG_FACTORY_MAILBOXES == TRUE) || \ + (CH_CFG_FACTORY_OBJ_FIFOS == TRUE)) #if (CH_CFG_FACTORY_MAX_NAMES_LENGHT < 0) || \ (CH_CFG_FACTORY_MAX_NAMES_LENGHT > 32) @@ -115,6 +123,10 @@ #error "CH_CFG_FACTORY_MAILBOXES requires CH_CFG_USE_MAILBOXES" #endif +#if (CH_CFG_FACTORY_OBJ_FIFOS == TRUE) && (CH_CFG_USE_OBJ_FIFOS == FALSE) +#error "CH_CFG_FACTORY_OBJ_FIFOS requires CH_CFG_USE_OBJ_FIFOS" +#endif + /*===========================================================================*/ /* Module data structures and types. */ /*===========================================================================*/ @@ -209,13 +221,36 @@ typedef struct ch_dyn_mailbox { */ mailbox_t mbx; /** - * @brief Mailbox buffer. + * @brief Messages buffer. * @note This requires C99. */ - msg_t buffer[]; + msg_t msgbuf[]; } dyn_mailbox_t; #endif +#if (CH_CFG_FACTORY_OBJ_FIFOS == TRUE) || defined(__DOXIGEN__) +/** + * @brief Type of a dynamic buffer object. + */ +typedef struct ch_dyn_objects_fifo { + /** + * @brief List element of the dynamic buffer object. + */ + dyn_element_t element; + /** + * @brief The objects FIFO. + */ + objects_fifo_t fifo; + /** + * @brief Messages buffer. + * @note This open array is followed by another area containing the + * objects, this area is not represented in this structure. + * @note This requires C99. + */ + msg_t msgbuf[]; +} dyn_objects_fifo_t; +#endif + /** * @brief Type of the factory main object. */ @@ -250,6 +285,12 @@ typedef struct ch_objects_factory { */ dyn_list_t mbx_list; #endif /* CH_CFG_FACTORY_MAILBOXES = TRUE */ +#if (CH_CFG_FACTORY_OBJ_FIFOS == TRUE) || defined(__DOXIGEN__) + /** + * @brief List of the allocated "objects FIFO" objects. + */ + dyn_list_t fifo_list; +#endif /* CH_CFG_FACTORY_OBJ_FIFOS = TRUE */ } objects_factory_t; /*===========================================================================*/ @@ -289,6 +330,13 @@ extern "C" { dyn_mailbox_t *chFactoryFindMailbox(const char *name); void chFactoryReleaseMailbox(dyn_mailbox_t *dmp); #endif +#if (CH_CFG_FACTORY_OBJ_FIFOS == TRUE) || defined(__DOXIGEN__) + dyn_objects_fifo_t *chFactoryCreateObjectsFIFO(const char *name, + size_t objsize, + size_t objn); + dyn_objects_fifo_t *chFactoryFindObjectsFIFO(const char *name); + void chFactoryReleaseObjectsFIFO(dyn_objects_fifo_t *dofp); +#endif #ifdef __cplusplus } #endif diff --git a/os/common/oslib/include/chfifo.h b/os/common/oslib/include/chfifo.h index 537314192..9f3c0924b 100644 --- a/os/common/oslib/include/chfifo.h +++ b/os/common/oslib/include/chfifo.h @@ -44,11 +44,11 @@ #ifndef CHFIFO_H #define CHFIFO_H -#if !defined(CH_CFG_USE_FIFO) -#define CH_CFG_USE_FIFO TRUE +#if !defined(CH_CFG_USE_OBJ_FIFOS) +#define CH_CFG_USE_OBJ_FIFOS TRUE #endif -#if (CH_CFG_USE_FIFO == TRUE) || defined(__DOXYGEN__) +#if (CH_CFG_USE_OBJ_FIFOS == TRUE) || defined(__DOXYGEN__) /*===========================================================================*/ /* Module constants. */ @@ -327,7 +327,7 @@ static inline msg_t chFifoReceiveObjectTimeout(objects_fifo_t *ofp, return chMBFetchTimeout(&ofp->mbx, (msg_t *)objpp, timeout); } -#endif /* CH_CFG_USE_FIFO == TRUE */ +#endif /* CH_CFG_USE_OBJ_FIFOS == TRUE */ #endif /* CHFIFO_H */ -- cgit v1.2.3