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

@ -30,29 +30,26 @@
/* MICROELECTRONICS ACCEPTS NO RESPONSIBILITY OR LIABILITY FOR ANY ERRORS OR */ /* MICROELECTRONICS ACCEPTS NO RESPONSIBILITY OR LIABILITY FOR ANY ERRORS OR */
/* ELIGIBILITY FOR ANY PURPOSES. */ /* ELIGIBILITY FOR ANY PURPOSES. */
/* (C) Fujitsu Microelectronics Europe GmbH */ /* (C) Fujitsu Microelectronics Europe GmbH */
/*--------------------------------------------------------------------------- /*---------------------------------------------------------------------------
* __STD_LIB_sbrk.C __STD_LIB_sbrk.C
* - Used by heap_3.c for memory allocation and deletion. - Used by heap_3.c for memory allocation and deletion.
*
* /*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
#include "FreeRTOSConfig.h" #include "FreeRTOSConfig.h"
#include <stdlib.h> #include <stdlib.h>
static long brk_siz = 0; static long brk_siz = 0;
typedef int _heep_t; typedef int _heep_t;
#define ROUNDUP( s ) ( ( ( s ) + sizeof( _heep_t ) - 1 ) & ~( sizeof( _heep_t ) - 1 ) ) #define ROUNDUP(s) (((s)+sizeof(_heep_t)-1)&~(sizeof(_heep_t)-1))
static _heep_t _heep[ ROUNDUP( configTOTAL_HEAP_SIZE ) / sizeof( _heep_t ) ]; static _heep_t _heep[ROUNDUP(configTOTAL_HEAP_SIZE)/sizeof(_heep_t)];
#define _heep_size ROUNDUP( configTOTAL_HEAP_SIZE ) #define _heep_size ROUNDUP(configTOTAL_HEAP_SIZE)
extern char * sbrk( int size ) extern char *sbrk(int size)
{
if( ( brk_siz + size > _heep_size ) || ( brk_siz + size < 0 ) )
{ {
return( ( char * ) -1 ); if (brk_siz + size > _heep_size || brk_siz + size < 0)
}
return((char*)-1);
brk_siz += size; brk_siz += size;
return( ( char * ) _heep + brk_siz - size ); return( (char*)_heep + brk_siz - size);
} }

View file

@ -33,7 +33,7 @@
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
/* We require the address of the pxCurrentTCB variable, but don't want to know /* We require the address of the pxCurrentTCB variable, but don't want to know
* any details of its type. */ any details of its type. */
typedef void TCB_t; typedef void TCB_t;
extern volatile TCB_t * volatile pxCurrentTCB; extern volatile TCB_t * volatile pxCurrentTCB;
@ -106,12 +106,10 @@ static void prvSetupTimerInterrupt( void );
* *
* See the header file portable.h. * See the header file portable.h.
*/ */
StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack, StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters )
TaskFunction_t pxCode,
void * pvParameters )
{ {
/* Place a few bytes of known values on the bottom of the stack. /* 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 = 0x11111111; *pxTopOfStack = 0x11111111;
pxTopOfStack--; pxTopOfStack--;
@ -121,9 +119,9 @@ StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack,
pxTopOfStack--; pxTopOfStack--;
/* This is a redundant push to the stack, it may be required if /* This is a redundant push to the stack, it may be required if
* in some implementations of the compiler the parameter to the task in some implementations of the compiler the parameter to the task
* is passed on to the stack rather than in R4 register. */ is passed on to the stack rather than in R4 register. */
*pxTopOfStack = ( StackType_t ) ( pvParameters ); *pxTopOfStack = (StackType_t)(pvParameters);
pxTopOfStack--; pxTopOfStack--;
*pxTopOfStack = ( StackType_t ) 0x00000000; /* RP */ *pxTopOfStack = ( StackType_t ) 0x00000000; /* RP */
@ -136,10 +134,10 @@ StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack,
pxTopOfStack--; pxTopOfStack--;
/* In the current implementation of the compiler the first /* In the current implementation of the compiler the first
* parameter to the task (or function) is passed via R4 parameter parameter to the task (or function) is passed via R4 parameter
* to the task, hence the pvParameters pointer is copied into the R4 to the task, hence the pvParameters pointer is copied into the R4
* register. See compiler manual section 4.6.2 for more information. */ register. See compiler manual section 4.6.2 for more information. */
*pxTopOfStack = ( StackType_t ) ( pvParameters ); /* R4 */ *pxTopOfStack = ( StackType_t ) (pvParameters); /* R4 */
pxTopOfStack--; pxTopOfStack--;
*pxTopOfStack = ( StackType_t ) 0x00003333; /* R3 */ *pxTopOfStack = ( StackType_t ) 0x00003333; /* R3 */
pxTopOfStack--; pxTopOfStack--;
@ -190,8 +188,8 @@ BaseType_t xPortStartScheduler( void )
#pragma endasm #pragma endasm
/* Simulate a function call end as generated by the compiler. We will now /* 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. */ jump to the start of the task the context of which we have just restored. */
__asm( " reti " ); __asm(" reti ");
/* Should not get here. */ /* Should not get here. */
return pdFAIL; return pdFAIL;
@ -201,14 +199,14 @@ BaseType_t xPortStartScheduler( void )
void vPortEndScheduler( void ) void vPortEndScheduler( void )
{ {
/* Not implemented - unlikely to ever be required as there is nothing to /* Not implemented - unlikely to ever be required as there is nothing to
* return to. */ return to. */
} }
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
static void prvSetupTimerInterrupt( void ) static void prvSetupTimerInterrupt( void )
{ {
/* The peripheral clock divided by 32 is used by the timer. */ /* The peripheral clock divided by 32 is used by the timer. */
const uint16_t usReloadValue = ( uint16_t ) ( ( ( configPER_CLOCK_HZ / configTICK_RATE_HZ ) / 32UL ) - 1UL ); const uint16_t usReloadValue = ( uint16_t ) ( ( ( configPER_CLOCK_HZ / configTICK_RATE_HZ ) / 32UL ) - 1UL );
/* Setup RLT0 to generate a tick interrupt. */ /* Setup RLT0 to generate a tick interrupt. */
@ -229,7 +227,7 @@ static void prvSetupTimerInterrupt( void )
#if configUSE_PREEMPTION == 1 #if configUSE_PREEMPTION == 1
/* /*
* Tick ISR for preemptive scheduler. The tick count is incremented * Tick ISR for preemptive scheduler. The tick count is incremented
* after the context is saved. Then the context is switched if required, * after the context is saved. Then the context is switched if required,
* and last the context of the task which is to be resumed is restored. * and last the context of the task which is to be resumed is restored.
@ -259,9 +257,9 @@ static void prvSetupTimerInterrupt( void )
#pragma endasm #pragma endasm
#else /* if configUSE_PREEMPTION == 1 */ #else
/* /*
* Tick ISR for the cooperative scheduler. All this does is increment the * 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 * tick count. We don't need to switch context, this can only be done by
* manual calls to taskYIELD(); * manual calls to taskYIELD();
@ -273,7 +271,7 @@ static void prvSetupTimerInterrupt( void )
xTaskIncrementTick(); 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

View file

@ -59,7 +59,7 @@ typedef long BaseType_t;
typedef unsigned long UBaseType_t; typedef unsigned long UBaseType_t;
#if ( configTICK_TYPE_WIDTH_IN_BITS == TICK_TYPE_WIDTH_16_BITS ) #if( configTICK_TYPE_WIDTH_IN_BITS == TICK_TYPE_WIDTH_16_BITS )
typedef uint16_t TickType_t; typedef uint16_t TickType_t;
#define portMAX_DELAY ( TickType_t ) 0xffff #define portMAX_DELAY ( TickType_t ) 0xffff
#elif ( configTICK_TYPE_WIDTH_IN_BITS == TICK_TYPE_WIDTH_32_BITS ) #elif ( configTICK_TYPE_WIDTH_IN_BITS == TICK_TYPE_WIDTH_32_BITS )
@ -74,16 +74,16 @@ typedef unsigned long UBaseType_t;
#if configKERNEL_INTERRUPT_PRIORITY != 30 #if configKERNEL_INTERRUPT_PRIORITY != 30
#error configKERNEL_INTERRUPT_PRIORITY (set in FreeRTOSConfig.h) must match the ILM value set in the following line - 30 (1Eh) being the default. #error configKERNEL_INTERRUPT_PRIORITY (set in FreeRTOSConfig.h) must match the ILM value set in the following line - 30 (1Eh) being the default.
#endif #endif
#define portDISABLE_INTERRUPTS() __asm( " STILM #1Eh " ) #define portDISABLE_INTERRUPTS() __asm(" STILM #1Eh ")
#define portENABLE_INTERRUPTS() __asm( " STILM #1Fh " ) #define portENABLE_INTERRUPTS() __asm(" STILM #1Fh ")
#define portENTER_CRITICAL() \ #define portENTER_CRITICAL() \
__asm( " ST PS,@-R15 " ); \ __asm(" ST PS,@-R15 "); \
__asm( " ANDCCR #0xef " ); \ __asm(" ANDCCR #0xef "); \
#define portEXIT_CRITICAL() \ #define portEXIT_CRITICAL() \
__asm( " LD @R15+,PS " ); \ __asm(" LD @R15+,PS "); \
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
@ -102,8 +102,8 @@ typedef unsigned long UBaseType_t;
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
/* Task function macros as described on the FreeRTOS.org WEB site. */ /* Task function macros as described on the FreeRTOS.org WEB site. */
#define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void * pvParameters ) #define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void *pvParameters )
#define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void * pvParameters ) #define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void *pvParameters )
#define portMINIMAL_STACK_SIZE configMINIMAL_STACK_SIZE #define portMINIMAL_STACK_SIZE configMINIMAL_STACK_SIZE

View file

@ -30,29 +30,26 @@
/* MICROELECTRONICS ACCEPTS NO RESPONSIBILITY OR LIABILITY FOR ANY ERRORS OR */ /* MICROELECTRONICS ACCEPTS NO RESPONSIBILITY OR LIABILITY FOR ANY ERRORS OR */
/* ELIGIBILITY FOR ANY PURPOSES. */ /* ELIGIBILITY FOR ANY PURPOSES. */
/* (C) Fujitsu Microelectronics Europe GmbH */ /* (C) Fujitsu Microelectronics Europe GmbH */
/*--------------------------------------------------------------------------- /*---------------------------------------------------------------------------
* __STD_LIB_sbrk.C __STD_LIB_sbrk.C
* - Used by heap_3.c for memory allocation and deletion. - Used by heap_3.c for memory allocation and deletion.
*
* /*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
#include "FreeRTOSConfig.h" #include "FreeRTOSConfig.h"
#include <stdlib.h> #include <stdlib.h>
static long brk_siz = 0; static long brk_siz = 0;
typedef int _heep_t; typedef int _heep_t;
#define ROUNDUP( s ) ( ( ( s ) + sizeof( _heep_t ) - 1 ) & ~( sizeof( _heep_t ) - 1 ) ) #define ROUNDUP(s) (((s)+sizeof(_heep_t)-1)&~(sizeof(_heep_t)-1))
static _heep_t _heep[ ROUNDUP( configTOTAL_HEAP_SIZE ) / sizeof( _heep_t ) ]; static _heep_t _heep[ROUNDUP(configTOTAL_HEAP_SIZE)/sizeof(_heep_t)];
#define _heep_size ROUNDUP( configTOTAL_HEAP_SIZE ) #define _heep_size ROUNDUP(configTOTAL_HEAP_SIZE)
extern char * sbrk( int size ) extern char *sbrk(int size)
{
if( ( brk_siz + size > _heep_size ) || ( brk_siz + size < 0 ) )
{ {
return( ( char * ) -1 ); if (brk_siz + size > _heep_size || brk_siz + size < 0)
}
return((char*)-1);
brk_siz += size; brk_siz += size;
return( ( char * ) _heep + brk_siz - size ); return( (char*)_heep + brk_siz - size);
} }

View file

@ -30,8 +30,8 @@
#include "task.h" #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 * Get current value of DPR and ADB registers
@ -70,150 +70,150 @@ extern volatile TCB_t * volatile pxCurrentTCB;
* task control block so it can be retrieved the next time the task * task control block so it can be retrieved the next time the task
* executes. * executes.
*/ */
#if ( ( configMEMMODEL == portSMALL ) || ( configMEMMODEL == portMEDIUM ) ) #if( ( configMEMMODEL == portSMALL ) || ( configMEMMODEL == portMEDIUM ) )
#define portSAVE_CONTEXT() \ #define portSAVE_CONTEXT() \
{ __asm( " POPW A " ); \ { __asm(" POPW A "); \
__asm( " AND CCR,#H'DF " ); \ __asm(" AND CCR,#H'DF "); \
__asm( " PUSHW A " ); \ __asm(" PUSHW A "); \
__asm( " OR CCR,#H'20 " ); \ __asm(" OR CCR,#H'20 "); \
__asm( " POPW A " ); \ __asm(" POPW A "); \
__asm( " AND CCR,#H'DF " ); \ __asm(" AND CCR,#H'DF "); \
__asm( " PUSHW A " ); \ __asm(" PUSHW A "); \
__asm( " OR CCR,#H'20 " ); \ __asm(" OR CCR,#H'20 "); \
__asm( " POPW A " ); \ __asm(" POPW A "); \
__asm( " AND CCR,#H'DF " ); \ __asm(" AND CCR,#H'DF "); \
__asm( " PUSHW A " ); \ __asm(" PUSHW A "); \
__asm( " OR CCR,#H'20 " ); \ __asm(" OR CCR,#H'20 "); \
__asm( " POPW A " ); \ __asm(" POPW A "); \
__asm( " AND CCR,#H'DF " ); \ __asm(" AND CCR,#H'DF "); \
__asm( " PUSHW A " ); \ __asm(" PUSHW A "); \
__asm( " OR CCR,#H'20 " ); \ __asm(" OR CCR,#H'20 "); \
__asm( " POPW A " ); \ __asm(" POPW A "); \
__asm( " AND CCR,#H'DF " ); \ __asm(" AND CCR,#H'DF "); \
__asm( " PUSHW A " ); \ __asm(" PUSHW A "); \
__asm( " OR CCR,#H'20 " ); \ __asm(" OR CCR,#H'20 "); \
__asm( " POPW A " ); \ __asm(" POPW A "); \
__asm( " AND CCR,#H'DF " ); \ __asm(" AND CCR,#H'DF "); \
__asm( " PUSHW A " ); \ __asm(" PUSHW A "); \
__asm( " PUSHW (RW0,RW1,RW2,RW3,RW4,RW5,RW6,RW7) " ); \ __asm(" PUSHW (RW0,RW1,RW2,RW3,RW4,RW5,RW6,RW7) "); \
__asm( " MOVW A, _pxCurrentTCB " ); \ __asm(" MOVW A, _pxCurrentTCB "); \
__asm( " MOVW A, SP " ); \ __asm(" MOVW A, SP "); \
__asm( " SWAPW " ); \ __asm(" SWAPW "); \
__asm( " MOVW @AL, AH " ); \ __asm(" MOVW @AL, AH "); \
__asm( " OR CCR,#H'20 " ); \ __asm(" OR CCR,#H'20 "); \
} }
/* /*
* Macro to restore a task context from the task stack. This is * Macro to restore a task context from the task stack. This is
* effectively the reverse of SAVE_CONTEXT(). First the stack pointer * effectively the reverse of SAVE_CONTEXT(). First the stack pointer
* value (USP for SMALL and MEDIUM memory model amd USB:USP for COMPACT * 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 * and LARGE memory model ) is loaded from the task control block. Next
* value of all the general purpose registers RW0-RW7 is retrieved. * 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) * 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. * of the task to be executed upon RETI from user stack to system stack.
*/ */
#define portRESTORE_CONTEXT() \ #define portRESTORE_CONTEXT() \
{ __asm( " MOVW A, _pxCurrentTCB " ); \ { __asm(" MOVW A, _pxCurrentTCB "); \
__asm( " MOVW A, @A " ); \ __asm(" MOVW A, @A "); \
__asm( " AND CCR,#H'DF " ); \ __asm(" AND CCR,#H'DF "); \
__asm( " MOVW SP, A " ); \ __asm(" MOVW SP, A "); \
__asm( " POPW (RW0,RW1,RW2,RW3,RW4,RW5,RW6,RW7) " ); \ __asm(" POPW (RW0,RW1,RW2,RW3,RW4,RW5,RW6,RW7) "); \
__asm( " POPW A " ); \ __asm(" POPW A "); \
__asm( " OR CCR,#H'20 " ); \ __asm(" OR CCR,#H'20 "); \
__asm( " PUSHW A " ); \ __asm(" PUSHW A "); \
__asm( " AND CCR,#H'DF " ); \ __asm(" AND CCR,#H'DF "); \
__asm( " POPW A " ); \ __asm(" POPW A "); \
__asm( " OR CCR,#H'20 " ); \ __asm(" OR CCR,#H'20 "); \
__asm( " PUSHW A " ); \ __asm(" PUSHW A "); \
__asm( " AND CCR,#H'DF " ); \ __asm(" AND CCR,#H'DF "); \
__asm( " POPW A " ); \ __asm(" POPW A "); \
__asm( " OR CCR,#H'20 " ); \ __asm(" OR CCR,#H'20 "); \
__asm( " PUSHW A " ); \ __asm(" PUSHW A "); \
__asm( " AND CCR,#H'DF " ); \ __asm(" AND CCR,#H'DF "); \
__asm( " POPW A " ); \ __asm(" POPW A "); \
__asm( " OR CCR,#H'20 " ); \ __asm(" OR CCR,#H'20 "); \
__asm( " PUSHW A " ); \ __asm(" PUSHW A "); \
__asm( " AND CCR,#H'DF " ); \ __asm(" AND CCR,#H'DF "); \
__asm( " POPW A " ); \ __asm(" POPW A "); \
__asm( " OR CCR,#H'20 " ); \ __asm(" OR CCR,#H'20 "); \
__asm( " PUSHW A " ); \ __asm(" PUSHW A "); \
__asm( " AND CCR,#H'DF " ); \ __asm(" AND CCR,#H'DF "); \
__asm( " POPW A " ); \ __asm(" POPW A "); \
__asm( " OR CCR,#H'20 " ); \ __asm(" OR CCR,#H'20 "); \
__asm( " PUSHW A " ); \ __asm(" PUSHW A "); \
} }
#elif ( ( configMEMMODEL == portCOMPACT ) || ( configMEMMODEL == portLARGE ) ) #elif( ( configMEMMODEL == portCOMPACT ) || ( configMEMMODEL == portLARGE ) )
#define portSAVE_CONTEXT() \ #define portSAVE_CONTEXT() \
{ __asm( " POPW A " ); \ { __asm(" POPW A "); \
__asm( " AND CCR,#H'DF " ); \ __asm(" AND CCR,#H'DF "); \
__asm( " PUSHW A " ); \ __asm(" PUSHW A "); \
__asm( " OR CCR,#H'20 " ); \ __asm(" OR CCR,#H'20 "); \
__asm( " POPW A " ); \ __asm(" POPW A "); \
__asm( " AND CCR,#H'DF " ); \ __asm(" AND CCR,#H'DF "); \
__asm( " PUSHW A " ); \ __asm(" PUSHW A "); \
__asm( " OR CCR,#H'20 " ); \ __asm(" OR CCR,#H'20 "); \
__asm( " POPW A " ); \ __asm(" POPW A "); \
__asm( " AND CCR,#H'DF " ); \ __asm(" AND CCR,#H'DF "); \
__asm( " PUSHW A " ); \ __asm(" PUSHW A "); \
__asm( " OR CCR,#H'20 " ); \ __asm(" OR CCR,#H'20 "); \
__asm( " POPW A " ); \ __asm(" POPW A "); \
__asm( " AND CCR,#H'DF " ); \ __asm(" AND CCR,#H'DF "); \
__asm( " PUSHW A " ); \ __asm(" PUSHW A "); \
__asm( " OR CCR,#H'20 " ); \ __asm(" OR CCR,#H'20 "); \
__asm( " POPW A " ); \ __asm(" POPW A "); \
__asm( " AND CCR,#H'DF " ); \ __asm(" AND CCR,#H'DF "); \
__asm( " PUSHW A " ); \ __asm(" PUSHW A "); \
__asm( " OR CCR,#H'20 " ); \ __asm(" OR CCR,#H'20 "); \
__asm( " POPW A " ); \ __asm(" POPW A "); \
__asm( " AND CCR,#H'DF " ); \ __asm(" AND CCR,#H'DF "); \
__asm( " PUSHW A " ); \ __asm(" PUSHW A "); \
__asm( " PUSHW (RW0,RW1,RW2,RW3,RW4,RW5,RW6,RW7) " ); \ __asm(" PUSHW (RW0,RW1,RW2,RW3,RW4,RW5,RW6,RW7) "); \
__asm( " MOVL A, _pxCurrentTCB " ); \ __asm(" MOVL A, _pxCurrentTCB "); \
__asm( " MOVL RL2, A " ); \ __asm(" MOVL RL2, A "); \
__asm( " MOVW A, SP " ); \ __asm(" MOVW A, SP "); \
__asm( " MOVW @RL2+0, A " ); \ __asm(" MOVW @RL2+0, A "); \
__asm( " MOV A, USB " ); \ __asm(" MOV A, USB "); \
__asm( " MOV @RL2+2, A " ); \ __asm(" MOV @RL2+2, A "); \
} }
#define portRESTORE_CONTEXT() \ #define portRESTORE_CONTEXT() \
{ __asm( " MOVL A, _pxCurrentTCB " ); \ { __asm(" MOVL A, _pxCurrentTCB "); \
__asm( " MOVL RL2, A " ); \ __asm(" MOVL RL2, A "); \
__asm( " MOVW A, @RL2+0 " ); \ __asm(" MOVW A, @RL2+0 "); \
__asm( " AND CCR,#H'DF " ); \ __asm(" AND CCR,#H'DF "); \
__asm( " MOVW SP, A " ); \ __asm(" MOVW SP, A "); \
__asm( " MOV A, @RL2+2 " ); \ __asm(" MOV A, @RL2+2 "); \
__asm( " MOV USB, A " ); \ __asm(" MOV USB, A "); \
__asm( " POPW (RW0,RW1,RW2,RW3,RW4,RW5,RW6,RW7) " ); \ __asm(" POPW (RW0,RW1,RW2,RW3,RW4,RW5,RW6,RW7) "); \
__asm( " POPW A " ); \ __asm(" POPW A "); \
__asm( " OR CCR,#H'20 " ); \ __asm(" OR CCR,#H'20 "); \
__asm( " PUSHW A " ); \ __asm(" PUSHW A "); \
__asm( " AND CCR,#H'DF " ); \ __asm(" AND CCR,#H'DF "); \
__asm( " POPW A " ); \ __asm(" POPW A "); \
__asm( " OR CCR,#H'20 " ); \ __asm(" OR CCR,#H'20 "); \
__asm( " PUSHW A " ); \ __asm(" PUSHW A "); \
__asm( " AND CCR,#H'DF " ); \ __asm(" AND CCR,#H'DF "); \
__asm( " POPW A " ); \ __asm(" POPW A "); \
__asm( " OR CCR,#H'20 " ); \ __asm(" OR CCR,#H'20 "); \
__asm( " PUSHW A " ); \ __asm(" PUSHW A "); \
__asm( " AND CCR,#H'DF " ); \ __asm(" AND CCR,#H'DF "); \
__asm( " POPW A " ); \ __asm(" POPW A "); \
__asm( " OR CCR,#H'20 " ); \ __asm(" OR CCR,#H'20 "); \
__asm( " PUSHW A " ); \ __asm(" PUSHW A "); \
__asm( " AND CCR,#H'DF " ); \ __asm(" AND CCR,#H'DF "); \
__asm( " POPW A " ); \ __asm(" POPW A "); \
__asm( " OR CCR,#H'20 " ); \ __asm(" OR CCR,#H'20 "); \
__asm( " PUSHW A " ); \ __asm(" PUSHW A "); \
__asm( " AND CCR,#H'DF " ); \ __asm(" AND CCR,#H'DF "); \
__asm( " POPW A " ); \ __asm(" POPW A "); \
__asm( " OR CCR,#H'20 " ); \ __asm(" OR CCR,#H'20 "); \
__asm( " PUSHW A " ); \ __asm(" PUSHW A "); \
} }
#endif /* if ( ( configMEMMODEL == portSMALL ) || ( configMEMMODEL == portMEDIUM ) ) */ #endif
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
@ -261,12 +261,10 @@ _xGet_DTB_PCB_bank:
* *
* See the header file portable.h. * See the header file portable.h.
*/ */
StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack, StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters )
TaskFunction_t pxCode,
void * pvParameters )
{ {
/* Place a few bytes of known values on the bottom of the stack. /* 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 = 0x1111;
pxTopOfStack--; pxTopOfStack--;
*pxTopOfStack = 0x2222; *pxTopOfStack = 0x2222;
@ -275,11 +273,11 @@ StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack,
pxTopOfStack--; pxTopOfStack--;
/* Once the task is called the task would push the pointer to the /* 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 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 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, and when using the SMALL or MEDIUM memory model the pointer would be 16
* bits. */ bits. */
#if ( ( configMEMMODEL == portCOMPACT ) || ( configMEMMODEL == portLARGE ) ) #if( ( configMEMMODEL == portCOMPACT ) || ( configMEMMODEL == portLARGE ) )
{ {
*pxTopOfStack = ( StackType_t ) ( ( uint32_t ) ( pvParameters ) >> 16 ); *pxTopOfStack = ( StackType_t ) ( ( uint32_t ) ( pvParameters ) >> 16 );
pxTopOfStack--; pxTopOfStack--;
@ -290,9 +288,9 @@ StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack,
pxTopOfStack--; pxTopOfStack--;
/* This is redundant push to the stack. This is required in order to introduce /* 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 an offset so that the task accesses a parameter correctly that is passed on to
* the task stack. */ the task stack. */
#if ( ( configMEMMODEL == portMEDIUM ) || ( configMEMMODEL == portLARGE ) ) #if( ( configMEMMODEL == portMEDIUM ) || ( configMEMMODEL == portLARGE ) )
{ {
*pxTopOfStack = ( xGet_DTB_PCB_bank() & 0xff00 ) | ( ( ( int32_t ) ( pxCode ) >> 16 ) & 0xff ); *pxTopOfStack = ( xGet_DTB_PCB_bank() & 0xff00 ) | ( ( ( int32_t ) ( pxCode ) >> 16 ) & 0xff );
pxTopOfStack--; pxTopOfStack--;
@ -300,7 +298,7 @@ StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack,
#endif #endif
/* This is redundant push to the stack. This is required in order to introduce /* 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 = ( StackType_t ) ( pxCode );
pxTopOfStack--; pxTopOfStack--;
@ -321,8 +319,8 @@ StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack,
#endif #endif
/* DTB | PCB, in case of MEDIUM and LARGE memory models, PCB would be used /* 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. */ along with PC to indicate the start address of the function. */
#if ( ( configMEMMODEL == portMEDIUM ) || ( configMEMMODEL == portLARGE ) ) #if( ( configMEMMODEL == portMEDIUM ) || ( configMEMMODEL == portLARGE ) )
{ {
*pxTopOfStack = ( xGet_DTB_PCB_bank() & 0xff00 ) | ( ( ( int32_t ) ( pxCode ) >> 16 ) & 0xff ); *pxTopOfStack = ( xGet_DTB_PCB_bank() & 0xff00 ) | ( ( ( int32_t ) ( pxCode ) >> 16 ) & 0xff );
pxTopOfStack--; pxTopOfStack--;
@ -365,7 +363,7 @@ StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack,
static void prvSetupRLT0Interrupt( void ) static void prvSetupRLT0Interrupt( void )
{ {
/* The peripheral clock divided by 16 is used by the timer. */ /* 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 */ /* set reload value = 34999+1, TICK Interrupt after 10 ms @ 56MHz of CLKP1 */
TMRLR0 = usReloadValue; TMRLR0 = usReloadValue;
@ -384,8 +382,8 @@ BaseType_t xPortStartScheduler( void )
portRESTORE_CONTEXT(); portRESTORE_CONTEXT();
/* Simulate a function call end as generated by the compiler. We will now /* 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. */ jump to the start of the task the context of which we have just restored. */
__asm( " reti " ); __asm(" reti ");
/* Should not get here. */ /* Should not get here. */
@ -396,7 +394,7 @@ BaseType_t xPortStartScheduler( void )
void vPortEndScheduler( void ) void vPortEndScheduler( void )
{ {
/* Not implemented - unlikely to ever be required as there is nothing to /* Not implemented - unlikely to ever be required as there is nothing to
* return to. */ return to. */
} }
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
@ -408,7 +406,7 @@ void vPortEndScheduler( void )
#if configUSE_PREEMPTION == 1 #if configUSE_PREEMPTION == 1
/* /*
* Tick ISR for preemptive scheduler. We can use a __nosavereg attribute * 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 * 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 * compiler generated code. The tick count is incremented after the context
@ -429,7 +427,7 @@ void vPortEndScheduler( void )
TMCSR0_UF = 0; TMCSR0_UF = 0;
/* Increment the tick count then switch to the highest priority task /* Increment the tick count then switch to the highest priority task
* that is ready to run. */ that is ready to run. */
if( xTaskIncrementTick() != pdFALSE ) if( xTaskIncrementTick() != pdFALSE )
{ {
vTaskSwitchContext(); vTaskSwitchContext();
@ -445,9 +443,9 @@ void vPortEndScheduler( void )
__EI(); __EI();
} }
#else /* if configUSE_PREEMPTION == 1 */ #else
/* /*
* Tick ISR for the cooperative scheduler. All this does is increment the * 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 * tick count. We don't need to switch context, this can only be done by
* manual calls to taskYIELD(); * manual calls to taskYIELD();
@ -460,7 +458,7 @@ void vPortEndScheduler( void )
xTaskIncrementTick(); xTaskIncrementTick();
} }
#endif /* if configUSE_PREEMPTION == 1 */ #endif
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
@ -494,7 +492,7 @@ __nosavereg __interrupt void vPortYieldDelayed( void )
__EI(); __EI();
/* Clear delayed interrupt flag */ /* Clear delayed interrupt flag */
__asm( " CLRB 03A4H:0 " ); __asm (" CLRB 03A4H:0 ");
/* Switch to the highest priority task that is ready to run. */ /* Switch to the highest priority task that is ready to run. */
vTaskSwitchContext(); vTaskSwitchContext();

View file

@ -34,7 +34,7 @@
#include <stddef.h> #include <stddef.h>
/* Constants denoting the available memory models. These are used within /* Constants denoting the available memory models. These are used within
* FreeRTOSConfig.h to set the configMEMMODEL value. */ FreeRTOSConfig.h to set the configMEMMODEL value. */
#define portSMALL 0 #define portSMALL 0
#define portMEDIUM 1 #define portMEDIUM 1
#define portCOMPACT 2 #define portCOMPACT 2
@ -65,7 +65,7 @@ typedef short BaseType_t;
typedef unsigned short UBaseType_t; typedef unsigned short UBaseType_t;
#if ( configTICK_TYPE_WIDTH_IN_BITS == TICK_TYPE_WIDTH_16_BITS ) #if( configTICK_TYPE_WIDTH_IN_BITS == TICK_TYPE_WIDTH_16_BITS )
typedef uint16_t TickType_t; typedef uint16_t TickType_t;
#define portMAX_DELAY ( TickType_t ) 0xffff #define portMAX_DELAY ( TickType_t ) 0xffff
#elif ( configTICK_TYPE_WIDTH_IN_BITS == TICK_TYPE_WIDTH_32_BITS ) #elif ( configTICK_TYPE_WIDTH_IN_BITS == TICK_TYPE_WIDTH_32_BITS )
@ -80,16 +80,16 @@ typedef unsigned short UBaseType_t;
#if configKERNEL_INTERRUPT_PRIORITY != 6 #if configKERNEL_INTERRUPT_PRIORITY != 6
#error configKERNEL_INTERRUPT_PRIORITY (set in FreeRTOSConfig.h) must match the ILM value set in the following line - #06H being the default. #error configKERNEL_INTERRUPT_PRIORITY (set in FreeRTOSConfig.h) must match the ILM value set in the following line - #06H being the default.
#endif #endif
#define portDISABLE_INTERRUPTS() __asm( " MOV ILM, #06h " ) #define portDISABLE_INTERRUPTS() __asm(" MOV ILM, #06h ")
#define portENABLE_INTERRUPTS() __asm( " MOV ILM, #07h " ) #define portENABLE_INTERRUPTS() __asm(" MOV ILM, #07h ")
#define portENTER_CRITICAL() \ #define portENTER_CRITICAL() \
{ __asm( " PUSHW PS " ); \ { __asm(" PUSHW PS "); \
portDISABLE_INTERRUPTS(); \ portDISABLE_INTERRUPTS(); \
} }
#define portEXIT_CRITICAL() \ #define portEXIT_CRITICAL() \
{ __asm( " POPW PS " ); \ { __asm(" POPW PS "); \
} }
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
@ -109,8 +109,8 @@ typedef unsigned short UBaseType_t;
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
/* Task function macros as described on the FreeRTOS.org WEB site. */ /* Task function macros as described on the FreeRTOS.org WEB site. */
#define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void * pvParameters ) #define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void *pvParameters )
#define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void * pvParameters ) #define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void *pvParameters )
#define portMINIMAL_STACK_SIZE configMINIMAL_STACK_SIZE #define portMINIMAL_STACK_SIZE configMINIMAL_STACK_SIZE