31 #if !defined(CH_CFG_USE_FACTORY) 32 #define CH_CFG_USE_FACTORY FALSE 35 #if (CH_CFG_USE_FACTORY == TRUE) || defined(__DOXYGEN__) 50 #if !defined(CH_CFG_FACTORY_MAX_NAMES_LENGTH) || defined(__DOXYGEN__) 51 #define CH_CFG_FACTORY_MAX_NAMES_LENGTH 8 57 #if !defined(CH_CFG_FACTORY_OBJECTS_REGISTRY) || defined(__DOXYGEN__) 58 #define CH_CFG_FACTORY_OBJECTS_REGISTRY TRUE 64 #if !defined(CH_CFG_FACTORY_GENERIC_BUFFERS) || defined(__DOXYGEN__) 65 #define CH_CFG_FACTORY_GENERIC_BUFFERS TRUE 71 #if !defined(CH_CFG_FACTORY_SEMAPHORES) || defined(__DOXYGEN__) 72 #define CH_CFG_FACTORY_SEMAPHORES TRUE 78 #if !defined(CH_CFG_FACTORY_MAILBOXES) || defined(__DOXYGEN__) 79 #define CH_CFG_FACTORY_MAILBOXES TRUE 85 #if !defined(CH_CFG_FACTORY_OBJ_FIFOS) || defined(__DOXYGEN__) 86 #define CH_CFG_FACTORY_OBJ_FIFOS TRUE 93 #if (CH_CFG_FACTORY_SEMAPHORES == TRUE) && (CH_CFG_USE_SEMAPHORES == FALSE) 95 #undef CH_CFG_FACTORY_SEMAPHORES 96 #define CH_CFG_FACTORY_SEMAPHORES FALSE 100 #if (CH_CFG_FACTORY_MAILBOXES == TRUE) && (CH_CFG_USE_MAILBOXES == FALSE) 102 #undef CH_CFG_FACTORY_MAILBOXES 103 #define CH_CFG_FACTORY_MAILBOXES FALSE 107 #if (CH_CFG_FACTORY_OBJ_FIFOS == TRUE) && (CH_CFG_USE_OBJ_FIFOS == FALSE) 109 #undef CH_CFG_FACTORY_OBJ_FIFOS 110 #define CH_CFG_FACTORY_OBJ_FIFOS FALSE 114 #define CH_FACTORY_REQUIRES_POOLS \ 115 ((CH_CFG_FACTORY_OBJECTS_REGISTRY == TRUE) || \ 116 (CH_CFG_FACTORY_SEMAPHORES == TRUE)) 118 #define CH_FACTORY_REQUIRES_HEAP \ 119 ((CH_CFG_FACTORY_GENERIC_BUFFERS == TRUE) || \ 120 (CH_CFG_FACTORY_MAILBOXES == TRUE) || \ 121 (CH_CFG_FACTORY_OBJ_FIFOS == TRUE)) 123 #if (CH_CFG_FACTORY_MAX_NAMES_LENGTH < 0) || \ 124 (CH_CFG_FACTORY_MAX_NAMES_LENGTH > 32) 125 #error "invalid CH_CFG_FACTORY_MAX_NAMES_LENGTH value" 128 #if (CH_CFG_USE_MUTEXES == FALSE) && (CH_CFG_USE_SEMAPHORES == FALSE) 129 #error "CH_CFG_USE_FACTORY requires CH_CFG_USE_MUTEXES and/or CH_CFG_USE_SEMAPHORES" 132 #if CH_CFG_USE_MEMCORE == FALSE 133 #error "CH_CFG_USE_FACTORY requires CH_CFG_USE_MEMCORE" 136 #if CH_FACTORY_REQUIRES_POOLS && (CH_CFG_USE_MEMPOOLS == FALSE) 137 #error "CH_CFG_USE_MEMPOOLS is required" 140 #if CH_FACTORY_REQUIRES_HEAP && (CH_CFG_USE_HEAP == FALSE) 141 #error "CH_CFG_USE_HEAP is required" 160 #if (CH_CFG_FACTORY_MAX_NAMES_LENGTH > 0) || defined(__DOXYGEN__) 174 #if (CH_CFG_FACTORY_OBJECTS_REGISTRY == TRUE) || defined(__DOXYGEN__) 191 #if (CH_CFG_FACTORY_GENERIC_BUFFERS == TRUE) || defined(__DOXYGEN__) 210 #if (CH_CFG_FACTORY_SEMAPHORES == TRUE) || defined(__DOXYGEN__) 226 #if (CH_CFG_FACTORY_MAILBOXES == TRUE) || defined(__DOXYGEN__) 249 #if (CH_CFG_FACTORY_OBJ_FIFOS == TRUE) || defined(__DOXYGEN__) 281 #if (CH_CFG_USE_MUTEXES == TRUE) || defined(__DOXYGEN__) 294 #if (CH_CFG_FACTORY_GENERIC_BUFFERS == TRUE) || defined(__DOXYGEN__) 300 #if (CH_CFG_FACTORY_SEMAPHORES == TRUE) || defined(__DOXYGEN__) 310 #if (CH_CFG_FACTORY_MAILBOXES == TRUE) || defined(__DOXYGEN__) 316 #if (CH_CFG_FACTORY_OBJ_FIFOS == TRUE) || defined(__DOXYGEN__) 332 #if !defined(__DOXYGEN__) 340 #if (CH_CFG_FACTORY_OBJECTS_REGISTRY == TRUE) || defined(__DOXYGEN__) 347 #if (CH_CFG_FACTORY_GENERIC_BUFFERS == TRUE) || defined(__DOXYGEN__) 352 #if (CH_CFG_FACTORY_SEMAPHORES == TRUE) || defined(__DOXYGEN__) 357 #if (CH_CFG_FACTORY_MAILBOXES == TRUE) || defined(__DOXYGEN__) 362 #if (CH_CFG_FACTORY_OBJ_FIFOS == TRUE) || defined(__DOXYGEN__) 394 #if (CH_CFG_FACTORY_OBJECTS_REGISTRY == TRUE) || defined(__DOXYGEN__) 409 #if (CH_CFG_FACTORY_GENERIC_BUFFERS == TRUE) || defined(__DOXYGEN__) 437 #if (CH_CFG_FACTORY_SEMAPHORES == TRUE) || defined(__DOXYGEN__) 452 #if (CH_CFG_FACTORY_MAILBOXES == TRUE) || defined(__DOXYGEN__) 467 #if (CH_CFG_FACTORY_OBJ_FIFOS == TRUE) || defined(__DOXYGEN__)
Type of a dynamic buffer object.
static size_t chHeapGetSize(const void *p)
Returns the size of an allocated block.
struct ch_dyn_semaphore dyn_semaphore_t
Type of a dynamic semaphore.
static void * chFactoryGetObject(registered_object_t *rop)
Returns the pointer to the inner registered object.
mailbox_t mbx
The mailbox.
struct ch_objects_factory objects_factory_t
Type of the factory main object.
dyn_element_t element
List element of the dynamic buffer object.
uint8_t buffer[]
The buffer.
void _factory_init(void)
Initializes the objects factory.
static mailbox_t * chFactoryGetMailbox(dyn_mailbox_t *dmp)
Returns the pointer to the inner mailbox.
struct ch_dyn_element * next
Next dynamic object in the list.
static dyn_element_t * chFactoryDuplicateReference(dyn_element_t *dep)
Duplicates an object reference.
Type of a dynamic object list element.
void chFactoryReleaseSemaphore(dyn_semaphore_t *dsp)
Releases a dynamic semaphore object.
struct ch_dyn_object dyn_buffer_t
Type of a dynamic buffer object.
struct ch_dyn_objects_fifo dyn_objects_fifo_t
Type of a dynamic buffer object.
registered_object_t * chFactoryFindObject(const char *name)
Retrieves a registered object.
semaphore_t sem
The semaphore.
Type of a dynamic buffer object.
#define CH_CFG_FACTORY_MAX_NAMES_LENGTH
Maximum length for object names.
dyn_element_t element
List element of the dynamic semaphore.
struct ch_registered_static_object registered_object_t
Type of a registered object.
struct ch_dyn_element dyn_element_t
Type of a dynamic object list element.
dyn_mailbox_t * chFactoryCreateMailbox(const char *name, size_t n)
Creates a dynamic mailbox object.
static objects_fifo_t * chFactoryGetObjectsFIFO(dyn_objects_fifo_t *dofp)
Returns the pointer to the inner objects FIFO.
dyn_element_t element
List element of the dynamic buffer object.
struct ch_dyn_list dyn_list_t
Type of a dynamic object list.
void chFactoryReleaseObjectsFIFO(dyn_objects_fifo_t *dofp)
Releases a dynamic "objects FIFO" object.
Type of a dynamic semaphore.
dyn_mailbox_t * chFactoryFindMailbox(const char *name)
Retrieves a dynamic mailbox object.
memory_pool_t sem_pool
Pool of the available semaphores.
Type of a registered object.
static semaphore_t * chFactoryGetSemaphore(dyn_semaphore_t *dsp)
Returns the pointer to the inner semaphore.
dyn_buffer_t * chFactoryCreateBuffer(const char *name, size_t size)
Creates a generic dynamic buffer object.
registered_object_t * chFactoryRegisterObject(const char *name, void *objp)
Registers a generic object.
ucnt_t refs
Number of references to this object.
mutex_t mtx
Factory access mutex or semaphore.
dyn_list_t buf_list
List of the allocated buffer objects.
registered_object_t * chFactoryFindObjectByPointer(void *objp)
Retrieves a registered object by pointer.
dyn_list_t sem_list
List of the allocated semaphores.
dyn_semaphore_t * chFactoryCreateSemaphore(const char *name, cnt_t n)
Creates a dynamic semaphore object.
dyn_objects_fifo_t * chFactoryCreateObjectsFIFO(const char *name, size_t objsize, size_t objn, unsigned objalign)
Creates a dynamic "objects FIFO" object.
void chFactoryReleaseBuffer(dyn_buffer_t *dbp)
Releases a dynamic buffer object.
dyn_list_t obj_list
List of the registered objects.
void * objp
Pointer to the object.
dyn_semaphore_t * chFactoryFindSemaphore(const char *name)
Retrieves a dynamic semaphore object.
memory_pool_t obj_pool
Pool of the available registered objects.
static uint8_t * chFactoryGetBuffer(dyn_buffer_t *dbp)
Returns the pointer to the inner buffer.
dyn_element_t element
List element of the dynamic buffer object.
void chFactoryReleaseMailbox(dyn_mailbox_t *dmp)
Releases a dynamic mailbox object.
dyn_buffer_t * chFactoryFindBuffer(const char *name)
Retrieves a dynamic buffer object.
Type of a dynamic buffer object.
struct ch_dyn_mailbox dyn_mailbox_t
Type of a dynamic buffer object.
dyn_element_t element
List element of the registered object.
objects_fifo_t fifo
The objects FIFO.
Structure representing a mailbox object.
dyn_objects_fifo_t * chFactoryFindObjectsFIFO(const char *name)
Retrieves a dynamic "objects FIFO" object.
void chFactoryReleaseObject(registered_object_t *rop)
Releases a registered object.
objects_factory_t ch_factory
Factory object static instance.
static size_t chFactoryGetBufferSize(dyn_buffer_t *dbp)
Returns the size of a generic dynamic buffer object.
dyn_list_t fifo_list
List of the allocated "objects FIFO" objects.
Type of the factory main object.
dyn_list_t mbx_list
List of the allocated buffer objects.
Type of a dynamic object list.