Revert Portable/Softune Formatting (#886)

* Revert formatting on Softune ports

* Fix spelling mistakes

---------

Co-authored-by: Rahul Kar <118818625+kar-rahul-aws@users.noreply.github.com>
Co-authored-by: Gaurav-Aggarwal-AWS <33462878+aggarg@users.noreply.github.com>
This commit is contained in:
Soren Ptak 2023-11-23 03:39:28 -08:00 committed by GitHub
parent 96cdeaa725
commit 92365c9784
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 326 additions and 336 deletions

View file

@ -1,6 +1,6 @@
/*
* FreeRTOS Kernel <DEVELOPMENT BRANCH>
* Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
* Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* SPDX-License-Identifier: MIT
*
@ -30,8 +30,8 @@
#include "task.h"
/*-----------------------------------------------------------
* Implementation of functions defined in portable.h for the 16FX port.
*----------------------------------------------------------*/
* Implementation of functions defined in portable.h for the 16FX port.
*----------------------------------------------------------*/
/*
* Get current value of DPR and ADB registers
@ -44,7 +44,7 @@ StackType_t xGet_DPR_ADB_bank( void );
StackType_t xGet_DTB_PCB_bank( void );
/*
* Sets up the periodic ISR used for the RTOS tick. This uses RLT0, but
* Sets up the periodic ISR used for the RTOS tick. This uses RLT0, but
* can be done using any given RLT.
*/
static void prvSetupRLT0Interrupt( void );
@ -61,164 +61,164 @@ extern volatile TCB_t * volatile pxCurrentTCB;
/*-----------------------------------------------------------*/
/*
* Macro to save a task context to the task stack. This macro copies the
* saved context (AH:AL, DPR:ADB, DTB:PCB , PC and PS) from the system
* stack to task stack pointed by user stack pointer ( USP for SMALL and
* MEDIUM memory model amd USB:USP for COMPACT and LARGE memory model ),
* then it pushes the general purpose registers RW0-RW7 on to the task
* stack. Finally the resultant stack pointer value is saved into the
* task control block so it can be retrieved the next time the task
* Macro to save a task context to the task stack. This macro copies the
* saved context (AH:AL, DPR:ADB, DTB:PCB , PC and PS) from the system
* stack to task stack pointed by user stack pointer ( USP for SMALL and
* MEDIUM memory model amd USB:USP for COMPACT and LARGE memory model ),
* then it pushes the general purpose registers RW0-RW7 on to the task
* stack. Finally the resultant stack pointer value is saved into the
* task control block so it can be retrieved the next time the task
* executes.
*/
#if ( ( configMEMMODEL == portSMALL ) || ( configMEMMODEL == portMEDIUM ) )
#if( ( configMEMMODEL == portSMALL ) || ( configMEMMODEL == portMEDIUM ) )
#define portSAVE_CONTEXT() \
{ __asm( " POPW A " ); \
__asm( " AND CCR,#H'DF " ); \
__asm( " PUSHW A " ); \
__asm( " OR CCR,#H'20 " ); \
__asm( " POPW A " ); \
__asm( " AND CCR,#H'DF " ); \
__asm( " PUSHW A " ); \
__asm( " OR CCR,#H'20 " ); \
__asm( " POPW A " ); \
__asm( " AND CCR,#H'DF " ); \
__asm( " PUSHW A " ); \
__asm( " OR CCR,#H'20 " ); \
__asm( " POPW A " ); \
__asm( " AND CCR,#H'DF " ); \
__asm( " PUSHW A " ); \
__asm( " OR CCR,#H'20 " ); \
__asm( " POPW A " ); \
__asm( " AND CCR,#H'DF " ); \
__asm( " PUSHW A " ); \
__asm( " OR CCR,#H'20 " ); \
__asm( " POPW A " ); \
__asm( " AND CCR,#H'DF " ); \
__asm( " PUSHW A " ); \
__asm( " PUSHW (RW0,RW1,RW2,RW3,RW4,RW5,RW6,RW7) " ); \
__asm( " MOVW A, _pxCurrentTCB " ); \
__asm( " MOVW A, SP " ); \
__asm( " SWAPW " ); \
__asm( " MOVW @AL, AH " ); \
__asm( " OR CCR,#H'20 " ); \
}
#define portSAVE_CONTEXT() \
{ __asm(" POPW A "); \
__asm(" AND CCR,#H'DF "); \
__asm(" PUSHW A "); \
__asm(" OR CCR,#H'20 "); \
__asm(" POPW A "); \
__asm(" AND CCR,#H'DF "); \
__asm(" PUSHW A "); \
__asm(" OR CCR,#H'20 "); \
__asm(" POPW A "); \
__asm(" AND CCR,#H'DF "); \
__asm(" PUSHW A "); \
__asm(" OR CCR,#H'20 "); \
__asm(" POPW A "); \
__asm(" AND CCR,#H'DF "); \
__asm(" PUSHW A "); \
__asm(" OR CCR,#H'20 "); \
__asm(" POPW A "); \
__asm(" AND CCR,#H'DF "); \
__asm(" PUSHW A "); \
__asm(" OR CCR,#H'20 "); \
__asm(" POPW A "); \
__asm(" AND CCR,#H'DF "); \
__asm(" PUSHW A "); \
__asm(" PUSHW (RW0,RW1,RW2,RW3,RW4,RW5,RW6,RW7) "); \
__asm(" MOVW A, _pxCurrentTCB "); \
__asm(" MOVW A, SP "); \
__asm(" SWAPW "); \
__asm(" MOVW @AL, AH "); \
__asm(" OR CCR,#H'20 "); \
}
/*
* Macro to restore a task context from the task stack. This is
* effectively the reverse of SAVE_CONTEXT(). First the stack pointer
* value (USP for SMALL and MEDIUM memory model amd USB:USP for COMPACT
* and LARGE memory model ) is loaded from the task control block. Next the
* value of all the general purpose registers RW0-RW7 is retrieved.
* and LARGE memory model ) is loaded from the task control block. Next
* the value of all the general purpose registers RW0-RW7 is retrieved.
* Finally it copies of the context ( AH:AL, DPR:ADB, DTB:PCB, PC and PS)
* of the task to be executed upon RETI from user stack to system stack.
*/
#define portRESTORE_CONTEXT() \
{ __asm( " MOVW A, _pxCurrentTCB " ); \
__asm( " MOVW A, @A " ); \
__asm( " AND CCR,#H'DF " ); \
__asm( " MOVW SP, A " ); \
__asm( " POPW (RW0,RW1,RW2,RW3,RW4,RW5,RW6,RW7) " ); \
__asm( " POPW A " ); \
__asm( " OR CCR,#H'20 " ); \
__asm( " PUSHW A " ); \
__asm( " AND CCR,#H'DF " ); \
__asm( " POPW A " ); \
__asm( " OR CCR,#H'20 " ); \
__asm( " PUSHW A " ); \
__asm( " AND CCR,#H'DF " ); \
__asm( " POPW A " ); \
__asm( " OR CCR,#H'20 " ); \
__asm( " PUSHW A " ); \
__asm( " AND CCR,#H'DF " ); \
__asm( " POPW A " ); \
__asm( " OR CCR,#H'20 " ); \
__asm( " PUSHW A " ); \
__asm( " AND CCR,#H'DF " ); \
__asm( " POPW A " ); \
__asm( " OR CCR,#H'20 " ); \
__asm( " PUSHW A " ); \
__asm( " AND CCR,#H'DF " ); \
__asm( " POPW A " ); \
__asm( " OR CCR,#H'20 " ); \
__asm( " PUSHW A " ); \
}
#define portRESTORE_CONTEXT() \
{ __asm(" MOVW A, _pxCurrentTCB "); \
__asm(" MOVW A, @A "); \
__asm(" AND CCR,#H'DF "); \
__asm(" MOVW SP, A "); \
__asm(" POPW (RW0,RW1,RW2,RW3,RW4,RW5,RW6,RW7) "); \
__asm(" POPW A "); \
__asm(" OR CCR,#H'20 "); \
__asm(" PUSHW A "); \
__asm(" AND CCR,#H'DF "); \
__asm(" POPW A "); \
__asm(" OR CCR,#H'20 "); \
__asm(" PUSHW A "); \
__asm(" AND CCR,#H'DF "); \
__asm(" POPW A "); \
__asm(" OR CCR,#H'20 "); \
__asm(" PUSHW A "); \
__asm(" AND CCR,#H'DF "); \
__asm(" POPW A "); \
__asm(" OR CCR,#H'20 "); \
__asm(" PUSHW A "); \
__asm(" AND CCR,#H'DF "); \
__asm(" POPW A "); \
__asm(" OR CCR,#H'20 "); \
__asm(" PUSHW A "); \
__asm(" AND CCR,#H'DF "); \
__asm(" POPW A "); \
__asm(" OR CCR,#H'20 "); \
__asm(" PUSHW A "); \
}
#elif ( ( configMEMMODEL == portCOMPACT ) || ( configMEMMODEL == portLARGE ) )
#elif( ( configMEMMODEL == portCOMPACT ) || ( configMEMMODEL == portLARGE ) )
#define portSAVE_CONTEXT() \
{ __asm( " POPW A " ); \
__asm( " AND CCR,#H'DF " ); \
__asm( " PUSHW A " ); \
__asm( " OR CCR,#H'20 " ); \
__asm( " POPW A " ); \
__asm( " AND CCR,#H'DF " ); \
__asm( " PUSHW A " ); \
__asm( " OR CCR,#H'20 " ); \
__asm( " POPW A " ); \
__asm( " AND CCR,#H'DF " ); \
__asm( " PUSHW A " ); \
__asm( " OR CCR,#H'20 " ); \
__asm( " POPW A " ); \
__asm( " AND CCR,#H'DF " ); \
__asm( " PUSHW A " ); \
__asm( " OR CCR,#H'20 " ); \
__asm( " POPW A " ); \
__asm( " AND CCR,#H'DF " ); \
__asm( " PUSHW A " ); \
__asm( " OR CCR,#H'20 " ); \
__asm( " POPW A " ); \
__asm( " AND CCR,#H'DF " ); \
__asm( " PUSHW A " ); \
__asm( " PUSHW (RW0,RW1,RW2,RW3,RW4,RW5,RW6,RW7) " ); \
__asm( " MOVL A, _pxCurrentTCB " ); \
__asm( " MOVL RL2, A " ); \
__asm( " MOVW A, SP " ); \
__asm( " MOVW @RL2+0, A " ); \
__asm( " MOV A, USB " ); \
__asm( " MOV @RL2+2, A " ); \
}
#define portSAVE_CONTEXT() \
{ __asm(" POPW A "); \
__asm(" AND CCR,#H'DF "); \
__asm(" PUSHW A "); \
__asm(" OR CCR,#H'20 "); \
__asm(" POPW A "); \
__asm(" AND CCR,#H'DF "); \
__asm(" PUSHW A "); \
__asm(" OR CCR,#H'20 "); \
__asm(" POPW A "); \
__asm(" AND CCR,#H'DF "); \
__asm(" PUSHW A "); \
__asm(" OR CCR,#H'20 "); \
__asm(" POPW A "); \
__asm(" AND CCR,#H'DF "); \
__asm(" PUSHW A "); \
__asm(" OR CCR,#H'20 "); \
__asm(" POPW A "); \
__asm(" AND CCR,#H'DF "); \
__asm(" PUSHW A "); \
__asm(" OR CCR,#H'20 "); \
__asm(" POPW A "); \
__asm(" AND CCR,#H'DF "); \
__asm(" PUSHW A "); \
__asm(" PUSHW (RW0,RW1,RW2,RW3,RW4,RW5,RW6,RW7) "); \
__asm(" MOVL A, _pxCurrentTCB "); \
__asm(" MOVL RL2, A "); \
__asm(" MOVW A, SP "); \
__asm(" MOVW @RL2+0, A "); \
__asm(" MOV A, USB "); \
__asm(" MOV @RL2+2, A "); \
}
#define portRESTORE_CONTEXT() \
{ __asm( " MOVL A, _pxCurrentTCB " ); \
__asm( " MOVL RL2, A " ); \
__asm( " MOVW A, @RL2+0 " ); \
__asm( " AND CCR,#H'DF " ); \
__asm( " MOVW SP, A " ); \
__asm( " MOV A, @RL2+2 " ); \
__asm( " MOV USB, A " ); \
__asm( " POPW (RW0,RW1,RW2,RW3,RW4,RW5,RW6,RW7) " ); \
__asm( " POPW A " ); \
__asm( " OR CCR,#H'20 " ); \
__asm( " PUSHW A " ); \
__asm( " AND CCR,#H'DF " ); \
__asm( " POPW A " ); \
__asm( " OR CCR,#H'20 " ); \
__asm( " PUSHW A " ); \
__asm( " AND CCR,#H'DF " ); \
__asm( " POPW A " ); \
__asm( " OR CCR,#H'20 " ); \
__asm( " PUSHW A " ); \
__asm( " AND CCR,#H'DF " ); \
__asm( " POPW A " ); \
__asm( " OR CCR,#H'20 " ); \
__asm( " PUSHW A " ); \
__asm( " AND CCR,#H'DF " ); \
__asm( " POPW A " ); \
__asm( " OR CCR,#H'20 " ); \
__asm( " PUSHW A " ); \
__asm( " AND CCR,#H'DF " ); \
__asm( " POPW A " ); \
__asm( " OR CCR,#H'20 " ); \
__asm( " PUSHW A " ); \
}
#endif /* if ( ( configMEMMODEL == portSMALL ) || ( configMEMMODEL == portMEDIUM ) ) */
#define portRESTORE_CONTEXT() \
{ __asm(" MOVL A, _pxCurrentTCB "); \
__asm(" MOVL RL2, A "); \
__asm(" MOVW A, @RL2+0 "); \
__asm(" AND CCR,#H'DF "); \
__asm(" MOVW SP, A "); \
__asm(" MOV A, @RL2+2 "); \
__asm(" MOV USB, A "); \
__asm(" POPW (RW0,RW1,RW2,RW3,RW4,RW5,RW6,RW7) "); \
__asm(" POPW A "); \
__asm(" OR CCR,#H'20 "); \
__asm(" PUSHW A "); \
__asm(" AND CCR,#H'DF "); \
__asm(" POPW A "); \
__asm(" OR CCR,#H'20 "); \
__asm(" PUSHW A "); \
__asm(" AND CCR,#H'DF "); \
__asm(" POPW A "); \
__asm(" OR CCR,#H'20 "); \
__asm(" PUSHW A "); \
__asm(" AND CCR,#H'DF "); \
__asm(" POPW A "); \
__asm(" OR CCR,#H'20 "); \
__asm(" PUSHW A "); \
__asm(" AND CCR,#H'DF "); \
__asm(" POPW A "); \
__asm(" OR CCR,#H'20 "); \
__asm(" PUSHW A "); \
__asm(" AND CCR,#H'DF "); \
__asm(" POPW A "); \
__asm(" OR CCR,#H'20 "); \
__asm(" PUSHW A "); \
}
#endif
/*-----------------------------------------------------------*/
/*
* Functions for obtaining the current value of DPR:ADB, DTB:PCB bank registers
* Functions for obtaining the current value of DPR:ADB, DTB:PCB bank registers
*/
#pragma asm
@ -261,12 +261,10 @@ _xGet_DTB_PCB_bank:
*
* See the header file portable.h.
*/
StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack,
TaskFunction_t pxCode,
void * pvParameters )
StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters )
{
/* Place a few bytes of known values on the bottom of the stack.
* This is just useful for debugging. */
This is just useful for debugging. */
*pxTopOfStack = 0x1111;
pxTopOfStack--;
*pxTopOfStack = 0x2222;
@ -274,12 +272,12 @@ StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack,
*pxTopOfStack = 0x3333;
pxTopOfStack--;
/* Once the task is called the task would push the pointer to the
* parameter onto the stack. Hence here the pointer would be copied to the stack
* first. When using the COMPACT or LARGE memory model the pointer would be 24
* bits, and when using the SMALL or MEDIUM memory model the pointer would be 16
* bits. */
#if ( ( configMEMMODEL == portCOMPACT ) || ( configMEMMODEL == portLARGE ) )
/* Once the task is called the task would push the pointer to the
parameter onto the stack. Hence here the pointer would be copied to the stack
first. When using the COMPACT or LARGE memory model the pointer would be 24
bits, and when using the SMALL or MEDIUM memory model the pointer would be 16
bits. */
#if( ( configMEMMODEL == portCOMPACT ) || ( configMEMMODEL == portLARGE ) )
{
*pxTopOfStack = ( StackType_t ) ( ( uint32_t ) ( pvParameters ) >> 16 );
pxTopOfStack--;
@ -290,9 +288,9 @@ StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack,
pxTopOfStack--;
/* This is redundant push to the stack. This is required in order to introduce
* an offset so that the task accesses a parameter correctly that is passed on to
* the task stack. */
#if ( ( configMEMMODEL == portMEDIUM ) || ( configMEMMODEL == portLARGE ) )
an offset so that the task accesses a parameter correctly that is passed on to
the task stack. */
#if( ( configMEMMODEL == portMEDIUM ) || ( configMEMMODEL == portLARGE ) )
{
*pxTopOfStack = ( xGet_DTB_PCB_bank() & 0xff00 ) | ( ( ( int32_t ) ( pxCode ) >> 16 ) & 0xff );
pxTopOfStack--;
@ -300,7 +298,7 @@ StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack,
#endif
/* This is redundant push to the stack. This is required in order to introduce
* an offset so the task correctly accesses the parameter passed on the task stack. */
an offset so the task correctly accesses the parameter passed on the task stack. */
*pxTopOfStack = ( StackType_t ) ( pxCode );
pxTopOfStack--;
@ -321,15 +319,15 @@ StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack,
#endif
/* DTB | PCB, in case of MEDIUM and LARGE memory models, PCB would be used
* along with PC to indicate the start address of the function. */
#if ( ( configMEMMODEL == portMEDIUM ) || ( configMEMMODEL == portLARGE ) )
along with PC to indicate the start address of the function. */
#if( ( configMEMMODEL == portMEDIUM ) || ( configMEMMODEL == portLARGE ) )
{
*pxTopOfStack = ( xGet_DTB_PCB_bank() & 0xff00 ) | ( ( ( int32_t ) ( pxCode ) >> 16 ) & 0xff );
pxTopOfStack--;
}
#endif
/* DPR | ADB */
/* DPR | ADB */
*pxTopOfStack = xGet_DPR_ADB_bank();
pxTopOfStack--;
@ -365,7 +363,7 @@ StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack,
static void prvSetupRLT0Interrupt( void )
{
/* The peripheral clock divided by 16 is used by the timer. */
const uint16_t usReloadValue = ( uint16_t ) ( ( ( configCLKP1_CLOCK_HZ / configTICK_RATE_HZ ) / 16UL ) - 1UL );
const uint16_t usReloadValue = ( uint16_t ) ( ( ( configCLKP1_CLOCK_HZ / configTICK_RATE_HZ ) / 16UL ) - 1UL );
/* set reload value = 34999+1, TICK Interrupt after 10 ms @ 56MHz of CLKP1 */
TMRLR0 = usReloadValue;
@ -383,9 +381,9 @@ BaseType_t xPortStartScheduler( void )
/* Restore the context of the first task that is going to run. */
portRESTORE_CONTEXT();
/* Simulate a function call end as generated by the compiler. We will now
* jump to the start of the task the context of which we have just restored. */
__asm( " reti " );
/* Simulate a function call end as generated by the compiler. We will now
jump to the start of the task the context of which we have just restored. */
__asm(" reti ");
/* Should not get here. */
@ -396,7 +394,7 @@ BaseType_t xPortStartScheduler( void )
void vPortEndScheduler( void )
{
/* Not implemented - unlikely to ever be required as there is nothing to
* return to. */
return to. */
}
/*-----------------------------------------------------------*/
@ -408,12 +406,12 @@ void vPortEndScheduler( void )
#if configUSE_PREEMPTION == 1
/*
* Tick ISR for preemptive scheduler. We can use a __nosavereg attribute
* as the context is to be saved by the portSAVE_CONTEXT() macro, not the
* compiler generated code. The tick count is incremented after the context
* is saved.
*/
/*
* Tick ISR for preemptive scheduler. We can use a __nosavereg attribute
* as the context is to be saved by the portSAVE_CONTEXT() macro, not the
* compiler generated code. The tick count is incremented after the context
* is saved.
*/
__nosavereg __interrupt void prvRLT0_TICKISR( void )
{
/* Disable interrupts so that portSAVE_CONTEXT() is not interrupted */
@ -429,7 +427,7 @@ void vPortEndScheduler( void )
TMCSR0_UF = 0;
/* Increment the tick count then switch to the highest priority task
* that is ready to run. */
that is ready to run. */
if( xTaskIncrementTick() != pdFALSE )
{
vTaskSwitchContext();
@ -445,13 +443,13 @@ void vPortEndScheduler( void )
__EI();
}
#else /* if configUSE_PREEMPTION == 1 */
#else
/*
* Tick ISR for the cooperative scheduler. All this does is increment the
* tick count. We don't need to switch context, this can only be done by
* manual calls to taskYIELD();
*/
/*
* Tick ISR for the cooperative scheduler. All this does is increment the
* tick count. We don't need to switch context, this can only be done by
* manual calls to taskYIELD();
*/
__interrupt void prvRLT0_TICKISR( void )
{
/* Clear RLT0 interrupt flag */
@ -460,12 +458,12 @@ void vPortEndScheduler( void )
xTaskIncrementTick();
}
#endif /* if configUSE_PREEMPTION == 1 */
#endif
/*-----------------------------------------------------------*/
/*
* Manual context switch. We can use a __nosavereg attribute as the context
* Manual context switch. We can use a __nosavereg attribute as the context
* is to be saved by the portSAVE_CONTEXT() macro, not the compiler generated
* code.
*/
@ -494,7 +492,7 @@ __nosavereg __interrupt void vPortYieldDelayed( void )
__EI();
/* Clear delayed interrupt flag */
__asm( " CLRB 03A4H:0 " );
__asm (" CLRB 03A4H:0 ");
/* Switch to the highest priority task that is ready to run. */
vTaskSwitchContext();