build(rtos): 适配 AC6 编译器
工程已参考 COD 战队《Keil 使用 FreeRTOS 后 AC6 编译器适配指南》,将 FreeRTOS 的 armcc 端口替换为 GCC 端口:portable/GCC/ARM_CM4F 的 port.c 与 portmacro.h 覆盖到 portable/RVDS/ARM_CM4F。 工程克隆后可直接用 AC6 编译,无需再改动工程文件。 但维护者若需要运行 CubeMX GENERATE,必须先按照文章在自己本机的固件包中做同样替换, 否则生成时会把 AC5 端口拷回工程,编译时重新出现 armcc 语法错误(`__forceinline` 等)。 详见 docs/ac6-migration.md。
This commit is contained in:
1 parent
7723c5d83a
commit
850fc67138
4 files changed
+279
-307
No files matched your search
@@ -11,7 +11,7 @@
|
|||||||
<ToolsetNumber>0x4</ToolsetNumber>
|
<ToolsetNumber>0x4</ToolsetNumber>
|
||||||
<ToolsetName>ARM-ADS</ToolsetName>
|
<ToolsetName>ARM-ADS</ToolsetName>
|
||||||
<pCCUsed>6240000::V6.24::ARMCLANG</pCCUsed>
|
<pCCUsed>6240000::V6.24::ARMCLANG</pCCUsed>
|
||||||
<uAC6>0</uAC6>
|
<uAC6>1</uAC6>
|
||||||
<TargetOption>
|
<TargetOption>
|
||||||
<TargetCommonOption>
|
<TargetCommonOption>
|
||||||
<Device>STM32H723VGTx</Device>
|
<Device>STM32H723VGTx</Device>
|
||||||
@@ -323,7 +323,7 @@
|
|||||||
<PlainCh>0</PlainCh>
|
<PlainCh>0</PlainCh>
|
||||||
<Ropi>0</Ropi>
|
<Ropi>0</Ropi>
|
||||||
<Rwpi>0</Rwpi>
|
<Rwpi>0</Rwpi>
|
||||||
<wLevel>2</wLevel>
|
<wLevel>3</wLevel>
|
||||||
<uThumb>0</uThumb>
|
<uThumb>0</uThumb>
|
||||||
<uSurpInc>0</uSurpInc>
|
<uSurpInc>0</uSurpInc>
|
||||||
<uC99>1</uC99>
|
<uC99>1</uC99>
|
||||||
|
|||||||
+10
@@ -0,0 +1,10 @@
|
|||||||
|
本目录内容不是 ST 原版的 armcc(RVDS) 端口。
|
||||||
|
|
||||||
|
来源:STM32Cube_FW_H7_V1.13.0/Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F
|
||||||
|
(port.c、portmacro.h)
|
||||||
|
|
||||||
|
原因:原版端口使用 armcc 专有语法(__forceinline、__asm void、preserve8),
|
||||||
|
在 Arm Compiler 6 下无法编译;替换为 GCC 写法后可同时支持 AC6。
|
||||||
|
|
||||||
|
注意:目录名仍保留 RVDS,是为了不改动 uvprojx 中的 include 路径。
|
||||||
|
替换步骤与本机固件包需要同步修改的原因,见 /docs/ac6-migration.md。
|
||||||
+183
-208
@@ -34,23 +34,10 @@
|
|||||||
#include "FreeRTOS.h"
|
#include "FreeRTOS.h"
|
||||||
#include "task.h"
|
#include "task.h"
|
||||||
|
|
||||||
#ifndef __TARGET_FPU_VFP
|
#ifndef __VFP_FP__
|
||||||
#error This port can only be used when the project options are configured to enable hardware floating point support.
|
#error This port can only be used when the project options are configured to enable hardware floating point support.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if configMAX_SYSCALL_INTERRUPT_PRIORITY == 0
|
|
||||||
#error configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to 0. See http: /*www.FreeRTOS.org/RTOS-Cortex-M3-M4.html */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Legacy macro for backward compatibility only. This macro used to be used to
|
|
||||||
* replace the function that configures the clock used to generate the tick
|
|
||||||
* interrupt (prvSetupTimerInterrupt()), but now the function is declared weak so
|
|
||||||
* the application writer can override it by simply defining a function of the
|
|
||||||
* same name (vApplicationSetupTickInterrupt()). */
|
|
||||||
#ifndef configOVERRIDE_DEFAULT_TICK_CONFIGURATION
|
|
||||||
#define configOVERRIDE_DEFAULT_TICK_CONFIGURATION 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Constants required to manipulate the core. Registers first... */
|
/* Constants required to manipulate the core. Registers first... */
|
||||||
#define portNVIC_SYSTICK_CTRL_REG ( *( ( volatile uint32_t * ) 0xe000e010 ) )
|
#define portNVIC_SYSTICK_CTRL_REG ( *( ( volatile uint32_t * ) 0xe000e010 ) )
|
||||||
#define portNVIC_SYSTICK_LOAD_REG ( *( ( volatile uint32_t * ) 0xe000e014 ) )
|
#define portNVIC_SYSTICK_LOAD_REG ( *( ( volatile uint32_t * ) 0xe000e014 ) )
|
||||||
@@ -99,15 +86,15 @@
|
|||||||
/* The systick is a 24-bit counter. */
|
/* The systick is a 24-bit counter. */
|
||||||
#define portMAX_24_BIT_NUMBER ( 0xffffffUL )
|
#define portMAX_24_BIT_NUMBER ( 0xffffffUL )
|
||||||
|
|
||||||
|
/* For strict compliance with the Cortex-M spec the task start address should
|
||||||
|
* have bit-0 clear, as it is loaded into the PC on exit from an ISR. */
|
||||||
|
#define portSTART_ADDRESS_MASK ( ( StackType_t ) 0xfffffffeUL )
|
||||||
|
|
||||||
/* A fiddle factor to estimate the number of SysTick counts that would have
|
/* A fiddle factor to estimate the number of SysTick counts that would have
|
||||||
* occurred while the SysTick counter is stopped during tickless idle
|
* occurred while the SysTick counter is stopped during tickless idle
|
||||||
* calculations. */
|
* calculations. */
|
||||||
#define portMISSED_COUNTS_FACTOR ( 94UL )
|
#define portMISSED_COUNTS_FACTOR ( 94UL )
|
||||||
|
|
||||||
/* For strict compliance with the Cortex-M spec the task start address should
|
|
||||||
* have bit-0 clear, as it is loaded into the PC on exit from an ISR. */
|
|
||||||
#define portSTART_ADDRESS_MASK ( ( StackType_t ) 0xfffffffeUL )
|
|
||||||
|
|
||||||
/* Let the user override the default SysTick clock rate. If defined by the
|
/* Let the user override the default SysTick clock rate. If defined by the
|
||||||
* user, this symbol must equal the SysTick clock rate when the CLK bit is 0 in the
|
* user, this symbol must equal the SysTick clock rate when the CLK bit is 0 in the
|
||||||
* configuration register. */
|
* configuration register. */
|
||||||
@@ -120,6 +107,15 @@
|
|||||||
#define portNVIC_SYSTICK_CLK_BIT_CONFIG ( 0 )
|
#define portNVIC_SYSTICK_CLK_BIT_CONFIG ( 0 )
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Let the user override the pre-loading of the initial LR with the address of
|
||||||
|
* prvTaskExitError() in case it messes up unwinding of the stack in the
|
||||||
|
* debugger. */
|
||||||
|
#ifdef configTASK_RETURN_ADDRESS
|
||||||
|
#define portTASK_RETURN_ADDRESS configTASK_RETURN_ADDRESS
|
||||||
|
#else
|
||||||
|
#define portTASK_RETURN_ADDRESS prvTaskExitError
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Setup the timer to generate the tick interrupts. The implementation in this
|
* Setup the timer to generate the tick interrupts. The implementation in this
|
||||||
* file is weak to allow application writers to change the timer used to
|
* file is weak to allow application writers to change the timer used to
|
||||||
@@ -130,19 +126,19 @@ void vPortSetupTimerInterrupt( void );
|
|||||||
/*
|
/*
|
||||||
* Exception handlers.
|
* Exception handlers.
|
||||||
*/
|
*/
|
||||||
void xPortPendSVHandler( void );
|
void xPortPendSVHandler( void ) __attribute__( ( naked ) );
|
||||||
void xPortSysTickHandler( void );
|
void xPortSysTickHandler( void );
|
||||||
void vPortSVCHandler( void );
|
void vPortSVCHandler( void ) __attribute__( ( naked ) );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Start first task is a separate function so it can be tested in isolation.
|
* Start first task is a separate function so it can be tested in isolation.
|
||||||
*/
|
*/
|
||||||
static void prvStartFirstTask( void );
|
static void prvPortStartFirstTask( void ) __attribute__( ( naked ) );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Functions defined in portasm.s to enable the VFP.
|
* Function to enable the VFP.
|
||||||
*/
|
*/
|
||||||
static void prvEnableVFP( void );
|
static void vPortEnableVFP( void ) __attribute__( ( naked ) );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Used to catch tasks that attempt to return from their implementing function.
|
* Used to catch tasks that attempt to return from their implementing function.
|
||||||
@@ -186,7 +182,7 @@ static UBaseType_t uxCriticalNesting = 0xaaaaaaaa;
|
|||||||
#if ( configASSERT_DEFINED == 1 )
|
#if ( configASSERT_DEFINED == 1 )
|
||||||
static uint8_t ucMaxSysCallPriority = 0;
|
static uint8_t ucMaxSysCallPriority = 0;
|
||||||
static uint32_t ulMaxPRIGROUPValue = 0;
|
static uint32_t ulMaxPRIGROUPValue = 0;
|
||||||
static const volatile uint8_t * const pcInterruptPriorityRegisters = ( uint8_t * ) portNVIC_IP_REGISTERS_OFFSET_16;
|
static const volatile uint8_t * const pcInterruptPriorityRegisters = ( const volatile uint8_t * const ) portNVIC_IP_REGISTERS_OFFSET_16;
|
||||||
#endif /* configASSERT_DEFINED */
|
#endif /* configASSERT_DEFINED */
|
||||||
|
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
@@ -209,7 +205,7 @@ StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack,
|
|||||||
pxTopOfStack--;
|
pxTopOfStack--;
|
||||||
*pxTopOfStack = ( ( StackType_t ) pxCode ) & portSTART_ADDRESS_MASK; /* PC */
|
*pxTopOfStack = ( ( StackType_t ) pxCode ) & portSTART_ADDRESS_MASK; /* PC */
|
||||||
pxTopOfStack--;
|
pxTopOfStack--;
|
||||||
*pxTopOfStack = ( StackType_t ) prvTaskExitError; /* LR */
|
*pxTopOfStack = ( StackType_t ) portTASK_RETURN_ADDRESS; /* LR */
|
||||||
|
|
||||||
/* Save code space by skipping register initialisation. */
|
/* Save code space by skipping register initialisation. */
|
||||||
pxTopOfStack -= 5; /* R12, R3, R2 and R1. */
|
pxTopOfStack -= 5; /* R12, R3, R2 and R1. */
|
||||||
@@ -228,6 +224,8 @@ StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack,
|
|||||||
|
|
||||||
static void prvTaskExitError( void )
|
static void prvTaskExitError( void )
|
||||||
{
|
{
|
||||||
|
volatile uint32_t ulDummy = 0;
|
||||||
|
|
||||||
/* A function that implements a task must not exit or attempt to return to
|
/* A function that implements a task must not exit or attempt to return to
|
||||||
* its caller as there is nothing to return to. If a task wants to exit it
|
* its caller as there is nothing to return to. If a task wants to exit it
|
||||||
* should instead call vTaskDelete( NULL ).
|
* should instead call vTaskDelete( NULL ).
|
||||||
@@ -237,78 +235,59 @@ static void prvTaskExitError( void )
|
|||||||
configASSERT( uxCriticalNesting == ~0UL );
|
configASSERT( uxCriticalNesting == ~0UL );
|
||||||
portDISABLE_INTERRUPTS();
|
portDISABLE_INTERRUPTS();
|
||||||
|
|
||||||
for( ; ; )
|
while( ulDummy == 0 )
|
||||||
{
|
{
|
||||||
|
/* This file calls prvTaskExitError() after the scheduler has been
|
||||||
|
* started to remove a compiler warning about the function being defined
|
||||||
|
* but never called. ulDummy is used purely to quieten other warnings
|
||||||
|
* about code appearing after this function is called - making ulDummy
|
||||||
|
* volatile makes the compiler think the function could return and
|
||||||
|
* therefore not output an 'unreachable code' warning for code that appears
|
||||||
|
* after it. */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
__asm void vPortSVCHandler( void )
|
void vPortSVCHandler( void )
|
||||||
{
|
{
|
||||||
/* *INDENT-OFF* */
|
__asm volatile (
|
||||||
PRESERVE8
|
" ldr r3, pxCurrentTCBConst2 \n" /* Restore the context. */
|
||||||
|
" ldr r1, [r3] \n" /* Use pxCurrentTCBConst to get the pxCurrentTCB address. */
|
||||||
/* Get the location of the current TCB. */
|
" ldr r0, [r1] \n" /* The first item in pxCurrentTCB is the task top of stack. */
|
||||||
ldr r3, =pxCurrentTCB
|
" ldmia r0!, {r4-r11, r14} \n" /* Pop the registers that are not automatically saved on exception entry and the critical nesting count. */
|
||||||
ldr r1, [ r3 ]
|
" msr psp, r0 \n" /* Restore the task stack pointer. */
|
||||||
ldr r0, [ r1 ]
|
" isb \n"
|
||||||
/* Pop the core registers. */
|
" mov r0, #0 \n"
|
||||||
ldmia r0!, {r4-r11,r14}
|
" msr basepri, r0 \n"
|
||||||
msr psp, r0
|
" bx r14 \n"
|
||||||
isb
|
" \n"
|
||||||
mov r0, #0
|
" .align 4 \n"
|
||||||
msr basepri, r0
|
"pxCurrentTCBConst2: .word pxCurrentTCB \n"
|
||||||
bx r14
|
);
|
||||||
/* *INDENT-ON* */
|
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
__asm void prvStartFirstTask( void )
|
static void prvPortStartFirstTask( void )
|
||||||
{
|
{
|
||||||
/* *INDENT-OFF* */
|
/* Start the first task. This also clears the bit that indicates the FPU is
|
||||||
PRESERVE8
|
* in use in case the FPU was used before the scheduler was started - which
|
||||||
|
* would otherwise result in the unnecessary leaving of space in the SVC stack
|
||||||
/* Use the NVIC offset register to locate the stack. */
|
* for lazy saving of FPU registers. */
|
||||||
ldr r0, =0xE000ED08
|
__asm volatile (
|
||||||
ldr r0, [ r0 ]
|
" ldr r0, =0xE000ED08 \n" /* Use the NVIC offset register to locate the stack. */
|
||||||
ldr r0, [ r0 ]
|
" ldr r0, [r0] \n"
|
||||||
/* Set the msp back to the start of the stack. */
|
" ldr r0, [r0] \n"
|
||||||
msr msp, r0
|
" msr msp, r0 \n" /* Set the msp back to the start of the stack. */
|
||||||
|
" mov r0, #0 \n" /* Clear the bit that indicates the FPU is in use, see comment above. */
|
||||||
/* Clear the bit that indicates the FPU is in use in case the FPU was used
|
" msr control, r0 \n"
|
||||||
* before the scheduler was started - which would otherwise result in the
|
" cpsie i \n" /* Globally enable interrupts. */
|
||||||
* unnecessary leaving of space in the SVC stack for lazy saving of FPU
|
" cpsie f \n"
|
||||||
* registers. */
|
" dsb \n"
|
||||||
mov r0, #0
|
" isb \n"
|
||||||
msr control, r0
|
" svc 0 \n" /* System call to start first task. */
|
||||||
/* Globally enable interrupts. */
|
" nop \n"
|
||||||
cpsie i
|
" .ltorg \n"
|
||||||
cpsie f
|
);
|
||||||
dsb
|
|
||||||
isb
|
|
||||||
/* Call SVC to start the first task. */
|
|
||||||
svc 0
|
|
||||||
nop
|
|
||||||
nop
|
|
||||||
/* *INDENT-ON* */
|
|
||||||
}
|
|
||||||
/*-----------------------------------------------------------*/
|
|
||||||
|
|
||||||
__asm void prvEnableVFP( void )
|
|
||||||
{
|
|
||||||
/* *INDENT-OFF* */
|
|
||||||
PRESERVE8
|
|
||||||
|
|
||||||
/* The FPU enable bits are in the CPACR. */
|
|
||||||
ldr.w r0, =0xE000ED88
|
|
||||||
ldr r1, [ r0 ]
|
|
||||||
|
|
||||||
/* Enable CP10 and CP11 coprocessors, then save back. */
|
|
||||||
orr r1, r1, #( 0xf << 20 )
|
|
||||||
str r1, [ r0 ]
|
|
||||||
bx r14
|
|
||||||
nop
|
|
||||||
/* *INDENT-ON* */
|
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
@@ -317,10 +296,6 @@ __asm void prvEnableVFP( void )
|
|||||||
*/
|
*/
|
||||||
BaseType_t xPortStartScheduler( void )
|
BaseType_t xPortStartScheduler( void )
|
||||||
{
|
{
|
||||||
/* configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to 0.
|
|
||||||
* See https://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html */
|
|
||||||
configASSERT( configMAX_SYSCALL_INTERRUPT_PRIORITY );
|
|
||||||
|
|
||||||
/* This port can be used on all revisions of the Cortex-M7 core other than
|
/* This port can be used on all revisions of the Cortex-M7 core other than
|
||||||
* the r0p1 parts. r0p1 parts should use the port from the
|
* the r0p1 parts. r0p1 parts should use the port from the
|
||||||
* /source/portable/GCC/ARM_CM7/r0p1 directory. */
|
* /source/portable/GCC/ARM_CM7/r0p1 directory. */
|
||||||
@@ -331,7 +306,7 @@ BaseType_t xPortStartScheduler( void )
|
|||||||
{
|
{
|
||||||
volatile uint8_t ucOriginalPriority;
|
volatile uint8_t ucOriginalPriority;
|
||||||
volatile uint32_t ulImplementedPrioBits = 0;
|
volatile uint32_t ulImplementedPrioBits = 0;
|
||||||
volatile uint8_t * const pucFirstUserPriorityRegister = ( uint8_t * ) ( portNVIC_IP_REGISTERS_OFFSET_16 + portFIRST_USER_INTERRUPT_NUMBER );
|
volatile uint8_t * const pucFirstUserPriorityRegister = ( volatile uint8_t * const ) ( portNVIC_IP_REGISTERS_OFFSET_16 + portFIRST_USER_INTERRUPT_NUMBER );
|
||||||
volatile uint8_t ucMaxPriorityValue;
|
volatile uint8_t ucMaxPriorityValue;
|
||||||
|
|
||||||
/* Determine the maximum priority from which ISR safe FreeRTOS API
|
/* Determine the maximum priority from which ISR safe FreeRTOS API
|
||||||
@@ -423,13 +398,22 @@ BaseType_t xPortStartScheduler( void )
|
|||||||
uxCriticalNesting = 0;
|
uxCriticalNesting = 0;
|
||||||
|
|
||||||
/* Ensure the VFP is enabled - it should be anyway. */
|
/* Ensure the VFP is enabled - it should be anyway. */
|
||||||
prvEnableVFP();
|
vPortEnableVFP();
|
||||||
|
|
||||||
/* Lazy save always. */
|
/* Lazy save always. */
|
||||||
*( portFPCCR ) |= portASPEN_AND_LSPEN_BITS;
|
*( portFPCCR ) |= portASPEN_AND_LSPEN_BITS;
|
||||||
|
|
||||||
/* Start the first task. */
|
/* Start the first task. */
|
||||||
prvStartFirstTask();
|
prvPortStartFirstTask();
|
||||||
|
|
||||||
|
/* Should never get here as the tasks will now be executing! Call the task
|
||||||
|
* exit error function to prevent compiler warnings about a static function
|
||||||
|
* not being called in the case that the application writer overrides this
|
||||||
|
* functionality by defining configTASK_RETURN_ADDRESS. Call
|
||||||
|
* vTaskSwitchContext() so link time optimisation does not remove the
|
||||||
|
* symbol. */
|
||||||
|
vTaskSwitchContext();
|
||||||
|
prvTaskExitError();
|
||||||
|
|
||||||
/* Should not get here! */
|
/* Should not get here! */
|
||||||
return 0;
|
return 0;
|
||||||
@@ -473,67 +457,60 @@ void vPortExitCritical( void )
|
|||||||
}
|
}
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
__asm void xPortPendSVHandler( void )
|
void xPortPendSVHandler( void )
|
||||||
{
|
{
|
||||||
extern uxCriticalNesting;
|
/* This is a naked function. */
|
||||||
extern pxCurrentTCB;
|
|
||||||
extern vTaskSwitchContext;
|
|
||||||
|
|
||||||
/* *INDENT-OFF* */
|
__asm volatile
|
||||||
PRESERVE8
|
(
|
||||||
|
" mrs r0, psp \n"
|
||||||
mrs r0, psp
|
" isb \n"
|
||||||
isb
|
" \n"
|
||||||
/* Get the location of the current TCB. */
|
" ldr r3, pxCurrentTCBConst \n" /* Get the location of the current TCB. */
|
||||||
ldr r3, =pxCurrentTCB
|
" ldr r2, [r3] \n"
|
||||||
ldr r2, [ r3 ]
|
" \n"
|
||||||
|
" tst r14, #0x10 \n" /* Is the task using the FPU context? If so, push high vfp registers. */
|
||||||
/* Is the task using the FPU context? If so, push high vfp registers. */
|
" it eq \n"
|
||||||
tst r14, #0x10
|
" vstmdbeq r0!, {s16-s31} \n"
|
||||||
it eq
|
" \n"
|
||||||
vstmdbeq r0!, {s16-s31}
|
" stmdb r0!, {r4-r11, r14} \n" /* Save the core registers. */
|
||||||
|
" str r0, [r2] \n" /* Save the new top of stack into the first member of the TCB. */
|
||||||
/* Save the core registers. */
|
" \n"
|
||||||
stmdb r0!, {r4-r11, r14}
|
" stmdb sp!, {r0, r3} \n"
|
||||||
|
" mov r0, %0 \n"
|
||||||
/* Save the new top of stack into the first member of the TCB. */
|
" msr basepri, r0 \n"
|
||||||
str r0, [ r2 ]
|
" dsb \n"
|
||||||
|
" isb \n"
|
||||||
stmdb sp!, {r0, r3}
|
" bl vTaskSwitchContext \n"
|
||||||
mov r0, #configMAX_SYSCALL_INTERRUPT_PRIORITY
|
" mov r0, #0 \n"
|
||||||
msr basepri, r0
|
" msr basepri, r0 \n"
|
||||||
dsb
|
" ldmia sp!, {r0, r3} \n"
|
||||||
isb
|
" \n"
|
||||||
bl vTaskSwitchContext
|
" ldr r1, [r3] \n" /* The first item in pxCurrentTCB is the task top of stack. */
|
||||||
mov r0, #0
|
" ldr r0, [r1] \n"
|
||||||
msr basepri, r0
|
" \n"
|
||||||
ldmia sp!, {r0, r3}
|
" ldmia r0!, {r4-r11, r14} \n" /* Pop the core registers. */
|
||||||
|
" \n"
|
||||||
/* The first item in pxCurrentTCB is the task top of stack. */
|
" tst r14, #0x10 \n" /* Is the task using the FPU context? If so, pop the high vfp registers too. */
|
||||||
ldr r1, [ r3 ]
|
" it eq \n"
|
||||||
ldr r0, [ r1 ]
|
" vldmiaeq r0!, {s16-s31} \n"
|
||||||
|
" \n"
|
||||||
/* Pop the core registers. */
|
" msr psp, r0 \n"
|
||||||
ldmia r0!, {r4-r11, r14}
|
" isb \n"
|
||||||
|
" \n"
|
||||||
/* Is the task using the FPU context? If so, pop the high vfp registers
|
#ifdef WORKAROUND_PMU_CM001 /* XMC4000 specific errata workaround. */
|
||||||
* too. */
|
#if WORKAROUND_PMU_CM001 == 1
|
||||||
tst r14, #0x10
|
" push { r14 } \n"
|
||||||
it eq
|
" pop { pc } \n"
|
||||||
vldmiaeq r0!, {s16-s31}
|
#endif
|
||||||
|
|
||||||
msr psp, r0
|
|
||||||
isb
|
|
||||||
#ifdef WORKAROUND_PMU_CM001 /* XMC4000 specific errata */
|
|
||||||
#if WORKAROUND_PMU_CM001 == 1
|
|
||||||
push { r14 }
|
|
||||||
pop { pc }
|
|
||||||
nop
|
|
||||||
#endif
|
#endif
|
||||||
#endif
|
" \n"
|
||||||
|
" bx r14 \n"
|
||||||
bx r14
|
" \n"
|
||||||
/* *INDENT-ON* */
|
" .align 4 \n"
|
||||||
|
"pxCurrentTCBConst: .word pxCurrentTCB \n"
|
||||||
|
::"i" ( configMAX_SYSCALL_INTERRUPT_PRIORITY )
|
||||||
|
);
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
@@ -542,9 +519,8 @@ void xPortSysTickHandler( void )
|
|||||||
/* The SysTick runs at the lowest interrupt priority, so when this interrupt
|
/* The SysTick runs at the lowest interrupt priority, so when this interrupt
|
||||||
* executes all interrupts must be unmasked. There is therefore no need to
|
* executes all interrupts must be unmasked. There is therefore no need to
|
||||||
* save and then restore the interrupt mask value as its value is already
|
* save and then restore the interrupt mask value as its value is already
|
||||||
* known - therefore the slightly faster vPortRaiseBASEPRI() function is used
|
* known. */
|
||||||
* in place of portSET_INTERRUPT_MASK_FROM_ISR(). */
|
portDISABLE_INTERRUPTS();
|
||||||
vPortRaiseBASEPRI();
|
|
||||||
{
|
{
|
||||||
/* Increment the RTOS tick. */
|
/* Increment the RTOS tick. */
|
||||||
if( xTaskIncrementTick() != pdFALSE )
|
if( xTaskIncrementTick() != pdFALSE )
|
||||||
@@ -554,14 +530,13 @@ void xPortSysTickHandler( void )
|
|||||||
portNVIC_INT_CTRL_REG = portNVIC_PENDSVSET_BIT;
|
portNVIC_INT_CTRL_REG = portNVIC_PENDSVSET_BIT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
portENABLE_INTERRUPTS();
|
||||||
vPortClearBASEPRIFromISR();
|
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
#if ( configUSE_TICKLESS_IDLE == 1 )
|
#if ( configUSE_TICKLESS_IDLE == 1 )
|
||||||
|
|
||||||
__weak void vPortSuppressTicksAndSleep( TickType_t xExpectedIdleTime )
|
__attribute__( ( weak ) ) void vPortSuppressTicksAndSleep( TickType_t xExpectedIdleTime )
|
||||||
{
|
{
|
||||||
uint32_t ulReloadValue, ulCompleteTickPeriods, ulCompletedSysTickDecrements, ulSysTickDecrementsLeft;
|
uint32_t ulReloadValue, ulCompleteTickPeriods, ulCompletedSysTickDecrements, ulSysTickDecrementsLeft;
|
||||||
TickType_t xModifiableIdleTime;
|
TickType_t xModifiableIdleTime;
|
||||||
@@ -574,17 +549,17 @@ void xPortSysTickHandler( void )
|
|||||||
|
|
||||||
/* Enter a critical section but don't use the taskENTER_CRITICAL()
|
/* Enter a critical section but don't use the taskENTER_CRITICAL()
|
||||||
* method as that will mask interrupts that should exit sleep mode. */
|
* method as that will mask interrupts that should exit sleep mode. */
|
||||||
__disable_irq();
|
__asm volatile ( "cpsid i" ::: "memory" );
|
||||||
__dsb( portSY_FULL_READ_WRITE );
|
__asm volatile ( "dsb" );
|
||||||
__isb( portSY_FULL_READ_WRITE );
|
__asm volatile ( "isb" );
|
||||||
|
|
||||||
/* If a context switch is pending or a task is waiting for the scheduler
|
/* If a context switch is pending or a task is waiting for the scheduler
|
||||||
* to be unsuspended then abandon the low power entry. */
|
* to be unsuspended then abandon the low power entry. */
|
||||||
if( eTaskConfirmSleepModeStatus() == eAbortSleep )
|
if( eTaskConfirmSleepModeStatus() == eAbortSleep )
|
||||||
{
|
{
|
||||||
/* Re-enable interrupts - see comments above the __disable_irq()
|
/* Re-enable interrupts - see comments above the cpsid instruction
|
||||||
* call above. */
|
* above. */
|
||||||
__enable_irq();
|
__asm volatile ( "cpsie i" ::: "memory" );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -645,27 +620,27 @@ void xPortSysTickHandler( void )
|
|||||||
|
|
||||||
if( xModifiableIdleTime > 0 )
|
if( xModifiableIdleTime > 0 )
|
||||||
{
|
{
|
||||||
__dsb( portSY_FULL_READ_WRITE );
|
__asm volatile ( "dsb" ::: "memory" );
|
||||||
__wfi();
|
__asm volatile ( "wfi" );
|
||||||
__isb( portSY_FULL_READ_WRITE );
|
__asm volatile ( "isb" );
|
||||||
}
|
}
|
||||||
|
|
||||||
configPOST_SLEEP_PROCESSING( xExpectedIdleTime );
|
configPOST_SLEEP_PROCESSING( xExpectedIdleTime );
|
||||||
|
|
||||||
/* Re-enable interrupts to allow the interrupt that brought the MCU
|
/* Re-enable interrupts to allow the interrupt that brought the MCU
|
||||||
* out of sleep mode to execute immediately. See comments above
|
* out of sleep mode to execute immediately. See comments above
|
||||||
* the __disable_irq() call above. */
|
* the cpsid instruction above. */
|
||||||
__enable_irq();
|
__asm volatile ( "cpsie i" ::: "memory" );
|
||||||
__dsb( portSY_FULL_READ_WRITE );
|
__asm volatile ( "dsb" );
|
||||||
__isb( portSY_FULL_READ_WRITE );
|
__asm volatile ( "isb" );
|
||||||
|
|
||||||
/* Disable interrupts again because the clock is about to be stopped
|
/* Disable interrupts again because the clock is about to be stopped
|
||||||
* and interrupts that execute while the clock is stopped will increase
|
* and interrupts that execute while the clock is stopped will increase
|
||||||
* any slippage between the time maintained by the RTOS and calendar
|
* any slippage between the time maintained by the RTOS and calendar
|
||||||
* time. */
|
* time. */
|
||||||
__disable_irq();
|
__asm volatile ( "cpsid i" ::: "memory" );
|
||||||
__dsb( portSY_FULL_READ_WRITE );
|
__asm volatile ( "dsb" );
|
||||||
__isb( portSY_FULL_READ_WRITE );
|
__asm volatile ( "isb" );
|
||||||
|
|
||||||
/* Disable the SysTick clock without reading the
|
/* Disable the SysTick clock without reading the
|
||||||
* portNVIC_SYSTICK_CTRL_REG register to ensure the
|
* portNVIC_SYSTICK_CTRL_REG register to ensure the
|
||||||
@@ -773,51 +748,51 @@ void xPortSysTickHandler( void )
|
|||||||
vTaskStepTick( ulCompleteTickPeriods );
|
vTaskStepTick( ulCompleteTickPeriods );
|
||||||
|
|
||||||
/* Exit with interrupts enabled. */
|
/* Exit with interrupts enabled. */
|
||||||
__enable_irq();
|
__asm volatile ( "cpsie i" ::: "memory" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* #if configUSE_TICKLESS_IDLE */
|
#endif /* #if configUSE_TICKLESS_IDLE */
|
||||||
|
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Setup the SysTick timer to generate the tick interrupts at the required
|
* Setup the systick timer to generate the tick interrupts at the required
|
||||||
* frequency.
|
* frequency.
|
||||||
*/
|
*/
|
||||||
#if ( configOVERRIDE_DEFAULT_TICK_CONFIGURATION == 0 )
|
__attribute__( ( weak ) ) void vPortSetupTimerInterrupt( void )
|
||||||
|
{
|
||||||
__weak void vPortSetupTimerInterrupt( void )
|
/* Calculate the constants required to configure the tick interrupt. */
|
||||||
|
#if ( configUSE_TICKLESS_IDLE == 1 )
|
||||||
{
|
{
|
||||||
/* Calculate the constants required to configure the tick interrupt. */
|
ulTimerCountsForOneTick = ( configSYSTICK_CLOCK_HZ / configTICK_RATE_HZ );
|
||||||
#if ( configUSE_TICKLESS_IDLE == 1 )
|
xMaximumPossibleSuppressedTicks = portMAX_24_BIT_NUMBER / ulTimerCountsForOneTick;
|
||||||
{
|
ulStoppedTimerCompensation = portMISSED_COUNTS_FACTOR / ( configCPU_CLOCK_HZ / configSYSTICK_CLOCK_HZ );
|
||||||
ulTimerCountsForOneTick = ( configSYSTICK_CLOCK_HZ / configTICK_RATE_HZ );
|
|
||||||
xMaximumPossibleSuppressedTicks = portMAX_24_BIT_NUMBER / ulTimerCountsForOneTick;
|
|
||||||
ulStoppedTimerCompensation = portMISSED_COUNTS_FACTOR / ( configCPU_CLOCK_HZ / configSYSTICK_CLOCK_HZ );
|
|
||||||
}
|
|
||||||
#endif /* configUSE_TICKLESS_IDLE */
|
|
||||||
|
|
||||||
/* Stop and clear the SysTick. */
|
|
||||||
portNVIC_SYSTICK_CTRL_REG = 0UL;
|
|
||||||
portNVIC_SYSTICK_CURRENT_VALUE_REG = 0UL;
|
|
||||||
|
|
||||||
/* Configure SysTick to interrupt at the requested rate. */
|
|
||||||
portNVIC_SYSTICK_LOAD_REG = ( configSYSTICK_CLOCK_HZ / configTICK_RATE_HZ ) - 1UL;
|
|
||||||
portNVIC_SYSTICK_CTRL_REG = ( portNVIC_SYSTICK_CLK_BIT_CONFIG | portNVIC_SYSTICK_INT_BIT | portNVIC_SYSTICK_ENABLE_BIT );
|
|
||||||
}
|
}
|
||||||
|
#endif /* configUSE_TICKLESS_IDLE */
|
||||||
|
|
||||||
#endif /* configOVERRIDE_DEFAULT_TICK_CONFIGURATION */
|
/* Stop and clear the SysTick. */
|
||||||
|
portNVIC_SYSTICK_CTRL_REG = 0UL;
|
||||||
|
portNVIC_SYSTICK_CURRENT_VALUE_REG = 0UL;
|
||||||
|
|
||||||
|
/* Configure SysTick to interrupt at the requested rate. */
|
||||||
|
portNVIC_SYSTICK_LOAD_REG = ( configSYSTICK_CLOCK_HZ / configTICK_RATE_HZ ) - 1UL;
|
||||||
|
portNVIC_SYSTICK_CTRL_REG = ( portNVIC_SYSTICK_CLK_BIT_CONFIG | portNVIC_SYSTICK_INT_BIT | portNVIC_SYSTICK_ENABLE_BIT );
|
||||||
|
}
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
__asm uint32_t vPortGetIPSR( void )
|
/* This is a naked function. */
|
||||||
|
static void vPortEnableVFP( void )
|
||||||
{
|
{
|
||||||
/* *INDENT-OFF* */
|
__asm volatile
|
||||||
PRESERVE8
|
(
|
||||||
|
" ldr.w r0, =0xE000ED88 \n" /* The FPU enable bits are in the CPACR. */
|
||||||
mrs r0, ipsr
|
" ldr r1, [r0] \n"
|
||||||
bx r14
|
" \n"
|
||||||
/* *INDENT-ON* */
|
" orr r1, r1, #( 0xf << 20 ) \n" /* Enable CP10 and CP11 coprocessors, then save back. */
|
||||||
|
" str r1, [r0] \n"
|
||||||
|
" bx r14 \n"
|
||||||
|
" .ltorg \n"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
@@ -829,7 +804,7 @@ __asm uint32_t vPortGetIPSR( void )
|
|||||||
uint8_t ucCurrentPriority;
|
uint8_t ucCurrentPriority;
|
||||||
|
|
||||||
/* Obtain the number of the currently executing interrupt. */
|
/* Obtain the number of the currently executing interrupt. */
|
||||||
ulCurrentInterrupt = vPortGetIPSR();
|
__asm volatile ( "mrs %0, ipsr" : "=r" ( ulCurrentInterrupt )::"memory" );
|
||||||
|
|
||||||
/* Is the interrupt number a user defined interrupt? */
|
/* Is the interrupt number a user defined interrupt? */
|
||||||
if( ulCurrentInterrupt >= portFIRST_USER_INTERRUPT_NUMBER )
|
if( ulCurrentInterrupt >= portFIRST_USER_INTERRUPT_NUMBER )
|
||||||
@@ -849,10 +824,10 @@ __asm uint32_t vPortGetIPSR( void )
|
|||||||
* be set to a value equal to or numerically *higher* than
|
* be set to a value equal to or numerically *higher* than
|
||||||
* configMAX_SYSCALL_INTERRUPT_PRIORITY.
|
* configMAX_SYSCALL_INTERRUPT_PRIORITY.
|
||||||
*
|
*
|
||||||
* Interrupts that use the FreeRTOS API must not be left at their
|
* Interrupts that use the FreeRTOS API must not be left at their
|
||||||
* default priority of zero as that is the highest possible priority,
|
* default priority of zero as that is the highest possible priority,
|
||||||
* which is guaranteed to be above configMAX_SYSCALL_INTERRUPT_PRIORITY,
|
* which is guaranteed to be above configMAX_SYSCALL_INTERRUPT_PRIORITY,
|
||||||
* and therefore also guaranteed to be invalid.
|
* and therefore also guaranteed to be invalid.
|
||||||
*
|
*
|
||||||
* FreeRTOS maintains separate thread and ISR API functions to ensure
|
* FreeRTOS maintains separate thread and ISR API functions to ensure
|
||||||
* interrupt entry is as fast and simple as possible.
|
* interrupt entry is as fast and simple as possible.
|
||||||
|
|||||||
+84
-97
@@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#ifndef PORTMACRO_H
|
#ifndef PORTMACRO_H
|
||||||
#define PORTMACRO_H
|
#define PORTMACRO_H
|
||||||
|
|
||||||
/* *INDENT-OFF* */
|
/* *INDENT-OFF* */
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
@@ -69,19 +69,19 @@
|
|||||||
/* 32-bit tick type on a 32-bit architecture, so reads of the tick count do
|
/* 32-bit tick type on a 32-bit architecture, so reads of the tick count do
|
||||||
* not need to be guarded with a critical section. */
|
* not need to be guarded with a critical section. */
|
||||||
#define portTICK_TYPE_IS_ATOMIC 1
|
#define portTICK_TYPE_IS_ATOMIC 1
|
||||||
|
#elif ( configTICK_TYPE_WIDTH_IN_BITS == TICK_TYPE_WIDTH_64_BITS )
|
||||||
|
typedef uint64_t TickType_t;
|
||||||
|
#define portMAX_DELAY ( TickType_t ) 0xffffffffffffffffULL
|
||||||
#else
|
#else
|
||||||
#error configTICK_TYPE_WIDTH_IN_BITS set to unsupported tick type width.
|
#error configTICK_TYPE_WIDTH_IN_BITS set to unsupported tick type width.
|
||||||
#endif
|
#endif
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
/* Architecture specifics. */
|
/* Architecture specifics. */
|
||||||
#define portSTACK_GROWTH ( -1 )
|
#define portSTACK_GROWTH ( -1 )
|
||||||
#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ )
|
#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ )
|
||||||
#define portBYTE_ALIGNMENT 8
|
#define portBYTE_ALIGNMENT 8
|
||||||
|
#define portDONT_DISCARD __attribute__( ( used ) )
|
||||||
/* Constants used with memory barrier intrinsics. */
|
|
||||||
#define portSY_FULL_READ_WRITE ( 15 )
|
|
||||||
|
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
/* Scheduler utilities. */
|
/* Scheduler utilities. */
|
||||||
@@ -92,10 +92,9 @@
|
|||||||
\
|
\
|
||||||
/* Barriers are normally not required but do ensure the code is completely \
|
/* Barriers are normally not required but do ensure the code is completely \
|
||||||
* within the specified behaviour for the architecture. */ \
|
* within the specified behaviour for the architecture. */ \
|
||||||
__dsb( portSY_FULL_READ_WRITE ); \
|
__asm volatile ( "dsb" ::: "memory" ); \
|
||||||
__isb( portSY_FULL_READ_WRITE ); \
|
__asm volatile ( "isb" ); \
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------*/
|
|
||||||
|
|
||||||
#define portNVIC_INT_CTRL_REG ( *( ( volatile uint32_t * ) 0xe000ed04 ) )
|
#define portNVIC_INT_CTRL_REG ( *( ( volatile uint32_t * ) 0xe000ed04 ) )
|
||||||
#define portNVIC_PENDSVSET_BIT ( 1UL << 28UL )
|
#define portNVIC_PENDSVSET_BIT ( 1UL << 28UL )
|
||||||
@@ -106,16 +105,22 @@
|
|||||||
/* Critical section management. */
|
/* Critical section management. */
|
||||||
extern void vPortEnterCritical( void );
|
extern void vPortEnterCritical( void );
|
||||||
extern void vPortExitCritical( void );
|
extern void vPortExitCritical( void );
|
||||||
|
#define portSET_INTERRUPT_MASK_FROM_ISR() ulPortRaiseBASEPRI()
|
||||||
|
#define portCLEAR_INTERRUPT_MASK_FROM_ISR( x ) vPortSetBASEPRI( x )
|
||||||
#define portDISABLE_INTERRUPTS() vPortRaiseBASEPRI()
|
#define portDISABLE_INTERRUPTS() vPortRaiseBASEPRI()
|
||||||
#define portENABLE_INTERRUPTS() vPortSetBASEPRI( 0 )
|
#define portENABLE_INTERRUPTS() vPortSetBASEPRI( 0 )
|
||||||
#define portENTER_CRITICAL() vPortEnterCritical()
|
#define portENTER_CRITICAL() vPortEnterCritical()
|
||||||
#define portEXIT_CRITICAL() vPortExitCritical()
|
#define portEXIT_CRITICAL() vPortExitCritical()
|
||||||
#define portSET_INTERRUPT_MASK_FROM_ISR() ulPortRaiseBASEPRI()
|
|
||||||
#define portCLEAR_INTERRUPT_MASK_FROM_ISR( x ) vPortSetBASEPRI( x )
|
|
||||||
|
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
/* Task function macros as described on the FreeRTOS.org WEB site. These are
|
||||||
|
* not necessary for to use this port. They are defined so the common demo files
|
||||||
|
* (which build with all the ports) will build. */
|
||||||
|
#define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void * pvParameters )
|
||||||
|
#define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void * pvParameters )
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
/* Tickless idle/low power functionality. */
|
/* Tickless idle/low power functionality. */
|
||||||
#ifndef portSUPPRESS_TICKS_AND_SLEEP
|
#ifndef portSUPPRESS_TICKS_AND_SLEEP
|
||||||
extern void vPortSuppressTicksAndSleep( TickType_t xExpectedIdleTime );
|
extern void vPortSuppressTicksAndSleep( TickType_t xExpectedIdleTime );
|
||||||
@@ -123,13 +128,23 @@
|
|||||||
#endif
|
#endif
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
/* Port specific optimisations. */
|
/* Architecture specific optimisations. */
|
||||||
#ifndef configUSE_PORT_OPTIMISED_TASK_SELECTION
|
#ifndef configUSE_PORT_OPTIMISED_TASK_SELECTION
|
||||||
#define configUSE_PORT_OPTIMISED_TASK_SELECTION 1
|
#define configUSE_PORT_OPTIMISED_TASK_SELECTION 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if configUSE_PORT_OPTIMISED_TASK_SELECTION == 1
|
#if configUSE_PORT_OPTIMISED_TASK_SELECTION == 1
|
||||||
|
|
||||||
|
/* Generic helper function. */
|
||||||
|
__attribute__( ( always_inline ) ) static inline uint8_t ucPortCountLeadingZeros( uint32_t ulBitmap )
|
||||||
|
{
|
||||||
|
uint8_t ucReturn;
|
||||||
|
|
||||||
|
__asm volatile ( "clz %0, %1" : "=r" ( ucReturn ) : "r" ( ulBitmap ) : "memory" );
|
||||||
|
|
||||||
|
return ucReturn;
|
||||||
|
}
|
||||||
|
|
||||||
/* Check the configuration. */
|
/* Check the configuration. */
|
||||||
#if ( configMAX_PRIORITIES > 32 )
|
#if ( configMAX_PRIORITIES > 32 )
|
||||||
#error configUSE_PORT_OPTIMISED_TASK_SELECTION can only be set to 1 when configMAX_PRIORITIES is less than or equal to 32. It is very rare that a system requires more than 10 to 15 difference priorities as tasks that share a priority will time slice.
|
#error configUSE_PORT_OPTIMISED_TASK_SELECTION can only be set to 1 when configMAX_PRIORITIES is less than or equal to 32. It is very rare that a system requires more than 10 to 15 difference priorities as tasks that share a priority will time slice.
|
||||||
@@ -141,16 +156,10 @@
|
|||||||
|
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
#define portGET_HIGHEST_PRIORITY( uxTopPriority, uxReadyPriorities ) uxTopPriority = ( 31UL - ( uint32_t ) __clz( ( uxReadyPriorities ) ) )
|
#define portGET_HIGHEST_PRIORITY( uxTopPriority, uxReadyPriorities ) uxTopPriority = ( 31UL - ( uint32_t ) ucPortCountLeadingZeros( ( uxReadyPriorities ) ) )
|
||||||
|
|
||||||
#endif /* taskRECORD_READY_PRIORITY */
|
#endif /* configUSE_PORT_OPTIMISED_TASK_SELECTION */
|
||||||
/*-----------------------------------------------------------*/
|
|
||||||
|
|
||||||
/* Task function macros as described on the FreeRTOS.org WEB site. These are
|
|
||||||
* not necessary for to use this port. They are defined so the common demo files
|
|
||||||
* (which build with all the ports) will build. */
|
|
||||||
#define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void * pvParameters )
|
|
||||||
#define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void * pvParameters )
|
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
#ifdef configASSERT
|
#ifdef configASSERT
|
||||||
@@ -164,87 +173,16 @@
|
|||||||
#define portINLINE __inline
|
#define portINLINE __inline
|
||||||
|
|
||||||
#ifndef portFORCE_INLINE
|
#ifndef portFORCE_INLINE
|
||||||
#define portFORCE_INLINE __forceinline
|
#define portFORCE_INLINE inline __attribute__( ( always_inline ) )
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*-----------------------------------------------------------*/
|
portFORCE_INLINE static BaseType_t xPortIsInsideInterrupt( void )
|
||||||
|
|
||||||
static portFORCE_INLINE void vPortSetBASEPRI( uint32_t ulBASEPRI )
|
|
||||||
{
|
|
||||||
__asm
|
|
||||||
{
|
|
||||||
/* Barrier instructions are not used as this function is only used to
|
|
||||||
* lower the BASEPRI value. */
|
|
||||||
/* *INDENT-OFF* */
|
|
||||||
msr basepri, ulBASEPRI
|
|
||||||
/* *INDENT-ON* */
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/*-----------------------------------------------------------*/
|
|
||||||
|
|
||||||
static portFORCE_INLINE void vPortRaiseBASEPRI( void )
|
|
||||||
{
|
|
||||||
uint32_t ulNewBASEPRI = configMAX_SYSCALL_INTERRUPT_PRIORITY;
|
|
||||||
|
|
||||||
__asm
|
|
||||||
{
|
|
||||||
/* Set BASEPRI to the max syscall priority to effect a critical
|
|
||||||
* section. */
|
|
||||||
/* *INDENT-OFF* */
|
|
||||||
msr basepri, ulNewBASEPRI
|
|
||||||
dsb
|
|
||||||
isb
|
|
||||||
/* *INDENT-ON* */
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/*-----------------------------------------------------------*/
|
|
||||||
|
|
||||||
static portFORCE_INLINE void vPortClearBASEPRIFromISR( void )
|
|
||||||
{
|
|
||||||
__asm
|
|
||||||
{
|
|
||||||
/* Set BASEPRI to 0 so no interrupts are masked. This function is only
|
|
||||||
* used to lower the mask in an interrupt, so memory barriers are not
|
|
||||||
* used. */
|
|
||||||
/* *INDENT-OFF* */
|
|
||||||
msr basepri, # 0
|
|
||||||
/* *INDENT-ON* */
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/*-----------------------------------------------------------*/
|
|
||||||
|
|
||||||
static portFORCE_INLINE uint32_t ulPortRaiseBASEPRI( void )
|
|
||||||
{
|
|
||||||
uint32_t ulReturn, ulNewBASEPRI = configMAX_SYSCALL_INTERRUPT_PRIORITY;
|
|
||||||
|
|
||||||
__asm
|
|
||||||
{
|
|
||||||
/* Set BASEPRI to the max syscall priority to effect a critical
|
|
||||||
* section. */
|
|
||||||
/* *INDENT-OFF* */
|
|
||||||
mrs ulReturn, basepri
|
|
||||||
msr basepri, ulNewBASEPRI
|
|
||||||
dsb
|
|
||||||
isb
|
|
||||||
/* *INDENT-ON* */
|
|
||||||
}
|
|
||||||
|
|
||||||
return ulReturn;
|
|
||||||
}
|
|
||||||
/*-----------------------------------------------------------*/
|
|
||||||
|
|
||||||
static portFORCE_INLINE BaseType_t xPortIsInsideInterrupt( void )
|
|
||||||
{
|
{
|
||||||
uint32_t ulCurrentInterrupt;
|
uint32_t ulCurrentInterrupt;
|
||||||
BaseType_t xReturn;
|
BaseType_t xReturn;
|
||||||
|
|
||||||
/* Obtain the number of the currently executing interrupt. */
|
/* Obtain the number of the currently executing interrupt. */
|
||||||
__asm
|
__asm volatile ( "mrs %0, ipsr" : "=r" ( ulCurrentInterrupt )::"memory" );
|
||||||
{
|
|
||||||
/* *INDENT-OFF* */
|
|
||||||
mrs ulCurrentInterrupt, ipsr
|
|
||||||
/* *INDENT-ON* */
|
|
||||||
}
|
|
||||||
|
|
||||||
if( ulCurrentInterrupt == 0 )
|
if( ulCurrentInterrupt == 0 )
|
||||||
{
|
{
|
||||||
@@ -258,6 +196,55 @@
|
|||||||
return xReturn;
|
return xReturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
portFORCE_INLINE static void vPortRaiseBASEPRI( void )
|
||||||
|
{
|
||||||
|
uint32_t ulNewBASEPRI;
|
||||||
|
|
||||||
|
__asm volatile
|
||||||
|
(
|
||||||
|
" mov %0, %1 \n"\
|
||||||
|
" msr basepri, %0 \n"\
|
||||||
|
" isb \n"\
|
||||||
|
" dsb \n"\
|
||||||
|
: "=r" ( ulNewBASEPRI ) : "i" ( configMAX_SYSCALL_INTERRUPT_PRIORITY ) : "memory"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
portFORCE_INLINE static uint32_t ulPortRaiseBASEPRI( void )
|
||||||
|
{
|
||||||
|
uint32_t ulOriginalBASEPRI, ulNewBASEPRI;
|
||||||
|
|
||||||
|
__asm volatile
|
||||||
|
(
|
||||||
|
" mrs %0, basepri \n"\
|
||||||
|
" mov %1, %2 \n"\
|
||||||
|
" msr basepri, %1 \n"\
|
||||||
|
" isb \n"\
|
||||||
|
" dsb \n"\
|
||||||
|
: "=r" ( ulOriginalBASEPRI ), "=r" ( ulNewBASEPRI ) : "i" ( configMAX_SYSCALL_INTERRUPT_PRIORITY ) : "memory"
|
||||||
|
);
|
||||||
|
|
||||||
|
/* This return will not be reached but is necessary to prevent compiler
|
||||||
|
* warnings. */
|
||||||
|
return ulOriginalBASEPRI;
|
||||||
|
}
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
portFORCE_INLINE static void vPortSetBASEPRI( uint32_t ulNewMaskValue )
|
||||||
|
{
|
||||||
|
__asm volatile
|
||||||
|
(
|
||||||
|
" msr basepri, %0 "::"r" ( ulNewMaskValue ) : "memory"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
#define portMEMORY_BARRIER() __asm volatile ( "" ::: "memory" )
|
||||||
|
|
||||||
/* *INDENT-OFF* */
|
/* *INDENT-OFF* */
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user