Skip to content

Commit 9488ba2

Browse files
Dazza0paulbartellamazonKamathaggarg
authored
Add functions to get the buffers of statically created objects (#641)
Added various ...GetStaticBuffer() functions to get the buffers of statically created objects. --------- Co-authored-by: Paul Bartell <[email protected]> Co-authored-by: Nikhil Kamath <[email protected]> Co-authored-by: Gaurav Aggarwal <[email protected]>
1 parent d4d5e43 commit 9488ba2

13 files changed

+400
-0
lines changed

.github/lexicon.txt

+19
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
@@ -3081,3 +3099,4 @@ xwritevalue
30813099
xxr
30823100
xyieldpending
30833101
xzr
3102+

event_groups.c

+36
Original file line numberDiff line numberDiff line change
@@ -677,6 +677,42 @@ 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 ( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
691+
{
692+
/* Check if the event group was statically allocated. */
693+
if( pxEventBits->ucStaticallyAllocated == ( uint8_t ) pdTRUE )
694+
{
695+
*ppxEventGroupBuffer = ( StaticEventGroup_t * ) pxEventBits;
696+
xReturn = pdTRUE;
697+
}
698+
else
699+
{
700+
xReturn = pdFALSE;
701+
}
702+
}
703+
#else /* configSUPPORT_DYNAMIC_ALLOCATION */
704+
{
705+
/* Event group must have been statically allocated. */
706+
*ppxEventGroupBuffer = ( StaticEventGroup_t * ) pxEventBits;
707+
xReturn = pdTRUE;
708+
}
709+
#endif /* configSUPPORT_DYNAMIC_ALLOCATION */
710+
711+
return xReturn;
712+
}
713+
#endif /* configSUPPORT_STATIC_ALLOCATION */
714+
/*-----------------------------------------------------------*/
715+
680716
/* For internal use only - execute a 'set bits' command that was pended from
681717
* an interrupt. */
682718
void vEventGroupSetBitsCallback( void * pvEventGroup,

include/event_groups.h

+22
Original file line numberDiff line numberDiff line change
@@ -763,6 +763,28 @@ 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+
* Retrieve a pointer to a statically created event groups's data structure
774+
* buffer. It is the same buffer that is supplied at the time of creation.
775+
*
776+
* @param xEventGroup The event group for which to retrieve the buffer.
777+
*
778+
* @param ppxEventGroupBuffer Used to return a pointer to the event groups's
779+
* data structure buffer.
780+
*
781+
* @return pdTRUE if the buffer was retrieved, pdFALSE otherwise.
782+
*/
783+
#if ( configSUPPORT_STATIC_ALLOCATION == 1 )
784+
BaseType_t xEventGroupGetStaticBuffer( EventGroupHandle_t xEventGroup,
785+
StaticEventGroup_t ** ppxEventGroupBuffer ) PRIVILEGED_FUNCTION;
786+
#endif /* configSUPPORT_STATIC_ALLOCATION */
787+
766788
/* For internal use only. */
767789
void vEventGroupSetBitsCallback( void * pvEventGroup,
768790
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+
* Retrieve pointers to a statically created message buffer's data structure
258+
* buffer and storage area buffer. These are the same buffers that are supplied
259+
* at the time of creation.
260+
*
261+
* @param xMessageBuffer The message buffer for which to retrieve the buffers.
262+
*
263+
* @param ppucMessageBufferStorageArea Used to return a pointer to the
264+
* message buffer's storage area buffer.
265+
*
266+
* @param ppxStaticMessageBuffer Used to return a pointer to the message
267+
* buffer's data structure buffer.
268+
*
269+
* @return pdTRUE if buffers were retrieved, pdFALSE otherwise..
270+
*
271+
* \defgroup xMessageBufferGetStaticBuffers xMessageBufferGetStaticBuffers
272+
* \ingroup MessageBufferManagement
273+
*/
274+
#if ( configSUPPORT_STATIC_ALLOCATION == 1 )
275+
#define xMessageBufferGetStaticBuffers( xMessageBuffer, ppucMessageBufferStorageArea, ppxStaticMessageBuffer ) \
276+
xStreamBufferGetStaticBuffers( ( 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+
* Retrieve pointers to a statically created queue's data structure buffer
247+
* and storage area buffer. These are the same buffers that are supplied
248+
* at the time of creation.
249+
*
250+
* @param xQueue The queue for which to retrieve the buffers.
251+
*
252+
* @param ppucQueueStorage Used to return a pointer to the queue's storage
253+
* area buffer.
254+
*
255+
* @param ppxStaticQueue Used to return a pointer to the queue's data
256+
* structure buffer.
257+
*
258+
* @return pdTRUE if buffers were retrieved, pdFALSE otherwise.
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 retrieve the buffers of statically
1576+
* created queues. This is called by other functions and macros that retrieve
1577+
* the buffers of other statically created RTOS objects that use the queue
1578+
* structure as 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+
* Retrieve pointer to a statically created binary semaphore, counting semaphore,
1200+
* or mutex semaphore's data structure buffer. This is the same buffer that is
1201+
* supplied at the time of creation.
1202+
*
1203+
* @param xSemaphore The semaphore for which to retrieve the buffer.
1204+
*
1205+
* @param ppxSemaphoreBuffer Used to return a pointer to the semaphore's
1206+
* data structure buffer.
1207+
*
1208+
* @return pdTRUE if buffer was retrieved, pdFALSE otherwise.
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

+32
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,38 @@ 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+
* Retrieve pointers to a statically created stream buffer's data structure
273+
* buffer and storage area buffer. These are the same buffers that are supplied
274+
* at the time of creation.
275+
*
276+
* @param xStreamBuffer The stream buffer for which to retrieve the buffers.
277+
*
278+
* @param ppucStreamBufferStorageArea Used to return a pointer to the stream
279+
* buffer's storage area buffer.
280+
*
281+
* @param ppxStaticStreamBuffer Used to return a pointer to the stream
282+
* buffer's data structure buffer.
283+
*
284+
* @return pdTRUE if buffers were retrieved, pdFALSE otherwise.
285+
*
286+
* \defgroup xStreamBufferGetStaticBuffers xStreamBufferGetStaticBuffers
287+
* \ingroup StreamBufferManagement
288+
*/
289+
#if ( configSUPPORT_STATIC_ALLOCATION == 1 )
290+
BaseType_t xStreamBufferGetStaticBuffers( StreamBufferHandle_t xStreamBuffer,
291+
uint8_t ** ppucStreamBufferStorageArea,
292+
StaticStreamBuffer_t ** ppxStaticStreamBuffer ) PRIVILEGED_FUNCTION;
293+
#endif /* configSUPPORT_STATIC_ALLOCATION */
294+
263295
/**
264296
* stream_buffer.h
265297
*

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+
* Retrieve pointers to a statically created task's data structure
1521+
* buffer and stack buffer. These are the same buffers that are supplied
1522+
* at the time of creation.
1523+
*
1524+
* @param xTask The task for which to retrieve the buffers.
1525+
*
1526+
* @param ppuxStackBuffer Used to return a pointer to the task's stack buffer.
1527+
*
1528+
* @param ppxTaskBuffer Used to return a pointer to the task's data structure
1529+
* buffer.
1530+
*
1531+
* @return pdTRUE if buffers were retrieved, pdFALSE otherwise.
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+
* Retrieve pointer to a statically created timer's data structure
1331+
* buffer. This is the same buffer that is supplied at the time of
1332+
* creation.
1333+
*
1334+
* @param xTimer The timer for which to retrieve the buffer.
1335+
*
1336+
* @param ppxTaskBuffer Used to return a pointer to the timers's data
1337+
* structure buffer.
1338+
*
1339+
* @return pdTRUE if the buffer was retrieved, pdFALSE otherwise.
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)