Skip to content

Commit 3a94c78

Browse files
committed
Add functions to get buffers of statically created objects
Added various ...GetStaticBuffer() functions to get the buffers of statically created objects.
1 parent 309a18a commit 3a94c78

13 files changed

+366
-0
lines changed

.github/lexicon.txt

+18
Original file line numberDiff line numberDiff line change
@@ -1464,13 +1464,24 @@ ppdc
14641464
ppio
14651465
ppitc
14661466
ppmc
1467+
ppucmessagebufferstoragearea
1468+
ppucqueuestorage
1469+
ppucstreambufferstoragearea
14671470
ppudr
14681471
ppuer
14691472
ppusr
1473+
ppuxstackbuffer
14701474
ppvdestination
14711475
ppwm
1476+
ppxeventgroupbuffer
14721477
ppxidletaskstackbuffer
14731478
ppxidletasktcbbuffer
1479+
ppxsemaphorebuffer
1480+
ppxstaticmessagebuffer
1481+
ppxstaticqueue
1482+
ppxstaticstreambuffer
1483+
ppxtaskbuffer
1484+
ppxtimerbuffer
14741485
ppxtimertaskstackbuffer
14751486
ppxtimertasktcbbuffer
14761487
pr
@@ -2723,6 +2734,7 @@ xeventgroupcreatestatic
27232734
xeventgroupdelete
27242735
xeventgroupgetbits
27252736
xeventgroupgetbitsfromisr
2737+
xeventgroupgetstaticbuffer
27262738
xeventgroupsetbits
27272739
xeventgroupsetbitsfromisr
27282740
xeventgroupsync
@@ -2796,6 +2808,7 @@ xmessage
27962808
xmessagebuffer
27972809
xmessagebuffercreate
27982810
xmessagebuffercreatestatic
2811+
xmessagebuffergetstaticbuffers
27992812
xmessagebufferisempty
28002813
xmessagebufferisfull
28012814
xmessagebuffernextlengthbytes
@@ -2865,6 +2878,7 @@ xqueuecreatestatic
28652878
xqueuegenericsend
28662879
xqueuegenericsendfromisr
28672880
xqueuegetmutexholder
2881+
xqueuegetstaticbuffers
28682882
xqueuegivefromisr
28692883
xqueuegivemutexrecursive
28702884
xqueueorsemaphore
@@ -2919,6 +2933,7 @@ xsemaphorecreaterecursivemutex
29192933
xsemaphorecreaterecursivemutexstatic
29202934
xsemaphoregetmutexholder
29212935
xsemaphoregetmutexholderfromisr
2936+
xsemaphoregetstaticbuffer
29222937
xsemaphoregive
29232938
xsemaphoregivefromisr
29242939
xsemaphoregivemutexrecursive
@@ -2943,6 +2958,7 @@ xstreambuffer
29432958
xstreambufferbytesavailable
29442959
xstreambuffercreate
29452960
xstreambuffercreatestatic
2961+
xstreambuffergetstaticbuffers
29462962
xstreambufferisempty
29472963
xstreambufferisfull
29482964
xstreambuffernextmessagelengthbytes
@@ -2981,6 +2997,7 @@ xtaskgetcurrenttaskhandle
29812997
xtaskgethandle
29822998
xtaskgetidletaskhandle
29832999
xtaskgetschedulerstate
3000+
xtaskgetstaticbuffers
29843001
xtaskgettickcount
29853002
xtaskgettickcountfromisr
29863003
xtaskhandle
@@ -3048,6 +3065,7 @@ xtimerdelete
30483065
xtimergetexpirytime
30493066
xtimergetperiod
30503067
xtimergetreloadmode
3068+
xtimergetstaticbuffer
30513069
xtimergettimerdaemontaskhandle
30523070
xtimeristimeractive
30533071
xtimerlistitem

event_groups.c

+25
Original file line numberDiff line numberDiff line change
@@ -677,6 +677,31 @@ void vEventGroupDelete( EventGroupHandle_t xEventGroup )
677677
}
678678
/*-----------------------------------------------------------*/
679679

