mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2026-01-18 15:50:32 -05:00
Style: Revert uncrustify for portable directories (#122)
* Style: revert uncrustify portable directories * Style: Uncrustify Some Portable files Co-authored-by: Alfred Gedeon <gedeonag@amazon.com>
This commit is contained in:
parent
a6da1cd0ce
commit
86653e2a1f
273 changed files with 64802 additions and 65931 deletions
|
|
@ -54,7 +54,8 @@
|
|||
extern void __mw_run_tls_dtor();
|
||||
extern void __mw_run_tls_ctor();
|
||||
|
||||
extern uint32_t exc_nest_count;
|
||||
extern uint32_t exc_nest_count;
|
||||
|
||||
/*
|
||||
* Linker generated symbols to mark .tls section addresses
|
||||
* first byte .. last byte
|
||||
|
|
|
|||
1
portable/ThirdParty/GCC/ARC_EM_HS/port.c
vendored
1
portable/ThirdParty/GCC/ARC_EM_HS/port.c
vendored
|
|
@ -41,6 +41,7 @@
|
|||
|
||||
volatile unsigned int ulCriticalNesting = 999UL;
|
||||
volatile unsigned int context_switch_reqflg; /* task context switch request flag in exceptions and interrupts handling */
|
||||
|
||||
/**
|
||||
* \var exc_nest_count
|
||||
* \brief the counter for exc/int processing, =0 no int/exc
|
||||
|
|
|
|||
148
portable/ThirdParty/GCC/ARC_EM_HS/portmacro.h
vendored
148
portable/ThirdParty/GCC/ARC_EM_HS/portmacro.h
vendored
|
|
@ -26,16 +26,18 @@
|
|||
*/
|
||||
|
||||
#ifndef PORTMACRO_H
|
||||
#define PORTMACRO_H
|
||||
#define PORTMACRO_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/* *INDENT-OFF* */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/* *INDENT-ON* */
|
||||
|
||||
/* record stack high address for stack check */
|
||||
#ifndef configRECORD_STACK_HIGH_ADDRESS
|
||||
#define configRECORD_STACK_HIGH_ADDRESS 1
|
||||
#endif
|
||||
#ifndef configRECORD_STACK_HIGH_ADDRESS
|
||||
#define configRECORD_STACK_HIGH_ADDRESS 1
|
||||
#endif
|
||||
|
||||
/*-----------------------------------------------------------
|
||||
* Port specific definitions.
|
||||
|
|
@ -48,78 +50,78 @@
|
|||
*/
|
||||
|
||||
/* Type definitions. */
|
||||
#define portCHAR char
|
||||
#define portFLOAT float
|
||||
#define portDOUBLE double
|
||||
#define portLONG long
|
||||
#define portSHORT short
|
||||
#define portSTACK_TYPE unsigned int
|
||||
#define portBASE_TYPE portLONG
|
||||
#define portCHAR char
|
||||
#define portFLOAT float
|
||||
#define portDOUBLE double
|
||||
#define portLONG long
|
||||
#define portSHORT short
|
||||
#define portSTACK_TYPE unsigned int
|
||||
#define portBASE_TYPE portLONG
|
||||
|
||||
#ifndef Asm
|
||||
#define Asm __asm__ volatile
|
||||
#endif
|
||||
#ifndef Asm
|
||||
#define Asm __asm__ volatile
|
||||
#endif
|
||||
|
||||
/*
|
||||
* normal constants
|
||||
*/
|
||||
#ifndef NULL
|
||||
#define NULL 0 /* invalid pointer */
|
||||
#endif /* NULL */
|
||||
#ifndef NULL
|
||||
#define NULL 0 /* invalid pointer */
|
||||
#endif /* NULL */
|
||||
|
||||
#ifndef true
|
||||
#define true 1 /* true */
|
||||
#endif /* true */
|
||||
#ifndef true
|
||||
#define true 1 /* true */
|
||||
#endif /* true */
|
||||
|
||||
#ifndef false
|
||||
#define false 0 /* false */
|
||||
#endif /* false */
|
||||
#ifndef false
|
||||
#define false 0 /* false */
|
||||
#endif /* false */
|
||||
|
||||
typedef portSTACK_TYPE StackType_t;
|
||||
typedef long BaseType_t;
|
||||
typedef unsigned long UBaseType_t;
|
||||
typedef portSTACK_TYPE StackType_t;
|
||||
typedef long BaseType_t;
|
||||
typedef unsigned long UBaseType_t;
|
||||
|
||||
#if ( configUSE_16_BIT_TICKS == 1 )
|
||||
typedef uint16_t TickType_t;
|
||||
#define portMAX_DELAY ( TickType_t ) 0xffff
|
||||
#else
|
||||
typedef unsigned int TickType_t;
|
||||
#define portMAX_DELAY ( TickType_t ) 0xffffffffUL
|
||||
#endif
|
||||
#if ( configUSE_16_BIT_TICKS == 1 )
|
||||
typedef uint16_t TickType_t;
|
||||
#define portMAX_DELAY ( TickType_t ) 0xffff
|
||||
#else
|
||||
typedef unsigned int TickType_t;
|
||||
#define portMAX_DELAY ( TickType_t ) 0xffffffffUL
|
||||
#endif
|
||||
|
||||
#define portNO_CRITICAL_NESTING ( ( uint32_t ) 0 )
|
||||
#define portSTACK_GROWTH ( -1 )
|
||||
#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ )
|
||||
#define portBYTE_ALIGNMENT 8
|
||||
#define portNOP() Asm( "nop_s" );
|
||||
#define IPM_ENABLE_ALL 1
|
||||
#define portNO_CRITICAL_NESTING ( ( uint32_t ) 0 )
|
||||
#define portSTACK_GROWTH ( -1 )
|
||||
#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ )
|
||||
#define portBYTE_ALIGNMENT 8
|
||||
#define portNOP() Asm( "nop_s" );
|
||||
#define IPM_ENABLE_ALL 1
|
||||
|
||||
#define portYIELD_FROM_ISR() vPortYieldFromIsr()
|
||||
#define portYIELD() vPortYield()
|
||||
#define portYIELD_FROM_ISR() vPortYieldFromIsr()
|
||||
#define portYIELD() vPortYield()
|
||||
|
||||
/* Critical section management. */
|
||||
#define portDISABLE_INTERRUPTS() \
|
||||
{ \
|
||||
Asm( "clri" ); \
|
||||
Asm( "" ::: "memory" ); \
|
||||
} \
|
||||
#define portDISABLE_INTERRUPTS() \
|
||||
{ \
|
||||
Asm( "clri" ); \
|
||||
Asm( "" ::: "memory" ); \
|
||||
} \
|
||||
|
||||
#define portENABLE_INTERRUPTS() \
|
||||
{ \
|
||||
Asm( "" ::: "memory" ); \
|
||||
Asm( "seti" ); \
|
||||
} \
|
||||
#define portENABLE_INTERRUPTS() \
|
||||
{ \
|
||||
Asm( "" ::: "memory" ); \
|
||||
Asm( "seti" ); \
|
||||
} \
|
||||
|
||||
extern volatile unsigned int ulCriticalNesting;
|
||||
extern volatile unsigned int ulCriticalNesting;
|
||||
|
||||
#define portENTER_CRITICAL() \
|
||||
#define portENTER_CRITICAL() \
|
||||
{ \
|
||||
portDISABLE_INTERRUPTS() \
|
||||
ulCriticalNesting++; \
|
||||
}
|
||||
|
||||
|
||||
#define portEXIT_CRITICAL() \
|
||||
#define portEXIT_CRITICAL() \
|
||||
{ \
|
||||
if( ulCriticalNesting > portNO_CRITICAL_NESTING ) \
|
||||
{ \
|
||||
|
|
@ -132,24 +134,26 @@
|
|||
}
|
||||
|
||||
|
||||
#define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void * pvParameters )
|
||||
#define portTASK_FUNCTION( 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 portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() do {} while( 0 ) /* we use the timer */
|
||||
#define portALT_GET_RUN_TIME_COUNTER_VALUE( dest ) ( dest = xTickCount )
|
||||
#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() do {} while( 0 ) /* we use the timer */
|
||||
#define portALT_GET_RUN_TIME_COUNTER_VALUE( dest ) ( dest = xTickCount )
|
||||
|
||||
#if defined( __MW__ )
|
||||
extern void task_end_hook( void * pxTCB );
|
||||
#define portCLEAN_UP_TCB( pxTCB ) task_end_hook( ( void * ) pxTCB )
|
||||
#else
|
||||
#define portCLEAN_UP_TCB( pxTCB ) ( void ) pxTCB
|
||||
#endif
|
||||
#if defined( __MW__ )
|
||||
extern void task_end_hook( void * pxTCB );
|
||||
#define portCLEAN_UP_TCB( pxTCB ) task_end_hook( ( void * ) pxTCB )
|
||||
#else
|
||||
#define portCLEAN_UP_TCB( pxTCB ) ( void ) pxTCB
|
||||
#endif
|
||||
|
||||
void vPortYield( void );
|
||||
void vPortYieldFromIsr( void );
|
||||
void vPortYield( void );
|
||||
void vPortYieldFromIsr( void );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
/* *INDENT-OFF* */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
/* *INDENT-ON* */
|
||||
|
||||
#endif /* PORTMACRO_H */
|
||||
|
|
|
|||
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
|
||||
*
|
||||
* 1 tab == 4 spaces!
|
||||
*/
|
||||
*/
|
||||
|
||||
#ifndef PORTMACRO_H
|
||||
#define PORTMACRO_H
|
||||
#define PORTMACRO_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*-----------------------------------------------------------
|
||||
* Port specific definitions.
|
||||
|
|
@ -42,49 +42,47 @@
|
|||
*-----------------------------------------------------------
|
||||
*/
|
||||
|
||||
#include <avr/wdt.h>
|
||||
#include <avr/wdt.h>
|
||||
|
||||
/* Type definitions. */
|
||||
#define portCHAR char
|
||||
#define portFLOAT float
|
||||
#define portDOUBLE double
|
||||
#define portLONG long
|
||||
#define portSHORT int
|
||||
#define portCHAR char
|
||||
#define portFLOAT float
|
||||
#define portDOUBLE double
|
||||
#define portLONG long
|
||||
#define portSHORT int
|
||||
|
||||
typedef uint8_t StackType_t;
|
||||
typedef int8_t BaseType_t;
|
||||
typedef uint8_t UBaseType_t;
|
||||
typedef uint8_t StackType_t;
|
||||
typedef int8_t BaseType_t;
|
||||
typedef uint8_t UBaseType_t;
|
||||
|
||||
#if configUSE_16_BIT_TICKS == 1
|
||||
typedef uint16_t TickType_t;
|
||||
#define portMAX_DELAY ( TickType_t ) 0xffff
|
||||
#else
|
||||
typedef uint32_t TickType_t;
|
||||
#define portMAX_DELAY ( TickType_t ) 0xffffffffUL
|
||||
#endif
|
||||
#if configUSE_16_BIT_TICKS == 1
|
||||
typedef uint16_t TickType_t;
|
||||
#define portMAX_DELAY ( TickType_t ) 0xffff
|
||||
#else
|
||||
typedef uint32_t TickType_t;
|
||||
#define portMAX_DELAY ( TickType_t ) 0xffffffffUL
|
||||
#endif
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* Critical section management. */
|
||||
|
||||
#define portENTER_CRITICAL() \
|
||||
__asm__ __volatile__ ( \
|
||||
"in __tmp_reg__, __SREG__" "\n\t" \
|
||||
"cli" "\n\t" \
|
||||
"push __tmp_reg__" "\n\t" \
|
||||
::: "memory" \
|
||||
)
|
||||
#define portENTER_CRITICAL() __asm__ __volatile__ ( \
|
||||
"in __tmp_reg__, __SREG__" "\n\t" \
|
||||
"cli" "\n\t" \
|
||||
"push __tmp_reg__" "\n\t" \
|
||||
::: "memory" \
|
||||
)
|
||||
|
||||
|
||||
#define portEXIT_CRITICAL() \
|
||||
__asm__ __volatile__ ( \
|
||||
"pop __tmp_reg__" "\n\t" \
|
||||
"out __SREG__, __tmp_reg__" "\n\t" \
|
||||
::: "memory" \
|
||||
)
|
||||
#define portEXIT_CRITICAL() __asm__ __volatile__ ( \
|
||||
"pop __tmp_reg__" "\n\t" \
|
||||
"out __SREG__, __tmp_reg__" "\n\t" \
|
||||
::: "memory" \
|
||||
)
|
||||
|
||||
|
||||
#define portDISABLE_INTERRUPTS() __asm__ __volatile__ ( "cli" ::: "memory" )
|
||||
#define portENABLE_INTERRUPTS() __asm__ __volatile__ ( "sei" ::: "memory" )
|
||||
#define portDISABLE_INTERRUPTS() __asm__ __volatile__ ( "cli" ::: "memory")
|
||||
#define portENABLE_INTERRUPTS() __asm__ __volatile__ ( "sei" ::: "memory")
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* Architecture specifics. */
|
||||
|
|
@ -93,66 +91,66 @@
|
|||
* 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
|
||||
* WDTO_30MS
|
||||
* WDTO_60MS
|
||||
* WDTO_120MS
|
||||
* WDTO_250MS
|
||||
* WDTO_500MS
|
||||
* WDTO_1S
|
||||
* WDTO_2S
|
||||
*/
|
||||
WDTO_30MS
|
||||
WDTO_60MS
|
||||
WDTO_120MS
|
||||
WDTO_250MS
|
||||
WDTO_500MS
|
||||
WDTO_1S
|
||||
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.
|
||||
* Watchdog Timer is 128kHz nominal,
|
||||
* but 120 kHz at 5V DC and 25 degrees is actually more accurate,
|
||||
* from data sheet.
|
||||
*/
|
||||
#if defined( portUSE_WDTO )
|
||||
#define portTICK_PERIOD_MS ( ( TickType_t ) _BV( portUSE_WDTO + 4 ) )
|
||||
#else
|
||||
#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ )
|
||||
#endif
|
||||
#if defined( portUSE_WDTO )
|
||||
#define portTICK_PERIOD_MS ( (TickType_t) _BV( portUSE_WDTO + 4 ) )
|
||||
#else
|
||||
#define portTICK_PERIOD_MS ( (TickType_t) 1000 / configTICK_RATE_HZ )
|
||||
#endif
|
||||
|
||||
#define portBYTE_ALIGNMENT 1
|
||||
#define portNOP() __asm__ __volatile__ ( "nop" );
|
||||
#define portBYTE_ALIGNMENT 1
|
||||
#define portNOP() __asm__ __volatile__ ( "nop" );
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* Kernel utilities. */
|
||||
extern void vPortYield( void ) __attribute__( ( naked ) );
|
||||
#define portYIELD() vPortYield()
|
||||
extern void vPortYield( void ) __attribute__ ( ( naked ) );
|
||||
#define portYIELD() vPortYield()
|
||||
|
||||
extern void vPortYieldFromISR( void ) __attribute__( ( naked ) );
|
||||
#define portYIELD_FROM_ISR() vPortYieldFromISR()
|
||||
extern void vPortYieldFromISR( void ) __attribute__ ( ( naked ) );
|
||||
#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. */
|
||||
|
||||
/* Add .lowtext tag from the avr linker script avr6.x for ATmega2560 and ATmega2561
|
||||
* to make sure functions are loaded in low memory.
|
||||
*/
|
||||
#define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void * pvParameters ) __attribute__( ( section( ".lowtext" ) ) )
|
||||
#else
|
||||
#define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void * pvParameters )
|
||||
#endif
|
||||
#define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void *pvParameters ) __attribute__ ((section (".lowtext")))
|
||||
#else
|
||||
#define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void *pvParameters )
|
||||
#endif
|
||||
|
||||
#define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void * pvParameters )
|
||||
#define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void *pvParameters )
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#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.
|
||||
*
|
||||
* Each task has a pthread which eases use of standard debuggers
|
||||
* (allowing backtraces of tasks etc). Threads for tasks that are not
|
||||
* running are blocked in sigwait().
|
||||
*
|
||||
* Task switch is done by resuming the thread for the next task by
|
||||
* sending it the resume signal (SIGUSR1) and then suspending the
|
||||
* current thread.
|
||||
*
|
||||
* The timer interrupt uses SIGALRM and care is taken to ensure that
|
||||
* the signal handler runs only on the thread for the current task.
|
||||
*
|
||||
* Use of part of the standard C library requires care as some
|
||||
* functions can take pthread mutexes internally which can result in
|
||||
* deadlocks as the FreeRTOS kernel can switch tasks while they're
|
||||
* holding a pthread mutex.
|
||||
*
|
||||
* Replacement malloc(), free(), calloc(), and realloc() are provided
|
||||
* for glibc (see below for more information).
|
||||
*
|
||||
* stdio (printf() and friends) should be called from a single task
|
||||
* only or serialized with a FreeRTOS primitive such as a binary
|
||||
* semaphore or mutex.
|
||||
*----------------------------------------------------------*/
|
||||
* Implementation of functions defined in portable.h for the Posix port.
|
||||
*
|
||||
* Each task has a pthread which eases use of standard debuggers
|
||||
* (allowing backtraces of tasks etc). Threads for tasks that are not
|
||||
* running are blocked in sigwait().
|
||||
*
|
||||
* Task switch is done by resuming the thread for the next task by
|
||||
* sending it the resume signal (SIGUSR1) and then suspending the
|
||||
* current thread.
|
||||
*
|
||||
* The timer interrupt uses SIGALRM and care is taken to ensure that
|
||||
* the signal handler runs only on the thread for the current task.
|
||||
*
|
||||
* Use of part of the standard C library requires care as some
|
||||
* functions can take pthread mutexes internally which can result in
|
||||
* deadlocks as the FreeRTOS kernel can switch tasks while they're
|
||||
* holding a pthread mutex.
|
||||
*
|
||||
* Replacement malloc(), free(), calloc(), and realloc() are provided
|
||||
* for glibc (see below for more information).
|
||||
*
|
||||
* stdio (printf() and friends) should be called from a single task
|
||||
* only or serialized with a FreeRTOS primitive such as a binary
|
||||
* semaphore or mutex.
|
||||
*----------------------------------------------------------*/
|
||||
|
||||
#include <errno.h>
|
||||
#include <pthread.h>
|
||||
|
|
@ -67,25 +67,25 @@
|
|||
#include "task.h"
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
#define SIG_RESUME SIGUSR1
|
||||
#define SIG_RESUME SIGUSR1
|
||||
|
||||
typedef struct THREAD
|
||||
{
|
||||
pthread_t pthread;
|
||||
pdTASK_CODE pxCode;
|
||||
void * pvParams;
|
||||
BaseType_t xDying;
|
||||
pthread_t pthread;
|
||||
pdTASK_CODE pxCode;
|
||||
void *pvParams;
|
||||
BaseType_t xDying;
|
||||
} Thread_t;
|
||||
|
||||
/*
|
||||
* The additional per-thread data is stored at the beginning of the
|
||||
* 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 xAllSignals;
|
||||
static sigset_t xSchedulerOriginalSignalMask;
|
||||
static pthread_t hMainThread = ( pthread_t ) NULL;
|
||||
static pthread_t hMainThread = ( pthread_t )NULL;
|
||||
static volatile portBASE_TYPE uxCriticalNesting;
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
|
|
@ -103,9 +103,8 @@ static portBASE_TYPE xSchedulerEnd = pdFALSE;
|
|||
|
||||
static void prvSetupSignalsAndSchedulerPolicy( void );
|
||||
static void prvSetupTimerInterrupt( void );
|
||||
static void * prvWaitForStart( void * pvParams );
|
||||
static void prvSwitchThread( Thread_t * xThreadToResume,
|
||||
Thread_t * xThreadToSuspend );
|
||||
static void *prvWaitForStart( void * pvParams );
|
||||
static void prvSwitchThread( Thread_t *xThreadToResume, Thread_t *xThreadToSuspend );
|
||||
static void prvSuspendSelf( void );
|
||||
static void prvResumeThread( pthread_t xThreadId );
|
||||
static void vPortSystemTickHandler( int sig );
|
||||
|
|
@ -132,117 +131,110 @@ static void vPortStartFirstTask( void );
|
|||
* timer (SIGALRM) and other signals.
|
||||
*/
|
||||
|
||||
extern void * __libc_malloc( size_t );
|
||||
extern void __libc_free( void * );
|
||||
extern void * __libc_calloc( size_t,
|
||||
size_t );
|
||||
extern void * __libc_realloc( void * ptr,
|
||||
size_t );
|
||||
extern void *__libc_malloc(size_t);
|
||||
extern void __libc_free(void *);
|
||||
extern void *__libc_calloc(size_t, size_t);
|
||||
extern void *__libc_realloc(void *ptr, size_t);
|
||||
|
||||
void * malloc( size_t size )
|
||||
void *malloc(size_t size)
|
||||
{
|
||||
sigset_t xSavedSignals;
|
||||
void * ptr;
|
||||
sigset_t xSavedSignals;
|
||||
void *ptr;
|
||||
|
||||
pthread_sigmask( SIG_BLOCK, &xAllSignals, &xSavedSignals );
|
||||
ptr = __libc_malloc( size );
|
||||
pthread_sigmask( SIG_SETMASK, &xSavedSignals, NULL );
|
||||
pthread_sigmask( SIG_BLOCK, &xAllSignals, &xSavedSignals );
|
||||
ptr = __libc_malloc( size );
|
||||
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 );
|
||||
__libc_free( ptr );
|
||||
pthread_sigmask( SIG_SETMASK, &xSavedSignals, NULL );
|
||||
pthread_sigmask( SIG_BLOCK, &xAllSignals, &xSavedSignals );
|
||||
__libc_free( ptr );
|
||||
pthread_sigmask( SIG_SETMASK, &xSavedSignals, NULL );
|
||||
}
|
||||
|
||||
void * calloc( size_t nmemb,
|
||||
size_t size )
|
||||
void *calloc(size_t nmemb, size_t size)
|
||||
{
|
||||
sigset_t xSavedSignals;
|
||||
void * ptr;
|
||||
sigset_t xSavedSignals;
|
||||
void *ptr;
|
||||
|
||||
pthread_sigmask( SIG_BLOCK, &xAllSignals, &xSavedSignals );
|
||||
ptr = __libc_calloc( nmemb, size );
|
||||
pthread_sigmask( SIG_SETMASK, &xSavedSignals, NULL );
|
||||
pthread_sigmask( SIG_BLOCK, &xAllSignals, &xSavedSignals );
|
||||
ptr = __libc_calloc( nmemb, size );
|
||||
pthread_sigmask( SIG_SETMASK, &xSavedSignals, NULL );
|
||||
|
||||
return ptr;
|
||||
return ptr;
|
||||
}
|
||||
|
||||
void * realloc( void * ptr,
|
||||
size_t size )
|
||||
void *realloc(void *ptr, size_t size)
|
||||
{
|
||||
sigset_t xSavedSignals;
|
||||
sigset_t xSavedSignals;
|
||||
|
||||
pthread_sigmask( SIG_BLOCK, &xAllSignals, &xSavedSignals );
|
||||
ptr = __libc_realloc( ptr, size );
|
||||
pthread_sigmask( SIG_SETMASK, &xSavedSignals, NULL );
|
||||
pthread_sigmask( SIG_BLOCK, &xAllSignals, &xSavedSignals );
|
||||
ptr = __libc_realloc( ptr, size );
|
||||
pthread_sigmask( SIG_SETMASK, &xSavedSignals, NULL );
|
||||
|
||||
return ptr;
|
||||
return ptr;
|
||||
}
|
||||
|
||||
static void prvFatalError( const char * pcCall,
|
||||
int iErrno )
|
||||
static void prvFatalError( const char *pcCall, int iErrno )
|
||||
{
|
||||
fprintf( stderr, "%s: %s\n", pcCall, strerror( iErrno ) );
|
||||
abort();
|
||||
fprintf( stderr, "%s: %s\n", pcCall, strerror( iErrno ) );
|
||||
abort();
|
||||
}
|
||||
|
||||
/*
|
||||
* See header file for description.
|
||||
*/
|
||||
portSTACK_TYPE * pxPortInitialiseStack( portSTACK_TYPE * pxTopOfStack,
|
||||
portSTACK_TYPE * pxEndOfStack,
|
||||
pdTASK_CODE pxCode,
|
||||
void * pvParameters )
|
||||
portSTACK_TYPE *pxPortInitialiseStack( portSTACK_TYPE *pxTopOfStack,
|
||||
portSTACK_TYPE *pxEndOfStack,
|
||||
pdTASK_CODE pxCode, void *pvParameters )
|
||||
{
|
||||
Thread_t * thread;
|
||||
pthread_attr_t xThreadAttributes;
|
||||
size_t ulStackSize;
|
||||
int iRet;
|
||||
Thread_t *thread;
|
||||
pthread_attr_t xThreadAttributes;
|
||||
size_t ulStackSize;
|
||||
int iRet;
|
||||
|
||||
( void ) pthread_once( &hSigSetupThread, prvSetupSignalsAndSchedulerPolicy );
|
||||
(void)pthread_once( &hSigSetupThread, prvSetupSignalsAndSchedulerPolicy );
|
||||
|
||||
/*
|
||||
* Store the additional thread data at the start of the stack.
|
||||
*/
|
||||
thread = ( Thread_t * ) ( pxTopOfStack + 1 ) - 1;
|
||||
pxTopOfStack = ( portSTACK_TYPE * ) thread - 1;
|
||||
ulStackSize = ( pxTopOfStack + 1 - pxEndOfStack ) * sizeof( *pxTopOfStack );
|
||||
/*
|
||||
* Store the additional thread data at the start of the stack.
|
||||
*/
|
||||
thread = (Thread_t *)(pxTopOfStack + 1) - 1;
|
||||
pxTopOfStack = (portSTACK_TYPE *)thread - 1;
|
||||
ulStackSize = (pxTopOfStack + 1 - pxEndOfStack) * sizeof(*pxTopOfStack);
|
||||
|
||||
thread->pxCode = pxCode;
|
||||
thread->pvParams = pvParameters;
|
||||
thread->xDying = pdFALSE;
|
||||
thread->pxCode = pxCode;
|
||||
thread->pvParams = pvParameters;
|
||||
thread->xDying = pdFALSE;
|
||||
|
||||
pthread_attr_init( &xThreadAttributes );
|
||||
pthread_attr_setstack( &xThreadAttributes, pxEndOfStack, ulStackSize );
|
||||
pthread_attr_init( &xThreadAttributes );
|
||||
pthread_attr_setstack( &xThreadAttributes, pxEndOfStack, ulStackSize );
|
||||
|
||||
vPortEnterCritical();
|
||||
vPortEnterCritical();
|
||||
|
||||
iRet = pthread_create( &thread->pthread, &xThreadAttributes,
|
||||
prvWaitForStart, thread );
|
||||
iRet = pthread_create( &thread->pthread, &xThreadAttributes,
|
||||
prvWaitForStart, thread );
|
||||
if ( iRet )
|
||||
{
|
||||
prvFatalError( "pthread_create", iRet );
|
||||
}
|
||||
|
||||
if( iRet )
|
||||
{
|
||||
prvFatalError( "pthread_create", iRet );
|
||||
}
|
||||
vPortExitCritical();
|
||||
|
||||
vPortExitCritical();
|
||||
|
||||
return pxTopOfStack;
|
||||
return pxTopOfStack;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vPortStartFirstTask( void )
|
||||
{
|
||||
Thread_t * pxFirstThread = prvGetThreadFromTask( xTaskGetCurrentTaskHandle() );
|
||||
Thread_t *pxFirstThread = prvGetThreadFromTask( xTaskGetCurrentTaskHandle() );
|
||||
|
||||
/* Start the first task. */
|
||||
prvResumeThread( pxFirstThread->pthread );
|
||||
/* Start the first task. */
|
||||
prvResumeThread( pxFirstThread->pthread );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
|
|
@ -251,126 +243,125 @@ void vPortStartFirstTask( void )
|
|||
*/
|
||||
portBASE_TYPE xPortStartScheduler( void )
|
||||
{
|
||||
int iSignal;
|
||||
sigset_t xSignals;
|
||||
int iSignal;
|
||||
sigset_t xSignals;
|
||||
|
||||
hMainThread = pthread_self();
|
||||
hMainThread = pthread_self();
|
||||
|
||||
/* Start the timer that generates the tick ISR. Interrupts are disabled
|
||||
* here already. */
|
||||
prvSetupTimerInterrupt();
|
||||
/* Start the timer that generates the tick ISR. Interrupts are disabled
|
||||
here already. */
|
||||
prvSetupTimerInterrupt();
|
||||
|
||||
/* Start the first task. */
|
||||
vPortStartFirstTask();
|
||||
/* Start the first task. */
|
||||
vPortStartFirstTask();
|
||||
|
||||
/* Wait until signaled by vPortEndScheduler(). */
|
||||
sigemptyset( &xSignals );
|
||||
sigaddset( &xSignals, SIG_RESUME );
|
||||
/* Wait until signaled by vPortEndScheduler(). */
|
||||
sigemptyset( &xSignals );
|
||||
sigaddset( &xSignals, SIG_RESUME );
|
||||
|
||||
while( !xSchedulerEnd )
|
||||
{
|
||||
sigwait( &xSignals, &iSignal );
|
||||
}
|
||||
while ( !xSchedulerEnd )
|
||||
{
|
||||
sigwait( &xSignals, &iSignal );
|
||||
}
|
||||
|
||||
/* Restore original signal mask. */
|
||||
( void ) pthread_sigmask( SIG_SETMASK, &xSchedulerOriginalSignalMask, NULL );
|
||||
/* Restore original signal mask. */
|
||||
(void)pthread_sigmask( SIG_SETMASK, &xSchedulerOriginalSignalMask, NULL );
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vPortEndScheduler( void )
|
||||
{
|
||||
struct itimerval itimer;
|
||||
struct sigaction sigtick;
|
||||
struct itimerval itimer;
|
||||
struct sigaction sigtick;
|
||||
|
||||
/* Stop the timer and ignore any pending SIGALRMs that would end
|
||||
* up running on the main thread when it is resumed. */
|
||||
itimer.it_value.tv_sec = 0;
|
||||
itimer.it_value.tv_usec = 0;
|
||||
/* Stop the timer and ignore any pending SIGALRMs that would end
|
||||
* up running on the main thread when it is resumed. */
|
||||
itimer.it_value.tv_sec = 0;
|
||||
itimer.it_value.tv_usec = 0;
|
||||
|
||||
itimer.it_interval.tv_sec = 0;
|
||||
itimer.it_interval.tv_usec = 0;
|
||||
( void ) setitimer( ITIMER_REAL, &itimer, NULL );
|
||||
itimer.it_interval.tv_sec = 0;
|
||||
itimer.it_interval.tv_usec = 0;
|
||||
(void)setitimer( ITIMER_REAL, &itimer, NULL );
|
||||
|
||||
sigtick.sa_flags = 0;
|
||||
sigtick.sa_handler = SIG_IGN;
|
||||
sigemptyset( &sigtick.sa_mask );
|
||||
sigaction( SIGALRM, &sigtick, NULL );
|
||||
sigtick.sa_flags = 0;
|
||||
sigtick.sa_handler = SIG_IGN;
|
||||
sigemptyset( &sigtick.sa_mask );
|
||||
sigaction( SIGALRM, &sigtick, NULL );
|
||||
|
||||
/* Signal the scheduler to exit its loop. */
|
||||
xSchedulerEnd = pdTRUE;
|
||||
( void ) pthread_kill( hMainThread, SIG_RESUME );
|
||||
/* Signal the scheduler to exit its loop. */
|
||||
xSchedulerEnd = pdTRUE;
|
||||
(void)pthread_kill( hMainThread, SIG_RESUME );
|
||||
|
||||
prvSuspendSelf();
|
||||
prvSuspendSelf();
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vPortEnterCritical( void )
|
||||
{
|
||||
if( uxCriticalNesting == 0 )
|
||||
{
|
||||
vPortDisableInterrupts();
|
||||
}
|
||||
|
||||
uxCriticalNesting++;
|
||||
if ( uxCriticalNesting == 0 )
|
||||
{
|
||||
vPortDisableInterrupts();
|
||||
}
|
||||
uxCriticalNesting++;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vPortExitCritical( void )
|
||||
{
|
||||
uxCriticalNesting--;
|
||||
uxCriticalNesting--;
|
||||
|
||||
/* If we have reached 0 then re-enable the interrupts. */
|
||||
if( uxCriticalNesting == 0 )
|
||||
{
|
||||
vPortEnableInterrupts();
|
||||
}
|
||||
/* If we have reached 0 then re-enable the interrupts. */
|
||||
if( uxCriticalNesting == 0 )
|
||||
{
|
||||
vPortEnableInterrupts();
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vPortYieldFromISR( void )
|
||||
{
|
||||
Thread_t * xThreadToSuspend;
|
||||
Thread_t * xThreadToResume;
|
||||
Thread_t *xThreadToSuspend;
|
||||
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 )
|
||||
{
|
||||
vPortEnterCritical();
|
||||
vPortEnterCritical();
|
||||
|
||||
vPortYieldFromISR();
|
||||
vPortYieldFromISR();
|
||||
|
||||
vPortExitCritical();
|
||||
vPortExitCritical();
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vPortDisableInterrupts( void )
|
||||
{
|
||||
pthread_sigmask( SIG_BLOCK, &xAllSignals, NULL );
|
||||
pthread_sigmask( SIG_BLOCK, &xAllSignals, NULL );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vPortEnableInterrupts( void )
|
||||
{
|
||||
pthread_sigmask( SIG_UNBLOCK, &xAllSignals, NULL );
|
||||
pthread_sigmask( SIG_UNBLOCK, &xAllSignals, NULL );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
portBASE_TYPE xPortSetInterruptMask( void )
|
||||
{
|
||||
/* Interrupts are always disabled inside ISRs (signals
|
||||
* handlers). */
|
||||
return pdTRUE;
|
||||
/* Interrupts are always disabled inside ISRs (signals
|
||||
handlers). */
|
||||
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;
|
||||
|
|
@ -397,228 +388,218 @@ static uint64_t prvTickCount;
|
|||
*/
|
||||
void prvSetupTimerInterrupt( void )
|
||||
{
|
||||
struct itimerval itimer;
|
||||
int iRet;
|
||||
struct itimerval itimer;
|
||||
int iRet;
|
||||
|
||||
/* Initialise the structure with the current timer information. */
|
||||
iRet = getitimer( ITIMER_REAL, &itimer );
|
||||
/* Initialise the structure with the current timer information. */
|
||||
iRet = getitimer( ITIMER_REAL, &itimer );
|
||||
if ( iRet )
|
||||
{
|
||||
prvFatalError( "getitimer", errno );
|
||||
}
|
||||
|
||||
if( iRet )
|
||||
{
|
||||
prvFatalError( "getitimer", errno );
|
||||
}
|
||||
/* Set the interval between timer events. */
|
||||
itimer.it_interval.tv_sec = 0;
|
||||
itimer.it_interval.tv_usec = portTICK_RATE_MICROSECONDS;
|
||||
|
||||
/* Set the interval between timer events. */
|
||||
itimer.it_interval.tv_sec = 0;
|
||||
itimer.it_interval.tv_usec = portTICK_RATE_MICROSECONDS;
|
||||
/* Set the current count-down. */
|
||||
itimer.it_value.tv_sec = 0;
|
||||
itimer.it_value.tv_usec = portTICK_RATE_MICROSECONDS;
|
||||
|
||||
/* Set the current count-down. */
|
||||
itimer.it_value.tv_sec = 0;
|
||||
itimer.it_value.tv_usec = portTICK_RATE_MICROSECONDS;
|
||||
/* Set-up the timer interrupt. */
|
||||
iRet = setitimer( ITIMER_REAL, &itimer, NULL );
|
||||
if ( iRet )
|
||||
{
|
||||
prvFatalError( "setitimer", errno );
|
||||
}
|
||||
|
||||
/* Set-up the timer interrupt. */
|
||||
iRet = setitimer( ITIMER_REAL, &itimer, NULL );
|
||||
|
||||
if( iRet )
|
||||
{
|
||||
prvFatalError( "setitimer", errno );
|
||||
}
|
||||
|
||||
prvStartTimeNs = prvGetTimeNs();
|
||||
prvStartTimeNs = prvGetTimeNs();
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void vPortSystemTickHandler( int sig )
|
||||
{
|
||||
Thread_t * pxThreadToSuspend;
|
||||
Thread_t * pxThreadToResume;
|
||||
uint64_t xExpectedTicks;
|
||||
Thread_t *pxThreadToSuspend;
|
||||
Thread_t *pxThreadToResume;
|
||||
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
|
||||
* the timer. */
|
||||
xExpectedTicks = ( prvGetTimeNs() - prvStartTimeNs )
|
||||
/ ( portTICK_RATE_MICROSECONDS * 1000 );
|
||||
/* Tick Increment, accounting for any lost signals or drift in
|
||||
* the timer. */
|
||||
xExpectedTicks = (prvGetTimeNs() - prvStartTimeNs)
|
||||
/ (portTICK_RATE_MICROSECONDS * 1000);
|
||||
do {
|
||||
xTaskIncrementTick();
|
||||
prvTickCount++;
|
||||
} while (prvTickCount < xExpectedTicks);
|
||||
|
||||
do
|
||||
{
|
||||
xTaskIncrementTick();
|
||||
prvTickCount++;
|
||||
} while( prvTickCount < xExpectedTicks );
|
||||
#if ( configUSE_PREEMPTION == 1 )
|
||||
/* Select Next Task. */
|
||||
vTaskSwitchContext();
|
||||
|
||||
#if ( configUSE_PREEMPTION == 1 )
|
||||
/* Select Next Task. */
|
||||
vTaskSwitchContext();
|
||||
pxThreadToResume = prvGetThreadFromTask( xTaskGetCurrentTaskHandle() );
|
||||
|
||||
pxThreadToResume = prvGetThreadFromTask( xTaskGetCurrentTaskHandle() );
|
||||
prvSwitchThread(pxThreadToResume, pxThreadToSuspend);
|
||||
#endif
|
||||
|
||||
prvSwitchThread( pxThreadToResume, pxThreadToSuspend );
|
||||
#endif
|
||||
|
||||
uxCriticalNesting--;
|
||||
uxCriticalNesting--;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vPortThreadDying( void * pxTaskToDelete,
|
||||
volatile BaseType_t * pxPendYield )
|
||||
void vPortThreadDying( void *pxTaskToDelete, 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
|
||||
* cancelled.
|
||||
*/
|
||||
pthread_cancel( pxThreadToCancel->pthread );
|
||||
pthread_join( pxThreadToCancel->pthread, NULL );
|
||||
/*
|
||||
* The thread has already been suspended so it can be safely
|
||||
* cancelled.
|
||||
*/
|
||||
pthread_cancel( pxThreadToCancel->pthread );
|
||||
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. */
|
||||
uxCriticalNesting = 0;
|
||||
vPortEnableInterrupts();
|
||||
/* Resumed for the first time, unblocks all signals. */
|
||||
uxCriticalNesting = 0;
|
||||
vPortEnableInterrupts();
|
||||
|
||||
/* Call the task's entry point. */
|
||||
pxThread->pxCode( pxThread->pvParams );
|
||||
/* Call the task's entry point. */
|
||||
pxThread->pxCode( pxThread->pvParams );
|
||||
|
||||
return NULL;
|
||||
return NULL;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvSwitchThread( Thread_t * pxThreadToResume,
|
||||
Thread_t * pxThreadToSuspend )
|
||||
static void prvSwitchThread( Thread_t *pxThreadToResume,
|
||||
Thread_t *pxThreadToSuspend )
|
||||
{
|
||||
BaseType_t uxSavedCriticalNesting;
|
||||
BaseType_t uxSavedCriticalNesting;
|
||||
|
||||
if( pxThreadToSuspend != pxThreadToResume )
|
||||
{
|
||||
/*
|
||||
* Switch tasks.
|
||||
*
|
||||
* The critical section nesting is per-task, so save it on the
|
||||
* stack of the current (suspending thread), restoring it when
|
||||
* we switch back to this task.
|
||||
*/
|
||||
uxSavedCriticalNesting = uxCriticalNesting;
|
||||
if ( pxThreadToSuspend != pxThreadToResume )
|
||||
{
|
||||
/*
|
||||
* Switch tasks.
|
||||
*
|
||||
* The critical section nesting is per-task, so save it on the
|
||||
* stack of the current (suspending thread), restoring it when
|
||||
* we switch back to this task.
|
||||
*/
|
||||
uxSavedCriticalNesting = uxCriticalNesting;
|
||||
|
||||
prvResumeThread( pxThreadToResume->pthread );
|
||||
prvResumeThread( pxThreadToResume->pthread );
|
||||
if ( pxThreadToSuspend->xDying )
|
||||
{
|
||||
pthread_exit( NULL );
|
||||
}
|
||||
prvSuspendSelf();
|
||||
|
||||
if( pxThreadToSuspend->xDying )
|
||||
{
|
||||
pthread_exit( NULL );
|
||||
}
|
||||
|
||||
prvSuspendSelf();
|
||||
|
||||
uxCriticalNesting = uxSavedCriticalNesting;
|
||||
}
|
||||
uxCriticalNesting = uxSavedCriticalNesting;
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvSuspendSelf( void )
|
||||
{
|
||||
int iSig;
|
||||
int iSig;
|
||||
|
||||
/*
|
||||
* Suspend this thread by waiting for a SIG_RESUME signal.
|
||||
*
|
||||
* A suspended thread must not handle signals (interrupts) so
|
||||
* all signals must be blocked by calling this from:
|
||||
*
|
||||
* - Inside a critical section (vPortEnterCritical() /
|
||||
* vPortExitCritical()).
|
||||
*
|
||||
* - From a signal handler that has all signals masked.
|
||||
*
|
||||
* - A thread with all signals blocked with pthread_sigmask().
|
||||
*/
|
||||
sigwait( &xResumeSignals, &iSig );
|
||||
/*
|
||||
* Suspend this thread by waiting for a SIG_RESUME signal.
|
||||
*
|
||||
* A suspended thread must not handle signals (interrupts) so
|
||||
* all signals must be blocked by calling this from:
|
||||
*
|
||||
* - Inside a critical section (vPortEnterCritical() /
|
||||
* vPortExitCritical()).
|
||||
*
|
||||
* - From a signal handler that has all signals masked.
|
||||
*
|
||||
* - A thread with all signals blocked with pthread_sigmask().
|
||||
*/
|
||||
sigwait( &xResumeSignals, &iSig );
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvResumeThread( pthread_t xThreadId )
|
||||
{
|
||||
if( pthread_self() != xThreadId )
|
||||
{
|
||||
pthread_kill( xThreadId, SIG_RESUME );
|
||||
}
|
||||
if ( pthread_self() != xThreadId )
|
||||
{
|
||||
pthread_kill( xThreadId, SIG_RESUME );
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvSetupSignalsAndSchedulerPolicy( void )
|
||||
{
|
||||
struct sigaction sigresume, sigtick;
|
||||
int iRet;
|
||||
struct sigaction sigresume, sigtick;
|
||||
int iRet;
|
||||
|
||||
hMainThread = pthread_self();
|
||||
hMainThread = pthread_self();
|
||||
|
||||
/* Initialise common signal masks. */
|
||||
sigemptyset( &xResumeSignals );
|
||||
sigaddset( &xResumeSignals, SIG_RESUME );
|
||||
sigfillset( &xAllSignals );
|
||||
/* Initialise common signal masks. */
|
||||
sigemptyset( &xResumeSignals );
|
||||
sigaddset( &xResumeSignals, SIG_RESUME );
|
||||
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. */
|
||||
sigdelset( &xAllSignals, SIGINT );
|
||||
/*
|
||||
* Block all signals in this thread so all new threads
|
||||
* inherits this mask.
|
||||
*
|
||||
* When a thread is resumed for the first time, all signals
|
||||
* will be unblocked.
|
||||
*/
|
||||
(void)pthread_sigmask( SIG_SETMASK, &xAllSignals,
|
||||
&xSchedulerOriginalSignalMask );
|
||||
|
||||
/*
|
||||
* Block all signals in this thread so all new threads
|
||||
* 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
|
||||
handler. */
|
||||
sigresume.sa_flags = 0;
|
||||
sigresume.sa_handler = SIG_IGN;
|
||||
sigfillset( &sigresume.sa_mask );
|
||||
|
||||
/* SIG_RESUME is only used with sigwait() so doesn't need a
|
||||
* handler. */
|
||||
sigresume.sa_flags = 0;
|
||||
sigresume.sa_handler = SIG_IGN;
|
||||
sigfillset( &sigresume.sa_mask );
|
||||
sigtick.sa_flags = 0;
|
||||
sigtick.sa_handler = vPortSystemTickHandler;
|
||||
sigfillset( &sigtick.sa_mask );
|
||||
|
||||
sigtick.sa_flags = 0;
|
||||
sigtick.sa_handler = vPortSystemTickHandler;
|
||||
sigfillset( &sigtick.sa_mask );
|
||||
iRet = sigaction( SIG_RESUME, &sigresume, NULL );
|
||||
if ( iRet )
|
||||
{
|
||||
prvFatalError( "sigaction", errno );
|
||||
}
|
||||
|
||||
iRet = sigaction( SIG_RESUME, &sigresume, NULL );
|
||||
|
||||
if( iRet )
|
||||
{
|
||||
prvFatalError( "sigaction", errno );
|
||||
}
|
||||
|
||||
iRet = sigaction( SIGALRM, &sigtick, NULL );
|
||||
|
||||
if( iRet )
|
||||
{
|
||||
prvFatalError( "sigaction", errno );
|
||||
}
|
||||
iRet = sigaction( SIGALRM, &sigtick, NULL );
|
||||
if ( iRet )
|
||||
{
|
||||
prvFatalError( "sigaction", errno );
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
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
|
||||
#define PORTMACRO_H
|
||||
#define PORTMACRO_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <limits.h>
|
||||
#include <limits.h>
|
||||
|
||||
/*-----------------------------------------------------------
|
||||
* Port specific definitions.
|
||||
|
|
@ -46,72 +46,71 @@
|
|||
*/
|
||||
|
||||
/* Type definitions. */
|
||||
#define portCHAR char
|
||||
#define portFLOAT float
|
||||
#define portDOUBLE double
|
||||
#define portLONG long
|
||||
#define portSHORT short
|
||||
#define portSTACK_TYPE unsigned long
|
||||
#define portBASE_TYPE long
|
||||
#define portPOINTER_SIZE_TYPE intptr_t
|
||||
#define portCHAR char
|
||||
#define portFLOAT float
|
||||
#define portDOUBLE double
|
||||
#define portLONG long
|
||||
#define portSHORT short
|
||||
#define portSTACK_TYPE unsigned long
|
||||
#define portBASE_TYPE long
|
||||
#define portPOINTER_SIZE_TYPE intptr_t
|
||||
|
||||
typedef portSTACK_TYPE StackType_t;
|
||||
typedef long BaseType_t;
|
||||
typedef unsigned long UBaseType_t;
|
||||
typedef portSTACK_TYPE StackType_t;
|
||||
typedef long BaseType_t;
|
||||
typedef unsigned long UBaseType_t;
|
||||
|
||||
typedef unsigned long TickType_t;
|
||||
#define portMAX_DELAY ( TickType_t ) ULONG_MAX
|
||||
typedef unsigned long TickType_t;
|
||||
#define portMAX_DELAY ( TickType_t ) ULONG_MAX
|
||||
|
||||
#define portTICK_TYPE_IS_ATOMIC 1
|
||||
#define portTICK_TYPE_IS_ATOMIC 1
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* Architecture specifics. */
|
||||
#define portSTACK_GROWTH ( -1 )
|
||||
#define portHAS_STACK_OVERFLOW_CHECKING ( 1 )
|
||||
#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ )
|
||||
#define portTICK_RATE_MICROSECONDS ( ( portTickType ) 1000000 / configTICK_RATE_HZ )
|
||||
#define portBYTE_ALIGNMENT 8
|
||||
#define portSTACK_GROWTH ( -1 )
|
||||
#define portHAS_STACK_OVERFLOW_CHECKING ( 1 )
|
||||
#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ )
|
||||
#define portTICK_RATE_MICROSECONDS ( ( portTickType ) 1000000 / configTICK_RATE_HZ )
|
||||
#define portBYTE_ALIGNMENT 8
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* 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 portYIELD_FROM_ISR( x ) portEND_SWITCHING_ISR( x )
|
||||
#define portEND_SWITCHING_ISR( xSwitchRequired ) if( xSwitchRequired != pdFALSE ) vPortYield()
|
||||
#define portYIELD_FROM_ISR( x ) portEND_SWITCHING_ISR( x )
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* Critical section management. */
|
||||
extern void vPortDisableInterrupts( void );
|
||||
extern void vPortEnableInterrupts( void );
|
||||
#define portSET_INTERRUPT_MASK() ( vPortDisableInterrupts() )
|
||||
#define portCLEAR_INTERRUPT_MASK() ( vPortEnableInterrupts() )
|
||||
extern void vPortDisableInterrupts( void );
|
||||
extern void vPortEnableInterrupts( void );
|
||||
#define portSET_INTERRUPT_MASK() ( vPortDisableInterrupts() )
|
||||
#define portCLEAR_INTERRUPT_MASK() ( vPortEnableInterrupts() )
|
||||
|
||||
extern portBASE_TYPE xPortSetInterruptMask( void );
|
||||
extern void vPortClearInterruptMask( portBASE_TYPE xMask );
|
||||
extern portBASE_TYPE xPortSetInterruptMask( void );
|
||||
extern void vPortClearInterruptMask( portBASE_TYPE xMask );
|
||||
|
||||
extern void vPortEnterCritical( void );
|
||||
extern void vPortExitCritical( void );
|
||||
#define portSET_INTERRUPT_MASK_FROM_ISR() xPortSetInterruptMask()
|
||||
#define portCLEAR_INTERRUPT_MASK_FROM_ISR( x ) vPortClearInterruptMask( x )
|
||||
#define portDISABLE_INTERRUPTS() portSET_INTERRUPT_MASK()
|
||||
#define portENABLE_INTERRUPTS() portCLEAR_INTERRUPT_MASK()
|
||||
#define portENTER_CRITICAL() vPortEnterCritical()
|
||||
#define portEXIT_CRITICAL() vPortExitCritical()
|
||||
extern void vPortEnterCritical( void );
|
||||
extern void vPortExitCritical( void );
|
||||
#define portSET_INTERRUPT_MASK_FROM_ISR() xPortSetInterruptMask()
|
||||
#define portCLEAR_INTERRUPT_MASK_FROM_ISR(x) vPortClearInterruptMask(x)
|
||||
#define portDISABLE_INTERRUPTS() portSET_INTERRUPT_MASK()
|
||||
#define portENABLE_INTERRUPTS() portCLEAR_INTERRUPT_MASK()
|
||||
#define portENTER_CRITICAL() vPortEnterCritical()
|
||||
#define portEXIT_CRITICAL() vPortExitCritical()
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
extern void vPortThreadDying( void * pxTaskToDelete,
|
||||
volatile BaseType_t * pxPendYield );
|
||||
extern void vPortCancelThread( void * pxTaskToDelete );
|
||||
#define portPRE_TASK_DELETE_HOOK( pvTaskToDelete, pxPendYield ) vPortThreadDying( ( pvTaskToDelete ), ( pxPendYield ) )
|
||||
#define portCLEAN_UP_TCB( pxTCB ) vPortCancelThread( pxTCB )
|
||||
extern void vPortThreadDying( void *pxTaskToDelete, volatile BaseType_t *pxPendYield );
|
||||
extern void vPortCancelThread( void *pxTaskToDelete );
|
||||
#define portPRE_TASK_DELETE_HOOK( pvTaskToDelete, pxPendYield ) vPortThreadDying( ( pvTaskToDelete ), ( pxPendYield ) )
|
||||
#define portCLEAN_UP_TCB( pxTCB ) vPortCancelThread( pxTCB )
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
#define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void * pvParameters )
|
||||
#define portTASK_FUNCTION( 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 )
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
|
|
@ -122,14 +121,14 @@
|
|||
* Thus, only a compilier barrier is needed to prevent the compiler
|
||||
* reordering.
|
||||
*/
|
||||
#define portMEMORY_BARRIER() __asm volatile ( "" ::: "memory" )
|
||||
#define portMEMORY_BARRIER() __asm volatile( "" ::: "memory" )
|
||||
|
||||
extern unsigned long ulPortGetRunTime( void );
|
||||
#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() /* no-op */
|
||||
#define portGET_RUN_TIME_COUNTER_VALUE() ulPortGetRunTime()
|
||||
extern unsigned long ulPortGetRunTime( void );
|
||||
#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() /* no-op */
|
||||
#define portGET_RUN_TIME_COUNTER_VALUE() ulPortGetRunTime()
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* PORTMACRO_H */
|
||||
|
|
|
|||
|
|
@ -64,26 +64,28 @@
|
|||
*/
|
||||
|
||||
#ifndef PORTMACRO_H
|
||||
#define PORTMACRO_H
|
||||
#define PORTMACRO_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/* *INDENT-OFF* */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/* *INDENT-ON* */
|
||||
|
||||
#ifndef __ASSEMBLER__
|
||||
#ifndef __ASSEMBLER__
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <xtensa/hal.h>
|
||||
#include <xtensa/config/core.h>
|
||||
#include <xtensa/config/system.h> /* required for XSHAL_CLIB */
|
||||
#include <xtensa/xtruntime.h>
|
||||
#include "esp_timer.h" /* required for FreeRTOS run time stats */
|
||||
#include "esp_system.h"
|
||||
#include <xtensa/hal.h>
|
||||
#include <xtensa/config/core.h>
|
||||
#include <xtensa/config/system.h> /* required for XSHAL_CLIB */
|
||||
#include <xtensa/xtruntime.h>
|
||||
#include "esp_timer.h" /* required for FreeRTOS run time stats */
|
||||
#include "esp_system.h"
|
||||
|
||||
|
||||
#include <esp_heap_caps.h>
|
||||
#include "soc/soc_memory_layout.h"
|
||||
#include <esp_heap_caps.h>
|
||||
#include "soc/soc_memory_layout.h"
|
||||
|
||||
/*#include "xtensa_context.h" */
|
||||
|
||||
|
|
@ -99,84 +101,84 @@
|
|||
|
||||
/* Type definitions. */
|
||||
|
||||
#define portCHAR int8_t
|
||||
#define portFLOAT float
|
||||
#define portDOUBLE double
|
||||
#define portLONG int32_t
|
||||
#define portSHORT int16_t
|
||||
#define portSTACK_TYPE uint8_t
|
||||
#define portBASE_TYPE int
|
||||
#define portCHAR int8_t
|
||||
#define portFLOAT float
|
||||
#define portDOUBLE double
|
||||
#define portLONG int32_t
|
||||
#define portSHORT int16_t
|
||||
#define portSTACK_TYPE uint8_t
|
||||
#define portBASE_TYPE int
|
||||
|
||||
typedef portSTACK_TYPE StackType_t;
|
||||
typedef portBASE_TYPE BaseType_t;
|
||||
typedef unsigned portBASE_TYPE UBaseType_t;
|
||||
typedef portSTACK_TYPE StackType_t;
|
||||
typedef portBASE_TYPE BaseType_t;
|
||||
typedef unsigned portBASE_TYPE UBaseType_t;
|
||||
|
||||
#if ( configUSE_16_BIT_TICKS == 1 )
|
||||
typedef uint16_t TickType_t;
|
||||
#define portMAX_DELAY ( TickType_t ) 0xffff
|
||||
#else
|
||||
typedef uint32_t TickType_t;
|
||||
#define portMAX_DELAY ( TickType_t ) 0xffffffffUL
|
||||
#endif
|
||||
#if ( configUSE_16_BIT_TICKS == 1 )
|
||||
typedef uint16_t TickType_t;
|
||||
#define portMAX_DELAY ( TickType_t ) 0xffff
|
||||
#else
|
||||
typedef uint32_t TickType_t;
|
||||
#define portMAX_DELAY ( TickType_t ) 0xffffffffUL
|
||||
#endif
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* portbenchmark */
|
||||
#include "portbenchmark.h"
|
||||
#include "portbenchmark.h"
|
||||
|
||||
#include "sdkconfig.h"
|
||||
#include "esp_attr.h"
|
||||
#include "sdkconfig.h"
|
||||
#include "esp_attr.h"
|
||||
|
||||
/* "mux" data structure (spinlock) */
|
||||
typedef struct
|
||||
{
|
||||
/* owner field values:
|
||||
* 0 - Uninitialized (invalid)
|
||||
* portMUX_FREE_VAL - Mux is free, can be locked by either CPU
|
||||
* CORE_ID_PRO / CORE_ID_APP - Mux is locked to the particular core
|
||||
*
|
||||
* Any value other than portMUX_FREE_VAL, CORE_ID_PRO, CORE_ID_APP indicates corruption
|
||||
*/
|
||||
uint32_t owner;
|
||||
typedef struct
|
||||
{
|
||||
/* owner field values:
|
||||
* 0 - Uninitialized (invalid)
|
||||
* portMUX_FREE_VAL - Mux is free, can be locked by either CPU
|
||||
* CORE_ID_PRO / CORE_ID_APP - Mux is locked to the particular core
|
||||
*
|
||||
* Any value other than portMUX_FREE_VAL, CORE_ID_PRO, CORE_ID_APP indicates corruption
|
||||
*/
|
||||
uint32_t owner;
|
||||
|
||||
/* count field:
|
||||
* If mux is unlocked, count should be zero.
|
||||
* If mux is locked, count is non-zero & represents the number of recursive locks on the mux.
|
||||
*/
|
||||
uint32_t count;
|
||||
#ifdef CONFIG_FREERTOS_PORTMUX_DEBUG
|
||||
const char * lastLockedFn;
|
||||
int lastLockedLine;
|
||||
#endif
|
||||
} portMUX_TYPE;
|
||||
/* count field:
|
||||
* If mux is unlocked, count should be zero.
|
||||
* If mux is locked, count is non-zero & represents the number of recursive locks on the mux.
|
||||
*/
|
||||
uint32_t count;
|
||||
#ifdef CONFIG_FREERTOS_PORTMUX_DEBUG
|
||||
const char * lastLockedFn;
|
||||
int lastLockedLine;
|
||||
#endif
|
||||
} portMUX_TYPE;
|
||||
|
||||
#define portMUX_FREE_VAL 0xB33FFFFF
|
||||
#define portMUX_FREE_VAL 0xB33FFFFF
|
||||
|
||||
/* Special constants for vPortCPUAcquireMutexTimeout() */
|
||||
#define portMUX_NO_TIMEOUT ( -1 ) /* When passed for 'timeout_cycles', spin forever if necessary */
|
||||
#define portMUX_TRY_LOCK 0 /* Try to acquire the spinlock a single time only */
|
||||
#define portMUX_NO_TIMEOUT ( -1 ) /* When passed for 'timeout_cycles', spin forever if necessary */
|
||||
#define portMUX_TRY_LOCK 0 /* Try to acquire the spinlock a single time only */
|
||||
|
||||
/* Keep this in sync with the portMUX_TYPE struct definition please. */
|
||||
#ifndef CONFIG_FREERTOS_PORTMUX_DEBUG
|
||||
#define portMUX_INITIALIZER_UNLOCKED \
|
||||
{ \
|
||||
.owner = portMUX_FREE_VAL, \
|
||||
.count = 0, \
|
||||
#ifndef CONFIG_FREERTOS_PORTMUX_DEBUG
|
||||
#define portMUX_INITIALIZER_UNLOCKED \
|
||||
{ \
|
||||
.owner = portMUX_FREE_VAL, \
|
||||
.count = 0, \
|
||||
}
|
||||
#else
|
||||
#define portMUX_INITIALIZER_UNLOCKED \
|
||||
{ \
|
||||
.owner = portMUX_FREE_VAL, \
|
||||
.count = 0, \
|
||||
.lastLockedFn = "(never locked)", \
|
||||
.lastLockedLine = -1 \
|
||||
#else
|
||||
#define portMUX_INITIALIZER_UNLOCKED \
|
||||
{ \
|
||||
.owner = portMUX_FREE_VAL, \
|
||||
.count = 0, \
|
||||
.lastLockedFn = "(never locked)", \
|
||||
.lastLockedLine = -1 \
|
||||
}
|
||||
#endif /* ifndef CONFIG_FREERTOS_PORTMUX_DEBUG */
|
||||
#endif /* ifndef CONFIG_FREERTOS_PORTMUX_DEBUG */
|
||||
|
||||
|
||||
#define portASSERT_IF_IN_ISR() vPortAssertIfInISR()
|
||||
void vPortAssertIfInISR();
|
||||
#define portASSERT_IF_IN_ISR() vPortAssertIfInISR()
|
||||
void vPortAssertIfInISR();
|
||||
|
||||
#define portCRITICAL_NESTING_IN_TCB 1
|
||||
#define portCRITICAL_NESTING_IN_TCB 1
|
||||
|
||||
/*
|
||||
* Modifications to portENTER_CRITICAL.
|
||||
|
|
@ -204,17 +206,17 @@
|
|||
* that either function can be called both from ISR as well as task context. This is not standard FreeRTOS
|
||||
* behaviour; please keep this in mind if you need any compatibility with other FreeRTOS implementations.
|
||||
*/
|
||||
void vPortCPUInitializeMutex( portMUX_TYPE * mux );
|
||||
#ifdef CONFIG_FREERTOS_PORTMUX_DEBUG
|
||||
#error CONFIG_FREERTOS_PORTMUX_DEBUG not supported in Amazon FreeRTOS
|
||||
#endif
|
||||
void vPortCPUInitializeMutex( portMUX_TYPE * mux );
|
||||
#ifdef CONFIG_FREERTOS_PORTMUX_DEBUG
|
||||
#error CONFIG_FREERTOS_PORTMUX_DEBUG not supported in Amazon FreeRTOS
|
||||
#endif
|
||||
|
||||
void vTaskExitCritical();
|
||||
void vTaskEnterCritical();
|
||||
static inline void vPortConsumeSpinlockArg( int unused,
|
||||
... )
|
||||
{
|
||||
}
|
||||
void vTaskExitCritical();
|
||||
void vTaskEnterCritical();
|
||||
static inline void vPortConsumeSpinlockArg( int unused,
|
||||
... )
|
||||
{
|
||||
}
|
||||
|
||||
/** @brief Acquire a portmux spinlock with a timeout
|
||||
*
|
||||
|
|
@ -224,35 +226,35 @@
|
|||
*
|
||||
* @return true if mutex is successfully acquired, false on timeout.
|
||||
*/
|
||||
bool vPortCPUAcquireMutexTimeout( portMUX_TYPE * mux,
|
||||
int timeout_cycles );
|
||||
void vPortCPUReleaseMutex( portMUX_TYPE * mux );
|
||||
bool vPortCPUAcquireMutexTimeout( portMUX_TYPE * mux,
|
||||
int timeout_cycles );
|
||||
void vPortCPUReleaseMutex( portMUX_TYPE * mux );
|
||||
|
||||
#define portENTER_CRITICAL( ... ) do { vTaskEnterCritical(); vPortConsumeSpinlockArg( 0, ## __VA_ARGS__ ); } while( 0 )
|
||||
#define portEXIT_CRITICAL( ... ) do { vTaskExitCritical(); vPortConsumeSpinlockArg( 0, ## __VA_ARGS__ ); } while( 0 )
|
||||
#define portENTER_CRITICAL( ... ) do { vTaskEnterCritical(); vPortConsumeSpinlockArg( 0, ## __VA_ARGS__ ); } while( 0 )
|
||||
#define portEXIT_CRITICAL( ... ) do { vTaskExitCritical(); vPortConsumeSpinlockArg( 0, ## __VA_ARGS__ ); } while( 0 )
|
||||
|
||||
|
||||
#define portENTER_CRITICAL_ISR( mux ) vPortCPUAcquireMutexTimeout( mux, portMUX_NO_TIMEOUT )
|
||||
#define portEXIT_CRITICAL_ISR( mux ) vPortCPUReleaseMutex( mux )
|
||||
#define portENTER_CRITICAL_ISR( mux ) vPortCPUAcquireMutexTimeout( mux, portMUX_NO_TIMEOUT )
|
||||
#define portEXIT_CRITICAL_ISR( mux ) vPortCPUReleaseMutex( mux )
|
||||
|
||||
#define portENTER_CRITICAL_SAFE( mux ) \
|
||||
do { \
|
||||
if( xPortInIsrContext() ) { \
|
||||
portENTER_CRITICAL_ISR( mux ); \
|
||||
} \
|
||||
else { \
|
||||
portENTER_CRITICAL( mux ); \
|
||||
} \
|
||||
#define portENTER_CRITICAL_SAFE( mux ) \
|
||||
do { \
|
||||
if( xPortInIsrContext() ) { \
|
||||
portENTER_CRITICAL_ISR( mux ); \
|
||||
} \
|
||||
else { \
|
||||
portENTER_CRITICAL( mux ); \
|
||||
} \
|
||||
} while( 0 )
|
||||
|
||||
#define portEXIT_CRITICAL_SAFE( mux ) \
|
||||
do { \
|
||||
if( xPortInIsrContext() ) { \
|
||||
portEXIT_CRITICAL_ISR( mux ); \
|
||||
} \
|
||||
else { \
|
||||
portEXIT_CRITICAL( mux ); \
|
||||
} \
|
||||
#define portEXIT_CRITICAL_SAFE( mux ) \
|
||||
do { \
|
||||
if( xPortInIsrContext() ) { \
|
||||
portEXIT_CRITICAL_ISR( mux ); \
|
||||
} \
|
||||
else { \
|
||||
portEXIT_CRITICAL( mux ); \
|
||||
} \
|
||||
} while( 0 )
|
||||
|
||||
|
||||
|
|
@ -260,37 +262,37 @@
|
|||
/* These cannot be nested. They should be used with a lot of care and cannot be called from interrupt level. */
|
||||
/* */
|
||||
/* Only applies to one CPU. See notes above & below for reasons not to use these. */
|
||||
#define portDISABLE_INTERRUPTS() do { XTOS_SET_INTLEVEL( XCHAL_EXCM_LEVEL ); portbenchmarkINTERRUPT_DISABLE(); } while( 0 )
|
||||
#define portENABLE_INTERRUPTS() do { portbenchmarkINTERRUPT_RESTORE( 0 ); XTOS_SET_INTLEVEL( 0 ); } while( 0 )
|
||||
#define portDISABLE_INTERRUPTS() do { XTOS_SET_INTLEVEL( XCHAL_EXCM_LEVEL ); portbenchmarkINTERRUPT_DISABLE(); } while( 0 )
|
||||
#define portENABLE_INTERRUPTS() do { portbenchmarkINTERRUPT_RESTORE( 0 ); XTOS_SET_INTLEVEL( 0 ); } while( 0 )
|
||||
|
||||
/* Cleaner solution allows nested interrupts disabling and restoring via local registers or stack. */
|
||||
/* They can be called from interrupts too. */
|
||||
/* WARNING: Only applies to current CPU. See notes above. */
|
||||
static inline unsigned portENTER_CRITICAL_NESTED()
|
||||
{
|
||||
unsigned state = XTOS_SET_INTLEVEL( XCHAL_EXCM_LEVEL );
|
||||
static inline unsigned portENTER_CRITICAL_NESTED()
|
||||
{
|
||||
unsigned state = XTOS_SET_INTLEVEL( XCHAL_EXCM_LEVEL );
|
||||
|
||||
portbenchmarkINTERRUPT_DISABLE();
|
||||
return state;
|
||||
}
|
||||
#define portEXIT_CRITICAL_NESTED( state ) do { portbenchmarkINTERRUPT_RESTORE( state ); XTOS_RESTORE_JUST_INTLEVEL( state ); } while( 0 )
|
||||
portbenchmarkINTERRUPT_DISABLE();
|
||||
return state;
|
||||
}
|
||||
#define portEXIT_CRITICAL_NESTED( state ) do { portbenchmarkINTERRUPT_RESTORE( state ); XTOS_RESTORE_JUST_INTLEVEL( state ); } while( 0 )
|
||||
|
||||
/* These FreeRTOS versions are similar to the nested versions above */
|
||||
#define portSET_INTERRUPT_MASK_FROM_ISR() portENTER_CRITICAL_NESTED()
|
||||
#define portCLEAR_INTERRUPT_MASK_FROM_ISR( state ) portEXIT_CRITICAL_NESTED( state )
|
||||
#define portSET_INTERRUPT_MASK_FROM_ISR() portENTER_CRITICAL_NESTED()
|
||||
#define portCLEAR_INTERRUPT_MASK_FROM_ISR( state ) portEXIT_CRITICAL_NESTED( state )
|
||||
|
||||
/*Because the ROM routines don't necessarily handle a stack in external RAM correctly, we force */
|
||||
/*the stack memory to always be internal. */
|
||||
#define pvPortMallocTcbMem( size ) heap_caps_malloc( size, MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT )
|
||||
#define pvPortMallocStackMem( size ) heap_caps_malloc( size, MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT )
|
||||
#define pvPortMallocTcbMem( size ) heap_caps_malloc( size, MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT )
|
||||
#define pvPortMallocStackMem( size ) heap_caps_malloc( size, MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT )
|
||||
|
||||
/*xTaskCreateStatic uses these functions to check incoming memory. */
|
||||
#define portVALID_TCB_MEM( ptr ) ( esp_ptr_internal( ptr ) && esp_ptr_byte_accessible( ptr ) )
|
||||
#ifdef CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY
|
||||
#define portVALID_STACK_MEM( ptr ) esp_ptr_byte_accessible( ptr )
|
||||
#else
|
||||
#define portVALID_STACK_MEM( ptr ) ( esp_ptr_internal( ptr ) && esp_ptr_byte_accessible( ptr ) )
|
||||
#endif
|
||||
#define portVALID_TCB_MEM( ptr ) ( esp_ptr_internal( ptr ) && esp_ptr_byte_accessible( ptr ) )
|
||||
#ifdef CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY
|
||||
#define portVALID_STACK_MEM( ptr ) esp_ptr_byte_accessible( ptr )
|
||||
#else
|
||||
#define portVALID_STACK_MEM( ptr ) ( esp_ptr_internal( ptr ) && esp_ptr_byte_accessible( ptr ) )
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Wrapper for the Xtensa compare-and-set instruction. This subroutine will atomically compare
|
||||
|
|
@ -301,118 +303,118 @@
|
|||
* *bitwise inverse* of the old mem if the mem wasn't written. This doesn't seem to happen on the
|
||||
* ESP32 (portMUX assertions would fail).
|
||||
*/
|
||||
static inline void uxPortCompareSet( volatile uint32_t * addr,
|
||||
uint32_t compare,
|
||||
uint32_t * set )
|
||||
{
|
||||
#if ( XCHAL_HAVE_S32C1I > 0 )
|
||||
__asm__ __volatile__ (
|
||||
"WSR %2,SCOMPARE1 \n"
|
||||
"S32C1I %0, %1, 0 \n"
|
||||
: "=r" ( *set )
|
||||
: "r" ( addr ), "r" ( compare ), "0" ( *set )
|
||||
);
|
||||
#else
|
||||
/* No S32C1I, so do this by disabling and re-enabling interrupts (slower) */
|
||||
uint32_t intlevel, old_value;
|
||||
__asm__ __volatile__ ( "rsil %0, " XTSTR( XCHAL_EXCM_LEVEL ) "\n"
|
||||
: "=r" ( intlevel ) );
|
||||
static inline void uxPortCompareSet( volatile uint32_t * addr,
|
||||
uint32_t compare,
|
||||
uint32_t * set )
|
||||
{
|
||||
#if ( XCHAL_HAVE_S32C1I > 0 )
|
||||
__asm__ __volatile__ (
|
||||
"WSR %2,SCOMPARE1 \n"
|
||||
"S32C1I %0, %1, 0 \n"
|
||||
: "=r" ( *set )
|
||||
: "r" ( addr ), "r" ( compare ), "0" ( *set )
|
||||
);
|
||||
#else
|
||||
/* No S32C1I, so do this by disabling and re-enabling interrupts (slower) */
|
||||
uint32_t intlevel, old_value;
|
||||
__asm__ __volatile__ ( "rsil %0, " XTSTR( XCHAL_EXCM_LEVEL ) "\n"
|
||||
: "=r" ( intlevel ) );
|
||||
|
||||
old_value = *addr;
|
||||
old_value = *addr;
|
||||
|
||||
if( old_value == compare )
|
||||
{
|
||||
*addr = *set;
|
||||
}
|
||||
if( old_value == compare )
|
||||
{
|
||||
*addr = *set;
|
||||
}
|
||||
|
||||
__asm__ __volatile__ ( "memw \n"
|
||||
"wsr %0, ps\n"
|
||||
: : "r" ( intlevel ) );
|
||||
__asm__ __volatile__ ( "memw \n"
|
||||
"wsr %0, ps\n"
|
||||
: : "r" ( intlevel ) );
|
||||
|
||||
*set = old_value;
|
||||
#endif /* if ( XCHAL_HAVE_S32C1I > 0 ) */
|
||||
}
|
||||
*set = old_value;
|
||||
#endif /* if ( XCHAL_HAVE_S32C1I > 0 ) */
|
||||
}
|
||||
|
||||
void uxPortCompareSetExtram( volatile uint32_t * addr,
|
||||
uint32_t compare,
|
||||
uint32_t * set );
|
||||
void uxPortCompareSetExtram( volatile uint32_t * addr,
|
||||
uint32_t compare,
|
||||
uint32_t * set );
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* Architecture specifics. */
|
||||
#define portSTACK_GROWTH ( -1 )
|
||||
#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ )
|
||||
#define portBYTE_ALIGNMENT 4
|
||||
#define portNOP() XT_NOP()
|
||||
#define portSTACK_GROWTH ( -1 )
|
||||
#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ )
|
||||
#define portBYTE_ALIGNMENT 4
|
||||
#define portNOP() XT_NOP()
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* Fine resolution time */
|
||||
#define portGET_RUN_TIME_COUNTER_VALUE() xthal_get_ccount()
|
||||
#define portGET_RUN_TIME_COUNTER_VALUE() xthal_get_ccount()
|
||||
/*ccount or esp_timer are initialized elsewhere */
|
||||
#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS()
|
||||
#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS()
|
||||
|
||||
#ifdef CONFIG_FREERTOS_RUN_TIME_STATS_USING_ESP_TIMER
|
||||
#ifdef CONFIG_FREERTOS_RUN_TIME_STATS_USING_ESP_TIMER
|
||||
/* Coarse resolution time (us) */
|
||||
#define portALT_GET_RUN_TIME_COUNTER_VALUE( x ) x = ( uint32_t ) esp_timer_get_time()
|
||||
#endif
|
||||
#define portALT_GET_RUN_TIME_COUNTER_VALUE( x ) x = ( uint32_t ) esp_timer_get_time()
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/* Kernel utilities. */
|
||||
void vPortYield( void );
|
||||
void _frxt_setup_switch( void );
|
||||
#define portYIELD() vPortYield()
|
||||
#define portYIELD_FROM_ISR() { traceISR_EXIT_TO_SCHEDULER(); _frxt_setup_switch(); }
|
||||
void vPortYield( void );
|
||||
void _frxt_setup_switch( void );
|
||||
#define portYIELD() vPortYield()
|
||||
#define portYIELD_FROM_ISR() { traceISR_EXIT_TO_SCHEDULER(); _frxt_setup_switch(); }
|
||||
|
||||
static inline uint32_t xPortGetCoreID();
|
||||
static inline uint32_t xPortGetCoreID();
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* Task function macros as described on the FreeRTOS.org WEB site. */
|
||||
#define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void * pvParameters )
|
||||
#define portTASK_FUNCTION( 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 )
|
||||
|
||||
/* When coprocessors are defined, we to maintain a pointer to coprocessors area. */
|
||||
/* We currently use a hack: redefine field xMPU_SETTINGS in TCB block as a structure that can hold: */
|
||||
/* MPU wrappers, coprocessor area pointer, trace code structure, and more if needed. */
|
||||
/* The field is normally used for memory protection. FreeRTOS should create another general purpose field. */
|
||||
typedef struct
|
||||
{
|
||||
#if XCHAL_CP_NUM > 0
|
||||
volatile StackType_t * coproc_area; /* Pointer to coprocessor save area; MUST BE FIRST */
|
||||
#endif
|
||||
|
||||
#if portUSING_MPU_WRAPPERS
|
||||
/* Define here mpu_settings, which is port dependent */
|
||||
int mpu_setting; /* Just a dummy example here; MPU not ported to Xtensa yet */
|
||||
#endif
|
||||
|
||||
#if configUSE_TRACE_FACILITY_2
|
||||
struct
|
||||
{
|
||||
/* Cf. porttraceStamp() */
|
||||
int taskstamp; /* Stamp from inside task to see where we are */
|
||||
int taskstampcount; /* A counter usually incremented when we restart the task's loop */
|
||||
} porttrace;
|
||||
#endif
|
||||
} xMPU_SETTINGS;
|
||||
|
||||
/* Main hack to use MPU_wrappers even when no MPU is defined (warning: mpu_setting should not be accessed; otherwise move this above xMPU_SETTINGS) */
|
||||
#if ( XCHAL_CP_NUM > 0 || configUSE_TRACE_FACILITY_2 ) && !portUSING_MPU_WRAPPERS /* If MPU wrappers not used, we still need to allocate coproc area */
|
||||
#undef portUSING_MPU_WRAPPERS
|
||||
#define portUSING_MPU_WRAPPERS 1 /* Enable it to allocate coproc area */
|
||||
#define MPU_WRAPPERS_H /* Override mpu_wrapper.h to disable unwanted code */
|
||||
#define PRIVILEGED_FUNCTION
|
||||
#define PRIVILEGED_DATA
|
||||
typedef struct
|
||||
{
|
||||
#if XCHAL_CP_NUM > 0
|
||||
volatile StackType_t * coproc_area; /* Pointer to coprocessor save area; MUST BE FIRST */
|
||||
#endif
|
||||
|
||||
bool vApplicationSleep( TickType_t xExpectedIdleTime );
|
||||
#if portUSING_MPU_WRAPPERS
|
||||
/* Define here mpu_settings, which is port dependent */
|
||||
int mpu_setting; /* Just a dummy example here; MPU not ported to Xtensa yet */
|
||||
#endif
|
||||
|
||||
#define portSUPPRESS_TICKS_AND_SLEEP( idleTime ) vApplicationSleep( idleTime )
|
||||
#if configUSE_TRACE_FACILITY_2
|
||||
struct
|
||||
{
|
||||
/* Cf. porttraceStamp() */
|
||||
int taskstamp; /* Stamp from inside task to see where we are */
|
||||
int taskstampcount; /* A counter usually incremented when we restart the task's loop */
|
||||
} porttrace;
|
||||
#endif
|
||||
} xMPU_SETTINGS;
|
||||
|
||||
/* Main hack to use MPU_wrappers even when no MPU is defined (warning: mpu_setting should not be accessed; otherwise move this above xMPU_SETTINGS) */
|
||||
#if ( XCHAL_CP_NUM > 0 || configUSE_TRACE_FACILITY_2 ) && !portUSING_MPU_WRAPPERS /* If MPU wrappers not used, we still need to allocate coproc area */
|
||||
#undef portUSING_MPU_WRAPPERS
|
||||
#define portUSING_MPU_WRAPPERS 1 /* Enable it to allocate coproc area */
|
||||
#define MPU_WRAPPERS_H /* Override mpu_wrapper.h to disable unwanted code */
|
||||
#define PRIVILEGED_FUNCTION
|
||||
#define PRIVILEGED_DATA
|
||||
#endif
|
||||
|
||||
bool vApplicationSleep( TickType_t xExpectedIdleTime );
|
||||
|
||||
#define portSUPPRESS_TICKS_AND_SLEEP( idleTime ) vApplicationSleep( idleTime )
|
||||
|
||||
|
||||
|
||||
void _xt_coproc_release( volatile void * coproc_sa_base );
|
||||
void _xt_coproc_release( volatile void * coproc_sa_base );
|
||||
|
||||
|
||||
/*
|
||||
|
|
@ -422,29 +424,29 @@
|
|||
* non-FreeRTOS-specific code, and behave the same as
|
||||
* pvPortMalloc()/vPortFree().
|
||||
*/
|
||||
#define pvPortMalloc heap_caps_malloc_default
|
||||
#define vPortFree heap_caps_free
|
||||
#define xPortGetFreeHeapSize esp_get_free_heap_size
|
||||
#define xPortGetMinimumEverFreeHeapSize esp_get_minimum_free_heap_size
|
||||
#define pvPortMalloc heap_caps_malloc_default
|
||||
#define vPortFree heap_caps_free
|
||||
#define xPortGetFreeHeapSize esp_get_free_heap_size
|
||||
#define xPortGetMinimumEverFreeHeapSize esp_get_minimum_free_heap_size
|
||||
|
||||
|
||||
/*
|
||||
* Callback to set a watchpoint on the end of the stack. Called every context switch to change the stack
|
||||
* watchpoint around.
|
||||
*/
|
||||
void vPortSetStackWatchpoint( void * pxStackStart );
|
||||
void vPortSetStackWatchpoint( void * pxStackStart );
|
||||
|
||||
/*
|
||||
* Returns true if the current core is in ISR context; low prio ISR, med prio ISR or timer tick ISR. High prio ISRs
|
||||
* aren't detected here, but they normally cannot call C code, so that should not be an issue anyway.
|
||||
*/
|
||||
BaseType_t xPortInIsrContext();
|
||||
BaseType_t xPortInIsrContext();
|
||||
|
||||
/*
|
||||
* This function will be called in High prio ISRs. Returns true if the current core was in ISR context
|
||||
* before calling into high prio ISR context.
|
||||
*/
|
||||
BaseType_t xPortInterruptedFromISRContext();
|
||||
BaseType_t xPortInterruptedFromISRContext();
|
||||
|
||||
/*
|
||||
* The structures and methods of manipulating the MPU are contained within the
|
||||
|
|
@ -453,46 +455,48 @@
|
|||
* Fills the xMPUSettings structure with the memory region information
|
||||
* contained in xRegions.
|
||||
*/
|
||||
#if ( portUSING_MPU_WRAPPERS == 1 )
|
||||
struct xMEMORY_REGION;
|
||||
void vPortStoreTaskMPUSettings( xMPU_SETTINGS * xMPUSettings,
|
||||
const struct xMEMORY_REGION * const xRegions,
|
||||
StackType_t * pxBottomOfStack,
|
||||
uint32_t usStackDepth ) PRIVILEGED_FUNCTION;
|
||||
void vPortReleaseTaskMPUSettings( xMPU_SETTINGS * xMPUSettings );
|
||||
#endif
|
||||
|
||||
/* Multi-core: get current core ID */
|
||||
static inline uint32_t IRAM_ATTR xPortGetCoreID()
|
||||
{
|
||||
int id;
|
||||
|
||||
asm (
|
||||
"rsr.prid %0\n"
|
||||
" extui %0,%0,13,1"
|
||||
: "=r" ( id ) );
|
||||
return id;
|
||||
}
|
||||
|
||||
/* Get tick rate per second */
|
||||
uint32_t xPortGetTickRateHz( void );
|
||||
|
||||
/* porttrace */
|
||||
#if configUSE_TRACE_FACILITY_2
|
||||
#include "porttrace.h"
|
||||
#endif
|
||||
|
||||
/* configASSERT_2 if requested */
|
||||
#if configASSERT_2
|
||||
#include <stdio.h>
|
||||
void exit( int );
|
||||
#define configASSERT( x ) if( !( x ) ) { porttracePrint( -1 ); printf( "\nAssertion failed in %s:%d\n", __FILE__, __LINE__ ); exit( -1 ); }
|
||||
#endif
|
||||
|
||||
#endif // __ASSEMBLER__
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#if ( portUSING_MPU_WRAPPERS == 1 )
|
||||
struct xMEMORY_REGION;
|
||||
void vPortStoreTaskMPUSettings( xMPU_SETTINGS * xMPUSettings,
|
||||
const struct xMEMORY_REGION * const xRegions,
|
||||
StackType_t * pxBottomOfStack,
|
||||
uint32_t usStackDepth ) PRIVILEGED_FUNCTION;
|
||||
void vPortReleaseTaskMPUSettings( xMPU_SETTINGS * xMPUSettings );
|
||||
#endif
|
||||
|
||||
/* Multi-core: get current core ID */
|
||||
static inline uint32_t IRAM_ATTR xPortGetCoreID()
|
||||
{
|
||||
int id;
|
||||
|
||||
asm (
|
||||
"rsr.prid %0\n"
|
||||
" extui %0,%0,13,1"
|
||||
: "=r" ( id ) );
|
||||
return id;
|
||||
}
|
||||
|
||||
/* Get tick rate per second */
|
||||
uint32_t xPortGetTickRateHz( void );
|
||||
|
||||
/* porttrace */
|
||||
#if configUSE_TRACE_FACILITY_2
|
||||
#include "porttrace.h"
|
||||
#endif
|
||||
|
||||
/* configASSERT_2 if requested */
|
||||
#if configASSERT_2
|
||||
#include <stdio.h>
|
||||
void exit( int );
|
||||
#define configASSERT( x ) if( !( x ) ) { porttracePrint( -1 ); printf( "\nAssertion failed in %s:%d\n", __FILE__, __LINE__ ); exit( -1 ); }
|
||||
#endif
|
||||
|
||||
#endif // __ASSEMBLER__
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
/* *INDENT-ON* */
|
||||
|
||||
#endif /* PORTMACRO_H */
|
||||
|
|
|
|||
4
portable/ThirdParty/GCC/Xtensa_ESP32/port.c
vendored
4
portable/ThirdParty/GCC/Xtensa_ESP32/port.c
vendored
|
|
@ -154,6 +154,7 @@ void _xt_user_exit( void );
|
|||
/*
|
||||
* Stack initialization
|
||||
*/
|
||||
/* *INDENT-OFF* */
|
||||
#if portUSING_MPU_WRAPPERS
|
||||
StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack,
|
||||
TaskFunction_t pxCode,
|
||||
|
|
@ -164,6 +165,7 @@ void _xt_user_exit( void );
|
|||
TaskFunction_t pxCode,
|
||||
void * pvParameters )
|
||||
#endif
|
||||
/* *INDENT-ON* */
|
||||
{
|
||||
StackType_t * sp, * tp;
|
||||
XtExcFrame * frame;
|
||||
|
|
@ -409,7 +411,7 @@ void vPortCPUInitializeMutex( portMUX_TYPE * mux )
|
|||
return result;
|
||||
}
|
||||
|
||||
#else /* ifdef CONFIG_FREERTOS_PORTMUX_DEBUG */
|
||||
#else /* ifdef CONFIG_FREERTOS_PORTMUX_DEBUG */
|
||||
void vPortCPUAcquireMutex( portMUX_TYPE * mux )
|
||||
{
|
||||
unsigned int irqStatus = portENTER_CRITICAL_NESTED();
|
||||
|
|
|
|||
|
|
@ -35,9 +35,9 @@
|
|||
|
||||
#include "xtensa_rtos.h"
|
||||
#if CONFIG_IDF_TARGET_ESP32S2
|
||||
#include "esp32s2/clk.h"
|
||||
#include "esp32s2/clk.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32
|
||||
#include "esp32/clk.h"
|
||||
#include "esp32/clk.h"
|
||||
#endif
|
||||
|
||||
#ifdef XT_RTOS_TIMER_INT
|
||||
|
|
|
|||
|
|
@ -35,9 +35,9 @@
|
|||
#include "freertos/portable.h"
|
||||
|
||||
#if CONFIG_IDF_TARGET_ESP32S2
|
||||
#include "esp32s2/rom/ets_sys.h"
|
||||
#include "esp32s2/rom/ets_sys.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32
|
||||
#include "esp32/rom/ets_sys.h"
|
||||
#include "esp32/rom/ets_sys.h"
|
||||
#endif
|
||||
|
||||
#if XCHAL_HAVE_EXCEPTIONS
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue