feat(freertos/smp): Update SMP FreeRTOS files to V11.0.1

This commit updates the source files of Amazon SMP FreeRTOS to upstream
V11.0.1 (https://github.com/FreeRTOS/FreeRTOS-Kernel/tree/V11.0.1).

This version contains SMP support.
This commit is contained in:
Darian Leung
2024-01-05 17:14:26 +08:00
parent 0286a78ca4
commit 421dab29fa
32 changed files with 11463 additions and 5107 deletions

View File

@@ -1,6 +1,12 @@
/*
* FreeRTOS SMP Kernel V202110.00
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
* FreeRTOS Kernel V11.0.1
* Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* SPDX-FileCopyrightText: 2021 Amazon.com, Inc. or its affiliates
*
* SPDX-License-Identifier: MIT
*
* SPDX-FileContributor: 2023-2024 Espressif Systems (Shanghai) CO LTD
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
@@ -69,13 +75,19 @@
struct StreamBufferDef_t;
typedef struct StreamBufferDef_t * StreamBufferHandle_t;
/**
* Type used as a stream buffer's optional callback.
*/
typedef void (* StreamBufferCallbackFunction_t)( StreamBufferHandle_t xStreamBuffer,
BaseType_t xIsInsideISR,
BaseType_t * const pxHigherPriorityTaskWoken );
/**
* message_buffer.h
* stream_buffer.h
*
* <pre>
* @code{c}
* StreamBufferHandle_t xStreamBufferCreate( size_t xBufferSizeBytes, size_t xTriggerLevelBytes );
* </pre>
* @endcode
*
* Creates a new stream buffer using dynamically allocated memory. See
* xStreamBufferCreateStatic() for a version that uses statically allocated
@@ -101,6 +113,16 @@ typedef struct StreamBufferDef_t * StreamBufferHandle_t;
* trigger level of 1 being used. It is not valid to specify a trigger level
* that is greater than the buffer size.
*
* @param pxSendCompletedCallback Callback invoked when number of bytes at least equal to
* trigger level is sent to the stream buffer. If the parameter is NULL, it will use the default
* implementation provided by sbSEND_COMPLETED macro. To enable the callback,
* configUSE_SB_COMPLETED_CALLBACK must be set to 1 in FreeRTOSConfig.h.
*
* @param pxReceiveCompletedCallback Callback invoked when more than zero bytes are read from a
* stream buffer. If the parameter is NULL, it will use the default
* implementation provided by sbRECEIVE_COMPLETED macro. To enable the callback,
* configUSE_SB_COMPLETED_CALLBACK must be set to 1 in FreeRTOSConfig.h.
*
* @return If NULL is returned, then the stream buffer cannot be created
* because there is insufficient heap memory available for FreeRTOS to allocate
* the stream buffer data structures and storage area. A non-NULL value being
@@ -109,7 +131,7 @@ typedef struct StreamBufferDef_t * StreamBufferHandle_t;
* buffer.
*
* Example use:
* <pre>
* @code{c}
*
* void vAFunction( void )
* {
@@ -131,21 +153,28 @@ typedef struct StreamBufferDef_t * StreamBufferHandle_t;
* // The stream buffer was created successfully and can now be used.
* }
* }
* </pre>
* @endcode
* \defgroup xStreamBufferCreate xStreamBufferCreate
* \ingroup StreamBufferManagement
*/
#define xStreamBufferCreate( xBufferSizeBytes, xTriggerLevelBytes ) xStreamBufferGenericCreate( xBufferSizeBytes, xTriggerLevelBytes, pdFALSE )
#define xStreamBufferCreate( xBufferSizeBytes, xTriggerLevelBytes ) \
xStreamBufferGenericCreate( ( xBufferSizeBytes ), ( xTriggerLevelBytes ), pdFALSE, NULL, NULL )
#if ( configUSE_SB_COMPLETED_CALLBACK == 1 )
#define xStreamBufferCreateWithCallback( xBufferSizeBytes, xTriggerLevelBytes, pxSendCompletedCallback, pxReceiveCompletedCallback ) \
xStreamBufferGenericCreate( ( xBufferSizeBytes ), ( xTriggerLevelBytes ), pdFALSE, ( pxSendCompletedCallback ), ( pxReceiveCompletedCallback ) )
#endif
/**
* stream_buffer.h
*
* <pre>
* @code{c}
* StreamBufferHandle_t xStreamBufferCreateStatic( size_t xBufferSizeBytes,
* size_t xTriggerLevelBytes,
* uint8_t *pucStreamBufferStorageArea,
* StaticStreamBuffer_t *pxStaticStreamBuffer );
* </pre>
* @endcode
* Creates a new stream buffer using statically allocated memory. See
* xStreamBufferCreate() for a version that uses dynamically allocated memory.
*
@@ -170,19 +199,29 @@ typedef struct StreamBufferDef_t * StreamBufferHandle_t;
* that is greater than the buffer size.
*
* @param pucStreamBufferStorageArea Must point to a uint8_t array that is at
* least xBufferSizeBytes + 1 big. This is the array to which streams are
* least xBufferSizeBytes big. This is the array to which streams are
* copied when they are written to the stream buffer.
*
* @param pxStaticStreamBuffer Must point to a variable of type
* StaticStreamBuffer_t, which will be used to hold the stream buffer's data
* structure.
*
* @param pxSendCompletedCallback Callback invoked when number of bytes at least equal to
* trigger level is sent to the stream buffer. If the parameter is NULL, it will use the default
* implementation provided by sbSEND_COMPLETED macro. To enable the callback,
* configUSE_SB_COMPLETED_CALLBACK must be set to 1 in FreeRTOSConfig.h.
*
* @param pxReceiveCompletedCallback Callback invoked when more than zero bytes are read from a
* stream buffer. If the parameter is NULL, it will use the default
* implementation provided by sbRECEIVE_COMPLETED macro. To enable the callback,
* configUSE_SB_COMPLETED_CALLBACK must be set to 1 in FreeRTOSConfig.h.
*
* @return If the stream buffer is created successfully then a handle to the
* created stream buffer is returned. If either pucStreamBufferStorageArea or
* pxStaticstreamBuffer are NULL then NULL is returned.
*
* Example use:
* <pre>
* @code{c}
*
* // Used to dimension the array used to hold the streams. The available space
* // will actually be one less than this, so 999.
@@ -200,9 +239,9 @@ typedef struct StreamBufferDef_t * StreamBufferHandle_t;
* StreamBufferHandle_t xStreamBuffer;
* const size_t xTriggerLevel = 1;
*
* xStreamBuffer = xStreamBufferCreateStatic( sizeof( ucBufferStorage ),
* xStreamBuffer = xStreamBufferCreateStatic( sizeof( ucStorageBuffer ),
* xTriggerLevel,
* ucBufferStorage,
* ucStorageBuffer,
* &xStreamBufferStruct );
*
* // As neither the pucStreamBufferStorageArea or pxStaticStreamBuffer
@@ -212,12 +251,18 @@ typedef struct StreamBufferDef_t * StreamBufferHandle_t;
* // Other code that uses the stream buffer can go here.
* }
*
* </pre>
* @endcode
* \defgroup xStreamBufferCreateStatic xStreamBufferCreateStatic
* \ingroup StreamBufferManagement
*/
#define xStreamBufferCreateStatic( xBufferSizeBytes, xTriggerLevelBytes, pucStreamBufferStorageArea, pxStaticStreamBuffer ) \
xStreamBufferGenericCreateStatic( xBufferSizeBytes, xTriggerLevelBytes, pdFALSE, pucStreamBufferStorageArea, pxStaticStreamBuffer )
xStreamBufferGenericCreateStatic( ( xBufferSizeBytes ), ( xTriggerLevelBytes ), pdFALSE, ( pucStreamBufferStorageArea ), ( pxStaticStreamBuffer ), NULL, NULL )
#if ( configUSE_SB_COMPLETED_CALLBACK == 1 )
#define xStreamBufferCreateStaticWithCallback( xBufferSizeBytes, xTriggerLevelBytes, pucStreamBufferStorageArea, pxStaticStreamBuffer, pxSendCompletedCallback, pxReceiveCompletedCallback ) \
xStreamBufferGenericCreateStatic( ( xBufferSizeBytes ), ( xTriggerLevelBytes ), pdFALSE, ( pucStreamBufferStorageArea ), ( pxStaticStreamBuffer ), ( pxSendCompletedCallback ), ( pxReceiveCompletedCallback ) )
#endif
/**
* stream_buffer.h
@@ -254,12 +299,12 @@ typedef struct StreamBufferDef_t * StreamBufferHandle_t;
/**
* stream_buffer.h
*
* <pre>
* @code{c}
* size_t xStreamBufferSend( StreamBufferHandle_t xStreamBuffer,
* const void *pvTxData,
* size_t xDataLengthBytes,
* TickType_t xTicksToWait );
* </pre>
* @endcode
*
* Sends bytes to a stream buffer. The bytes are copied into the stream buffer.
*
@@ -309,7 +354,7 @@ typedef struct StreamBufferDef_t * StreamBufferHandle_t;
* write as many bytes as possible.
*
* Example use:
* <pre>
* @code{c}
* void vAFunction( StreamBufferHandle_t xStreamBuffer )
* {
* size_t xBytesSent;
@@ -339,7 +384,7 @@ typedef struct StreamBufferDef_t * StreamBufferHandle_t;
* // were sent. Could try again to send the remaining bytes.
* }
* }
* </pre>
* @endcode
* \defgroup xStreamBufferSend xStreamBufferSend
* \ingroup StreamBufferManagement
*/
@@ -351,12 +396,12 @@ size_t xStreamBufferSend( StreamBufferHandle_t xStreamBuffer,
/**
* stream_buffer.h
*
* <pre>
* @code{c}
* size_t xStreamBufferSendFromISR( StreamBufferHandle_t xStreamBuffer,
* const void *pvTxData,
* size_t xDataLengthBytes,
* BaseType_t *pxHigherPriorityTaskWoken );
* </pre>
* @endcode
*
* Interrupt safe version of the API function that sends a stream of bytes to
* the stream buffer.
@@ -408,7 +453,7 @@ size_t xStreamBufferSend( StreamBufferHandle_t xStreamBuffer,
* space for all the bytes to be written.
*
* Example use:
* <pre>
* @code{c}
* // A stream buffer that has already been created.
* StreamBufferHandle_t xStreamBuffer;
*
@@ -435,12 +480,12 @@ size_t xStreamBufferSend( StreamBufferHandle_t xStreamBuffer,
* // priority of the currently executing task was unblocked and a context
* // switch should be performed to ensure the ISR returns to the unblocked
* // task. In most FreeRTOS ports this is done by simply passing
* // xHigherPriorityTaskWoken into taskYIELD_FROM_ISR(), which will test the
* // xHigherPriorityTaskWoken into portYIELD_FROM_ISR(), which will test the
* // variables value, and perform the context switch if necessary. Check the
* // documentation for the port in use for port specific instructions.
* taskYIELD_FROM_ISR( xHigherPriorityTaskWoken );
* portYIELD_FROM_ISR( xHigherPriorityTaskWoken );
* }
* </pre>
* @endcode
* \defgroup xStreamBufferSendFromISR xStreamBufferSendFromISR
* \ingroup StreamBufferManagement
*/
@@ -452,12 +497,12 @@ size_t xStreamBufferSendFromISR( StreamBufferHandle_t xStreamBuffer,
/**
* stream_buffer.h
*
* <pre>
* @code{c}
* size_t xStreamBufferReceive( StreamBufferHandle_t xStreamBuffer,
* void *pvRxData,
* size_t xBufferLengthBytes,
* TickType_t xTicksToWait );
* </pre>
* @endcode
*
* Receives bytes from a stream buffer.
*
@@ -507,7 +552,7 @@ size_t xStreamBufferSendFromISR( StreamBufferHandle_t xStreamBuffer,
* out before xBufferLengthBytes were available.
*
* Example use:
* <pre>
* @code{c}
* void vAFunction( StreamBuffer_t xStreamBuffer )
* {
* uint8_t ucRxData[ 20 ];
@@ -525,11 +570,11 @@ size_t xStreamBufferSendFromISR( StreamBufferHandle_t xStreamBuffer,
*
* if( xReceivedBytes > 0 )
* {
* // A ucRxData contains another xRecievedBytes bytes of data, which can
* // A ucRxData contains another xReceivedBytes bytes of data, which can
* // be processed here....
* }
* }
* </pre>
* @endcode
* \defgroup xStreamBufferReceive xStreamBufferReceive
* \ingroup StreamBufferManagement
*/
@@ -541,12 +586,12 @@ size_t xStreamBufferReceive( StreamBufferHandle_t xStreamBuffer,
/**
* stream_buffer.h
*
* <pre>
* @code{c}
* size_t xStreamBufferReceiveFromISR( StreamBufferHandle_t xStreamBuffer,
* void *pvRxData,
* size_t xBufferLengthBytes,
* BaseType_t *pxHigherPriorityTaskWoken );
* </pre>
* @endcode
*
* An interrupt safe version of the API function that receives bytes from a
* stream buffer.
@@ -583,7 +628,7 @@ size_t xStreamBufferReceive( StreamBufferHandle_t xStreamBuffer,
* @return The number of bytes read from the stream buffer, if any.
*
* Example use:
* <pre>
* @code{c}
* // A stream buffer that has already been created.
* StreamBuffer_t xStreamBuffer;
*
@@ -610,12 +655,12 @@ size_t xStreamBufferReceive( StreamBufferHandle_t xStreamBuffer,
* // priority of the currently executing task was unblocked and a context
* // switch should be performed to ensure the ISR returns to the unblocked
* // task. In most FreeRTOS ports this is done by simply passing
* // xHigherPriorityTaskWoken into taskYIELD_FROM_ISR(), which will test the
* // xHigherPriorityTaskWoken into portYIELD_FROM_ISR(), which will test the
* // variables value, and perform the context switch if necessary. Check the
* // documentation for the port in use for port specific instructions.
* taskYIELD_FROM_ISR( xHigherPriorityTaskWoken );
* portYIELD_FROM_ISR( xHigherPriorityTaskWoken );
* }
* </pre>
* @endcode
* \defgroup xStreamBufferReceiveFromISR xStreamBufferReceiveFromISR
* \ingroup StreamBufferManagement
*/
@@ -627,9 +672,9 @@ size_t xStreamBufferReceiveFromISR( StreamBufferHandle_t xStreamBuffer,
/**
* stream_buffer.h
*
* <pre>
* @code{c}
* void vStreamBufferDelete( StreamBufferHandle_t xStreamBuffer );
* </pre>
* @endcode
*
* Deletes a stream buffer that was previously created using a call to
* xStreamBufferCreate() or xStreamBufferCreateStatic(). If the stream
@@ -649,9 +694,9 @@ void vStreamBufferDelete( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTI
/**
* stream_buffer.h
*
* <pre>
* @code{c}
* BaseType_t xStreamBufferIsFull( StreamBufferHandle_t xStreamBuffer );
* </pre>
* @endcode
*
* Queries a stream buffer to see if it is full. A stream buffer is full if it
* does not have any free space, and therefore cannot accept any more data.
@@ -669,9 +714,9 @@ BaseType_t xStreamBufferIsFull( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_
/**
* stream_buffer.h
*
* <pre>
* @code{c}
* BaseType_t xStreamBufferIsEmpty( StreamBufferHandle_t xStreamBuffer );
* </pre>
* @endcode
*
* Queries a stream buffer to see if it is empty. A stream buffer is empty if
* it does not contain any data.
@@ -689,9 +734,9 @@ BaseType_t xStreamBufferIsEmpty( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED
/**
* stream_buffer.h
*
* <pre>
* @code{c}
* BaseType_t xStreamBufferReset( StreamBufferHandle_t xStreamBuffer );
* </pre>
* @endcode
*
* Resets a stream buffer to its initial, empty, state. Any data that was in
* the stream buffer is discarded. A stream buffer can only be reset if there
@@ -712,9 +757,9 @@ BaseType_t xStreamBufferReset( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_F
/**
* stream_buffer.h
*
* <pre>
* @code{c}
* size_t xStreamBufferSpacesAvailable( StreamBufferHandle_t xStreamBuffer );
* </pre>
* @endcode
*
* Queries a stream buffer to see how much free space it contains, which is
* equal to the amount of data that can be sent to the stream buffer before it
@@ -733,9 +778,9 @@ size_t xStreamBufferSpacesAvailable( StreamBufferHandle_t xStreamBuffer ) PRIVIL
/**
* stream_buffer.h
*
* <pre>
* @code{c}
* size_t xStreamBufferBytesAvailable( StreamBufferHandle_t xStreamBuffer );
* </pre>
* @endcode
*
* Queries a stream buffer to see how much data it contains, which is equal to
* the number of bytes that can be read from the stream buffer before the stream
@@ -754,9 +799,9 @@ size_t xStreamBufferBytesAvailable( StreamBufferHandle_t xStreamBuffer ) PRIVILE
/**
* stream_buffer.h
*
* <pre>
* @code{c}
* BaseType_t xStreamBufferSetTriggerLevel( StreamBufferHandle_t xStreamBuffer, size_t xTriggerLevel );
* </pre>
* @endcode
*
* A stream buffer's trigger level is the number of bytes that must be in the
* stream buffer before a task that is blocked on the stream buffer to
@@ -792,9 +837,9 @@ BaseType_t xStreamBufferSetTriggerLevel( StreamBufferHandle_t xStreamBuffer,
/**
* stream_buffer.h
*
* <pre>
* @code{c}
* BaseType_t xStreamBufferSendCompletedFromISR( StreamBufferHandle_t xStreamBuffer, BaseType_t *pxHigherPriorityTaskWoken );
* </pre>
* @endcode
*
* For advanced users only.
*
@@ -832,9 +877,9 @@ BaseType_t xStreamBufferSendCompletedFromISR( StreamBufferHandle_t xStreamBuffer
/**
* stream_buffer.h
*
* <pre>
* @code{c}
* BaseType_t xStreamBufferReceiveCompletedFromISR( StreamBufferHandle_t xStreamBuffer, BaseType_t *pxHigherPriorityTaskWoken );
* </pre>
* @endcode
*
* For advanced users only.
*
@@ -873,13 +918,19 @@ BaseType_t xStreamBufferReceiveCompletedFromISR( StreamBufferHandle_t xStreamBuf
/* Functions below here are not part of the public API. */
StreamBufferHandle_t xStreamBufferGenericCreate( size_t xBufferSizeBytes,
size_t xTriggerLevelBytes,
BaseType_t xIsMessageBuffer ) PRIVILEGED_FUNCTION;
BaseType_t xIsMessageBuffer,
StreamBufferCallbackFunction_t pxSendCompletedCallback,
StreamBufferCallbackFunction_t pxReceiveCompletedCallback ) PRIVILEGED_FUNCTION;
StreamBufferHandle_t xStreamBufferGenericCreateStatic( size_t xBufferSizeBytes,
size_t xTriggerLevelBytes,
BaseType_t xIsMessageBuffer,
uint8_t * const pucStreamBufferStorageArea,
StaticStreamBuffer_t * const pxStaticStreamBuffer ) PRIVILEGED_FUNCTION;
#if ( configSUPPORT_STATIC_ALLOCATION == 1 )
StreamBufferHandle_t xStreamBufferGenericCreateStatic( size_t xBufferSizeBytes,
size_t xTriggerLevelBytes,
BaseType_t xIsMessageBuffer,
uint8_t * const pucStreamBufferStorageArea,
StaticStreamBuffer_t * const pxStaticStreamBuffer,
StreamBufferCallbackFunction_t pxSendCompletedCallback,
StreamBufferCallbackFunction_t pxReceiveCompletedCallback ) PRIVILEGED_FUNCTION;
#endif
size_t xStreamBufferNextMessageLengthBytes( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION;