Synopsys ARC v1 port: run uncrustify to fix code style

Signed-off-by: Yuguo Zou <yuguo.zou@synopsys.com>
This commit is contained in:
Yuguo Zou 2020-08-04 09:55:34 +08:00
parent 1f9ffc5abf
commit c9cfead54d
4 changed files with 237 additions and 227 deletions

View file

@ -30,23 +30,22 @@
* \brief exception processing for freertos * \brief exception processing for freertos
*/ */
// #include "embARC.h" /* #include "embARC.h" */
#include "arc_freertos_exceptions.h" #include "arc_freertos_exceptions.h"
#ifdef __GNU__ #ifdef __GNU__
extern void gnu_printf_setup(void); extern void gnu_printf_setup( void );
#endif #endif
/** /**
* \brief freertos related cpu exception initialization, all the interrupts handled by freertos must be not * \brief freertos related cpu exception initialization, all the interrupts handled by freertos must be not
* fast irqs. If fiq is needed, please install the default firq_exc_entry or your own fast irq entry into * fast irqs. If fiq is needed, please install the default firq_exc_entry or your own fast irq entry into
* the specific interrupt exception. * the specific interrupt exception.
*/ */
void freertos_exc_init(void) void freertos_exc_init( void )
{ {
#ifdef __GNU__
#ifdef __GNU__
gnu_printf_setup(); gnu_printf_setup();
#endif #endif
} }

View file

@ -32,14 +32,14 @@
* here, all arc cpu exceptions share the same entry, also for all interrupt * here, all arc cpu exceptions share the same entry, also for all interrupt
* exceptions * exceptions
*/ */
extern void exc_entry_cpu(void); /* cpu exception entry for freertos */ extern void exc_entry_cpu( void ); /* cpu exception entry for freertos */
extern void exc_entry_int(void); /* int exception entry for freertos */ extern void exc_entry_int( void ); /* int exception entry for freertos */
/* task dispatch functions in .s */ /* task dispatch functions in .s */
extern void start_r(void); extern void start_r( void );
extern void start_dispatch(); extern void start_dispatch();
extern void dispatch(); extern void dispatch();
extern void freertos_exc_init(void); extern void freertos_exc_init( void );
#endif /* ARC_FREERTOS_EXCEPTIONS_H */ #endif /* ARC_FREERTOS_EXCEPTIONS_H */

View file

