Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add functions to get the buffers of statically created objects #641

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .github/lexicon.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1464,13 +1464,24 @@ ppdc
ppio
ppitc
ppmc
ppucmessagebufferstoragearea
ppucqueuestorage
ppucstreambufferstoragearea
ppudr
ppuer
ppusr
ppuxstackbuffer
ppvdestination
ppwm
ppxeventgroupbuffer
ppxidletaskstackbuffer
ppxidletasktcbbuffer
ppxsemaphorebuffer
ppxstaticmessagebuffer
ppxstaticqueue
ppxstaticstreambuffer
ppxtaskbuffer
ppxtimerbuffer
ppxtimertaskstackbuffer
ppxtimertasktcbbuffer
pr
Expand Down Expand Up @@ -2723,6 +2734,7 @@ xeventgroupcreatestatic
xeventgroupdelete
xeventgroupgetbits
xeventgroupgetbitsfromisr
xeventgroupgetstaticbuffer
xeventgroupsetbits
xeventgroupsetbitsfromisr
xeventgroupsync
Expand Down Expand Up @@ -2796,6 +2808,7 @@ xmessage
xmessagebuffer
xmessagebuffercreate
xmessagebuffercreatestatic
xmessagebuffergetstaticbuffers
xmessagebufferisempty
xmessagebufferisfull
xmessagebuffernextlengthbytes
Expand Down Expand Up @@ -2865,6 +2878,7 @@ xqueuecreatestatic
xqueuegenericsend
xqueuegenericsendfromisr
xqueuegetmutexholder
xqueuegetstaticbuffers
xqueuegivefromisr
xqueuegivemutexrecursive
xqueueorsemaphore
Expand Down Expand Up @@ -2919,6 +2933,7 @@ xsemaphorecreaterecursivemutex
xsemaphorecreaterecursivemutexstatic
xsemaphoregetmutexholder
xsemaphoregetmutexholderfromisr
xsemaphoregetstaticbuffer
xsemaphoregive
xsemaphoregivefromisr
xsemaphoregivemutexrecursive
Expand All @@ -2943,6 +2958,7 @@ xstreambuffer
xstreambufferbytesavailable
xstreambuffercreate
xstreambuffercreatestatic
xstreambuffergetstaticbuffers
xstreambufferisempty
xstreambufferisfull
xstreambuffernextmessagelengthbytes
Expand Down Expand Up @@ -2981,6 +2997,7 @@ xtaskgetcurrenttaskhandle
xtaskgethandle
xtaskgetidletaskhandle
xtaskgetschedulerstate
xtaskgetstaticbuffers
xtaskgettickcount
xtaskgettickcountfromisr
xtaskhandle
Expand Down Expand Up @@ -3048,6 +3065,7 @@ xtimerdelete
xtimergetexpirytime
xtimergetperiod
xtimergetreloadmode
xtimergetstaticbuffer
xtimergettimerdaemontaskhandle
xtimeristimeractive
xtimerlistitem
Expand Down Expand Up @@ -3081,3 +3099,4 @@ xwritevalue
xxr
xyieldpending
xzr

36 changes: 36 additions & 0 deletions event_groups.c
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,42 @@ void vEventGroupDelete( EventGroupHandle_t xEventGroup )
}
/*-----------------------------------------------------------*/

#if ( configSUPPORT_STATIC_ALLOCATION == 1 )
BaseType_t xEventGroupGetStaticBuffer( EventGroupHandle_t xEventGroup,
StaticEventGroup_t ** ppxEventGroupBuffer )
{
BaseType_t xReturn;
EventGroup_t * pxEventBits = xEventGroup;

configASSERT( pxEventBits );
configASSERT( ppxEventGroupBuffer );

#if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
{
/* Check if the event group was statically allocated. */
if( pxEventBits->ucStaticallyAllocated == ( uint8_t ) pdTRUE )
{
*ppxEventGroupBuffer = ( StaticEventGroup_t * ) pxEventBits;
xReturn = pdTRUE;
}
else
{
xReturn = pdFALSE;
}
}
#else /* configSUPPORT_DYNAMIC_ALLOCATION */
{
/* Event group must have been statically allocated. */
*ppxEventGroupBuffer = ( StaticEventGroup_t * ) pxEventBits;
xReturn = pdTRUE;
}
#endif /* configSUPPORT_DYNAMIC_ALLOCATION */

return xReturn;
}
#endif /* configSUPPORT_STATIC_ALLOCATION */
/*-----------------------------------------------------------*/

