mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-09-12 09:07:46 -04:00
Style: revert more uncrustify files
This commit is contained in:
parent
949096a861
commit
88e692ff55
4 changed files with 927 additions and 960 deletions
1011
portable/ThirdParty/GCC/ATmega/port.c
vendored
1011
portable/ThirdParty/GCC/ATmega/port.c
vendored
File diff suppressed because it is too large
Load diff
138
portable/ThirdParty/GCC/ATmega/portmacro.h
vendored
138
portable/ThirdParty/GCC/ATmega/portmacro.h
vendored
|
@ -23,14 +23,14 @@
|
||||||
* http://aws.amazon.com/freertos
|
* http://aws.amazon.com/freertos
|
||||||
*
|
*
|
||||||
* 1 tab == 4 spaces!
|
* 1 tab == 4 spaces!
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef PORTMACRO_H
|
#ifndef PORTMACRO_H
|
||||||
#define PORTMACRO_H
|
#define PORTMACRO_H
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*-----------------------------------------------------------
|
/*-----------------------------------------------------------
|
||||||
* Port specific definitions.
|
* Port specific definitions.
|
||||||
|
@ -42,49 +42,47 @@
|
||||||
*-----------------------------------------------------------
|
*-----------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <avr/wdt.h>
|
#include <avr/wdt.h>
|
||||||
|
|
||||||
/* 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 int
|
#define portSHORT int
|
||||||
|
|
||||||
typedef uint8_t StackType_t;
|
typedef uint8_t StackType_t;
|
||||||
typedef int8_t BaseType_t;
|
typedef int8_t BaseType_t;
|
||||||
typedef uint8_t UBaseType_t;
|
typedef uint8_t 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 uint32_t TickType_t;
|
typedef uint32_t TickType_t;
|
||||||
#define portMAX_DELAY ( TickType_t ) 0xffffffffUL
|
#define portMAX_DELAY ( TickType_t ) 0xffffffffUL
|
||||||
#endif
|
#endif
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
/* Critical section management. */
|
/* Critical section management. */
|
||||||
|
|
||||||
#define portENTER_CRITICAL() \
|
#define portENTER_CRITICAL() __asm__ __volatile__ ( \
|
||||||
__asm__ __volatile__ ( \
|
"in __tmp_reg__, __SREG__" "\n\t" \
|
||||||
"in __tmp_reg__, __SREG__" "\n\t" \
|
"cli" "\n\t" \
|
||||||
"cli" "\n\t" \
|
"push __tmp_reg__" "\n\t" \
|
||||||
"push __tmp_reg__" "\n\t" \
|
::: "memory" \
|
||||||
::: "memory" \
|
)
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
#define portEXIT_CRITICAL() \
|
#define portEXIT_CRITICAL() __asm__ __volatile__ ( \
|
||||||
__asm__ __volatile__ ( \
|
"pop __tmp_reg__" "\n\t" \
|
||||||
"pop __tmp_reg__" "\n\t" \
|
"out __SREG__, __tmp_reg__" "\n\t" \
|
||||||
"out __SREG__, __tmp_reg__" "\n\t" \
|
::: "memory" \
|
||||||
::: "memory" \
|
)
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
#define portDISABLE_INTERRUPTS() __asm__ __volatile__ ( "cli" ::: "memory" )
|
#define portDISABLE_INTERRUPTS() __asm__ __volatile__ ( "cli" ::: "memory")
|
||||||
#define portENABLE_INTERRUPTS() __asm__ __volatile__ ( "sei" ::: "memory" )
|
#define portENABLE_INTERRUPTS() __asm__ __volatile__ ( "sei" ::: "memory")
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
/* Architecture specifics. */
|
/* Architecture specifics. */
|
||||||
|
@ -93,66 +91,66 @@
|
||||||
* Prefer to use the enhanced Watchdog Timer, but also Timer0 is ok.
|
* Prefer to use the enhanced Watchdog Timer, but also Timer0 is ok.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if defined( WDIE ) && defined( WDIF ) /* If Enhanced WDT with interrupt capability is available */
|
#if defined(WDIE) && defined(WDIF) /* If Enhanced WDT with interrupt capability is available */
|
||||||
|
|
||||||
#define portUSE_WDTO WDTO_15MS /* use the Watchdog Timer for xTaskIncrementTick */
|
#define portUSE_WDTO WDTO_15MS /* use the Watchdog Timer for xTaskIncrementTick */
|
||||||
|
|
||||||
/* Watchdog period options: WDTO_15MS
|
/* Watchdog period options: WDTO_15MS
|
||||||
* WDTO_30MS
|
WDTO_30MS
|
||||||
* WDTO_60MS
|
WDTO_60MS
|
||||||
* WDTO_120MS
|
WDTO_120MS
|
||||||
* WDTO_250MS
|
WDTO_250MS
|
||||||
* WDTO_500MS
|
WDTO_500MS
|
||||||
* WDTO_1S
|
WDTO_1S
|
||||||
* WDTO_2S
|
WDTO_2S
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#define portUSE_TIMER0 /* use the 8-bit Timer0 for xTaskIncrementTick */
|
#define portUSE_TIMER0 /* use the 8-bit Timer0 for xTaskIncrementTick */
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define portSTACK_GROWTH ( -1 )
|
#define portSTACK_GROWTH ( -1 )
|
||||||
|
|
||||||
/* Timing for the scheduler.
|
/* Timing for the scheduler.
|
||||||
* Watchdog Timer is 128kHz nominal,
|
* Watchdog Timer is 128kHz nominal,
|
||||||
* but 120 kHz at 5V DC and 25 degrees is actually more accurate,
|
* but 120 kHz at 5V DC and 25 degrees is actually more accurate,
|
||||||
* from data sheet.
|
* from data sheet.
|
||||||
*/
|
*/
|
||||||
#if defined( portUSE_WDTO )
|
#if defined( portUSE_WDTO )
|
||||||
#define portTICK_PERIOD_MS ( ( TickType_t ) _BV( portUSE_WDTO + 4 ) )
|
#define portTICK_PERIOD_MS ( (TickType_t) _BV( portUSE_WDTO + 4 ) )
|
||||||
#else
|
#else
|
||||||
#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ )
|
#define portTICK_PERIOD_MS ( (TickType_t) 1000 / configTICK_RATE_HZ )
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define portBYTE_ALIGNMENT 1
|
#define portBYTE_ALIGNMENT 1
|
||||||
#define portNOP() __asm__ __volatile__ ( "nop" );
|
#define portNOP() __asm__ __volatile__ ( "nop" );
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
/* Kernel utilities. */
|
/* Kernel utilities. */
|
||||||
extern void vPortYield( void ) __attribute__( ( naked ) );
|
extern void vPortYield( void ) __attribute__ ( ( naked ) );
|
||||||
#define portYIELD() vPortYield()
|
#define portYIELD() vPortYield()
|
||||||
|
|
||||||
extern void vPortYieldFromISR( void ) __attribute__( ( naked ) );
|
extern void vPortYieldFromISR( void ) __attribute__ ( ( naked ) );
|
||||||
#define portYIELD_FROM_ISR() vPortYieldFromISR()
|
#define portYIELD_FROM_ISR() vPortYieldFromISR()
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
#if defined( __AVR_3_BYTE_PC__ )
|
#if defined(__AVR_3_BYTE_PC__)
|
||||||
/* Task function macros as described on the FreeRTOS.org WEB site. */
|
/* Task function macros as described on the FreeRTOS.org WEB site. */
|
||||||
|
|
||||||
/* Add .lowtext tag from the avr linker script avr6.x for ATmega2560 and ATmega2561
|
/* Add .lowtext tag from the avr linker script avr6.x for ATmega2560 and ATmega2561
|
||||||
* to make sure functions are loaded in low memory.
|
* to make sure functions are loaded in low memory.
|
||||||
*/
|
*/
|
||||||
#define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void * pvParameters ) __attribute__( ( section( ".lowtext" ) ) )
|
#define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void *pvParameters ) __attribute__ ((section (".lowtext")))
|
||||||
#else
|
#else
|
||||||
#define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void * pvParameters )
|
#define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void *pvParameters )
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void * pvParameters )
|
#define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void *pvParameters )
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* PORTMACRO_H */
|
#endif /* PORTMACRO_H */
|
||||||
|
|
627
portable/ThirdParty/GCC/Posix/port.c
vendored
627
portable/ThirdParty/GCC/Posix/port.c
vendored
|
@ -26,31 +26,31 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*-----------------------------------------------------------
|
/*-----------------------------------------------------------
|
||||||
* Implementation of functions defined in portable.h for the Posix port.
|
* Implementation of functions defined in portable.h for the Posix port.
|
||||||
*
|
*
|
||||||
* Each task has a pthread which eases use of standard debuggers
|
* Each task has a pthread which eases use of standard debuggers
|
||||||
* (allowing backtraces of tasks etc). Threads for tasks that are not
|
* (allowing backtraces of tasks etc). Threads for tasks that are not
|
||||||
* running are blocked in sigwait().
|
* running are blocked in sigwait().
|
||||||
*
|
*
|
||||||
* Task switch is done by resuming the thread for the next task by
|
* Task switch is done by resuming the thread for the next task by
|
||||||
* sending it the resume signal (SIGUSR1) and then suspending the
|
* sending it the resume signal (SIGUSR1) and then suspending the
|
||||||
* current thread.
|
* current thread.
|
||||||
*
|
*
|
||||||
* The timer interrupt uses SIGALRM and care is taken to ensure that
|
* The timer interrupt uses SIGALRM and care is taken to ensure that
|
||||||
* the signal handler runs only on the thread for the current task.
|
* the signal handler runs only on the thread for the current task.
|
||||||
*
|
*
|
||||||
* Use of part of the standard C library requires care as some
|
* Use of part of the standard C library requires care as some
|
||||||
* functions can take pthread mutexes internally which can result in
|
* functions can take pthread mutexes internally which can result in
|
||||||
* deadlocks as the FreeRTOS kernel can switch tasks while they're
|
* deadlocks as the FreeRTOS kernel can switch tasks while they're
|
||||||
* holding a pthread mutex.
|
* holding a pthread mutex.
|
||||||
*
|
*
|
||||||
* Replacement malloc(), free(), calloc(), and realloc() are provided
|
* Replacement malloc(), free(), calloc(), and realloc() are provided
|
||||||
* for glibc (see below for more information).
|
* for glibc (see below for more information).
|
||||||
*
|
*
|
||||||
* stdio (printf() and friends) should be called from a single task
|
* stdio (printf() and friends) should be called from a single task
|
||||||
* only or serialized with a FreeRTOS primitive such as a binary
|
* only or serialized with a FreeRTOS primitive such as a binary
|
||||||
* semaphore or mutex.
|
* semaphore or mutex.
|
||||||
*----------------------------------------------------------*/
|
*----------------------------------------------------------*/
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
@ -67,25 +67,25 @@
|
||||||
#include "task.h"
|
#include "task.h"
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
#define SIG_RESUME SIGUSR1
|
#define SIG_RESUME SIGUSR1
|
||||||
|
|
||||||
typedef struct THREAD
|
typedef struct THREAD
|
||||||
{
|
{
|
||||||
pthread_t pthread;
|
pthread_t pthread;
|
||||||
pdTASK_CODE pxCode;
|
pdTASK_CODE pxCode;
|
||||||
void * pvParams;
|
void *pvParams;
|
||||||
BaseType_t xDying;
|
BaseType_t xDying;
|
||||||
} Thread_t;
|
} Thread_t;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The additional per-thread data is stored at the beginning of the
|
* The additional per-thread data is stored at the beginning of the
|
||||||
* task's stack.
|
* task's stack.
|
||||||
*/
|
*/
|
||||||
static inline Thread_t * prvGetThreadFromTask( TaskHandle_t xTask )
|
static inline Thread_t *prvGetThreadFromTask(TaskHandle_t xTask)
|
||||||
{
|
{
|
||||||
StackType_t * pxTopOfStack = *( StackType_t ** ) xTask;
|
StackType_t *pxTopOfStack = *(StackType_t **)xTask;
|
||||||
|
|
||||||
return ( Thread_t * ) ( pxTopOfStack + 1 );
|
return (Thread_t *)(pxTopOfStack + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
@ -94,7 +94,7 @@ static pthread_once_t hSigSetupThread = PTHREAD_ONCE_INIT;
|
||||||
static sigset_t xResumeSignals;
|
static sigset_t xResumeSignals;
|
||||||
static sigset_t xAllSignals;
|
static sigset_t xAllSignals;
|
||||||
static sigset_t xSchedulerOriginalSignalMask;
|
static sigset_t xSchedulerOriginalSignalMask;
|
||||||
static pthread_t hMainThread = ( pthread_t ) NULL;
|
static pthread_t hMainThread = ( pthread_t )NULL;
|
||||||
static volatile portBASE_TYPE uxCriticalNesting;
|
static volatile portBASE_TYPE uxCriticalNesting;
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
@ -103,9 +103,8 @@ static portBASE_TYPE xSchedulerEnd = pdFALSE;
|
||||||
|
|
||||||
static void prvSetupSignalsAndSchedulerPolicy( void );
|
static void prvSetupSignalsAndSchedulerPolicy( void );
|
||||||
static void prvSetupTimerInterrupt( void );
|
static void prvSetupTimerInterrupt( void );
|
||||||
static void * prvWaitForStart( void * pvParams );
|
static void *prvWaitForStart( void * pvParams );
|
||||||
static void prvSwitchThread( Thread_t * xThreadToResume,
|
static void prvSwitchThread( Thread_t *xThreadToResume, Thread_t *xThreadToSuspend );
|
||||||
Thread_t * xThreadToSuspend );
|
|
||||||
static void prvSuspendSelf( void );
|
static void prvSuspendSelf( void );
|
||||||
static void prvResumeThread( pthread_t xThreadId );
|
static void prvResumeThread( pthread_t xThreadId );
|
||||||
static void vPortSystemTickHandler( int sig );
|
static void vPortSystemTickHandler( int sig );
|
||||||
|
@ -132,117 +131,110 @@ static void vPortStartFirstTask( void );
|
||||||
* timer (SIGALRM) and other signals.
|
* timer (SIGALRM) and other signals.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
extern void * __libc_malloc( size_t );
|
extern void *__libc_malloc(size_t);
|
||||||
extern void __libc_free( void * );
|
extern void __libc_free(void *);
|
||||||
extern void * __libc_calloc( size_t,
|
extern void *__libc_calloc(size_t, size_t);
|
||||||
size_t );
|
extern void *__libc_realloc(void *ptr, size_t);
|
||||||
extern void * __libc_realloc( void * ptr,
|
|
||||||
size_t );
|
|
||||||
|
|
||||||
void * malloc( size_t size )
|
void *malloc(size_t size)
|
||||||
{
|
{
|
||||||
sigset_t xSavedSignals;
|
sigset_t xSavedSignals;
|
||||||
void * ptr;
|
void *ptr;
|
||||||
|
|
||||||
pthread_sigmask( SIG_BLOCK, &xAllSignals, &xSavedSignals );
|
pthread_sigmask( SIG_BLOCK, &xAllSignals, &xSavedSignals );
|
||||||
ptr = __libc_malloc( size );
|
ptr = __libc_malloc( size );
|
||||||
pthread_sigmask( SIG_SETMASK, &xSavedSignals, NULL );
|
pthread_sigmask( SIG_SETMASK, &xSavedSignals, NULL );
|
||||||
|
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void free( void * ptr )
|
void free(void *ptr)
|
||||||
{
|
{
|
||||||
sigset_t xSavedSignals;
|
sigset_t xSavedSignals;
|
||||||
|
|
||||||
pthread_sigmask( SIG_BLOCK, &xAllSignals, &xSavedSignals );
|
pthread_sigmask( SIG_BLOCK, &xAllSignals, &xSavedSignals );
|
||||||
__libc_free( ptr );
|
__libc_free( ptr );
|
||||||
pthread_sigmask( SIG_SETMASK, &xSavedSignals, NULL );
|
pthread_sigmask( SIG_SETMASK, &xSavedSignals, NULL );
|
||||||
}
|
}
|
||||||
|
|
||||||
void * calloc( size_t nmemb,
|
void *calloc(size_t nmemb, size_t size)
|
||||||
size_t size )
|
|
||||||
{
|
{
|
||||||
sigset_t xSavedSignals;
|
sigset_t xSavedSignals;
|
||||||
void * ptr;
|
void *ptr;
|
||||||
|
|
||||||
pthread_sigmask( SIG_BLOCK, &xAllSignals, &xSavedSignals );
|
pthread_sigmask( SIG_BLOCK, &xAllSignals, &xSavedSignals );
|
||||||
ptr = __libc_calloc( nmemb, size );
|
ptr = __libc_calloc( nmemb, size );
|
||||||
pthread_sigmask( SIG_SETMASK, &xSavedSignals, NULL );
|
pthread_sigmask( SIG_SETMASK, &xSavedSignals, NULL );
|
||||||
|
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void * realloc( void * ptr,
|
void *realloc(void *ptr, size_t size)
|
||||||
size_t size )
|
|
||||||
{
|
{
|
||||||
sigset_t xSavedSignals;
|
sigset_t xSavedSignals;
|
||||||
|
|
||||||
pthread_sigmask( SIG_BLOCK, &xAllSignals, &xSavedSignals );
|
pthread_sigmask( SIG_BLOCK, &xAllSignals, &xSavedSignals );
|
||||||
ptr = __libc_realloc( ptr, size );
|
ptr = __libc_realloc( ptr, size );
|
||||||
pthread_sigmask( SIG_SETMASK, &xSavedSignals, NULL );
|
pthread_sigmask( SIG_SETMASK, &xSavedSignals, NULL );
|
||||||
|
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void prvFatalError( const char * pcCall,
|
static void prvFatalError( const char *pcCall, int iErrno )
|
||||||
int iErrno )
|
|
||||||
{
|
{
|
||||||
fprintf( stderr, "%s: %s\n", pcCall, strerror( iErrno ) );
|
fprintf( stderr, "%s: %s\n", pcCall, strerror( iErrno ) );
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* See header file for description.
|
* See header file for description.
|
||||||
*/
|
*/
|
||||||
portSTACK_TYPE * pxPortInitialiseStack( portSTACK_TYPE * pxTopOfStack,
|
portSTACK_TYPE *pxPortInitialiseStack( portSTACK_TYPE *pxTopOfStack,
|
||||||
portSTACK_TYPE * pxEndOfStack,
|
portSTACK_TYPE *pxEndOfStack,
|
||||||
pdTASK_CODE pxCode,
|
pdTASK_CODE pxCode, void *pvParameters )
|
||||||
void * pvParameters )
|
|
||||||
{
|
{
|
||||||
Thread_t * thread;
|
Thread_t *thread;
|
||||||
pthread_attr_t xThreadAttributes;
|
pthread_attr_t xThreadAttributes;
|
||||||
size_t ulStackSize;
|
size_t ulStackSize;
|
||||||
int iRet;
|
int iRet;
|
||||||
|
|
||||||
( void ) pthread_once( &hSigSetupThread, prvSetupSignalsAndSchedulerPolicy );
|
(void)pthread_once( &hSigSetupThread, prvSetupSignalsAndSchedulerPolicy );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Store the additional thread data at the start of the stack.
|
* Store the additional thread data at the start of the stack.
|
||||||
*/
|
*/
|
||||||
thread = ( Thread_t * ) ( pxTopOfStack + 1 ) - 1;
|
thread = (Thread_t *)(pxTopOfStack + 1) - 1;
|
||||||
pxTopOfStack = ( portSTACK_TYPE * ) thread - 1;
|
pxTopOfStack = (portSTACK_TYPE *)thread - 1;
|
||||||
ulStackSize = ( pxTopOfStack + 1 - pxEndOfStack ) * sizeof( *pxTopOfStack );
|
ulStackSize = (pxTopOfStack + 1 - pxEndOfStack) * sizeof(*pxTopOfStack);
|
||||||
|
|
||||||
thread->pxCode = pxCode;
|
thread->pxCode = pxCode;
|
||||||
thread->pvParams = pvParameters;
|
thread->pvParams = pvParameters;
|
||||||
thread->xDying = pdFALSE;
|
thread->xDying = pdFALSE;
|
||||||
|
|
||||||
pthread_attr_init( &xThreadAttributes );
|
pthread_attr_init( &xThreadAttributes );
|
||||||
pthread_attr_setstack( &xThreadAttributes, pxEndOfStack, ulStackSize );
|
pthread_attr_setstack( &xThreadAttributes, pxEndOfStack, ulStackSize );
|
||||||
|
|
||||||
vPortEnterCritical();
|
vPortEnterCritical();
|
||||||
|
|
||||||
iRet = pthread_create( &thread->pthread, &xThreadAttributes,
|
iRet = pthread_create( &thread->pthread, &xThreadAttributes,
|
||||||
prvWaitForStart, thread );
|
prvWaitForStart, thread );
|
||||||
|
if ( iRet )
|
||||||
|
{
|
||||||
|
prvFatalError( "pthread_create", iRet );
|
||||||
|
}
|
||||||
|
|
||||||
if( iRet )
|
vPortExitCritical();
|
||||||
{
|
|
||||||
prvFatalError( "pthread_create", iRet );
|
|
||||||
}
|
|
||||||
|
|
||||||
vPortExitCritical();
|
return pxTopOfStack;
|
||||||
|
|
||||||
return pxTopOfStack;
|
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
void vPortStartFirstTask( void )
|
void vPortStartFirstTask( void )
|
||||||
{
|
{
|
||||||
Thread_t * pxFirstThread = prvGetThreadFromTask( xTaskGetCurrentTaskHandle() );
|
Thread_t *pxFirstThread = prvGetThreadFromTask( xTaskGetCurrentTaskHandle() );
|
||||||
|
|
||||||
/* Start the first task. */
|
/* Start the first task. */
|
||||||
prvResumeThread( pxFirstThread->pthread );
|
prvResumeThread( pxFirstThread->pthread );
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
@ -251,126 +243,125 @@ void vPortStartFirstTask( void )
|
||||||
*/
|
*/
|
||||||
portBASE_TYPE xPortStartScheduler( void )
|
portBASE_TYPE xPortStartScheduler( void )
|
||||||
{
|
{
|
||||||
int iSignal;
|
int iSignal;
|
||||||
sigset_t xSignals;
|
sigset_t xSignals;
|
||||||
|
|
||||||
hMainThread = pthread_self();
|
hMainThread = pthread_self();
|
||||||
|
|
||||||
/* Start the timer that generates the tick ISR. Interrupts are disabled
|
/* Start the timer that generates the tick ISR. Interrupts are disabled
|
||||||
* here already. */
|
here already. */
|
||||||
prvSetupTimerInterrupt();
|
prvSetupTimerInterrupt();
|
||||||
|
|
||||||
/* Start the first task. */
|
/* Start the first task. */
|
||||||
vPortStartFirstTask();
|
vPortStartFirstTask();
|
||||||
|
|
||||||
/* Wait until signaled by vPortEndScheduler(). */
|
/* Wait until signaled by vPortEndScheduler(). */
|
||||||
sigemptyset( &xSignals );
|
sigemptyset( &xSignals );
|
||||||
sigaddset( &xSignals, SIG_RESUME );
|
sigaddset( &xSignals, SIG_RESUME );
|
||||||
|
|
||||||
while( !xSchedulerEnd )
|
while ( !xSchedulerEnd )
|
||||||
{
|
{
|
||||||
sigwait( &xSignals, &iSignal );
|
sigwait( &xSignals, &iSignal );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Restore original signal mask. */
|
/* Restore original signal mask. */
|
||||||
( void ) pthread_sigmask( SIG_SETMASK, &xSchedulerOriginalSignalMask, NULL );
|
(void)pthread_sigmask( SIG_SETMASK, &xSchedulerOriginalSignalMask, NULL );
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
void vPortEndScheduler( void )
|
void vPortEndScheduler( void )
|
||||||
{
|
{
|
||||||
struct itimerval itimer;
|
struct itimerval itimer;
|
||||||
struct sigaction sigtick;
|
struct sigaction sigtick;
|
||||||
|
|
||||||
/* Stop the timer and ignore any pending SIGALRMs that would end
|
/* Stop the timer and ignore any pending SIGALRMs that would end
|
||||||
* up running on the main thread when it is resumed. */
|
* up running on the main thread when it is resumed. */
|
||||||
itimer.it_value.tv_sec = 0;
|
itimer.it_value.tv_sec = 0;
|
||||||
itimer.it_value.tv_usec = 0;
|
itimer.it_value.tv_usec = 0;
|
||||||
|
|
||||||
itimer.it_interval.tv_sec = 0;
|
itimer.it_interval.tv_sec = 0;
|
||||||
itimer.it_interval.tv_usec = 0;
|
itimer.it_interval.tv_usec = 0;
|
||||||
( void ) setitimer( ITIMER_REAL, &itimer, NULL );
|
(void)setitimer( ITIMER_REAL, &itimer, NULL );
|
||||||
|
|
||||||
sigtick.sa_flags = 0;
|
sigtick.sa_flags = 0;
|
||||||
sigtick.sa_handler = SIG_IGN;
|
sigtick.sa_handler = SIG_IGN;
|
||||||
sigemptyset( &sigtick.sa_mask );
|
sigemptyset( &sigtick.sa_mask );
|
||||||
sigaction( SIGALRM, &sigtick, NULL );
|
sigaction( SIGALRM, &sigtick, NULL );
|
||||||
|
|
||||||
/* Signal the scheduler to exit its loop. */
|
/* Signal the scheduler to exit its loop. */
|
||||||
xSchedulerEnd = pdTRUE;
|
xSchedulerEnd = pdTRUE;
|
||||||
( void ) pthread_kill( hMainThread, SIG_RESUME );
|
(void)pthread_kill( hMainThread, SIG_RESUME );
|
||||||
|
|
||||||
prvSuspendSelf();
|
prvSuspendSelf();
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
void vPortEnterCritical( void )
|
void vPortEnterCritical( void )
|
||||||
{
|
{
|
||||||
if( uxCriticalNesting == 0 )
|
if ( uxCriticalNesting == 0 )
|
||||||
{
|
{
|
||||||
vPortDisableInterrupts();
|
vPortDisableInterrupts();
|
||||||
}
|
}
|
||||||
|
uxCriticalNesting++;
|
||||||
uxCriticalNesting++;
|
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
void vPortExitCritical( void )
|
void vPortExitCritical( void )
|
||||||
{
|
{
|
||||||
uxCriticalNesting--;
|
uxCriticalNesting--;
|
||||||
|
|
||||||
/* If we have reached 0 then re-enable the interrupts. */
|
/* If we have reached 0 then re-enable the interrupts. */
|
||||||
if( uxCriticalNesting == 0 )
|
if( uxCriticalNesting == 0 )
|
||||||
{
|
{
|
||||||
vPortEnableInterrupts();
|
vPortEnableInterrupts();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
void vPortYieldFromISR( void )
|
void vPortYieldFromISR( void )
|
||||||
{
|
{
|
||||||
Thread_t * xThreadToSuspend;
|
Thread_t *xThreadToSuspend;
|
||||||
Thread_t * xThreadToResume;
|
Thread_t *xThreadToResume;
|
||||||
|
|
||||||
xThreadToSuspend = prvGetThreadFromTask( xTaskGetCurrentTaskHandle() );
|
xThreadToSuspend = prvGetThreadFromTask( xTaskGetCurrentTaskHandle() );
|
||||||
|
|
||||||
vTaskSwitchContext();
|
vTaskSwitchContext();
|
||||||
|
|
||||||
xThreadToResume = prvGetThreadFromTask( xTaskGetCurrentTaskHandle() );
|
xThreadToResume = prvGetThreadFromTask( xTaskGetCurrentTaskHandle() );
|
||||||
|
|
||||||
prvSwitchThread( xThreadToResume, xThreadToSuspend );
|
prvSwitchThread( xThreadToResume, xThreadToSuspend );
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
void vPortYield( void )
|
void vPortYield( void )
|
||||||
{
|
{
|
||||||
vPortEnterCritical();
|
vPortEnterCritical();
|
||||||
|
|
||||||
vPortYieldFromISR();
|
vPortYieldFromISR();
|
||||||
|
|
||||||
vPortExitCritical();
|
vPortExitCritical();
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
void vPortDisableInterrupts( void )
|
void vPortDisableInterrupts( void )
|
||||||
{
|
{
|
||||||
pthread_sigmask( SIG_BLOCK, &xAllSignals, NULL );
|
pthread_sigmask( SIG_BLOCK, &xAllSignals, NULL );
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
void vPortEnableInterrupts( void )
|
void vPortEnableInterrupts( void )
|
||||||
{
|
{
|
||||||
pthread_sigmask( SIG_UNBLOCK, &xAllSignals, NULL );
|
pthread_sigmask( SIG_UNBLOCK, &xAllSignals, NULL );
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
portBASE_TYPE xPortSetInterruptMask( void )
|
portBASE_TYPE xPortSetInterruptMask( void )
|
||||||
{
|
{
|
||||||
/* Interrupts are always disabled inside ISRs (signals
|
/* Interrupts are always disabled inside ISRs (signals
|
||||||
* handlers). */
|
handlers). */
|
||||||
return pdTRUE;
|
return pdTRUE;
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
@ -379,13 +370,13 @@ void vPortClearInterruptMask( portBASE_TYPE xMask )
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
static uint64_t prvGetTimeNs( void )
|
static uint64_t prvGetTimeNs(void)
|
||||||
{
|
{
|
||||||
struct timespec t;
|
struct timespec t;
|
||||||
|
|
||||||
clock_gettime( CLOCK_MONOTONIC, &t );
|
clock_gettime(CLOCK_MONOTONIC, &t);
|
||||||
|
|
||||||
return t.tv_sec * 1000000000ull + t.tv_nsec;
|
return t.tv_sec * 1000000000ull + t.tv_nsec;
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint64_t prvStartTimeNs;
|
static uint64_t prvStartTimeNs;
|
||||||
|
@ -397,228 +388,218 @@ static uint64_t prvTickCount;
|
||||||
*/
|
*/
|
||||||
void prvSetupTimerInterrupt( void )
|
void prvSetupTimerInterrupt( void )
|
||||||
{
|
{
|
||||||
struct itimerval itimer;
|
struct itimerval itimer;
|
||||||
int iRet;
|
int iRet;
|
||||||
|
|
||||||
/* Initialise the structure with the current timer information. */
|
/* Initialise the structure with the current timer information. */
|
||||||
iRet = getitimer( ITIMER_REAL, &itimer );
|
iRet = getitimer( ITIMER_REAL, &itimer );
|
||||||
|
if ( iRet )
|
||||||
|
{
|
||||||
|
prvFatalError( "getitimer", errno );
|
||||||
|
}
|
||||||
|
|
||||||
if( iRet )
|
/* Set the interval between timer events. */
|
||||||
{
|
itimer.it_interval.tv_sec = 0;
|
||||||
prvFatalError( "getitimer", errno );
|
itimer.it_interval.tv_usec = portTICK_RATE_MICROSECONDS;
|
||||||
}
|
|
||||||
|
|
||||||
/* Set the interval between timer events. */
|
/* Set the current count-down. */
|
||||||
itimer.it_interval.tv_sec = 0;
|
itimer.it_value.tv_sec = 0;
|
||||||
itimer.it_interval.tv_usec = portTICK_RATE_MICROSECONDS;
|
itimer.it_value.tv_usec = portTICK_RATE_MICROSECONDS;
|
||||||
|
|
||||||
/* Set the current count-down. */
|
/* Set-up the timer interrupt. */
|
||||||
itimer.it_value.tv_sec = 0;
|
iRet = setitimer( ITIMER_REAL, &itimer, NULL );
|
||||||
itimer.it_value.tv_usec = portTICK_RATE_MICROSECONDS;
|
if ( iRet )
|
||||||
|
{
|
||||||
|
prvFatalError( "setitimer", errno );
|
||||||
|
}
|
||||||
|
|
||||||
/* Set-up the timer interrupt. */
|
prvStartTimeNs = prvGetTimeNs();
|
||||||
iRet = setitimer( ITIMER_REAL, &itimer, NULL );
|
|
||||||
|
|
||||||
if( iRet )
|
|
||||||
{
|
|
||||||
prvFatalError( "setitimer", errno );
|
|
||||||
}
|
|
||||||
|
|
||||||
prvStartTimeNs = prvGetTimeNs();
|
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
static void vPortSystemTickHandler( int sig )
|
static void vPortSystemTickHandler( int sig )
|
||||||
{
|
{
|
||||||
Thread_t * pxThreadToSuspend;
|
Thread_t *pxThreadToSuspend;
|
||||||
Thread_t * pxThreadToResume;
|
Thread_t *pxThreadToResume;
|
||||||
uint64_t xExpectedTicks;
|
uint64_t xExpectedTicks;
|
||||||
|
|
||||||
uxCriticalNesting++; /* Signals are blocked in this signal handler. */
|
uxCriticalNesting++; /* Signals are blocked in this signal handler. */
|
||||||
|
|
||||||
pxThreadToSuspend = prvGetThreadFromTask( xTaskGetCurrentTaskHandle() );
|
pxThreadToSuspend = prvGetThreadFromTask( xTaskGetCurrentTaskHandle() );
|
||||||
|
|
||||||
/* Tick Increment, accounting for any lost signals or drift in
|
/* Tick Increment, accounting for any lost signals or drift in
|
||||||
* the timer. */
|
* the timer. */
|
||||||
xExpectedTicks = ( prvGetTimeNs() - prvStartTimeNs )
|
xExpectedTicks = (prvGetTimeNs() - prvStartTimeNs)
|
||||||
/ ( portTICK_RATE_MICROSECONDS * 1000 );
|
/ (portTICK_RATE_MICROSECONDS * 1000);
|
||||||
|
do {
|
||||||
|
xTaskIncrementTick();
|
||||||
|
prvTickCount++;
|
||||||
|
} while (prvTickCount < xExpectedTicks);
|
||||||
|
|
||||||
do
|
#if ( configUSE_PREEMPTION == 1 )
|
||||||
{
|
/* Select Next Task. */
|
||||||
xTaskIncrementTick();
|
vTaskSwitchContext();
|
||||||
prvTickCount++;
|
|
||||||
} while( prvTickCount < xExpectedTicks );
|
|
||||||
|
|
||||||
#if ( configUSE_PREEMPTION == 1 )
|
pxThreadToResume = prvGetThreadFromTask( xTaskGetCurrentTaskHandle() );
|
||||||
/* Select Next Task. */
|
|
||||||
vTaskSwitchContext();
|
|
||||||
|
|
||||||
pxThreadToResume = prvGetThreadFromTask( xTaskGetCurrentTaskHandle() );
|
prvSwitchThread(pxThreadToResume, pxThreadToSuspend);
|
||||||
|
#endif
|
||||||
|
|
||||||
prvSwitchThread( pxThreadToResume, pxThreadToSuspend );
|
uxCriticalNesting--;
|
||||||
#endif
|
|
||||||
|
|
||||||
uxCriticalNesting--;
|
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
void vPortThreadDying( void * pxTaskToDelete,
|
void vPortThreadDying( void *pxTaskToDelete, volatile BaseType_t *pxPendYield )
|
||||||
volatile BaseType_t * pxPendYield )
|
|
||||||
{
|
{
|
||||||
Thread_t * pxThread = prvGetThreadFromTask( pxTaskToDelete );
|
Thread_t *pxThread = prvGetThreadFromTask( pxTaskToDelete );
|
||||||
|
|
||||||
pxThread->xDying = pdTRUE;
|
pxThread->xDying = pdTRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void vPortCancelThread( void * pxTaskToDelete )
|
void vPortCancelThread( void *pxTaskToDelete )
|
||||||
{
|
{
|
||||||
Thread_t * pxThreadToCancel = prvGetThreadFromTask( pxTaskToDelete );
|
Thread_t *pxThreadToCancel = prvGetThreadFromTask( pxTaskToDelete );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The thread has already been suspended so it can be safely
|
* The thread has already been suspended so it can be safely
|
||||||
* cancelled.
|
* cancelled.
|
||||||
*/
|
*/
|
||||||
pthread_cancel( pxThreadToCancel->pthread );
|
pthread_cancel( pxThreadToCancel->pthread );
|
||||||
pthread_join( pxThreadToCancel->pthread, NULL );
|
pthread_join( pxThreadToCancel->pthread, NULL );
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
static void * prvWaitForStart( void * pvParams )
|
static void *prvWaitForStart( void * pvParams )
|
||||||
{
|
{
|
||||||
Thread_t * pxThread = pvParams;
|
Thread_t *pxThread = pvParams;
|
||||||
|
|
||||||
prvSuspendSelf();
|
prvSuspendSelf();
|
||||||
|
|
||||||
/* Resumed for the first time, unblocks all signals. */
|
/* Resumed for the first time, unblocks all signals. */
|
||||||
uxCriticalNesting = 0;
|
uxCriticalNesting = 0;
|
||||||
vPortEnableInterrupts();
|
vPortEnableInterrupts();
|
||||||
|
|
||||||
/* Call the task's entry point. */
|
/* Call the task's entry point. */
|
||||||
pxThread->pxCode( pxThread->pvParams );
|
pxThread->pxCode( pxThread->pvParams );
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
static void prvSwitchThread( Thread_t * pxThreadToResume,
|
static void prvSwitchThread( Thread_t *pxThreadToResume,
|
||||||
Thread_t * pxThreadToSuspend )
|
Thread_t *pxThreadToSuspend )
|
||||||
{
|
{
|
||||||
BaseType_t uxSavedCriticalNesting;
|
BaseType_t uxSavedCriticalNesting;
|
||||||
|
|
||||||
if( pxThreadToSuspend != pxThreadToResume )
|
if ( pxThreadToSuspend != pxThreadToResume )
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Switch tasks.
|
* Switch tasks.
|
||||||
*
|
*
|
||||||
* The critical section nesting is per-task, so save it on the
|
* The critical section nesting is per-task, so save it on the
|
||||||
* stack of the current (suspending thread), restoring it when
|
* stack of the current (suspending thread), restoring it when
|
||||||
* we switch back to this task.
|
* we switch back to this task.
|
||||||
*/
|
*/
|
||||||
uxSavedCriticalNesting = uxCriticalNesting;
|
uxSavedCriticalNesting = uxCriticalNesting;
|
||||||
|
|
||||||
prvResumeThread( pxThreadToResume->pthread );
|
prvResumeThread( pxThreadToResume->pthread );
|
||||||
|
if ( pxThreadToSuspend->xDying )
|
||||||
|
{
|
||||||
|
pthread_exit( NULL );
|
||||||
|
}
|
||||||
|
prvSuspendSelf();
|
||||||
|
|
||||||
if( pxThreadToSuspend->xDying )
|
uxCriticalNesting = uxSavedCriticalNesting;
|
||||||
{
|
}
|
||||||
pthread_exit( NULL );
|
|
||||||
}
|
|
||||||
|
|
||||||
prvSuspendSelf();
|
|
||||||
|
|
||||||
uxCriticalNesting = uxSavedCriticalNesting;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
static void prvSuspendSelf( void )
|
static void prvSuspendSelf( void )
|
||||||
{
|
{
|
||||||
int iSig;
|
int iSig;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Suspend this thread by waiting for a SIG_RESUME signal.
|
* Suspend this thread by waiting for a SIG_RESUME signal.
|
||||||
*
|
*
|
||||||
* A suspended thread must not handle signals (interrupts) so
|
* A suspended thread must not handle signals (interrupts) so
|
||||||
* all signals must be blocked by calling this from:
|
* all signals must be blocked by calling this from:
|
||||||
*
|
*
|
||||||
* - Inside a critical section (vPortEnterCritical() /
|
* - Inside a critical section (vPortEnterCritical() /
|
||||||
* vPortExitCritical()).
|
* vPortExitCritical()).
|
||||||
*
|
*
|
||||||
* - From a signal handler that has all signals masked.
|
* - From a signal handler that has all signals masked.
|
||||||
*
|
*
|
||||||
* - A thread with all signals blocked with pthread_sigmask().
|
* - A thread with all signals blocked with pthread_sigmask().
|
||||||
*/
|
*/
|
||||||
sigwait( &xResumeSignals, &iSig );
|
sigwait( &xResumeSignals, &iSig );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
static void prvResumeThread( pthread_t xThreadId )
|
static void prvResumeThread( pthread_t xThreadId )
|
||||||
{
|
{
|
||||||
if( pthread_self() != xThreadId )
|
if ( pthread_self() != xThreadId )
|
||||||
{
|
{
|
||||||
pthread_kill( xThreadId, SIG_RESUME );
|
pthread_kill( xThreadId, SIG_RESUME );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
static void prvSetupSignalsAndSchedulerPolicy( void )
|
static void prvSetupSignalsAndSchedulerPolicy( void )
|
||||||
{
|
{
|
||||||
struct sigaction sigresume, sigtick;
|
struct sigaction sigresume, sigtick;
|
||||||
int iRet;
|
int iRet;
|
||||||
|
|
||||||
hMainThread = pthread_self();
|
hMainThread = pthread_self();
|
||||||
|
|
||||||
/* Initialise common signal masks. */
|
/* Initialise common signal masks. */
|
||||||
sigemptyset( &xResumeSignals );
|
sigemptyset( &xResumeSignals );
|
||||||
sigaddset( &xResumeSignals, SIG_RESUME );
|
sigaddset( &xResumeSignals, SIG_RESUME );
|
||||||
sigfillset( &xAllSignals );
|
sigfillset( &xAllSignals );
|
||||||
|
/* Don't block SIGINT so this can be used to break into GDB while
|
||||||
|
* in a critical section. */
|
||||||
|
sigdelset( &xAllSignals, SIGINT );
|
||||||
|
|
||||||
/* Don't block SIGINT so this can be used to break into GDB while
|
/*
|
||||||
* in a critical section. */
|
* Block all signals in this thread so all new threads
|
||||||
sigdelset( &xAllSignals, SIGINT );
|
* inherits this mask.
|
||||||
|
*
|
||||||
|
* When a thread is resumed for the first time, all signals
|
||||||
|
* will be unblocked.
|
||||||
|
*/
|
||||||
|
(void)pthread_sigmask( SIG_SETMASK, &xAllSignals,
|
||||||
|
&xSchedulerOriginalSignalMask );
|
||||||
|
|
||||||
/*
|
/* SIG_RESUME is only used with sigwait() so doesn't need a
|
||||||
* Block all signals in this thread so all new threads
|
handler. */
|
||||||
* inherits this mask.
|
sigresume.sa_flags = 0;
|
||||||
*
|
sigresume.sa_handler = SIG_IGN;
|
||||||
* When a thread is resumed for the first time, all signals
|
sigfillset( &sigresume.sa_mask );
|
||||||
* will be unblocked.
|
|
||||||
*/
|
|
||||||
( void ) pthread_sigmask( SIG_SETMASK, &xAllSignals,
|
|
||||||
&xSchedulerOriginalSignalMask );
|
|
||||||
|
|
||||||
/* SIG_RESUME is only used with sigwait() so doesn't need a
|
sigtick.sa_flags = 0;
|
||||||
* handler. */
|
sigtick.sa_handler = vPortSystemTickHandler;
|
||||||
sigresume.sa_flags = 0;
|
sigfillset( &sigtick.sa_mask );
|
||||||
sigresume.sa_handler = SIG_IGN;
|
|
||||||
sigfillset( &sigresume.sa_mask );
|
|
||||||
|
|
||||||
sigtick.sa_flags = 0;
|
iRet = sigaction( SIG_RESUME, &sigresume, NULL );
|
||||||
sigtick.sa_handler = vPortSystemTickHandler;
|
if ( iRet )
|
||||||
sigfillset( &sigtick.sa_mask );
|
{
|
||||||
|
prvFatalError( "sigaction", errno );
|
||||||
|
}
|
||||||
|
|
||||||
iRet = sigaction( SIG_RESUME, &sigresume, NULL );
|
iRet = sigaction( SIGALRM, &sigtick, NULL );
|
||||||
|
if ( iRet )
|
||||||
if( iRet )
|
{
|
||||||
{
|
prvFatalError( "sigaction", errno );
|
||||||
prvFatalError( "sigaction", errno );
|
}
|
||||||
}
|
|
||||||
|
|
||||||
iRet = sigaction( SIGALRM, &sigtick, NULL );
|
|
||||||
|
|
||||||
if( iRet )
|
|
||||||
{
|
|
||||||
prvFatalError( "sigaction", errno );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
unsigned long ulPortGetRunTime( void )
|
unsigned long ulPortGetRunTime( void )
|
||||||
{
|
{
|
||||||
struct tms xTimes;
|
struct tms xTimes;
|
||||||
|
|
||||||
times( &xTimes );
|
times( &xTimes );
|
||||||
|
|
||||||
return ( unsigned long ) xTimes.tms_utime;
|
return ( unsigned long ) xTimes.tms_utime;
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
111
portable/ThirdParty/GCC/Posix/portmacro.h
vendored
111
portable/ThirdParty/GCC/Posix/portmacro.h
vendored
|
@ -27,13 +27,13 @@
|
||||||
|
|
||||||
|
|
||||||
#ifndef PORTMACRO_H
|
#ifndef PORTMACRO_H
|
||||||
#define PORTMACRO_H
|
#define PORTMACRO_H
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
|
||||||
/*-----------------------------------------------------------
|
/*-----------------------------------------------------------
|
||||||
* Port specific definitions.
|
* Port specific definitions.
|
||||||
|
@ -46,72 +46,71 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* 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 long
|
#define portSTACK_TYPE unsigned long
|
||||||
#define portBASE_TYPE long
|
#define portBASE_TYPE long
|
||||||
#define portPOINTER_SIZE_TYPE intptr_t
|
#define portPOINTER_SIZE_TYPE intptr_t
|
||||||
|
|
||||||
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;
|
||||||
|
|
||||||
typedef unsigned long TickType_t;
|
typedef unsigned long TickType_t;
|
||||||
#define portMAX_DELAY ( TickType_t ) ULONG_MAX
|
#define portMAX_DELAY ( TickType_t ) ULONG_MAX
|
||||||
|
|
||||||
#define portTICK_TYPE_IS_ATOMIC 1
|
#define portTICK_TYPE_IS_ATOMIC 1
|
||||||
|
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
/* Architecture specifics. */
|
/* Architecture specifics. */
|
||||||
#define portSTACK_GROWTH ( -1 )
|
#define portSTACK_GROWTH ( -1 )
|
||||||
#define portHAS_STACK_OVERFLOW_CHECKING ( 1 )
|
#define portHAS_STACK_OVERFLOW_CHECKING ( 1 )
|
||||||
#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ )
|
#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ )
|
||||||
#define portTICK_RATE_MICROSECONDS ( ( portTickType ) 1000000 / configTICK_RATE_HZ )
|
#define portTICK_RATE_MICROSECONDS ( ( portTickType ) 1000000 / configTICK_RATE_HZ )
|
||||||
#define portBYTE_ALIGNMENT 8
|
#define portBYTE_ALIGNMENT 8
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
/* Scheduler utilities. */
|
/* Scheduler utilities. */
|
||||||
extern void vPortYield( void );
|
extern void vPortYield( void );
|
||||||
|
|
||||||
#define portYIELD() vPortYield()
|
#define portYIELD() vPortYield()
|
||||||
|
|
||||||
#define portEND_SWITCHING_ISR( xSwitchRequired ) if( xSwitchRequired != pdFALSE ) vPortYield()
|
#define portEND_SWITCHING_ISR( xSwitchRequired ) if( xSwitchRequired != pdFALSE ) vPortYield()
|
||||||
#define portYIELD_FROM_ISR( x ) portEND_SWITCHING_ISR( x )
|
#define portYIELD_FROM_ISR( x ) portEND_SWITCHING_ISR( x )
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
/* Critical section management. */
|
/* Critical section management. */
|
||||||
extern void vPortDisableInterrupts( void );
|
extern void vPortDisableInterrupts( void );
|
||||||
extern void vPortEnableInterrupts( void );
|
extern void vPortEnableInterrupts( void );
|
||||||
#define portSET_INTERRUPT_MASK() ( vPortDisableInterrupts() )
|
#define portSET_INTERRUPT_MASK() ( vPortDisableInterrupts() )
|
||||||
#define portCLEAR_INTERRUPT_MASK() ( vPortEnableInterrupts() )
|
#define portCLEAR_INTERRUPT_MASK() ( vPortEnableInterrupts() )
|
||||||
|
|
||||||
extern portBASE_TYPE xPortSetInterruptMask( void );
|
extern portBASE_TYPE xPortSetInterruptMask( void );
|
||||||
extern void vPortClearInterruptMask( portBASE_TYPE xMask );
|
extern void vPortClearInterruptMask( portBASE_TYPE xMask );
|
||||||
|
|
||||||
extern void vPortEnterCritical( void );
|
extern void vPortEnterCritical( void );
|
||||||
extern void vPortExitCritical( void );
|
extern void vPortExitCritical( void );
|
||||||
#define portSET_INTERRUPT_MASK_FROM_ISR() xPortSetInterruptMask()
|
#define portSET_INTERRUPT_MASK_FROM_ISR() xPortSetInterruptMask()
|
||||||
#define portCLEAR_INTERRUPT_MASK_FROM_ISR( x ) vPortClearInterruptMask( x )
|
#define portCLEAR_INTERRUPT_MASK_FROM_ISR(x) vPortClearInterruptMask(x)
|
||||||
#define portDISABLE_INTERRUPTS() portSET_INTERRUPT_MASK()
|
#define portDISABLE_INTERRUPTS() portSET_INTERRUPT_MASK()
|
||||||
#define portENABLE_INTERRUPTS() portCLEAR_INTERRUPT_MASK()
|
#define portENABLE_INTERRUPTS() portCLEAR_INTERRUPT_MASK()
|
||||||
#define portENTER_CRITICAL() vPortEnterCritical()
|
#define portENTER_CRITICAL() vPortEnterCritical()
|
||||||
#define portEXIT_CRITICAL() vPortExitCritical()
|
#define portEXIT_CRITICAL() vPortExitCritical()
|
||||||
|
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
extern void vPortThreadDying( void * pxTaskToDelete,
|
extern void vPortThreadDying( void *pxTaskToDelete, volatile BaseType_t *pxPendYield );
|
||||||
volatile BaseType_t * pxPendYield );
|
extern void vPortCancelThread( void *pxTaskToDelete );
|
||||||
extern void vPortCancelThread( void * pxTaskToDelete );
|
#define portPRE_TASK_DELETE_HOOK( pvTaskToDelete, pxPendYield ) vPortThreadDying( ( pvTaskToDelete ), ( pxPendYield ) )
|
||||||
#define portPRE_TASK_DELETE_HOOK( pvTaskToDelete, pxPendYield ) vPortThreadDying( ( pvTaskToDelete ), ( pxPendYield ) )
|
#define portCLEAN_UP_TCB( pxTCB ) vPortCancelThread( pxTCB )
|
||||||
#define portCLEAN_UP_TCB( pxTCB ) vPortCancelThread( pxTCB )
|
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
#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 )
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -122,14 +121,14 @@
|
||||||
* Thus, only a compilier barrier is needed to prevent the compiler
|
* Thus, only a compilier barrier is needed to prevent the compiler
|
||||||
* reordering.
|
* reordering.
|
||||||
*/
|
*/
|
||||||
#define portMEMORY_BARRIER() __asm volatile ( "" ::: "memory" )
|
#define portMEMORY_BARRIER() __asm volatile( "" ::: "memory" )
|
||||||
|
|
||||||
extern unsigned long ulPortGetRunTime( void );
|
extern unsigned long ulPortGetRunTime( void );
|
||||||
#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() /* no-op */
|
#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() /* no-op */
|
||||||
#define portGET_RUN_TIME_COUNTER_VALUE() ulPortGetRunTime()
|
#define portGET_RUN_TIME_COUNTER_VALUE() ulPortGetRunTime()
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* PORTMACRO_H */
|
#endif /* PORTMACRO_H */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue