31 #if (CH_CFG_USE_FACTORY == TRUE) || defined(__DOXYGEN__) 46 #if !defined(CH_CFG_FACTORY_MAX_NAMES_LENGTH) || defined(__DOXYGEN__) 47 #define CH_CFG_FACTORY_MAX_NAMES_LENGTH 8 53 #if !defined(CH_CFG_FACTORY_OBJECTS_REGISTRY) || defined(__DOXYGEN__) 54 #define CH_CFG_FACTORY_OBJECTS_REGISTRY TRUE 60 #if !defined(CH_CFG_FACTORY_GENERIC_BUFFERS) || defined(__DOXYGEN__) 61 #define CH_CFG_FACTORY_GENERIC_BUFFERS TRUE 67 #if !defined(CH_CFG_FACTORY_SEMAPHORES) || defined(__DOXYGEN__) 68 #define CH_CFG_FACTORY_SEMAPHORES TRUE 74 #if !defined(CH_CFG_FACTORY_MAILBOXES) || defined(__DOXYGEN__) 75 #define CH_CFG_FACTORY_MAILBOXES TRUE 81 #if !defined(CH_CFG_FACTORY_OBJ_FIFOS) || defined(__DOXYGEN__) 82 #define CH_CFG_FACTORY_OBJ_FIFOS TRUE 88 #if !defined(CH_CFG_FACTORY_OBJ_FIFOS) || defined(__DOXYGEN__) 89 #define CH_CFG_FACTORY_OBJ_FIFOS TRUE 95 #if !defined(CH_CFG_FACTORY_PIPES) || defined(__DOXYGEN__) 96 #define CH_CFG_FACTORY_PIPES TRUE 103 #if (CH_CFG_FACTORY_SEMAPHORES == TRUE) && (CH_CFG_USE_SEMAPHORES == FALSE) 105 #undef CH_CFG_FACTORY_SEMAPHORES 106 #define CH_CFG_FACTORY_SEMAPHORES FALSE 110 #if (CH_CFG_FACTORY_MAILBOXES == TRUE) && (CH_CFG_USE_MAILBOXES == FALSE) 112 #undef CH_CFG_FACTORY_MAILBOXES 113 #define CH_CFG_FACTORY_MAILBOXES FALSE 117 #if (CH_CFG_FACTORY_OBJ_FIFOS == TRUE) && (CH_CFG_USE_OBJ_FIFOS == FALSE) 119 #undef CH_CFG_FACTORY_OBJ_FIFOS 120 #define CH_CFG_FACTORY_OBJ_FIFOS FALSE 124 #if (CH_CFG_FACTORY_PIPES == TRUE) && (CH_CFG_USE_PIPES == FALSE) 126 #undef CH_CFG_FACTORY_PIPES 127 #define CH_CFG_FACTORY_PIPES FALSE 131 #define CH_FACTORY_REQUIRES_POOLS \ 132 ((CH_CFG_FACTORY_OBJECTS_REGISTRY == TRUE) || \ 133 (CH_CFG_FACTORY_SEMAPHORES == TRUE)) 135 #define CH_FACTORY_REQUIRES_HEAP \ 136 ((CH_CFG_FACTORY_GENERIC_BUFFERS == TRUE) || \ 137 (CH_CFG_FACTORY_MAILBOXES == TRUE) || \ 138 (CH_CFG_FACTORY_OBJ_FIFOS == TRUE) || \ 139 (CH_CFG_FACTORY_PIPES == TRUE)) 141 #if (CH_CFG_FACTORY_MAX_NAMES_LENGTH < 0) || \ 142 (CH_CFG_FACTORY_MAX_NAMES_LENGTH > 32) 143 #error "invalid CH_CFG_FACTORY_MAX_NAMES_LENGTH value" 146 #if (CH_CFG_USE_MUTEXES == FALSE) && (CH_CFG_USE_SEMAPHORES == FALSE) 147 #error "CH_CFG_USE_FACTORY requires CH_CFG_USE_MUTEXES and/or CH_CFG_USE_SEMAPHORES" 150 #if CH_CFG_USE_MEMCORE == FALSE 151 #error "CH_CFG_USE_FACTORY requires CH_CFG_USE_MEMCORE" 154 #if CH_FACTORY_REQUIRES_POOLS && (CH_CFG_USE_MEMPOOLS == FALSE) 155 #error "CH_CFG_USE_MEMPOOLS is required" 158 #if CH_FACTORY_REQUIRES_HEAP && (CH_CFG_USE_HEAP == FALSE) 159 #error "CH_CFG_USE_HEAP is required" 178 #if (CH_CFG_FACTORY_MAX_NAMES_LENGTH > 0) || defined(__DOXYGEN__) 192 #if (CH_CFG_FACTORY_OBJECTS_REGISTRY == TRUE) || defined(__DOXYGEN__) 209 #if (CH_CFG_FACTORY_GENERIC_BUFFERS == TRUE) || defined(__DOXYGEN__) 228 #if (CH_CFG_FACTORY_SEMAPHORES == TRUE) || defined(__DOXYGEN__) 244 #if (CH_CFG_FACTORY_MAILBOXES == TRUE) || defined(__DOXYGEN__) 267 #if (CH_CFG_FACTORY_OBJ_FIFOS == TRUE) || defined(__DOXYGEN__) 292 #if (CH_CFG_FACTORY_PIPES == TRUE) || defined(__DOXYGEN__) 322 #if (CH_CFG_USE_MUTEXES == TRUE) || defined(__DOXYGEN__) 335 #if (CH_CFG_FACTORY_GENERIC_BUFFERS == TRUE) || defined(__DOXYGEN__) 341 #if (CH_CFG_FACTORY_SEMAPHORES == TRUE) || defined(__DOXYGEN__) 351 #if (CH_CFG_FACTORY_MAILBOXES == TRUE) || defined(__DOXYGEN__) 357 #if (CH_CFG_FACTORY_OBJ_FIFOS == TRUE) || defined(__DOXYGEN__) 363 #if (CH_CFG_FACTORY_PIPES == TRUE) || defined(__DOXYGEN__) 379 #if !defined(__DOXYGEN__) 387 #if (CH_CFG_FACTORY_OBJECTS_REGISTRY == TRUE) || defined(__DOXYGEN__) 394 #if (CH_CFG_FACTORY_GENERIC_BUFFERS == TRUE) || defined(__DOXYGEN__) 399 #if (CH_CFG_FACTORY_SEMAPHORES == TRUE) || defined(__DOXYGEN__) 404 #if (CH_CFG_FACTORY_MAILBOXES == TRUE) || defined(__DOXYGEN__) 409 #if (CH_CFG_FACTORY_OBJ_FIFOS == TRUE) || defined(__DOXYGEN__) 417 #if (CH_CFG_FACTORY_PIPES == TRUE) || defined(__DOXYGEN__) 446 #if (CH_CFG_FACTORY_OBJECTS_REGISTRY == TRUE) || defined(__DOXYGEN__) 461 #if (CH_CFG_FACTORY_GENERIC_BUFFERS == TRUE) || defined(__DOXYGEN__) 489 #if (CH_CFG_FACTORY_SEMAPHORES == TRUE) || defined(__DOXYGEN__) 504 #if (CH_CFG_FACTORY_MAILBOXES == TRUE) || defined(__DOXYGEN__) 519 #if (CH_CFG_FACTORY_OBJ_FIFOS == TRUE) || defined(__DOXYGEN__) 534 #if (CH_CFG_FACTORY_PIPES == TRUE) || defined(__DOXYGEN__)
Type of a dynamic buffer object.
dyn_pipe_t * chFactoryFindPipe(const char *name)
Retrieves a dynamic pipe object.
struct ch_registered_static_object registered_object_t
Type of a registered object.
void chFactoryReleaseObjectsFIFO(dyn_objects_fifo_t *dofp)
Releases a dynamic "objects FIFO" object.
void chFactoryReleaseObject(registered_object_t *rop)
Releases a registered object.
dyn_element_t element
List element of the dynamic pipe object.
mailbox_t mbx
The mailbox.
dyn_element_t element
List element of the dynamic buffer object.
static uint8_t * chFactoryGetBuffer(dyn_buffer_t *dbp)
Returns the pointer to the inner buffer.
uint8_t buffer[]
The buffer.
dyn_mailbox_t * chFactoryFindMailbox(const char *name)
Retrieves a dynamic mailbox object.
dyn_objects_fifo_t * chFactoryCreateObjectsFIFO(const char *name, size_t objsize, size_t objn, unsigned objalign)
Creates a dynamic "objects FIFO" object.
struct ch_dyn_element * next
Next dynamic object in the list.
registered_object_t * chFactoryRegisterObject(const char *name, void *objp)
Registers a generic object.
Type of a dynamic object list element.
struct ch_dyn_mailbox dyn_mailbox_t
Type of a dynamic buffer object.
static semaphore_t * chFactoryGetSemaphore(dyn_semaphore_t *dsp)
Returns the pointer to the inner semaphore.
static size_t chHeapGetSize(const void *p)
Returns the size of an allocated block.
struct ch_objects_factory objects_factory_t
Type of the factory main object.
semaphore_t sem
The semaphore.
Structure representing a pipe object.
dyn_objects_fifo_t * chFactoryFindObjectsFIFO(const char *name)
Retrieves a dynamic "objects FIFO" object.
void chFactoryReleaseMailbox(dyn_mailbox_t *dmp)
Releases a dynamic mailbox object.
void chFactoryReleasePipe(dyn_pipe_t *dpp)
Releases a dynamic pipe object.
Type of a dynamic buffer object.
void chFactoryReleaseSemaphore(dyn_semaphore_t *dsp)
Releases a dynamic semaphore object.
dyn_element_t element
List element of the dynamic semaphore.
static void * chFactoryGetObject(registered_object_t *rop)
Returns the pointer to the inner registered object.
static dyn_element_t * chFactoryDuplicateReference(dyn_element_t *dep)
Duplicates an object reference.
struct ch_dyn_semaphore dyn_semaphore_t
Type of a dynamic semaphore.
dyn_element_t element
List element of the dynamic buffer object.
Type of a dynamic semaphore.
static size_t chFactoryGetBufferSize(dyn_buffer_t *dbp)
Returns the size of a generic dynamic buffer object.
memory_pool_t sem_pool
Pool of the available semaphores.
Type of a registered object.
dyn_buffer_t * chFactoryFindBuffer(const char *name)
Retrieves a dynamic buffer object.
void chFactoryReleaseBuffer(dyn_buffer_t *dbp)
Releases a dynamic buffer object.
struct ch_dyn_element dyn_element_t
Type of a dynamic object list element.
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.
Type of a dynamic pipe object.
dyn_list_t sem_list
List of the allocated semaphores.
struct ch_dyn_object dyn_buffer_t
Type of a dynamic buffer object.
dyn_buffer_t * chFactoryCreateBuffer(const char *name, size_t size)
Creates a generic dynamic buffer object.
dyn_mailbox_t * chFactoryCreateMailbox(const char *name, size_t n)
Creates a dynamic mailbox object.
objects_factory_t ch_factory
Factory object static instance.
dyn_list_t obj_list
List of the registered objects.
void * objp
Pointer to the object.
registered_object_t * chFactoryFindObject(const char *name)
Retrieves a registered object.
dyn_list_t pipe_list
List of the allocated pipe objects.
memory_pool_t obj_pool
Pool of the available registered objects.
dyn_element_t element
List element of the dynamic buffer object.
struct ch_dyn_list dyn_list_t
Type of a dynamic object list.
struct ch_dyn_pipe dyn_pipe_t
Type of a dynamic pipe object.
dyn_semaphore_t * chFactoryCreateSemaphore(const char *name, cnt_t n)
Creates a dynamic semaphore object.
Type of a dynamic buffer object.
void _factory_init(void)
Initializes the objects factory.
dyn_element_t element
List element of the registered object.
objects_fifo_t fifo
The objects FIFO.
Structure representing a mailbox object.
static objects_fifo_t * chFactoryGetObjectsFIFO(dyn_objects_fifo_t *dofp)
Returns the pointer to the inner objects FIFO.
dyn_semaphore_t * chFactoryFindSemaphore(const char *name)
Retrieves a dynamic semaphore object.
static pipe_t * chFactoryGetPipe(dyn_pipe_t *dpp)
Returns the pointer to the inner pipe.
dyn_list_t fifo_list
List of the allocated "objects FIFO" objects.
struct ch_dyn_objects_fifo dyn_objects_fifo_t
Type of a dynamic buffer object.
Type of the factory main object.
dyn_list_t mbx_list
List of the allocated buffer objects.
dyn_pipe_t * chFactoryCreatePipe(const char *name, size_t size)
Creates a dynamic pipe object.
static mailbox_t * chFactoryGetMailbox(dyn_mailbox_t *dmp)
Returns the pointer to the inner mailbox.
Type of a dynamic object list.
#define CH_CFG_FACTORY_MAX_NAMES_LENGTH
Maximum length for object names.