/*\r
- * FreeRTOS Kernel V10.0.1\r
- * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.\r
+ * FreeRTOS Kernel V10.3.0\r
+ * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.\r
*\r
* Permission is hereby granted, free of charge, to any person obtaining a copy of\r
* this software and associated documentation files (the "Software"), to deal in\r
uint8_t * const pucBuffer,\r
size_t xBufferSizeBytes,\r
size_t xTriggerLevelBytes,\r
- BaseType_t xIsMessageBuffer ) PRIVILEGED_FUNCTION;\r
+ uint8_t ucFlags ) PRIVILEGED_FUNCTION;\r
\r
/*-----------------------------------------------------------*/\r
\r
StreamBufferHandle_t xStreamBufferGenericCreate( size_t xBufferSizeBytes, size_t xTriggerLevelBytes, BaseType_t xIsMessageBuffer )\r
{\r
uint8_t *pucAllocatedMemory;\r
+ uint8_t ucFlags;\r
\r
/* In case the stream buffer is going to be used as a message buffer\r
(that is, it will hold discrete messages with a little meta data that\r
says how big the next message is) check the buffer will be large enough\r
to hold at least one message. */\r
- configASSERT( xBufferSizeBytes > sbBYTES_TO_STORE_MESSAGE_LENGTH );\r
+ if( xIsMessageBuffer == pdTRUE )\r
+ {\r
+ /* Is a message buffer but not statically allocated. */\r
+ ucFlags = sbFLAGS_IS_MESSAGE_BUFFER;\r
+ configASSERT( xBufferSizeBytes > sbBYTES_TO_STORE_MESSAGE_LENGTH );\r
+ }\r
+ else\r
+ {\r
+ /* Not a message buffer and not statically allocated. */\r
+ ucFlags = 0;\r
+ configASSERT( xBufferSizeBytes > 0 );\r
+ }\r
configASSERT( xTriggerLevelBytes <= xBufferSizeBytes );\r
\r
/* A trigger level of 0 would cause a waiting task to unblock even when\r
pucAllocatedMemory + sizeof( StreamBuffer_t ), /* Storage area follows. */ /*lint !e9016 Indexing past structure valid for uint8_t pointer, also storage area has no alignment requirement. */\r
xBufferSizeBytes,\r
xTriggerLevelBytes,\r
- xIsMessageBuffer );\r
+ ucFlags );\r
\r
traceSTREAM_BUFFER_CREATE( ( ( StreamBuffer_t * ) pucAllocatedMemory ), xIsMessageBuffer );\r
}\r
{\r
StreamBuffer_t * const pxStreamBuffer = ( StreamBuffer_t * ) pxStaticStreamBuffer; /*lint !e740 !e9087 Safe cast as StaticStreamBuffer_t is opaque Streambuffer_t. */\r
StreamBufferHandle_t xReturn;\r
+ uint8_t ucFlags;\r
\r
configASSERT( pucStreamBufferStorageArea );\r
configASSERT( pxStaticStreamBuffer );\r
xTriggerLevelBytes = ( size_t ) 1;\r
}\r
\r
+ if( xIsMessageBuffer != pdFALSE )\r
+ {\r
+ /* Statically allocated message buffer. */\r
+ ucFlags = sbFLAGS_IS_MESSAGE_BUFFER | sbFLAGS_IS_STATICALLY_ALLOCATED;\r
+ }\r
+ else\r
+ {\r
+ /* Statically allocated stream buffer. */\r
+ ucFlags = sbFLAGS_IS_STATICALLY_ALLOCATED;\r
+ }\r
+\r
/* In case the stream buffer is going to be used as a message buffer\r
(that is, it will hold discrete messages with a little meta data that\r
says how big the next message is) check the buffer will be large enough\r
pucStreamBufferStorageArea,\r
xBufferSizeBytes,\r
xTriggerLevelBytes,\r
- xIsMessageBuffer );\r
+ ucFlags );\r
\r
/* Remember this was statically allocated in case it is ever deleted\r
again. */\r
{\r
/* The structure and buffer were not allocated dynamically and cannot be\r
freed - just scrub the structure so future use will assert. */\r
- memset( pxStreamBuffer, 0x00, sizeof( StreamBuffer_t ) );\r
+ ( void ) memset( pxStreamBuffer, 0x00, sizeof( StreamBuffer_t ) );\r
}\r
}\r
/*-----------------------------------------------------------*/\r
BaseType_t xStreamBufferReset( StreamBufferHandle_t xStreamBuffer )\r
{\r
StreamBuffer_t * const pxStreamBuffer = xStreamBuffer;\r
-BaseType_t xReturn = pdFAIL, xIsMessageBuffer;\r
+BaseType_t xReturn = pdFAIL;\r
\r
#if( configUSE_TRACE_FACILITY == 1 )\r
UBaseType_t uxStreamBufferNumber;\r
{\r
if( pxStreamBuffer->xTaskWaitingToSend == NULL )\r
{\r
- if( ( pxStreamBuffer->ucFlags & sbFLAGS_IS_MESSAGE_BUFFER ) != ( uint8_t ) 0 )\r
- {\r
- xIsMessageBuffer = pdTRUE;\r
- }\r
- else\r
- {\r
- xIsMessageBuffer = pdFALSE;\r
- }\r
-\r
prvInitialiseNewStreamBuffer( pxStreamBuffer,\r
pxStreamBuffer->pucBuffer,\r
pxStreamBuffer->xLength,\r
pxStreamBuffer->xTriggerLevelBytes,\r
- xIsMessageBuffer );\r
+ pxStreamBuffer->ucFlags );\r
xReturn = pdPASS;\r
\r
#if( configUSE_TRACE_FACILITY == 1 )\r
\r
/* Write as many bytes as can be written in the first write. */\r
configASSERT( ( xNextHead + xFirstLength ) <= pxStreamBuffer->xLength );\r
- memcpy( ( void* ) ( &( pxStreamBuffer->pucBuffer[ xNextHead ] ) ), ( const void * ) pucData, xFirstLength ); /*lint !e9087 memcpy() requires void *. */\r
+ ( void ) memcpy( ( void* ) ( &( pxStreamBuffer->pucBuffer[ xNextHead ] ) ), ( const void * ) pucData, xFirstLength ); /*lint !e9087 memcpy() requires void *. */\r
\r
/* If the number of bytes written was less than the number that could be\r
written in the first write... */\r
{\r
/* ...then write the remaining bytes to the start of the buffer. */\r
configASSERT( ( xCount - xFirstLength ) <= pxStreamBuffer->xLength );\r
- memcpy( ( void * ) pxStreamBuffer->pucBuffer, ( const void * ) &( pucData[ xFirstLength ] ), xCount - xFirstLength ); /*lint !e9087 memcpy() requires void *. */\r
+ ( void ) memcpy( ( void * ) pxStreamBuffer->pucBuffer, ( const void * ) &( pucData[ xFirstLength ] ), xCount - xFirstLength ); /*lint !e9087 memcpy() requires void *. */\r
}\r
else\r
{\r
read. Asserts check bounds of read and write. */\r
configASSERT( xFirstLength <= xMaxCount );\r
configASSERT( ( xNextTail + xFirstLength ) <= pxStreamBuffer->xLength );\r
- memcpy( ( void * ) pucData, ( const void * ) &( pxStreamBuffer->pucBuffer[ xNextTail ] ), xFirstLength ); /*lint !e9087 memcpy() requires void *. */\r
+ ( void ) memcpy( ( void * ) pucData, ( const void * ) &( pxStreamBuffer->pucBuffer[ xNextTail ] ), xFirstLength ); /*lint !e9087 memcpy() requires void *. */\r
\r
/* If the total number of wanted bytes is greater than the number\r
that could be read in the first read... */\r
{\r
/*...then read the remaining bytes from the start of the buffer. */\r
configASSERT( xCount <= xMaxCount );\r
- memcpy( ( void * ) &( pucData[ xFirstLength ] ), ( void * ) ( pxStreamBuffer->pucBuffer ), xCount - xFirstLength ); /*lint !e9087 memcpy() requires void *. */\r
+ ( void ) memcpy( ( void * ) &( pucData[ xFirstLength ] ), ( void * ) ( pxStreamBuffer->pucBuffer ), xCount - xFirstLength ); /*lint !e9087 memcpy() requires void *. */\r
}\r
else\r
{\r
uint8_t * const pucBuffer,\r
size_t xBufferSizeBytes,\r
size_t xTriggerLevelBytes,\r
- BaseType_t xIsMessageBuffer )\r
+ uint8_t ucFlags )\r
{\r
/* Assert here is deliberately writing to the entire buffer to ensure it can\r
be written to without generating exceptions, and is setting the buffer to a\r
} /*lint !e529 !e438 xWriteValue is only used if configASSERT() is defined. */\r
#endif\r
\r
- memset( ( void * ) pxStreamBuffer, 0x00, sizeof( StreamBuffer_t ) ); /*lint !e9087 memset() requires void *. */\r
+ ( void ) memset( ( void * ) pxStreamBuffer, 0x00, sizeof( StreamBuffer_t ) ); /*lint !e9087 memset() requires void *. */\r
pxStreamBuffer->pucBuffer = pucBuffer;\r
pxStreamBuffer->xLength = xBufferSizeBytes;\r
pxStreamBuffer->xTriggerLevelBytes = xTriggerLevelBytes;\r
-\r
- if( xIsMessageBuffer != pdFALSE )\r
- {\r
- pxStreamBuffer->ucFlags |= sbFLAGS_IS_MESSAGE_BUFFER;\r
- }\r
+ pxStreamBuffer->ucFlags = ucFlags;\r
}\r
\r
#if ( configUSE_TRACE_FACILITY == 1 )\r