680+
#if ( configSUPPORT_STATIC_ALLOCATION == 1 )
681+
BaseType_t xEventGroupGetStaticBuffer( EventGroupHandle_t xEventGroup,
682+
StaticEventGroup_t ** ppxEventGroupBuffer )
683+
{
684+
BaseType_t xReturn;
685+
EventGroup_t * pxEventBits = xEventGroup;
686+
687+
configASSERT( pxEventBits );
688+
configASSERT( ppxEventGroupBuffer );
689+
690+
if( pxEventBits->ucStaticallyAllocated == ( uint8_t ) pdTRUE )
691+
{
692+
*ppxEventGroupBuffer = ( StaticEventGroup_t * ) pxEventBits;
693+
xReturn = pdTRUE;
694+
}
695+
else
696+
{
697+
xReturn = pdFALSE;
698+
}
699+
700+
return xReturn;
701+
}
702+
#endif /* configSUPPORT_STATIC_ALLOCATION */
703+
/*-----------------------------------------------------------*/
704+
680705
/* For internal use only - execute a 'set bits' command that was pended from
681706
* an interrupt. */
682707
void vEventGroupSetBitsCallback( void * pvEventGroup,

include/event_groups.h

+23
Original file line numberDiff line numberDiff line change
@@ -763,6 +763,29 @@ EventBits_t xEventGroupGetBitsFromISR( EventGroupHandle_t xEventGroup ) PRIVILEG
763763
*/
764764
void vEventGroupDelete( EventGroupHandle_t xEventGroup ) PRIVILEGED_FUNCTION;
765765

766+
/**
767+
* event_groups.h
768+
* @code{c}
769+
* BaseType_t xEventGroupGetStaticBuffer( EventGroupHandle_t xEventGroup,
770+
* StaticEventGroup_t ** ppxEventGroupBuffer );
771+
* @endcode
772+
*
773+
* This function fetches a pointer to the memory buffer of a statically created
774+
* event group.
775+
*
776+
* @param xEventGroup The handle of the event group
777+
*
778+
* @param ppxEventGroupBuffer Used to pass back a pointer to the event groups's
779+
* data structure buffer.
780+
*
781+
* @return pdTRUE if the buffer were fetched. pdFALSE if the event group was not
782+
* statically created.
783+
*/
784+
#if ( configSUPPORT_STATIC_ALLOCATION == 1 )
785+
BaseType_t xEventGroupGetStaticBuffer( EventGroupHandle_t xEventGroup,
786+
StaticEventGroup_t ** ppxEventGroupBuffer ) PRIVILEGED_FUNCTION;
787+
#endif /* configSUPPORT_STATIC_ALLOCATION */
788+
766789
/* For internal use only. */
767790
void vEventGroupSetBitsCallback( void * pvEventGroup,
768791
const uint32_t ulBitsToSet ) PRIVILEGED_FUNCTION;

include/message_buffer.h

+31
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,37 @@ typedef StreamBufferHandle_t MessageBufferHandle_t;
245245
xStreamBufferGenericCreateStatic( ( xBufferSizeBytes ), 0, pdTRUE, ( pucMessageBufferStorageArea ), ( pxStaticMessageBuffer ), ( pxSendCompletedCallback ), ( pxReceiveCompletedCallback ) )
246246
#endif
247247

248+
/**
249+
* message_buffer.h
250+
*
251+
* @code{c}
252+
* BaseType_t xMessageBufferGetStaticBuffers( MessageBufferHandle_t xMessageBuffer,
253+
* uint8_t ** ppucMessageBufferStorageArea,
254+
* StaticMessageBuffer_t ** ppxStaticMessageBuffer );
255+
* @endcode
256+
*
257+
* This function fetches the pointers to the memory buffers of a statically
258+
* created message buffer.
259+
*
260+
* @param xMessageBuffer The handle to the message buffer
261+
*
262+
* @param ppucMessageBufferStorageArea Used to pass back a pointer to the
263+
* message buffer's storage area buffer.
264+
*
265+
* @param ppxStaticMessageBuffer Used to pass back a pointer to the message
266+
* buffer's data structure buffer.
267+
*
268+
* @return pdTRUE if buffers were fetched. pdFALSE if the message buffer was not
269+
* statically created.
270+
*
271+
* \defgroup xMessageBufferGetStaticBuffers xMessageBufferGetStaticBuffers
272+
* \ingroup MessageBufferManagement
273+
*/
274+
#if ( configSUPPORT_STATIC_ALLOCATION == 1 )
275+
#define xMessageBufferGetStaticBuffers( xMessageBuffer, ppucMessageBufferStorageArea, ppxStaticMessageBuffer ) \
276+
xStreamBufferGenericGetStaticBuffers( ( xMessageBuffer ), ( ppucMessageBufferStorageArea ), ( ppxStaticMessageBuffer ) )
277+
#endif /* configSUPPORT_STATIC_ALLOCATION */
278+
248279
/**
249280
* message_buffer.h
250281
*

include/queue.h

+41
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,35 @@ typedef struct QueueDefinition * QueueSetMemberHandle_t;
235235
#define xQueueCreateStatic( uxQueueLength, uxItemSize, pucQueueStorage, pxQueueBuffer ) xQueueGenericCreateStatic( ( uxQueueLength ), ( uxItemSize ), ( pucQueueStorage ), ( pxQueueBuffer ), ( queueQUEUE_TYPE_BASE ) )
236236
#endif /* configSUPPORT_STATIC_ALLOCATION */
237237

238+
/**
239+
* queue. h
240+
* @code{c}
241+
* BaseType_t xQueueGetStaticBuffers( QueueHandle_t xQueue,
242+
* uint8_t ** ppucQueueStorage,
243+
* StaticQueue_t ** ppxStaticQueue );
244+
* @endcode
245+
*
246+
* This function fetches the pointers to the memory buffers of a statically
247+
* created queue.
248+
*
249+
* @param xQueue The handle to the queue
250+
*
251+
* @param ppucQueueStorage Used to pass back a pointer to the queue's storage
252+
* area buffer.
253+
*
254+
* @param ppxStaticQueue Used to pass back a pointer to the queue's data
255+
* structure buffer.
256+
*
257+
* @return pdTRUE if buffers were fetched. pdFALSE if the queue was not
258+
* created using xQueueCreateStatic().
259+
*
260+
* \defgroup xQueueGetStaticBuffers xQueueGetStaticBuffers
261+
* \ingroup QueueManagement
262+
*/
263+
#if ( configSUPPORT_STATIC_ALLOCATION == 1 )
264+
#define xQueueGetStaticBuffers( xQueue, ppucQueueStorage, ppxStaticQueue ) xQueueGenericGetStaticBuffers( ( xQueue ), ( ppucQueueStorage ), ( ppxStaticQueue ) )
265+
#endif /* configSUPPORT_STATIC_ALLOCATION */
266+
238267
/**
239268
* queue. h
240269
* @code{c}
@@ -1542,6 +1571,18 @@ BaseType_t xQueueGiveMutexRecursive( QueueHandle_t xMutex ) PRIVILEGED_FUNCTION;
15421571
const uint8_t ucQueueType ) PRIVILEGED_FUNCTION;
15431572
#endif
15441573

1574+
/*
1575+
* Generic version of the function used to get the buffers of statically created
1576+
* queues. This is called by other functions and macros that get the buffers
1577+
* of other statically created RTOS objects that use the queue structure as
1578+
* their base.
1579+
*/
1580+
#if ( configSUPPORT_STATIC_ALLOCATION == 1 )
1581+
BaseType_t xQueueGenericGetStaticBuffers( QueueHandle_t xQueue,
1582+
uint8_t ** ppucQueueStorage,
1583+
StaticQueue_t ** ppxStaticQueue ) PRIVILEGED_FUNCTION;
1584+
#endif
1585+
15451586
/*
15461587
* Queue sets provide a mechanism to allow a task to block (pend) on a read
15471588
* operation from multiple queues or semaphores simultaneously.

include/semphr.h

+21
Original file line numberDiff line numberDiff line change
@@ -1190,4 +1190,25 @@ typedef QueueHandle_t SemaphoreHandle_t;
11901190
*/
11911191
#define uxSemaphoreGetCountFromISR( xSemaphore ) uxQueueMessagesWaitingFromISR( ( QueueHandle_t ) ( xSemaphore ) )
11921192

1193+
/**
1194+
* semphr.h
1195+
* @code{c}
1196+
* BaseType_t xSemaphoreGetStaticBuffer( SemaphoreHandle_t xSemaphore );
1197+
* @endcode
1198+
*
1199+
* This function fetches a pointer to the memory buffer of a statically created
1200+
* binary semaphore, counting semaphore, or mutex semaphore.
1201+
*
1202+
* @param xSemaphore The handle of the statically created semaphore
1203+
*
1204+
* @param ppxSemaphoreBuffer Used to pass back a pointer to the semaphore's
1205+
* data structure buffer
1206+
*
1207+
* @return pdTRUE if buffer was fetched. pdFALSE if the semaphore was not
1208+
* statically allocated.
1209+
*/
1210+
#if ( configSUPPORT_STATIC_ALLOCATION == 1 )
1211+
#define xSemaphoreGetStaticBuffer( xSemaphore, ppxSemaphoreBuffer ) xQueueGenericGetStaticBuffers( ( QueueHandle_t ) ( xSemaphore ), NULL, ( ppxSemaphoreBuffer ) )
1212+
#endif /* configSUPPORT_STATIC_ALLOCATION */
1213+
11931214
#endif /* SEMAPHORE_H */

include/stream_buffer.h

+41
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,37 @@ typedef void (* StreamBufferCallbackFunction_t)( StreamBufferHandle_t xStreamBuf
260260
xStreamBufferGenericCreateStatic( ( xBufferSizeBytes ), ( xTriggerLevelBytes ), pdFALSE, ( pucStreamBufferStorageArea ), ( pxStaticStreamBuffer ), ( pxSendCompletedCallback ), ( pxReceiveCompletedCallback ) )
261261
#endif
262262

263+
/**
264+
* stream_buffer.h
265+
*
266+
* @code{c}
267+
* BaseType_t xStreamBufferGetStaticBuffers( StreamBufferHandle_t xStreamBuffer,
268+
* uint8_t ** ppucStreamBufferStorageArea,
269+
* StaticStreamBuffer_t ** ppxStaticStreamBuffer );
270+
* @endcode
271+
*
272+
* This function fetches the pointers to the memory buffers of a statically
273+
* created stream buffer.
274+
*
275+
* @param xStreamBuffer The handle to the stream buffer
276+
*
277+
* @param ppucStreamBufferStorageArea Used to pass back a pointer to the stream
278+
* buffer's storage area buffer.
279+
*
280+
* @param ppxStaticStreamBuffer Used to pass back a pointer to the stream
281+
* buffer's data structure buffer.
282+
*
283+
* @return pdTRUE if buffers were fetched. pdFALSE if the stream buffer was not
284+
* statically created.
285+
*
286+
* \defgroup xStreamBufferGetStaticBuffers xStreamBufferGetStaticBuffers
287+
* \ingroup StreamBufferManagement
288+
*/
289+
#if ( configSUPPORT_STATIC_ALLOCATION == 1 )
290+
#define xStreamBufferGetStaticBuffers( xStreamBuffer, ppucStreamBufferStorageArea, ppxStaticStreamBuffer ) \
291+
xStreamBufferGenericGetStaticBuffers( ( xStreamBuffer ), ( ppucStreamBufferStorageArea ), ( ppxStaticStreamBuffer ) )
292+
#endif /* configSUPPORT_STATIC_ALLOCATION */
293+
263294
/**
264295
* stream_buffer.h
265296
*
@@ -895,6 +926,16 @@ StreamBufferHandle_t xStreamBufferGenericCreateStatic( size_t xBufferSizeBytes,
895926
StreamBufferCallbackFunction_t pxSendCompletedCallback,
896927
StreamBufferCallbackFunction_t pxReceiveCompletedCallback ) PRIVILEGED_FUNCTION;
897928

929+
/*
930+
* Generic version of the function used to get the buffers of statically created
931+
* stream or message buffer.
932+
*/
933+
#if ( configSUPPORT_STATIC_ALLOCATION == 1 )
934+
BaseType_t xStreamBufferGenericGetStaticBuffers( StreamBufferHandle_t xStreamBuffer,
935+
uint8_t ** ppucStreamBufferStorageArea,
936+
StaticStreamBuffer_t ** ppxStaticStreamBuffer ) PRIVILEGED_FUNCTION;
937+
#endif /* configSUPPORT_STATIC_ALLOCATION */
938+
898939
size_t xStreamBufferNextMessageLengthBytes( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION;
899940

900941
#if ( configUSE_TRACE_FACILITY == 1 )

include/task.h

+30
Original file line numberDiff line numberDiff line change
@@ -1509,6 +1509,36 @@ char * pcTaskGetName( TaskHandle_t xTaskToQuery ) PRIVILEGED_FUNCTION; /*lint !e
15091509
*/
15101510
TaskHandle_t xTaskGetHandle( const char * pcNameToQuery ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
15111511

1512+
/**
1513+
* task. h
1514+
* @code{c}
1515+
* BaseType_t xTaskGetStaticBuffers( TaskHandle_t xTask,
1516+
* StackType_t ** ppuxStackBuffer,
1517+
* StaticTask_t ** ppxTaskBuffer );
1518+
* @endcode
1519+
*
1520+
* This function fetches a pointer to the memory buffers of a statically created
1521+
* task.
1522+
*
1523+
* @param xTask The handle of the statically created task
1524+
*
1525+
* @param ppuxStackBuffer Used to pass back a pointer to the task's stack buffer
1526+
*
1527+
* @param ppxTaskBuffer Used to pass back a pointer to the task's data structure
1528+
* buffer
1529+
*
1530+
* @return pdTRUE if buffers were fetched. pdFALSE if the task was not
1531+
* statically created.
1532+
*
1533+
* \defgroup xTaskGetStaticBuffers xTaskGetStaticBuffers
1534+
* \ingroup TaskUtils
1535+
*/
1536+
#if ( configSUPPORT_STATIC_ALLOCATION == 1 )
1537+
BaseType_t xTaskGetStaticBuffers( TaskHandle_t xTask,
1538+
StackType_t ** ppuxStackBuffer,
1539+
StaticTask_t ** ppxTaskBuffer ) PRIVILEGED_FUNCTION;
1540+
#endif /* configSUPPORT_STATIC_ALLOCATION */
1541+
15121542
/**
15131543
* task.h
15141544
* @code{c}

include/timers.h

+20
Original file line numberDiff line numberDiff line change
@@ -1323,6 +1323,26 @@ TickType_t xTimerGetPeriod( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION;
13231323
*/
13241324
TickType_t xTimerGetExpiryTime( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION;
13251325

1326+
/**
1327+
* BaseType_t xTimerGetStaticBuffer( TimerHandle_t xTimer,
1328+
* StaticTimer_t ** ppxTimerBuffer );
1329+
*
1330+
* This function fetches a pointer to the memory buffer of a statically created
1331+
* timer.
1332+
*
1333+
* @param xTimer The handle of the timer
1334+
*
1335+
* @param ppxTaskBuffer Used to pass back a pointer to the timers's data
1336+
* structure buffer.
1337+
*
1338+
* @return pdTRUE if the buffer were fetched. pdFALSE if the timer was not
1339+
* statically created.
1340+
*/
1341+
#if ( configSUPPORT_STATIC_ALLOCATION == 1 )
1342+
BaseType_t xTimerGetStaticBuffer( TimerHandle_t xTimer,
1343+
StaticTimer_t ** ppxTimerBuffer ) PRIVILEGED_FUNCTION;
1344+
#endif /* configSUPPORT_STATIC_ALLOCATION */
1345+
13261346
/*
13271347
* Functions beyond this part are not part of the public API and are intended
13281348
* for use by the kernel only.

0 commit comments

Comments
 (0)