@ -41,6 +41,7 @@
volatile unsigned int ulCriticalNesting = 999UL; volatile unsigned int ulCriticalNesting = 999UL;
volatile unsigned int context_switch_reqflg; /* task context switch request flag in exceptions and interrupts handling */ volatile unsigned int context_switch_reqflg; /* task context switch request flag in exceptions and interrupts handling */
/** /**
* \var exc_nest_count * \var exc_nest_count
* \brief the counter for exc/int processing, =0 no int/exc * \brief the counter for exc/int processing, =0 no int/exc
@ -49,37 +50,40 @@ volatile unsigned int context_switch_reqflg; /* task context switch request flag
*/ */
uint32_t exc_nest_count; uint32_t exc_nest_count;
/* --------------------------------------------------------------------------*/ /* --------------------------------------------------------------------------*/
/** /**
* @brief kernel tick interrupt handler of freertos * @brief kernel tick interrupt handler of freertos
*/ */
/* ----------------------------------------------------------------------------*/ /* ----------------------------------------------------------------------------*/
static void vKernelTick( void *ptr ) static void vKernelTick( void * ptr )
{ {
/* clear timer interrupt */ /* clear timer interrupt */
arc_timer_int_clear(BOARD_OS_TIMER_ID); arc_timer_int_clear( BOARD_OS_TIMER_ID );
board_timer_update(configTICK_RATE_HZ); board_timer_update( configTICK_RATE_HZ );
if (xTaskIncrementTick()) { if( xTaskIncrementTick() )
{
portYIELD_FROM_ISR(); /* need to make task switch */ portYIELD_FROM_ISR(); /* need to make task switch */
} }
} }
/* --------------------------------------------------------------------------*/ /* --------------------------------------------------------------------------*/
/** /**
* @brief setup freertos kernel tick * @brief setup freertos kernel tick
*/ */
/* ----------------------------------------------------------------------------*/ /* ----------------------------------------------------------------------------*/
static void prvSetupTimerInterrupt(void) static void prvSetupTimerInterrupt( void )
{ {
unsigned int cyc = configCPU_CLOCK_HZ / configTICK_RATE_HZ; unsigned int cyc = configCPU_CLOCK_HZ / configTICK_RATE_HZ;
int_disable(BOARD_OS_TIMER_INTNO); /* disable os timer interrupt */ int_disable( BOARD_OS_TIMER_INTNO ); /* disable os timer interrupt */
arc_timer_stop(BOARD_OS_TIMER_ID); arc_timer_stop( BOARD_OS_TIMER_ID );
arc_timer_start(BOARD_OS_TIMER_ID, TIMER_CTRL_IE | TIMER_CTRL_NH, cyc); arc_timer_start( BOARD_OS_TIMER_ID, TIMER_CTRL_IE | TIMER_CTRL_NH, cyc );
int_handler_install(BOARD_OS_TIMER_INTNO, (INT_HANDLER_T)vKernelTick); int_handler_install( BOARD_OS_TIMER_INTNO, ( INT_HANDLER_T ) vKernelTick );
int_pri_set(BOARD_OS_TIMER_INTNO, INT_PRI_MIN); int_pri_set( BOARD_OS_TIMER_INTNO, INT_PRI_MIN );
int_enable(BOARD_OS_TIMER_INTNO); int_enable( BOARD_OS_TIMER_INTNO );
} }
/* /*
@ -91,17 +95,19 @@ static void prvSetupTimerInterrupt(void)
* It's not efficient but simple. * It's not efficient but simple.
* *
*/ */
StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters ) StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack,
TaskFunction_t pxCode,
void * pvParameters )
{ {
/* To ensure asserts in tasks.c don't fail, although in this case the assert /* To ensure asserts in tasks.c don't fail, although in this case the assert
is not really required. */ * is not really required. */
pxTopOfStack--; pxTopOfStack--;
/* Setup the initial stack of the task. The stack is set exactly as /* Setup the initial stack of the task. The stack is set exactly as
expected by the portRESTORE_CONTEXT() macro. */ * expected by the portRESTORE_CONTEXT() macro. */
/* When the task starts is will expect to find the function parameter in /* When the task starts is will expect to find the function parameter in
R0. */ * R0. */
*pxTopOfStack = ( StackType_t ) pvParameters; /* R0 */ *pxTopOfStack = ( StackType_t ) pvParameters; /* R0 */
pxTopOfStack--; pxTopOfStack--;
@ -112,11 +118,12 @@ StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t px
*pxTopOfStack = ( StackType_t ) start_r; /* dispatch return address */ *pxTopOfStack = ( StackType_t ) start_r; /* dispatch return address */
pxTopOfStack--; pxTopOfStack--;
*pxTopOfStack = (StackType_t) portNO_CRITICAL_NESTING; *pxTopOfStack = ( StackType_t ) portNO_CRITICAL_NESTING;
return pxTopOfStack; return pxTopOfStack;
} }
/* --------------------------------------------------------------------------*/ /* --------------------------------------------------------------------------*/
/** /**
* @brief start the freertos scheduler, go to the first task * @brief start the freertos scheduler, go to the first task
* *
@ -134,56 +141,59 @@ BaseType_t xPortStartScheduler( void )
} }
/* --------------------------------------------------------------------------*/ /* --------------------------------------------------------------------------*/
/** /**
* @brief * @brief
*/ */
/* ----------------------------------------------------------------------------*/ /* ----------------------------------------------------------------------------*/
void vPortEndScheduler( void ) void vPortEndScheduler( void )
{ {
} }
/* --------------------------------------------------------------------------*/ /* --------------------------------------------------------------------------*/
/** /**
* @brief generate a task switch request in ISR * @brief generate a task switch request in ISR
*/ */
/* ----------------------------------------------------------------------------*/ /* ----------------------------------------------------------------------------*/
void vPortYieldFromIsr(void) void vPortYieldFromIsr( void )
{ {
unsigned int status32; unsigned int status32;
status32 = cpu_lock_save(); status32 = cpu_lock_save();
context_switch_reqflg = true; context_switch_reqflg = true;
cpu_unlock_restore(status32); cpu_unlock_restore( status32 );
} }
/* --------------------------------------------------------------------------*/ /* --------------------------------------------------------------------------*/
/** /**
* @brief * @brief
*/ */
/* ----------------------------------------------------------------------------*/ /* ----------------------------------------------------------------------------*/
void vPortYield(void) void vPortYield( void )
{ {
unsigned int status32; unsigned int status32;
status32 = cpu_lock_save(); status32 = cpu_lock_save();
dispatch(); dispatch();
cpu_unlock_restore(status32); cpu_unlock_restore( status32 );
} }
/* --------------------------------------------------------------------------*/ /* --------------------------------------------------------------------------*/
/** /**
* @brief * @brief
*/ */
/* ----------------------------------------------------------------------------*/ /* ----------------------------------------------------------------------------*/
void vPortEndTask(void) void vPortEndTask( void )
{ {
#if ( INCLUDE_vTaskDelete == 1 )
vTaskDelete( NULL ); /* Delete task itself */
#endif
#if ( INCLUDE_vTaskDelete == 1 ) while( 1 ) /* Yield to other task */
vTaskDelete(NULL); /* Delete task itself */ {
#endif
while(1) { /* Yield to other task */
vPortYield(); vPortYield();
} }
} }
@ -196,9 +206,9 @@ void vPortEndTask(void)
* It's a copy from task.c. We need to konw the definition of TCB for the purpose of hardware * It's a copy from task.c. We need to konw the definition of TCB for the purpose of hardware
* stack check. Pls don't forget to update it when FreeRTOS is updated. * stack check. Pls don't forget to update it when FreeRTOS is updated.
*/ */
typedef struct tskTaskControlBlock /* The old naming convention is used to prevent breaking kernel aware debuggers. */ typedef struct tskTaskControlBlock /* The old naming convention is used to prevent breaking kernel aware debuggers. */
{ {
volatile StackType_t *pxTopOfStack; /*< Points to the location of the last item placed on the tasks stack. THIS MUST BE THE FIRST MEMBER OF THE TCB STRUCT. */ volatile StackType_t * pxTopOfStack; /*< Points to the location of the last item placed on the tasks stack. THIS MUST BE THE FIRST MEMBER OF THE TCB STRUCT. */
#if ( portUSING_MPU_WRAPPERS == 1 ) #if ( portUSING_MPU_WRAPPERS == 1 )
xMPU_SETTINGS xMPUSettings; /*< The MPU settings are defined as part of the port layer. THIS MUST BE THE SECOND MEMBER OF THE TCB STRUCT. */ xMPU_SETTINGS xMPUSettings; /*< The MPU settings are defined as part of the port layer. THIS MUST BE THE SECOND MEMBER OF THE TCB STRUCT. */
@ -207,11 +217,11 @@ typedef struct tskTaskControlBlock /* The old naming convention is used to preve
ListItem_t xStateListItem; /*< The list that the state list item of a task is reference from denotes the state of that task (Ready, Blocked, Suspended ). */ ListItem_t xStateListItem; /*< The list that the state list item of a task is reference from denotes the state of that task (Ready, Blocked, Suspended ). */
ListItem_t xEventListItem; /*< Used to reference a task from an event list. */ ListItem_t xEventListItem; /*< Used to reference a task from an event list. */
UBaseType_t uxPriority; /*< The priority of the task. 0 is the lowest priority. */ UBaseType_t uxPriority; /*< The priority of the task. 0 is the lowest priority. */
StackType_t *pxStack; /*< Points to the start of the stack. */ StackType_t * pxStack; /*< Points to the start of the stack. */
char pcTaskName[ configMAX_TASK_NAME_LEN ];/*< Descriptive name given to the task when created. Facilitates debugging only. */ /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ char pcTaskName[ configMAX_TASK_NAME_LEN ]; /*< Descriptive name given to the task when created. Facilitates debugging only. */ /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
#if ( ( portSTACK_GROWTH > 0 ) || ( configRECORD_STACK_HIGH_ADDRESS == 1 ) ) #if ( ( portSTACK_GROWTH > 0 ) || ( configRECORD_STACK_HIGH_ADDRESS == 1 ) )
StackType_t *pxEndOfStack; /*< Points to the highest valid address for the stack. */ StackType_t * pxEndOfStack; /*< Points to the highest valid address for the stack. */
#endif #endif
#if ( portCRITICAL_NESTING_IN_TCB == 1 ) #if ( portCRITICAL_NESTING_IN_TCB == 1 )
@ -232,53 +242,54 @@ typedef struct tskTaskControlBlock /* The old naming convention is used to preve
TaskHookFunction_t pxTaskTag; TaskHookFunction_t pxTaskTag;
#endif #endif
#if( configNUM_THREAD_LOCAL_STORAGE_POINTERS > 0 ) #if ( configNUM_THREAD_LOCAL_STORAGE_POINTERS > 0 )
void *pvThreadLocalStoragePointers[ configNUM_THREAD_LOCAL_STORAGE_POINTERS ]; void * pvThreadLocalStoragePointers[ configNUM_THREAD_LOCAL_STORAGE_POINTERS ];
#endif #endif
#if( configGENERATE_RUN_TIME_STATS == 1 ) #if ( configGENERATE_RUN_TIME_STATS == 1 )
uint32_t ulRunTimeCounter; /*< Stores the amount of time the task has spent in the Running state. */ uint32_t ulRunTimeCounter; /*< Stores the amount of time the task has spent in the Running state. */
#endif #endif
#if ( configUSE_NEWLIB_REENTRANT == 1 ) #if ( configUSE_NEWLIB_REENTRANT == 1 )
/* Allocate a Newlib reent structure that is specific to this task. /* Allocate a Newlib reent structure that is specific to this task.
Note Newlib support has been included by popular demand, but is not * Note Newlib support has been included by popular demand, but is not
used by the FreeRTOS maintainers themselves. FreeRTOS is not * used by the FreeRTOS maintainers themselves. FreeRTOS is not
responsible for resulting newlib operation. User must be familiar with * responsible for resulting newlib operation. User must be familiar with
newlib and must provide system-wide implementations of the necessary * newlib and must provide system-wide implementations of the necessary
stubs. Be warned that (at the time of writing) the current newlib design * stubs. Be warned that (at the time of writing) the current newlib design
implements a system-wide malloc() that must be provided with locks. */ * implements a system-wide malloc() that must be provided with locks. */
struct _reent xNewLib_reent; struct _reent xNewLib_reent;
#endif #endif
#if( configUSE_TASK_NOTIFICATIONS == 1 ) #if ( configUSE_TASK_NOTIFICATIONS == 1 )
volatile uint32_t ulNotifiedValue; volatile uint32_t ulNotifiedValue;
volatile uint8_t ucNotifyState; volatile uint8_t ucNotifyState;
#endif #endif
/* See the comments above the definition of /* See the comments above the definition of
tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE. */ * tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE. */
#if( tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE != 0 ) /*lint !e731 !e9029 Macro has been consolidated for readability reasons. */ #if ( tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE != 0 ) /*lint !e731 !e9029 Macro has been consolidated for readability reasons. */
uint8_t ucStaticallyAllocated; /*< Set to pdTRUE if the task is a statically allocated to ensure no attempt is made to free the memory. */ uint8_t ucStaticallyAllocated; /*< Set to pdTRUE if the task is a statically allocated to ensure no attempt is made to free the memory. */
#endif #endif
#if( INCLUDE_xTaskAbortDelay == 1 ) #if ( INCLUDE_xTaskAbortDelay == 1 )
uint8_t ucDelayAborted; uint8_t ucDelayAborted;
#endif #endif
#if( configUSE_POSIX_ERRNO == 1 ) #if ( configUSE_POSIX_ERRNO == 1 )
int iTaskErrno; int iTaskErrno;
#endif #endif
} tskTCB;
} tskTCB;
void vPortSetStackCheck(TaskHandle_t old, TaskHandle_t new) void vPortSetStackCheck( TaskHandle_t old,
{ TaskHandle_t new )
{
if (new != NULL) { if( new != NULL )
arc_aux_write(AUX_USTACK_BASE, (uint32_t)(new->pxEndOfStack)); {
arc_aux_write(AUX_USTACK_TOP, (uint32_t)(new->pxStack)); arc_aux_write( AUX_USTACK_BASE, ( uint32_t ) ( new->pxEndOfStack ) );
arc_aux_write( AUX_USTACK_TOP, ( uint32_t ) ( new->pxStack ) );
} }
} }
#endif #endif /* if ARC_FEATURE_STACK_CHECK */