/* For internal use only - execute a 'set bits' command that was pended from
* an interrupt. */
void vEventGroupSetBitsCallback( void * pvEventGroup,
Expand Down
22 changes: 22 additions & 0 deletions include/event_groups.h
Original file line number Diff line number Diff line change
Expand Up @@ -763,6 +763,28 @@ EventBits_t xEventGroupGetBitsFromISR( EventGroupHandle_t xEventGroup ) PRIVILEG
*/
void vEventGroupDelete( EventGroupHandle_t xEventGroup ) PRIVILEGED_FUNCTION;

/**
* event_groups.h
* @code{c}
* BaseType_t xEventGroupGetStaticBuffer( EventGroupHandle_t xEventGroup,
* StaticEventGroup_t ** ppxEventGroupBuffer );
* @endcode
*
* Retrieve a pointer to a statically created event groups's data structure
* buffer. It is the same buffer that is supplied at the time of creation.
*
* @param xEventGroup The event group for which to retrieve the buffer.
*
* @param ppxEventGroupBuffer Used to return a pointer to the event groups's
* data structure buffer.
*
* @return pdTRUE if the buffer was retrieved, pdFALSE otherwise.
*/
#if ( configSUPPORT_STATIC_ALLOCATION == 1 )
BaseType_t xEventGroupGetStaticBuffer( EventGroupHandle_t xEventGroup,
StaticEventGroup_t ** ppxEventGroupBuffer ) PRIVILEGED_FUNCTION;
#endif /* configSUPPORT_STATIC_ALLOCATION */

/* For internal use only. */
void vEventGroupSetBitsCallback( void * pvEventGroup,
const uint32_t ulBitsToSet ) PRIVILEGED_FUNCTION;
Expand Down
31 changes: 31 additions & 0 deletions include/message_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,37 @@ typedef StreamBufferHandle_t MessageBufferHandle_t;
xStreamBufferGenericCreateStatic( ( xBufferSizeBytes ), 0, pdTRUE, ( pucMessageBufferStorageArea ), ( pxStaticMessageBuffer ), ( pxSendCompletedCallback ), ( pxReceiveCompletedCallback ) )
#endif

/**
* message_buffer.h
*
* @code{c}
* BaseType_t xMessageBufferGetStaticBuffers( MessageBufferHandle_t xMessageBuffer,
* uint8_t ** ppucMessageBufferStorageArea,
* StaticMessageBuffer_t ** ppxStaticMessageBuffer );
* @endcode
*
* Retrieve pointers to a statically created message buffer's data structure
* buffer and storage area buffer. These are the same buffers that are supplied
* at the time of creation.
*
* @param xMessageBuffer The message buffer for which to retrieve the buffers.
*
* @param ppucMessageBufferStorageArea Used to return a pointer to the
* message buffer's storage area buffer.
*
* @param ppxStaticMessageBuffer Used to return a pointer to the message
* buffer's data structure buffer.
*
* @return pdTRUE if buffers were retrieved, pdFALSE otherwise..
*
* \defgroup xMessageBufferGetStaticBuffers xMessageBufferGetStaticBuffers
* \ingroup MessageBufferManagement
*/
#if ( configSUPPORT_STATIC_ALLOCATION == 1 )
#define xMessageBufferGetStaticBuffers( xMessageBuffer, ppucMessageBufferStorageArea, ppxStaticMessageBuffer ) \
xStreamBufferGetStaticBuffers( ( xMessageBuffer ), ( ppucMessageBufferStorageArea ), ( ppxStaticMessageBuffer ) )
#endif /* configSUPPORT_STATIC_ALLOCATION */

/**
* message_buffer.h
*
Expand Down
41 changes: 41 additions & 0 deletions include/queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,35 @@ typedef struct QueueDefinition * QueueSetMemberHandle_t;
#define xQueueCreateStatic( uxQueueLength, uxItemSize, pucQueueStorage, pxQueueBuffer ) xQueueGenericCreateStatic( ( uxQueueLength ), ( uxItemSize ), ( pucQueueStorage ), ( pxQueueBuffer ), ( queueQUEUE_TYPE_BASE ) )
#endif /* configSUPPORT_STATIC_ALLOCATION */

/**
* queue. h
* @code{c}
* BaseType_t xQueueGetStaticBuffers( QueueHandle_t xQueue,
* uint8_t ** ppucQueueStorage,
* StaticQueue_t ** ppxStaticQueue );
* @endcode
*
* Retrieve pointers to a statically created queue's data structure buffer
* and storage area buffer. These are the same buffers that are supplied
* at the time of creation.
*
* @param xQueue The queue for which to retrieve the buffers.
*
* @param ppucQueueStorage Used to return a pointer to the queue's storage
* area buffer.
*
* @param ppxStaticQueue Used to return a pointer to the queue's data
* structure buffer.
*
* @return pdTRUE if buffers were retrieved, pdFALSE otherwise.
*
* \defgroup xQueueGetStaticBuffers xQueueGetStaticBuffers
* \ingroup QueueManagement
*/
#if ( configSUPPORT_STATIC_ALLOCATION == 1 )
#define xQueueGetStaticBuffers( xQueue, ppucQueueStorage, ppxStaticQueue ) xQueueGenericGetStaticBuffers( ( xQueue ), ( ppucQueueStorage ), ( ppxStaticQueue ) )
#endif /* configSUPPORT_STATIC_ALLOCATION */

/**
* queue. h
* @code{c}
Expand Down Expand Up @@ -1542,6 +1571,18 @@ BaseType_t xQueueGiveMutexRecursive( QueueHandle_t xMutex ) PRIVILEGED_FUNCTION;
const uint8_t ucQueueType ) PRIVILEGED_FUNCTION;
#endif

/*
* Generic version of the function used to retrieve the buffers of statically
* created queues. This is called by other functions and macros that retrieve
* the buffers of other statically created RTOS objects that use the queue
* structure as their base.
*/
#if ( configSUPPORT_STATIC_ALLOCATION == 1 )
BaseType_t xQueueGenericGetStaticBuffers( QueueHandle_t xQueue,
uint8_t ** ppucQueueStorage,
StaticQueue_t ** ppxStaticQueue ) PRIVILEGED_FUNCTION;
#endif

/*
* Queue sets provide a mechanism to allow a task to block (pend) on a read
* operation from multiple queues or semaphores simultaneously.
Expand Down
21 changes: 21 additions & 0 deletions include/semphr.h
Original file line number Diff line number Diff line change
Expand Up @@ -1190,4 +1190,25 @@ typedef QueueHandle_t SemaphoreHandle_t;
*/
#define uxSemaphoreGetCountFromISR( xSemaphore ) uxQueueMessagesWaitingFromISR( ( QueueHandle_t ) ( xSemaphore ) )

/**
* semphr.h
* @code{c}
* BaseType_t xSemaphoreGetStaticBuffer( SemaphoreHandle_t xSemaphore );
* @endcode
*
* Retrieve pointer to a statically created binary semaphore, counting semaphore,
* or mutex semaphore's data structure buffer. This is the same buffer that is
* supplied at the time of creation.
*
* @param xSemaphore The semaphore for which to retrieve the buffer.
*
* @param ppxSemaphoreBuffer Used to return a pointer to the semaphore's
* data structure buffer.
*
* @return pdTRUE if buffer was retrieved, pdFALSE otherwise.
*/
#if ( configSUPPORT_STATIC_ALLOCATION == 1 )
#define xSemaphoreGetStaticBuffer( xSemaphore, ppxSemaphoreBuffer ) xQueueGenericGetStaticBuffers( ( QueueHandle_t ) ( xSemaphore ), NULL, ( ppxSemaphoreBuffer ) )
#endif /* configSUPPORT_STATIC_ALLOCATION */

#endif /* SEMAPHORE_H */
32 changes: 32 additions & 0 deletions include/stream_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,38 @@ typedef void (* StreamBufferCallbackFunction_t)( StreamBufferHandle_t xStreamBuf
xStreamBufferGenericCreateStatic( ( xBufferSizeBytes ), ( xTriggerLevelBytes ), pdFALSE, ( pucStreamBufferStorageArea ), ( pxStaticStreamBuffer ), ( pxSendCompletedCallback ), ( pxReceiveCompletedCallback ) )
#endif

/**
* stream_buffer.h
*
* @code{c}
* BaseType_t xStreamBufferGetStaticBuffers( StreamBufferHandle_t xStreamBuffer,
* uint8_t ** ppucStreamBufferStorageArea,
* StaticStreamBuffer_t ** ppxStaticStreamBuffer );
* @endcode
*
* Retrieve pointers to a statically created stream buffer's data structure
* buffer and storage area buffer. These are the same buffers that are supplied
* at the time of creation.
*
* @param xStreamBuffer The stream buffer for which to retrieve the buffers.
*
* @param ppucStreamBufferStorageArea Used to return a pointer to the stream
* buffer's storage area buffer.
*
* @param ppxStaticStreamBuffer Used to return a pointer to the stream
* buffer's data structure buffer.
*
* @return pdTRUE if buffers were retrieved, pdFALSE otherwise.
*
* \defgroup xStreamBufferGetStaticBuffers xStreamBufferGetStaticBuffers
* \ingroup StreamBufferManagement
*/
#if ( configSUPPORT_STATIC_ALLOCATION == 1 )
BaseType_t xStreamBufferGetStaticBuffers( StreamBufferHandle_t xStreamBuffer,
uint8_t ** ppucStreamBufferStorageArea,
StaticStreamBuffer_t ** ppxStaticStreamBuffer ) PRIVILEGED_FUNCTION;
#endif /* configSUPPORT_STATIC_ALLOCATION */

/**
* stream_buffer.h
*
Expand Down
30 changes: 30 additions & 0 deletions include/task.h
Original file line number Diff line number Diff line change
Expand Up @@ -1509,6 +1509,36 @@ char * pcTaskGetName( TaskHandle_t xTaskToQuery ) PRIVILEGED_FUNCTION; /*lint !e
*/
TaskHandle_t xTaskGetHandle( const char * pcNameToQuery ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */

/**
* task. h
* @code{c}
* BaseType_t xTaskGetStaticBuffers( TaskHandle_t xTask,
* StackType_t ** ppuxStackBuffer,
* StaticTask_t ** ppxTaskBuffer );
* @endcode
*
* Retrieve pointers to a statically created task's data structure
* buffer and stack buffer. These are the same buffers that are supplied
* at the time of creation.
*
* @param xTask The task for which to retrieve the buffers.
*
* @param ppuxStackBuffer Used to return a pointer to the task's stack buffer.
*
* @param ppxTaskBuffer Used to return a pointer to the task's data structure
* buffer.
*
* @return pdTRUE if buffers were retrieved, pdFALSE otherwise.
*
* \defgroup xTaskGetStaticBuffers xTaskGetStaticBuffers
* \ingroup TaskUtils
*/
#if ( configSUPPORT_STATIC_ALLOCATION == 1 )
BaseType_t xTaskGetStaticBuffers( TaskHandle_t xTask,
StackType_t ** ppuxStackBuffer,
StaticTask_t ** ppxTaskBuffer ) PRIVILEGED_FUNCTION;
#endif /* configSUPPORT_STATIC_ALLOCATION */

/**
* task.h
* @code{c}
Expand Down
20 changes: 20 additions & 0 deletions include/timers.h
Original file line number Diff line number Diff line change
Expand Up @@ -1323,6 +1323,26 @@ TickType_t xTimerGetPeriod( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION;
*/
TickType_t xTimerGetExpiryTime( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION;

/**
* BaseType_t xTimerGetStaticBuffer( TimerHandle_t xTimer,
* StaticTimer_t ** ppxTimerBuffer );
*
* Retrieve pointer to a statically created timer's data structure
* buffer. This is the same buffer that is supplied at the time of
* creation.
*
* @param xTimer The timer for which to retrieve the buffer.
*
* @param ppxTaskBuffer Used to return a pointer to the timers's data
* structure buffer.
*
* @return pdTRUE if the buffer was retrieved, pdFALSE otherwise.
*/
#if ( configSUPPORT_STATIC_ALLOCATION == 1 )
BaseType_t xTimerGetStaticBuffer( TimerHandle_t xTimer,
StaticTimer_t ** ppxTimerBuffer ) PRIVILEGED_FUNCTION;
#endif /* configSUPPORT_STATIC_ALLOCATION */

/*
* Functions beyond this part are not part of the public API and are intended
* for use by the kernel only.
Expand Down
Loading