Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
dawood87 committed Oct 19, 2021
2 parents 647b786 + d649a77 commit 553cc57
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
21 changes: 21 additions & 0 deletions portable/GCC/ARM_CA53_64_BIT_SRE/portASM.S
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,14 @@ vPortRestoreTaskContext:

/******************************************************************************
* FreeRTOS_IRQ_Handler handles IRQ entry and exit.
* This handler is supposed to be used only for IRQs and never for FIQs. Per ARM
* GIC documentation [1], Group 0 interrupts are always signaled as FIQs. Since
* this handler is only for IRQs, We can safely assume Group 1 while accessing
* Interrupt Acknowledge and End Of Interrupt registers and therefore, use
* ICC_IAR1_EL1 and ICC_EOIR1_EL1.
*
* [1] https://developer.arm.com/documentation/198123/0300/Arm-CoreLink-GIC-fundamentals
*****************************************************************************/
.align 8
.type FreeRTOS_IRQ_Handler, %function
Expand Down Expand Up @@ -303,6 +311,13 @@ FreeRTOS_IRQ_Handler:
/* Maintain the interrupt nesting information across the function call. */
STP X1, X5, [SP, #-0x10]!

/* Read interrupt ID from the interrupt acknowledge register and store it
in X0 for future parameter and interrupt clearing use. */
MRS X0, S3_0_C12_C12_0 /* S3_0_C12_C12_0 is ICC_IAR1_EL1. */

/* Maintain the interrupt ID value across the function call. */
STP X0, X1, [SP, #-0x10]!

/* Call the C handler. */
BL vApplicationIRQHandler

Expand All @@ -311,6 +326,12 @@ FreeRTOS_IRQ_Handler:
DSB SY
ISB SY

/* Restore the interrupt ID value. */
LDP X0, X1, [SP], #0x10

/* End IRQ processing by writing interrupt ID value to the EOI register. */
MSR S3_0_C12_C12_1, X0 /* S3_0_C12_C12_1 is ICC_EOIR1_EL1. */

/* Restore the critical nesting count. */
LDP X1, X5, [SP], #0x10
STR X1, [X5]
Expand Down
9 changes: 8 additions & 1 deletion stream_buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -728,17 +728,24 @@ static size_t prvWriteMessageToBuffer( StreamBuffer_t * const pxStreamBuffer,
size_t xRequiredSpace )
{
size_t xNextHead = pxStreamBuffer->xHead;
configMESSAGE_BUFFER_LENGTH_TYPE xMessageLength;

if( ( pxStreamBuffer->ucFlags & sbFLAGS_IS_MESSAGE_BUFFER ) != ( uint8_t ) 0 )
{
/* This is a message buffer, as opposed to a stream buffer. */

/* Convert xDataLengthBytes to the message length type. */
xMessageLength = ( configMESSAGE_BUFFER_LENGTH_TYPE ) xDataLengthBytes;

/* Ensure the data length given fits within configMESSAGE_BUFFER_LENGTH_TYPE. */
configASSERT( ( size_t ) xMessageLength == xDataLengthBytes );

if( xSpace >= xRequiredSpace )
{
/* There is enough space to write both the message length and the message
* itself into the buffer. Start by writing the length of the data, the data
* itself will be written later in this function. */
xNextHead = prvWriteBytesToBuffer( pxStreamBuffer, ( const uint8_t * ) &( xDataLengthBytes ), sbBYTES_TO_STORE_MESSAGE_LENGTH, xNextHead );
xNextHead = prvWriteBytesToBuffer( pxStreamBuffer, ( const uint8_t * ) &( xMessageLength ), sbBYTES_TO_STORE_MESSAGE_LENGTH, xNextHead );
}
else
{
Expand Down

0 comments on commit 553cc57

Please sign in to comment.