View file

@ -26,17 +26,17 @@
*/ */
#ifndef PORTMACRO_H #ifndef PORTMACRO_H
#define PORTMACRO_H #define PORTMACRO_H
#include "embARC.h" #include "embARC.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
/* record stack high address for stack check */ /* record stack high address for stack check */
#ifndef configRECORD_STACK_HIGH_ADDRESS #ifndef configRECORD_STACK_HIGH_ADDRESS
#define configRECORD_STACK_HIGH_ADDRESS 1 #define configRECORD_STACK_HIGH_ADDRESS 1
#endif #endif
/*----------------------------------------------------------- /*-----------------------------------------------------------
* Port specific definitions. * Port specific definitions.
@ -49,101 +49,101 @@ extern "C" {
*/ */
/* Type definitions. */ /* Type definitions. */
#define portCHAR char #define portCHAR char
#define portFLOAT float #define portFLOAT float
#define portDOUBLE double #define portDOUBLE double
#define portLONG long #define portLONG long
#define portSHORT short #define portSHORT short
#define portSTACK_TYPE unsigned int #define portSTACK_TYPE unsigned int
#define portBASE_TYPE portLONG #define portBASE_TYPE portLONG
#ifndef Asm #ifndef Asm
#define Asm __asm__ volatile #define Asm __asm__ volatile
#endif #endif
/* /*
* normal constants * normal constants
*/ */
#ifndef NULL #ifndef NULL
#define NULL 0 /* invalid pointer */ #define NULL 0 /* invalid pointer */
#endif /* NULL */ #endif /* NULL */
#ifndef true #ifndef true
#define true 1 /* true */ #define true 1 /* true */
#endif /* true */ #endif /* true */
#ifndef false #ifndef false
#define false 0 /* false */ #define false 0 /* false */
#endif /* false */ #endif /* false */
typedef portSTACK_TYPE StackType_t; typedef portSTACK_TYPE StackType_t;
typedef long BaseType_t; typedef long BaseType_t;
typedef unsigned long UBaseType_t; typedef unsigned long UBaseType_t;
#if( configUSE_16_BIT_TICKS == 1 ) #if ( configUSE_16_BIT_TICKS == 1 )
typedef uint16_t TickType_t; typedef uint16_t TickType_t;
#define portMAX_DELAY ( TickType_t ) 0xffff #define portMAX_DELAY ( TickType_t ) 0xffff
#else #else
typedef unsigned int TickType_t; typedef unsigned int TickType_t;
#define portMAX_DELAY ( TickType_t ) 0xffffffffUL #define portMAX_DELAY ( TickType_t ) 0xffffffffUL
#endif #endif
#define portNO_CRITICAL_NESTING ( ( uint32_t ) 0 ) #define portNO_CRITICAL_NESTING ( ( uint32_t ) 0 )
#define portSTACK_GROWTH ( -1 ) #define portSTACK_GROWTH ( -1 )
#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ ) #define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ )
#define portBYTE_ALIGNMENT 8 #define portBYTE_ALIGNMENT 8
#define portNOP() Asm( "nop_s" ); #define portNOP() Asm( "nop_s" );
#define IPM_ENABLE_ALL 1 #define IPM_ENABLE_ALL 1
#define portYIELD_FROM_ISR() vPortYieldFromIsr() #define portYIELD_FROM_ISR() vPortYieldFromIsr()
#define portYIELD() vPortYield() #define portYIELD() vPortYield()
/* Critical section management. */ /* Critical section management. */
#define portDISABLE_INTERRUPTS() \ #define portDISABLE_INTERRUPTS() \
{ \ { \
arc_lock(); \ arc_lock(); \
} \ } \
#define portENABLE_INTERRUPTS() \ #define portENABLE_INTERRUPTS() \
{ \ { \
arc_unlock(); \ arc_unlock(); \
} \ } \
extern volatile unsigned int ulCriticalNesting; extern volatile unsigned int ulCriticalNesting;
#define portENTER_CRITICAL() \ #define portENTER_CRITICAL() \
{ \ { \
portDISABLE_INTERRUPTS() \ portDISABLE_INTERRUPTS() \
ulCriticalNesting++; \ ulCriticalNesting++; \
} }
#define portEXIT_CRITICAL() \ #define portEXIT_CRITICAL() \
{ \ { \
if (ulCriticalNesting > portNO_CRITICAL_NESTING) \ if( ulCriticalNesting > portNO_CRITICAL_NESTING ) \
{ \ { \
ulCriticalNesting--; \ ulCriticalNesting--; \
if (ulCriticalNesting == portNO_CRITICAL_NESTING) \ if( ulCriticalNesting == portNO_CRITICAL_NESTING ) \
{ \ { \
portENABLE_INTERRUPTS() \ portENABLE_INTERRUPTS() \
} \ } \
} \ } \
}
#define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void * pvParameters )
#define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void * pvParameters )
#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() do {} while( 0 ) /* we use the timer */
#define portALT_GET_RUN_TIME_COUNTER_VALUE( dest ) ( dest = xTickCount )
#define portCLEAN_UP_TCB( pxTCB ) ( void ) pxTCB
void vPortYield( void );
void vPortYieldFromIsr( void );
#ifdef __cplusplus
} }
#endif
#define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void *pvParameters )
#define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void *pvParameters )
#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() do {} while (0) /* we use the timer */
#define portALT_GET_RUN_TIME_COUNTER_VALUE(dest) (dest = xTickCount)
#define portCLEAN_UP_TCB( pxTCB ) ( void ) pxTCB
void vPortYield(void);
void vPortYieldFromIsr(void);
#ifdef __cplusplus
}
#endif
#endif /* PORTMACRO_H */ #endif /* PORTMACRO_H */