mirror of
https://github.com/eclipse-threadx/threadx.git
synced 2025-11-16 04:24:48 +00:00
Release 6.1.11
This commit is contained in:
@@ -26,7 +26,7 @@
|
||||
/* PORT SPECIFIC C INFORMATION RELEASE */
|
||||
/* */
|
||||
/* tx_port.h Cortex-M4/AC5 */
|
||||
/* 6.1.9 */
|
||||
/* 6.1.11 */
|
||||
/* */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
@@ -48,6 +48,9 @@
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* */
|
||||
/* 10-15-2021 Scott Larson Initial Version 6.1.9 */
|
||||
/* 04-25-2022 Scott Larson Modified comments and added */
|
||||
/* volatile to registers, */
|
||||
/* resulting in version 6.1.11 */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
|
||||
@@ -123,13 +126,13 @@ typedef unsigned short USHORT;
|
||||
For example, if the time source is at the address 0x0a800024 and is 16-bits in size, the clock
|
||||
source constants would be:
|
||||
|
||||
#define TX_TRACE_TIME_SOURCE *((ULONG *) 0x0a800024)
|
||||
#define TX_TRACE_TIME_SOURCE *((volatile ULONG *) 0x0a800024)
|
||||
#define TX_TRACE_TIME_MASK 0x0000FFFFUL
|
||||
|
||||
*/
|
||||
|
||||
#ifndef TX_TRACE_TIME_SOURCE
|
||||
#define TX_TRACE_TIME_SOURCE *((ULONG *) 0xE0001004)
|
||||
#define TX_TRACE_TIME_SOURCE *((volatile ULONG *) 0xE0001004)
|
||||
#endif
|
||||
#ifndef TX_TRACE_TIME_MASK
|
||||
#define TX_TRACE_TIME_MASK 0xFFFFFFFFUL
|
||||
@@ -282,7 +285,7 @@ void _tx_vfp_access(void);
|
||||
else \
|
||||
{ \
|
||||
ULONG _tx_fpccr; \
|
||||
_tx_fpccr = *((ULONG *) 0xE000EF34); \
|
||||
_tx_fpccr = *((volatile ULONG *) 0xE000EF34); \
|
||||
_tx_fpccr = _tx_fpccr & ((ULONG) 0x01); \
|
||||
if (_tx_fpccr == ((ULONG) 0x01)) \
|
||||
{ \
|
||||
@@ -435,7 +438,7 @@ unsigned int was_masked;
|
||||
|
||||
|
||||
/* Set PendSV to invoke ThreadX scheduler. */
|
||||
*((ULONG *) 0xE000ED04) = ((ULONG) 0x10000000);
|
||||
*((volatile ULONG *) 0xE000ED04) = ((ULONG) 0x10000000);
|
||||
if (_ipsr == 0)
|
||||
{
|
||||
was_masked = __disable_irq();
|
||||
@@ -458,7 +461,7 @@ void tx_thread_fpu_disable(void);
|
||||
|
||||
#ifdef TX_THREAD_INIT
|
||||
CHAR _tx_version_id[] =
|
||||
"Copyright (c) Microsoft Corporation. All rights reserved. * ThreadX Cortex-M4/AC5 Version 6.1.9 *";
|
||||
"Copyright (c) Microsoft Corporation. All rights reserved. * ThreadX Cortex-M4/AC5 Version 6.1.11 *";
|
||||
#else
|
||||
#ifdef TX_MISRA_ENABLE
|
||||
extern CHAR _tx_version_id[100];
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _tx_thread_schedule Cortex-M4/AC5 */
|
||||
/* 6.1.9 */
|
||||
/* 6.1.11 */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* Scott Larson, Microsoft Corporation */
|
||||
@@ -67,13 +67,15 @@
|
||||
/* */
|
||||
/* _tx_initialize_kernel_enter ThreadX entry function */
|
||||
/* _tx_thread_system_return Return to system from thread */
|
||||
/* _tx_thread_context_restore Restore thread's context */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* */
|
||||
/* 10-15-2021 Scott Larson Initial Version 6.1.9 */
|
||||
/* 04-25-2022 Scott Larson Optimized MPU configuration, */
|
||||
/* added BASEPRI support, */
|
||||
/* resulting in version 6.1.11 */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
// VOID _tx_thread_schedule(VOID)
|
||||
@@ -125,7 +127,12 @@ __tx_wait_here
|
||||
|
||||
EXPORT MemManage_Handler
|
||||
MemManage_Handler
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
LDR r1, =TX_PORT_BASEPRI // Mask interrupt priorities =< TX_PORT_BASEPRI
|
||||
MSR BASEPRI, r1
|
||||
#else
|
||||
CPSID i // Disable interrupts
|
||||
#endif /* TX_PORT_USE_BASEPRI */
|
||||
|
||||
/* Now pickup and store all the fault related information. */
|
||||
|
||||
@@ -208,7 +215,12 @@ MemManage_Handler
|
||||
LDR r1, =0x10000000 // Set PENDSVSET bit
|
||||
STR r1, [r0] // Store ICSR
|
||||
DSB // Wait for memory access to complete
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
MOV r0, 0 // Disable BASEPRI masking (enable interrupts)
|
||||
MSR BASEPRI, r0
|
||||
#else
|
||||
CPSIE i // Enable interrupts
|
||||
#endif
|
||||
MOV lr, #0xFFFFFFFD // Load exception return code
|
||||
BX lr // Return from exception
|
||||
|
||||
@@ -226,12 +238,22 @@ __tx_ts_handler
|
||||
|
||||
#if (defined(TX_ENABLE_EXECUTION_CHANGE_NOTIFY) || defined(TX_EXECUTION_PROFILE_ENABLE))
|
||||
/* Call the thread exit function to indicate the thread is no longer executing. */
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
LDR r1, =TX_PORT_BASEPRI // Mask interrupt priorities =< TX_PORT_BASEPRI
|
||||
MSR BASEPRI, r1
|
||||
#else
|
||||
CPSID i // Disable interrupts
|
||||
#endif /* TX_PORT_USE_BASEPRI */
|
||||
PUSH {r0, lr} // Save LR (and r0 just for alignment)
|
||||
BL _tx_execution_thread_exit // Call the thread exit function
|
||||
POP {r0, lr} // Recover LR
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
MOV r0, 0 // Disable BASEPRI masking (enable interrupts)
|
||||
MSR BASEPRI, r0
|
||||
#else
|
||||
CPSIE i // Enable interrupts
|
||||
#endif
|
||||
#endif /* TX_PORT_USE_BASEPRI */
|
||||
#endif /* EXECUTION PROFILE */
|
||||
|
||||
LDR r0, =_tx_thread_current_ptr // Build current thread pointer address
|
||||
LDR r2, =_tx_thread_execute_ptr // Build execute thread pointer address
|
||||
@@ -276,7 +298,12 @@ __tx_ts_new
|
||||
|
||||
/* Now we are looking for a new thread to execute! */
|
||||
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
LDR r1, =TX_PORT_BASEPRI // Mask interrupt priorities =< TX_PORT_BASEPRI
|
||||
MSR BASEPRI, r1
|
||||
#else
|
||||
CPSID i // Disable interrupts
|
||||
#endif
|
||||
LDR r1, [r2] // Is there another thread ready to execute?
|
||||
CBNZ r1, __tx_ts_restore // Yes, schedule it
|
||||
|
||||
@@ -285,7 +312,12 @@ __tx_ts_new
|
||||
are disabled to allow use of WFI for waiting for a thread to arrive. */
|
||||
|
||||
__tx_ts_wait
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
LDR r1, =TX_PORT_BASEPRI // Mask interrupt priorities =< TX_PORT_BASEPRI
|
||||
MSR BASEPRI, r1
|
||||
#else
|
||||
CPSID i // Disable interrupts
|
||||
#endif
|
||||
LDR r1, [r2] // Pickup the next thread to execute pointer
|
||||
CBNZ r1, __tx_ts_ready // If non-NULL, a new thread is ready!
|
||||
#ifdef TX_ENABLE_WFI
|
||||
@@ -293,7 +325,12 @@ __tx_ts_wait
|
||||
WFI // Wait for interrupt
|
||||
ISB // Ensure pipeline is flushed
|
||||
#endif
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
MOV r4, #0 // Disable BASEPRI masking (enable interrupts)
|
||||
MSR BASEPRI, r4
|
||||
#else
|
||||
CPSIE i // Enable interrupts
|
||||
#endif
|
||||
B __tx_ts_wait // Loop to continue waiting
|
||||
|
||||
/* At this point, we have a new thread ready to go. Clear any newly pended PendSV - since we are
|
||||
@@ -310,7 +347,12 @@ __tx_ts_restore
|
||||
and enable interrupts. */
|
||||
|
||||
STR r1, [r0] // Setup the current thread pointer to the new thread
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
MOV r4, #0 // Disable BASEPRI masking (enable interrupts)
|
||||
MSR BASEPRI, r4
|
||||
#else
|
||||
CPSIE i // Enable interrupts
|
||||
#endif
|
||||
|
||||
/* Increment the thread run count. */
|
||||
|
||||
@@ -346,27 +388,34 @@ __tx_ts_restore
|
||||
STR r3, [r0] // Disable MPU
|
||||
LDR r0, [r1, #0x90] // Pickup the module instance pointer
|
||||
CBZ r0, skip_mpu_setup // Is this thread owned by a module? No, skip MPU setup
|
||||
LDR r1, [r0, #0x64] // Pickup MPU register[0]
|
||||
CBZ r1, skip_mpu_setup // Is protection required for this module? No, skip MPU setup
|
||||
LDR r1, =0xE000ED9C // Build address of MPU base register
|
||||
|
||||
LDR r2, [r0, #0x8C] // Pickup MPU region 5 address
|
||||
CBZ r2, skip_mpu_setup // Is protection required for this module? No, skip MPU setup
|
||||
|
||||
// Is the MPU already set up for this module?
|
||||
MOV r1, #5 // Select region 5 from MPU
|
||||
LDR r3, =0xE000ED98 // MPU_RNR register address
|
||||
STR r1, [r3] // Set region to 5
|
||||
LDR r1, =0xE000ED9C // MPU_RBAR register address
|
||||
LDR r3, [r1] // Load address stored in MPU region 5
|
||||
BIC r2, r2, #0x10 // Clear VALID bit
|
||||
CMP r2, r3 // Is module already loaded?
|
||||
BEQ _tx_enable_mpu // Yes - skip MPU reconfiguration
|
||||
|
||||
// Use alias registers to quickly load MPU
|
||||
ADD r0, r0, #100 // Build address of MPU register start in thread control block
|
||||
#ifdef TXM_MODULE_MANAGER_16_MPU
|
||||
|
||||
LDM r0!,{r2-r9} // Load MPU regions 0-3
|
||||
STM r1,{r2-r9} // Store MPU regions 0-3
|
||||
LDM r0!,{r2-r9} // Load MPU regions 4-7
|
||||
STM r1,{r2-r9} // Store MPU regions 4-7
|
||||
#ifdef TXM_MODULE_MANAGER_16_MPU
|
||||
LDM r0!,{r2-r9} // Load MPU regions 8-11
|
||||
STM r1,{r2-r9} // Store MPU regions 8-11
|
||||
LDM r0,{r2-r9} // Load MPU regions 12-15
|
||||
STM r1,{r2-r9} // Store MPU regions 12-15
|
||||
#else
|
||||
LDM r0!,{r2-r9} // Load first four MPU regions
|
||||
STM r1,{r2-r9} // Store first four MPU regions
|
||||
LDM r0,{r2-r9} // Load second four MPU regions
|
||||
STM r1,{r2-r9} // Store second four MPU regions
|
||||
#endif
|
||||
_tx_enable_mpu
|
||||
LDR r0, =0xE000ED94 // Build MPU control reg address
|
||||
MOV r1, #5 // Build enable value with background region enabled
|
||||
STR r1, [r0] // Enable MPU
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
/* PORT SPECIFIC C INFORMATION RELEASE */
|
||||
/* */
|
||||
/* tx_port.h Cortex-M4/AC6 */
|
||||
/* 6.1.9 */
|
||||
/* 6.1.11 */
|
||||
/* */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
@@ -48,6 +48,9 @@
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* */
|
||||
/* 10-15-2021 Scott Larson Initial Version 6.1.9 */
|
||||
/* 04-25-2022 Scott Larson Modified comments and added */
|
||||
/* volatile to registers, */
|
||||
/* resulting in version 6.1.11 */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
|
||||
@@ -123,13 +126,13 @@ typedef unsigned short USHORT;
|
||||
For example, if the time source is at the address 0x0a800024 and is 16-bits in size, the clock
|
||||
source constants would be:
|
||||
|
||||
#define TX_TRACE_TIME_SOURCE *((ULONG *) 0x0a800024)
|
||||
#define TX_TRACE_TIME_SOURCE *((volatile ULONG *) 0x0a800024)
|
||||
#define TX_TRACE_TIME_MASK 0x0000FFFFUL
|
||||
|
||||
*/
|
||||
|
||||
#ifndef TX_TRACE_TIME_SOURCE
|
||||
#define TX_TRACE_TIME_SOURCE *((ULONG *) 0xE0001004)
|
||||
#define TX_TRACE_TIME_SOURCE *((volatile ULONG *) 0xE0001004)
|
||||
#endif
|
||||
#ifndef TX_TRACE_TIME_MASK
|
||||
#define TX_TRACE_TIME_MASK 0xFFFFFFFFUL
|
||||
@@ -291,7 +294,7 @@ __attribute__( ( always_inline ) ) static inline void __set_control(ULONG contro
|
||||
else \
|
||||
{ \
|
||||
ULONG _tx_fpccr; \
|
||||
_tx_fpccr = *((ULONG *) 0xE000EF34); \
|
||||
_tx_fpccr = *((volatile ULONG *) 0xE000EF34); \
|
||||
_tx_fpccr = _tx_fpccr & ((ULONG) 0x01); \
|
||||
if (_tx_fpccr == ((ULONG) 0x01)) \
|
||||
{ \
|
||||
@@ -467,7 +470,8 @@ __attribute__( ( always_inline ) ) static inline void _tx_thread_system_return_i
|
||||
{
|
||||
unsigned int interrupt_save;
|
||||
|
||||
*((ULONG *) 0xE000ED04) = ((ULONG) 0x10000000);
|
||||
/* Set PendSV to invoke ThreadX scheduler. */
|
||||
*((volatile ULONG *) 0xE000ED04) = ((ULONG) 0x10000000);
|
||||
if (__get_ipsr_value() == 0)
|
||||
{
|
||||
interrupt_save = __get_primask_value();
|
||||
@@ -497,7 +501,7 @@ unsigned int interrupt_save;
|
||||
#endif
|
||||
|
||||
|
||||
/* Define FPU extension for the Cortex-M7. Each is assumed to be called in the context of the executing
|
||||
/* Define FPU extension for the Cortex-M4. Each is assumed to be called in the context of the executing
|
||||
thread. These are no longer needed, but are preserved for backward compatibility only. */
|
||||
|
||||
void tx_thread_fpu_enable(void);
|
||||
@@ -508,7 +512,7 @@ void tx_thread_fpu_disable(void);
|
||||
|
||||
#ifdef TX_THREAD_INIT
|
||||
CHAR _tx_version_id[] =
|
||||
"Copyright (c) Microsoft Corporation. All rights reserved. * ThreadX Cortex-M4/AC6 Version 6.1.9 *";
|
||||
"Copyright (c) Microsoft Corporation. All rights reserved. * ThreadX Cortex-M4/AC6 Version 6.1.11 *";
|
||||
#else
|
||||
extern CHAR _tx_version_id[];
|
||||
#endif
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _tx_thread_schedule Cortex-M4/AC6 */
|
||||
/* 6.1.9 */
|
||||
/* 6.1.11 */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* Scott Larson, Microsoft Corporation */
|
||||
@@ -69,13 +69,15 @@
|
||||
/* */
|
||||
/* _tx_initialize_kernel_enter ThreadX entry function */
|
||||
/* _tx_thread_system_return Return to system from thread */
|
||||
/* _tx_thread_context_restore Restore thread's context */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* */
|
||||
/* 10-15-2021 Scott Larson Initial Version 6.1.9 */
|
||||
/* 04-25-2022 Scott Larson Optimized MPU configuration, */
|
||||
/* added BASEPRI support, */
|
||||
/* resulting in version 6.1.11 */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
// VOID _tx_thread_schedule(VOID)
|
||||
@@ -135,7 +137,12 @@ BusFault_Handler:
|
||||
.thumb_func
|
||||
UsageFault_Handler:
|
||||
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
LDR r1, =TX_PORT_BASEPRI // Mask interrupt priorities =< TX_PORT_BASEPRI
|
||||
MSR BASEPRI, r1
|
||||
#else
|
||||
CPSID i // Disable interrupts
|
||||
#endif /* TX_PORT_USE_BASEPRI */
|
||||
|
||||
/* Now pickup and store all the fault related information. */
|
||||
|
||||
@@ -197,7 +204,7 @@ UsageFault_Handler:
|
||||
LDR r0, =0xE000EF34 // Cleanup FPU context: Load FPCCR address
|
||||
LDR r1, [r0] // Load FPCCR
|
||||
BIC r1, r1, #1 // Clear the lazy preservation active bit
|
||||
STR r1, [r0] // Store the value
|
||||
STR r1, [r0] // Save FPCCR
|
||||
#endif
|
||||
|
||||
BL _txm_module_manager_memory_fault_handler // Call memory manager fault handler
|
||||
@@ -218,7 +225,12 @@ UsageFault_Handler:
|
||||
LDR r1, =0x10000000 // Set PENDSVSET bit
|
||||
STR r1, [r0] // Store ICSR
|
||||
DSB // Wait for memory access to complete
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
MOV r0, 0 // Disable BASEPRI masking (enable interrupts)
|
||||
MSR BASEPRI, r0
|
||||
#else
|
||||
CPSIE i // Enable interrupts
|
||||
#endif
|
||||
MOV lr, #0xFFFFFFFD // Load exception return code
|
||||
BX lr // Return from exception
|
||||
|
||||
@@ -239,12 +251,22 @@ __tx_ts_handler:
|
||||
|
||||
#if (defined(TX_ENABLE_EXECUTION_CHANGE_NOTIFY) || defined(TX_EXECUTION_PROFILE_ENABLE))
|
||||
/* Call the thread exit function to indicate the thread is no longer executing. */
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
LDR r1, =TX_PORT_BASEPRI // Mask interrupt priorities =< TX_PORT_BASEPRI
|
||||
MSR BASEPRI, r1
|
||||
#else
|
||||
CPSID i // Disable interrupts
|
||||
#endif /* TX_PORT_USE_BASEPRI */
|
||||
PUSH {r0, lr} // Save LR (and r0 just for alignment)
|
||||
BL _tx_execution_thread_exit // Call the thread exit function
|
||||
POP {r0, lr} // Recover LR
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
MOV r0, 0 // Disable BASEPRI masking (enable interrupts)
|
||||
MSR BASEPRI, r0
|
||||
#else
|
||||
CPSIE i // Enable interrupts
|
||||
#endif
|
||||
#endif /* TX_PORT_USE_BASEPRI */
|
||||
#endif /* EXECUTION PROFILE */
|
||||
|
||||
LDR r0, =_tx_thread_current_ptr // Build current thread pointer address
|
||||
LDR r2, =_tx_thread_execute_ptr // Build execute thread pointer address
|
||||
@@ -289,7 +311,12 @@ __tx_ts_new:
|
||||
|
||||
/* Now we are looking for a new thread to execute! */
|
||||
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
LDR r1, =TX_PORT_BASEPRI // Mask interrupt priorities =< TX_PORT_BASEPRI
|
||||
MSR BASEPRI, r1
|
||||
#else
|
||||
CPSID i // Disable interrupts
|
||||
#endif
|
||||
LDR r1, [r2] // Is there another thread ready to execute?
|
||||
CBNZ r1, __tx_ts_restore // Yes, schedule it
|
||||
|
||||
@@ -298,7 +325,12 @@ __tx_ts_new:
|
||||
are disabled to allow use of WFI for waiting for a thread to arrive. */
|
||||
|
||||
__tx_ts_wait:
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
LDR r1, =TX_PORT_BASEPRI // Mask interrupt priorities =< TX_PORT_BASEPRI
|
||||
MSR BASEPRI, r1
|
||||
#else
|
||||
CPSID i // Disable interrupts
|
||||
#endif
|
||||
LDR r1, [r2] // Pickup the next thread to execute pointer
|
||||
CBNZ r1, __tx_ts_ready // If non-NULL, a new thread is ready!
|
||||
#ifdef TX_ENABLE_WFI
|
||||
@@ -306,7 +338,12 @@ __tx_ts_wait:
|
||||
WFI // Wait for interrupt
|
||||
ISB // Ensure pipeline is flushed
|
||||
#endif
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
MOV r4, #0 // Disable BASEPRI masking (enable interrupts)
|
||||
MSR BASEPRI, r4
|
||||
#else
|
||||
CPSIE i // Enable interrupts
|
||||
#endif
|
||||
B __tx_ts_wait // Loop to continue waiting
|
||||
|
||||
/* At this point, we have a new thread ready to go. Clear any newly pended PendSV - since we are
|
||||
@@ -323,7 +360,12 @@ __tx_ts_restore:
|
||||
and enable interrupts. */
|
||||
|
||||
STR r1, [r0] // Setup the current thread pointer to the new thread
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
MOV r4, #0 // Disable BASEPRI masking (enable interrupts)
|
||||
MSR BASEPRI, r4
|
||||
#else
|
||||
CPSIE i // Enable interrupts
|
||||
#endif
|
||||
|
||||
/* Increment the thread run count. */
|
||||
|
||||
@@ -359,27 +401,34 @@ __tx_ts_restore:
|
||||
STR r3, [r0] // Disable MPU
|
||||
LDR r0, [r1, #0x90] // Pickup the module instance pointer
|
||||
CBZ r0, skip_mpu_setup // Is this thread owned by a module? No, skip MPU setup
|
||||
LDR r1, [r0, #0x64] // Pickup MPU register[0]
|
||||
CBZ r1, skip_mpu_setup // Is protection required for this module? No, skip MPU setup
|
||||
LDR r1, =0xE000ED9C // Build address of MPU base register
|
||||
|
||||
LDR r2, [r0, #0x8C] // Pickup MPU region 5 address
|
||||
CBZ r2, skip_mpu_setup // Is protection required for this module? No, skip MPU setup
|
||||
|
||||
// Is the MPU already set up for this module?
|
||||
MOV r1, #5 // Select region 5 from MPU
|
||||
LDR r3, =0xE000ED98 // MPU_RNR register address
|
||||
STR r1, [r3] // Set region to 5
|
||||
LDR r1, =0xE000ED9C // MPU_RBAR register address
|
||||
LDR r3, [r1] // Load address stored in MPU region 5
|
||||
BIC r2, r2, #0x10 // Clear VALID bit
|
||||
CMP r2, r3 // Is module already loaded?
|
||||
BEQ _tx_enable_mpu // Yes - skip MPU reconfiguration
|
||||
|
||||
// Use alias registers to quickly load MPU
|
||||
ADD r0, r0, #100 // Build address of MPU register start in thread control block
|
||||
#ifdef TXM_MODULE_MANAGER_16_MPU
|
||||
|
||||
LDM r0!,{r2-r9} // Load MPU regions 0-3
|
||||
STM r1,{r2-r9} // Store MPU regions 0-3
|
||||
LDM r0!,{r2-r9} // Load MPU regions 4-7
|
||||
STM r1,{r2-r9} // Store MPU regions 4-7
|
||||
#ifdef TXM_MODULE_MANAGER_16_MPU
|
||||
LDM r0!,{r2-r9} // Load MPU regions 8-11
|
||||
STM r1,{r2-r9} // Store MPU regions 8-11
|
||||
LDM r0,{r2-r9} // Load MPU regions 12-15
|
||||
STM r1,{r2-r9} // Store MPU regions 12-15
|
||||
#else
|
||||
LDM r0!,{r2-r9} // Load first four MPU regions
|
||||
STM r1,{r2-r9} // Store first four MPU regions
|
||||
LDM r0,{r2-r9} // Load second four MPU regions
|
||||
STM r1,{r2-r9} // Store second four MPU regions
|
||||
#endif
|
||||
_tx_enable_mpu:
|
||||
LDR r0, =0xE000ED94 // Build MPU control reg address
|
||||
MOV r1, #5 // Build enable value with background region enabled
|
||||
STR r1, [r0] // Enable MPU
|
||||
@@ -538,14 +587,14 @@ _tx_no_lazy_clear:
|
||||
#endif
|
||||
|
||||
/* Copy kernel hardware stack to module thread stack. */
|
||||
LDM r3!, {r1-r2}
|
||||
STM r0!, {r1-r2}
|
||||
LDM r3!, {r1-r2}
|
||||
STM r0!, {r1-r2}
|
||||
LDM r3!, {r1-r2}
|
||||
STM r0!, {r1-r2}
|
||||
LDM r3!, {r1-r2}
|
||||
STM r0!, {r1-r2}
|
||||
LDM r3!, {r1-r2} // Get r0, r1 from kernel stack
|
||||
STM r0!, {r1-r2} // Insert r0, r1 into thread stack
|
||||
LDM r3!, {r1-r2} // Get r2, r3 from kernel stack
|
||||
STM r0!, {r1-r2} // Insert r2, r3 into thread stack
|
||||
LDM r3!, {r1-r2} // Get r12, lr from kernel stack
|
||||
STM r0!, {r1-r2} // Insert r12, lr into thread stack
|
||||
LDM r3!, {r1-r2} // Get pc, xpsr from kernel stack
|
||||
STM r0!, {r1-r2} // Insert pc, xpsr into thread stack
|
||||
SUB r0, r0, #32 // Subtract 32 to get back to top of stack
|
||||
MSR PSP, r0 // Set thread stack pointer
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
/* PORT SPECIFIC C INFORMATION RELEASE */
|
||||
/* */
|
||||
/* tx_port.h Cortex-M4/GNU */
|
||||
/* 6.1.9 */
|
||||
/* 6.1.11 */
|
||||
/* */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
@@ -48,6 +48,9 @@
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* */
|
||||
/* 10-15-2021 Scott Larson Initial Version 6.1.9 */
|
||||
/* 04-25-2022 Scott Larson Modified comments and added */
|
||||
/* volatile to registers, */
|
||||
/* resulting in version 6.1.11 */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
|
||||
@@ -123,13 +126,13 @@ typedef unsigned short USHORT;
|
||||
For example, if the time source is at the address 0x0a800024 and is 16-bits in size, the clock
|
||||
source constants would be:
|
||||
|
||||
#define TX_TRACE_TIME_SOURCE *((ULONG *) 0x0a800024)
|
||||
#define TX_TRACE_TIME_SOURCE *((volatile ULONG *) 0x0a800024)
|
||||
#define TX_TRACE_TIME_MASK 0x0000FFFFUL
|
||||
|
||||
*/
|
||||
|
||||
#ifndef TX_TRACE_TIME_SOURCE
|
||||
#define TX_TRACE_TIME_SOURCE *((ULONG *) 0xE0001004)
|
||||
#define TX_TRACE_TIME_SOURCE *((volatile ULONG *) 0xE0001004)
|
||||
#endif
|
||||
#ifndef TX_TRACE_TIME_MASK
|
||||
#define TX_TRACE_TIME_MASK 0xFFFFFFFFUL
|
||||
@@ -291,7 +294,7 @@ __attribute__( ( always_inline ) ) static inline void __set_control(ULONG contro
|
||||
else \
|
||||
{ \
|
||||
ULONG _tx_fpccr; \
|
||||
_tx_fpccr = *((ULONG *) 0xE000EF34); \
|
||||
_tx_fpccr = *((volatile ULONG *) 0xE000EF34); \
|
||||
_tx_fpccr = _tx_fpccr & ((ULONG) 0x01); \
|
||||
if (_tx_fpccr == ((ULONG) 0x01)) \
|
||||
{ \
|
||||
@@ -461,7 +464,8 @@ __attribute__( ( always_inline ) ) static inline void _tx_thread_system_return_i
|
||||
{
|
||||
unsigned int interrupt_save;
|
||||
|
||||
*((ULONG *) 0xE000ED04) = ((ULONG) 0x10000000);
|
||||
/* Set PendSV to invoke ThreadX scheduler. */
|
||||
*((volatile ULONG *) 0xE000ED04) = ((ULONG) 0x10000000);
|
||||
if (__get_ipsr_value() == 0)
|
||||
{
|
||||
interrupt_save = __get_primask_value();
|
||||
@@ -491,8 +495,8 @@ unsigned int interrupt_save;
|
||||
#endif
|
||||
|
||||
|
||||
/* Define FPU extension for the Cortex-M7. Each is assumed to be called in the context of the executing
|
||||
thread. This is for legacy only, and not needed any longer. */
|
||||
/* Define FPU extension for the Cortex-M4. Each is assumed to be called in the context of the executing
|
||||
thread. These are no longer needed, but are preserved for backward compatibility only. */
|
||||
|
||||
void tx_thread_fpu_enable(void);
|
||||
void tx_thread_fpu_disable(void);
|
||||
@@ -502,7 +506,7 @@ void tx_thread_fpu_disable(void);
|
||||
|
||||
#ifdef TX_THREAD_INIT
|
||||
CHAR _tx_version_id[] =
|
||||
"Copyright (c) Microsoft Corporation. All rights reserved. * ThreadX Cortex-M4/GNU Version 6.1.9 *";
|
||||
"Copyright (c) Microsoft Corporation. All rights reserved. * ThreadX Cortex-M4/GNU Version 6.1.11 *";
|
||||
#else
|
||||
extern CHAR _tx_version_id[];
|
||||
#endif
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _tx_thread_schedule Cortex-M4/GNU */
|
||||
/* 6.1.10 */
|
||||
/* 6.1.11 */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* Scott Larson, Microsoft Corporation */
|
||||
@@ -67,7 +67,6 @@
|
||||
/* */
|
||||
/* _tx_initialize_kernel_enter ThreadX entry function */
|
||||
/* _tx_thread_system_return Return to system from thread */
|
||||
/* _tx_thread_context_restore Restore thread's context */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
@@ -76,6 +75,9 @@
|
||||
/* 10-15-2021 Scott Larson Initial Version 6.1.9 */
|
||||
/* 01-31-2022 Scott Larson Fixed predefined macro name, */
|
||||
/* resulting in version 6.1.10 */
|
||||
/* 04-25-2022 Scott Larson Optimized MPU configuration, */
|
||||
/* added BASEPRI support, */
|
||||
/* resulting in version 6.1.11 */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
// VOID _tx_thread_schedule(VOID)
|
||||
@@ -135,7 +137,12 @@ BusFault_Handler:
|
||||
.thumb_func
|
||||
UsageFault_Handler:
|
||||
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
LDR r1, =TX_PORT_BASEPRI // Mask interrupt priorities =< TX_PORT_BASEPRI
|
||||
MSR BASEPRI, r1
|
||||
#else
|
||||
CPSID i // Disable interrupts
|
||||
#endif /* TX_PORT_USE_BASEPRI */
|
||||
|
||||
/* Now pickup and store all the fault related information. */
|
||||
|
||||
@@ -197,7 +204,7 @@ UsageFault_Handler:
|
||||
LDR r0, =0xE000EF34 // Cleanup FPU context: Load FPCCR address
|
||||
LDR r1, [r0] // Load FPCCR
|
||||
BIC r1, r1, #1 // Clear the lazy preservation active bit
|
||||
STR r1, [r0] // Store the value
|
||||
STR r1, [r0] // Save FPCCR
|
||||
#endif
|
||||
|
||||
BL _txm_module_manager_memory_fault_handler // Call memory manager fault handler
|
||||
@@ -218,7 +225,12 @@ UsageFault_Handler:
|
||||
LDR r1, =0x10000000 // Set PENDSVSET bit
|
||||
STR r1, [r0] // Store ICSR
|
||||
DSB // Wait for memory access to complete
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
MOV r0, 0 // Disable BASEPRI masking (enable interrupts)
|
||||
MSR BASEPRI, r0
|
||||
#else
|
||||
CPSIE i // Enable interrupts
|
||||
#endif
|
||||
MOV lr, #0xFFFFFFFD // Load exception return code
|
||||
BX lr // Return from exception
|
||||
|
||||
@@ -239,12 +251,22 @@ __tx_ts_handler:
|
||||
|
||||
#if (defined(TX_ENABLE_EXECUTION_CHANGE_NOTIFY) || defined(TX_EXECUTION_PROFILE_ENABLE))
|
||||
/* Call the thread exit function to indicate the thread is no longer executing. */
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
LDR r1, =TX_PORT_BASEPRI // Mask interrupt priorities =< TX_PORT_BASEPRI
|
||||
MSR BASEPRI, r1
|
||||
#else
|
||||
CPSID i // Disable interrupts
|
||||
#endif /* TX_PORT_USE_BASEPRI */
|
||||
PUSH {r0, lr} // Save LR (and r0 just for alignment)
|
||||
BL _tx_execution_thread_exit // Call the thread exit function
|
||||
POP {r0, lr} // Recover LR
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
MOV r0, 0 // Disable BASEPRI masking (enable interrupts)
|
||||
MSR BASEPRI, r0
|
||||
#else
|
||||
CPSIE i // Enable interrupts
|
||||
#endif
|
||||
#endif /* TX_PORT_USE_BASEPRI */
|
||||
#endif /* EXECUTION PROFILE */
|
||||
|
||||
LDR r0, =_tx_thread_current_ptr // Build current thread pointer address
|
||||
LDR r2, =_tx_thread_execute_ptr // Build execute thread pointer address
|
||||
@@ -289,7 +311,12 @@ __tx_ts_new:
|
||||
|
||||
/* Now we are looking for a new thread to execute! */
|
||||
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
LDR r1, =TX_PORT_BASEPRI // Mask interrupt priorities =< TX_PORT_BASEPRI
|
||||
MSR BASEPRI, r1
|
||||
#else
|
||||
CPSID i // Disable interrupts
|
||||
#endif
|
||||
LDR r1, [r2] // Is there another thread ready to execute?
|
||||
CBNZ r1, __tx_ts_restore // Yes, schedule it
|
||||
|
||||
@@ -298,7 +325,12 @@ __tx_ts_new:
|
||||
are disabled to allow use of WFI for waiting for a thread to arrive. */
|
||||
|
||||
__tx_ts_wait:
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
LDR r1, =TX_PORT_BASEPRI // Mask interrupt priorities =< TX_PORT_BASEPRI
|
||||
MSR BASEPRI, r1
|
||||
#else
|
||||
CPSID i // Disable interrupts
|
||||
#endif
|
||||
LDR r1, [r2] // Pickup the next thread to execute pointer
|
||||
CBNZ r1, __tx_ts_ready // If non-NULL, a new thread is ready!
|
||||
#ifdef TX_ENABLE_WFI
|
||||
@@ -306,7 +338,12 @@ __tx_ts_wait:
|
||||
WFI // Wait for interrupt
|
||||
ISB // Ensure pipeline is flushed
|
||||
#endif
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
MOV r4, #0 // Disable BASEPRI masking (enable interrupts)
|
||||
MSR BASEPRI, r4
|
||||
#else
|
||||
CPSIE i // Enable interrupts
|
||||
#endif
|
||||
B __tx_ts_wait // Loop to continue waiting
|
||||
|
||||
/* At this point, we have a new thread ready to go. Clear any newly pended PendSV - since we are
|
||||
@@ -323,7 +360,12 @@ __tx_ts_restore:
|
||||
and enable interrupts. */
|
||||
|
||||
STR r1, [r0] // Setup the current thread pointer to the new thread
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
MOV r4, #0 // Disable BASEPRI masking (enable interrupts)
|
||||
MSR BASEPRI, r4
|
||||
#else
|
||||
CPSIE i // Enable interrupts
|
||||
#endif
|
||||
|
||||
/* Increment the thread run count. */
|
||||
|
||||
@@ -359,27 +401,34 @@ __tx_ts_restore:
|
||||
STR r3, [r0] // Disable MPU
|
||||
LDR r0, [r1, #0x90] // Pickup the module instance pointer
|
||||
CBZ r0, skip_mpu_setup // Is this thread owned by a module? No, skip MPU setup
|
||||
LDR r1, [r0, #0x64] // Pickup MPU register[0]
|
||||
CBZ r1, skip_mpu_setup // Is protection required for this module? No, skip MPU setup
|
||||
LDR r1, =0xE000ED9C // Build address of MPU base register
|
||||
|
||||
LDR r2, [r0, #0x8C] // Pickup MPU region 5 address
|
||||
CBZ r2, skip_mpu_setup // Is protection required for this module? No, skip MPU setup
|
||||
|
||||
// Is the MPU already set up for this module?
|
||||
MOV r1, #5 // Select region 5 from MPU
|
||||
LDR r3, =0xE000ED98 // MPU_RNR register address
|
||||
STR r1, [r3] // Set region to 5
|
||||
LDR r1, =0xE000ED9C // MPU_RBAR register address
|
||||
LDR r3, [r1] // Load address stored in MPU region 5
|
||||
BIC r2, r2, #0x10 // Clear VALID bit
|
||||
CMP r2, r3 // Is module already loaded?
|
||||
BEQ _tx_enable_mpu // Yes - skip MPU reconfiguration
|
||||
|
||||
// Use alias registers to quickly load MPU
|
||||
ADD r0, r0, #100 // Build address of MPU register start in thread control block
|
||||
#ifdef TXM_MODULE_MANAGER_16_MPU
|
||||
|
||||
LDM r0!,{r2-r9} // Load MPU regions 0-3
|
||||
STM r1,{r2-r9} // Store MPU regions 0-3
|
||||
LDM r0!,{r2-r9} // Load MPU regions 4-7
|
||||
STM r1,{r2-r9} // Store MPU regions 4-7
|
||||
#ifdef TXM_MODULE_MANAGER_16_MPU
|
||||
LDM r0!,{r2-r9} // Load MPU regions 8-11
|
||||
STM r1,{r2-r9} // Store MPU regions 8-11
|
||||
LDM r0,{r2-r9} // Load MPU regions 12-15
|
||||
STM r1,{r2-r9} // Store MPU regions 12-15
|
||||
#else
|
||||
LDM r0!,{r2-r9} // Load first four MPU regions
|
||||
STM r1,{r2-r9} // Store first four MPU regions
|
||||
LDM r0,{r2-r9} // Load second four MPU regions
|
||||
STM r1,{r2-r9} // Store second four MPU regions
|
||||
#endif
|
||||
_tx_enable_mpu:
|
||||
LDR r0, =0xE000ED94 // Build MPU control reg address
|
||||
MOV r1, #5 // Build enable value with background region enabled
|
||||
STR r1, [r0] // Enable MPU
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
/* PORT SPECIFIC C INFORMATION RELEASE */
|
||||
/* */
|
||||
/* tx_port.h Cortex-M4/IAR */
|
||||
/* 6.1.9 */
|
||||
/* 6.1.11 */
|
||||
/* */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
@@ -48,6 +48,9 @@
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* */
|
||||
/* 10-15-2021 Scott Larson Initial Version 6.1.9 */
|
||||
/* 04-25-2022 Scott Larson Modified comments and added */
|
||||
/* volatile to registers, */
|
||||
/* resulting in version 6.1.11 */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
|
||||
@@ -127,14 +130,14 @@ typedef unsigned short USHORT;
|
||||
For example, if the time source is at the address 0x0a800024 and is 16-bits in size, the clock
|
||||
source constants would be:
|
||||
|
||||
#define TX_TRACE_TIME_SOURCE *((ULONG *) 0x0a800024)
|
||||
#define TX_TRACE_TIME_SOURCE *((volatile ULONG *) 0x0a800024)
|
||||
#define TX_TRACE_TIME_MASK 0x0000FFFFUL
|
||||
|
||||
*/
|
||||
|
||||
#ifndef TX_MISRA_ENABLE
|
||||
#ifndef TX_TRACE_TIME_SOURCE
|
||||
#define TX_TRACE_TIME_SOURCE *((ULONG *) 0xE0001004)
|
||||
#define TX_TRACE_TIME_SOURCE *((volatile ULONG *) 0xE0001004)
|
||||
#endif
|
||||
#else
|
||||
ULONG _tx_misra_time_stamp_get(VOID);
|
||||
@@ -325,7 +328,7 @@ void _tx_misra_vfp_touch(void);
|
||||
else \
|
||||
{ \
|
||||
ULONG _tx_fpccr; \
|
||||
_tx_fpccr = *((ULONG *) 0xE000EF34); \
|
||||
_tx_fpccr = *((volatile ULONG *) 0xE000EF34); \
|
||||
_tx_fpccr = _tx_fpccr & ((ULONG) 0x01); \
|
||||
if (_tx_fpccr == ((ULONG) 0x01)) \
|
||||
{ \
|
||||
@@ -476,7 +479,7 @@ static void _tx_thread_system_return_inline(void)
|
||||
__istate_t interrupt_save;
|
||||
|
||||
/* Set PendSV to invoke ThreadX scheduler. */
|
||||
*((ULONG *) 0xE000ED04) = ((ULONG) 0x10000000);
|
||||
*((volatile ULONG *) 0xE000ED04) = ((ULONG) 0x10000000);
|
||||
if (__get_IPSR() == 0)
|
||||
{
|
||||
interrupt_save = __get_interrupt_state();
|
||||
@@ -488,7 +491,7 @@ __istate_t interrupt_save;
|
||||
#endif
|
||||
|
||||
|
||||
/* Define FPU extension for the Cortex-M7. Each is assumed to be called in the context of the executing
|
||||
/* Define FPU extension for the Cortex-M4. Each is assumed to be called in the context of the executing
|
||||
thread. These are no longer needed, but are preserved for backward compatibility only. */
|
||||
|
||||
void tx_thread_fpu_enable(void);
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _tx_thread_schedule Cortex-M4/IAR */
|
||||
/* 6.1.9 */
|
||||
/* 6.1.11 */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* Scott Larson, Microsoft Corporation */
|
||||
@@ -63,13 +63,15 @@
|
||||
/* */
|
||||
/* _tx_initialize_kernel_enter ThreadX entry function */
|
||||
/* _tx_thread_system_return Return to system from thread */
|
||||
/* _tx_thread_context_restore Restore thread's context */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* */
|
||||
/* 10-15-2021 Scott Larson Initial Version 6.1.9 */
|
||||
/* 04-25-2022 Scott Larson Optimized MPU configuration, */
|
||||
/* added BASEPRI support, */
|
||||
/* resulting in version 6.1.11 */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
// VOID _tx_thread_schedule(VOID)
|
||||
@@ -125,8 +127,12 @@ __tx_wait_here:
|
||||
MemManage_Handler:
|
||||
BusFault_Handler:
|
||||
UsageFault_Handler:
|
||||
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
LDR r1, =TX_PORT_BASEPRI // Mask interrupt priorities =< TX_PORT_BASEPRI
|
||||
MSR BASEPRI, r1
|
||||
#else
|
||||
CPSID i // Disable interrupts
|
||||
#endif /* TX_PORT_USE_BASEPRI */
|
||||
|
||||
/* Now pickup and store all the fault related information. */
|
||||
|
||||
@@ -209,7 +215,12 @@ UsageFault_Handler:
|
||||
LDR r1, =0x10000000 // Set PENDSVSET bit
|
||||
STR r1, [r0] // Store ICSR
|
||||
DSB // Wait for memory access to complete
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
MOV r0, 0 // Disable BASEPRI masking (enable interrupts)
|
||||
MSR BASEPRI, r0
|
||||
#else
|
||||
CPSIE i // Enable interrupts
|
||||
#endif
|
||||
MOV lr, #0xFFFFFFFD // Load exception return code
|
||||
BX lr // Return from exception
|
||||
|
||||
@@ -227,12 +238,22 @@ __tx_ts_handler:
|
||||
|
||||
#if (defined(TX_ENABLE_EXECUTION_CHANGE_NOTIFY) || defined(TX_EXECUTION_PROFILE_ENABLE))
|
||||
/* Call the thread exit function to indicate the thread is no longer executing. */
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
LDR r1, =TX_PORT_BASEPRI // Mask interrupt priorities =< TX_PORT_BASEPRI
|
||||
MSR BASEPRI, r1
|
||||
#else
|
||||
CPSID i // Disable interrupts
|
||||
#endif /* TX_PORT_USE_BASEPRI */
|
||||
PUSH {r0, lr} // Save LR (and r0 just for alignment)
|
||||
BL _tx_execution_thread_exit // Call the thread exit function
|
||||
POP {r0, lr} // Recover LR
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
MOV r0, 0 // Disable BASEPRI masking (enable interrupts)
|
||||
MSR BASEPRI, r0
|
||||
#else
|
||||
CPSIE i // Enable interrupts
|
||||
#endif
|
||||
#endif /* TX_PORT_USE_BASEPRI */
|
||||
#endif /* EXECUTION PROFILE */
|
||||
|
||||
LDR r0, =_tx_thread_current_ptr // Build current thread pointer address
|
||||
LDR r2, =_tx_thread_execute_ptr // Build execute thread pointer address
|
||||
@@ -277,7 +298,12 @@ __tx_ts_new:
|
||||
|
||||
/* Now we are looking for a new thread to execute! */
|
||||
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
LDR r1, =TX_PORT_BASEPRI // Mask interrupt priorities =< TX_PORT_BASEPRI
|
||||
MSR BASEPRI, r1
|
||||
#else
|
||||
CPSID i // Disable interrupts
|
||||
#endif
|
||||
LDR r1, [r2] // Is there another thread ready to execute?
|
||||
CBNZ r1, __tx_ts_restore // Yes, schedule it
|
||||
|
||||
@@ -286,7 +312,12 @@ __tx_ts_new:
|
||||
are disabled to allow use of WFI for waiting for a thread to arrive. */
|
||||
|
||||
__tx_ts_wait:
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
LDR r1, =TX_PORT_BASEPRI // Mask interrupt priorities =< TX_PORT_BASEPRI
|
||||
MSR BASEPRI, r1
|
||||
#else
|
||||
CPSID i // Disable interrupts
|
||||
#endif
|
||||
LDR r1, [r2] // Pickup the next thread to execute pointer
|
||||
CBNZ r1, __tx_ts_ready // If non-NULL, a new thread is ready!
|
||||
#ifdef TX_ENABLE_WFI
|
||||
@@ -294,7 +325,12 @@ __tx_ts_wait:
|
||||
WFI // Wait for interrupt
|
||||
ISB // Ensure pipeline is flushed
|
||||
#endif
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
MOV r4, #0 // Disable BASEPRI masking (enable interrupts)
|
||||
MSR BASEPRI, r4
|
||||
#else
|
||||
CPSIE i // Enable interrupts
|
||||
#endif
|
||||
B __tx_ts_wait // Loop to continue waiting
|
||||
|
||||
/* At this point, we have a new thread ready to go. Clear any newly pended PendSV - since we are
|
||||
@@ -311,7 +347,12 @@ __tx_ts_restore:
|
||||
and enable interrupts. */
|
||||
|
||||
STR r1, [r0] // Setup the current thread pointer to the new thread
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
MOV r4, #0 // Disable BASEPRI masking (enable interrupts)
|
||||
MSR BASEPRI, r4
|
||||
#else
|
||||
CPSIE i // Enable interrupts
|
||||
#endif
|
||||
|
||||
/* Increment the thread run count. */
|
||||
|
||||
@@ -347,27 +388,34 @@ __tx_ts_restore:
|
||||
STR r3, [r0] // Disable MPU
|
||||
LDR r0, [r1, #0x90] // Pickup the module instance pointer
|
||||
CBZ r0, skip_mpu_setup // Is this thread owned by a module? No, skip MPU setup
|
||||
LDR r1, [r0, #0x64] // Pickup MPU register[0]
|
||||
CBZ r1, skip_mpu_setup // Is protection required for this module? No, skip MPU setup
|
||||
LDR r1, =0xE000ED9C // Build address of MPU base register
|
||||
|
||||
LDR r2, [r0, #0x8C] // Pickup MPU region 5 address
|
||||
CBZ r2, skip_mpu_setup // Is protection required for this module? No, skip MPU setup
|
||||
|
||||
// Is the MPU already set up for this module?
|
||||
MOV r1, #5 // Select region 5 from MPU
|
||||
LDR r3, =0xE000ED98 // MPU_RNR register address
|
||||
STR r1, [r3] // Set region to 5
|
||||
LDR r1, =0xE000ED9C // MPU_RBAR register address
|
||||
LDR r3, [r1] // Load address stored in MPU region 5
|
||||
BIC r2, r2, #0x10 // Clear VALID bit
|
||||
CMP r2, r3 // Is module already loaded?
|
||||
BEQ _tx_enable_mpu // Yes - skip MPU reconfiguration
|
||||
|
||||
// Use alias registers to quickly load MPU
|
||||
ADD r0, r0, #100 // Build address of MPU register start in thread control block
|
||||
#ifdef TXM_MODULE_MANAGER_16_MPU
|
||||
|
||||
LDM r0!,{r2-r9} // Load MPU regions 0-3
|
||||
STM r1,{r2-r9} // Store MPU regions 0-3
|
||||
LDM r0!,{r2-r9} // Load MPU regions 4-7
|
||||
STM r1,{r2-r9} // Store MPU regions 4-7
|
||||
#ifdef TXM_MODULE_MANAGER_16_MPU
|
||||
LDM r0!,{r2-r9} // Load MPU regions 8-11
|
||||
STM r1,{r2-r9} // Store MPU regions 8-11
|
||||
LDM r0,{r2-r9} // Load MPU regions 12-15
|
||||
STM r1,{r2-r9} // Store MPU regions 12-15
|
||||
#else
|
||||
LDM r0!,{r2-r9} // Load first four MPU regions
|
||||
STM r1,{r2-r9} // Store first four MPU regions
|
||||
LDM r0,{r2-r9} // Load second four MPU regions
|
||||
STM r1,{r2-r9} // Store second four MPU regions
|
||||
#endif
|
||||
_tx_enable_mpu:
|
||||
LDR r0, =0xE000ED94 // Build MPU control reg address
|
||||
MOV r1, #5 // Build enable value with background region enabled
|
||||
STR r1, [r0] // Enable MPU
|
||||
|
||||
Reference in New Issue
Block a user