summaryrefslogtreecommitdiff
path: root/ports_arch/ARMv7-M/threadx
diff options
context:
space:
mode:
Diffstat (limited to 'ports_arch/ARMv7-M/threadx')
-rw-r--r--ports_arch/ARMv7-M/threadx/ac5/example_build/tx_initialize_low_level.s13
-rw-r--r--ports_arch/ARMv7-M/threadx/ac5/src/tx_thread_schedule.s14
-rw-r--r--ports_arch/ARMv7-M/threadx/ac6/example_build/sample_threadx/tx_initialize_low_level.S13
-rw-r--r--ports_arch/ARMv7-M/threadx/ac6/src/tx_thread_schedule.S12
-rw-r--r--ports_arch/ARMv7-M/threadx/ac6/src/tx_thread_system_return.S6
-rw-r--r--ports_arch/ARMv7-M/threadx/ghs/example_build/tx_initialize_low_level.arm17
-rw-r--r--ports_arch/ARMv7-M/threadx/ghs/inc/tx_port.h2
-rw-r--r--ports_arch/ARMv7-M/threadx/gnu/CMakeLists.txt4
-rw-r--r--ports_arch/ARMv7-M/threadx/gnu/example_build/tx_initialize_low_level.S14
-rw-r--r--ports_arch/ARMv7-M/threadx/gnu/src/tx_thread_schedule.S12
-rw-r--r--ports_arch/ARMv7-M/threadx/gnu/src/tx_thread_system_return.S6
-rw-r--r--ports_arch/ARMv7-M/threadx/iar/example_build/tx.ewp2
-rw-r--r--ports_arch/ARMv7-M/threadx/iar/example_build/tx_initialize_low_level.s14
-rw-r--r--ports_arch/ARMv7-M/threadx/iar/src/tx_iar.c9
-rw-r--r--ports_arch/ARMv7-M/threadx/iar/src/tx_thread_schedule.s14
-rw-r--r--ports_arch/ARMv7-M/threadx/iar/src/tx_thread_system_return.s29
-rw-r--r--ports_arch/ARMv7-M/threadx/inc/tx_port.h11
17 files changed, 103 insertions, 89 deletions
diff --git a/ports_arch/ARMv7-M/threadx/ac5/example_build/tx_initialize_low_level.s b/ports_arch/ARMv7-M/threadx/ac5/example_build/tx_initialize_low_level.s
index af05fba7..5df0582e 100644
--- a/ports_arch/ARMv7-M/threadx/ac5/example_build/tx_initialize_low_level.s
+++ b/ports_arch/ARMv7-M/threadx/ac5/example_build/tx_initialize_low_level.s
@@ -8,6 +8,7 @@
*
* SPDX-License-Identifier: MIT
**************************************************************************/
+// Portions of this file were generated with AI assistance.
/**************************************************************************/
@@ -20,7 +21,6 @@
/**************************************************************************/
/**************************************************************************/
- IMPORT _tx_thread_system_stack_ptr
IMPORT _tx_initialize_unused_memory
IMPORT _tx_thread_context_save
IMPORT _tx_thread_context_restore
@@ -151,17 +151,6 @@ _tx_initialize_low_level
ADD r1, r1, #4 // Add 4 to get to next free word
STR r1, [r0] // Setup first unused memory pointer
- /* Setup Vector Table Offset Register. */
- MOV r0, #0xE000E000 // Build address of NVIC registers
- LDR r1, =__tx_vectors // Pickup address of vector table
- STR r1, [r0, #0xD08] // Set vector table address
-
- /* Set system stack pointer from vector value. */
- LDR r0, =_tx_thread_system_stack_ptr // Build address of system stack pointer
- LDR r1, =__tx_vectors // Pickup address of vector table
- LDR r1, [r1] // Pickup reset stack pointer
- STR r1, [r0] // Save system stack pointer
-
#ifndef TX_NO_TIMER
/* Configure SysTick. */
MOV r0, #0xE000E000 // Build address of NVIC registers
diff --git a/ports_arch/ARMv7-M/threadx/ac5/src/tx_thread_schedule.s b/ports_arch/ARMv7-M/threadx/ac5/src/tx_thread_schedule.s
index 12da7d69..3e237f31 100644
--- a/ports_arch/ARMv7-M/threadx/ac5/src/tx_thread_schedule.s
+++ b/ports_arch/ARMv7-M/threadx/ac5/src/tx_thread_schedule.s
@@ -9,6 +9,8 @@
* SPDX-License-Identifier: MIT
**************************************************************************/
+// Portions of this file were generated with AI assistance.
+
/**************************************************************************/
/**************************************************************************/
@@ -132,7 +134,7 @@ __tx_ts_handler
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)
+ MOV r0, #0 // Disable BASEPRI masking (enable interrupts)
MSR BASEPRI, r0
#else
CPSIE i // Enable interrupts
@@ -260,9 +262,19 @@ __tx_ts_wait
#endif
#ifdef TX_ENABLE_WFI
+#ifdef TX_PORT_USE_BASEPRI
+ CPSID i // Mask every interrupt with PRIMASK, which WFI ignores
+ MOV r1, #0 // Clear BASEPRI so that an interrupt masked by it
+ MSR BASEPRI, r1 // is still able to wake the processor
+#endif
DSB // Ensure no outstanding memory transactions
WFI // Wait for interrupt
ISB // Ensure pipeline is flushed
+#ifdef TX_PORT_USE_BASEPRI
+ LDR r1, =TX_PORT_BASEPRI // Restore the BASEPRI mask
+ MSR BASEPRI, r1
+ CPSIE i // Clear PRIMASK; a pending interrupt is taken here
+#endif
#endif
#ifdef TX_LOW_POWER
diff --git a/ports_arch/ARMv7-M/threadx/ac6/example_build/sample_threadx/tx_initialize_low_level.S b/ports_arch/ARMv7-M/threadx/ac6/example_build/sample_threadx/tx_initialize_low_level.S
index 617d62de..d14efe4d 100644
--- a/ports_arch/ARMv7-M/threadx/ac6/example_build/sample_threadx/tx_initialize_low_level.S
+++ b/ports_arch/ARMv7-M/threadx/ac6/example_build/sample_threadx/tx_initialize_low_level.S
@@ -8,6 +8,7 @@
*
* SPDX-License-Identifier: MIT
**************************************************************************/
+// Portions of this file were generated with AI assistance.
/**************************************************************************/
@@ -20,7 +21,6 @@
/**************************************************************************/
/**************************************************************************/
- .global _tx_thread_system_stack_ptr
.global _tx_initialize_unused_memory
#ifndef TX_NO_TIMER
.global _tx_timer_interrupt
@@ -93,17 +93,6 @@ _tx_initialize_low_level:
ADD r1, r1, #4 //
STR r1, [r0] // Setup first unused memory pointer
- /* Setup Vector Table Offset Register. */
- MOV r0, #0xE000E000 // Build address of NVIC registers
- LDR r1, =vector_table // Pickup address of vector table
- STR r1, [r0, #0xD08] // Set vector table address
-
- /* Set system stack pointer from vector value. */
- LDR r0, =_tx_thread_system_stack_ptr // Build address of system stack pointer
- LDR r1, =vector_table // Pickup address of vector table
- LDR r1, [r1] // Pickup reset stack pointer
- STR r1, [r0] // Save system stack pointer
-
#ifndef TX_NO_TIMER
/* Configure SysTick. */
MOV r0, #0xE000E000 // Build address of NVIC registers
diff --git a/ports_arch/ARMv7-M/threadx/ac6/src/tx_thread_schedule.S b/ports_arch/ARMv7-M/threadx/ac6/src/tx_thread_schedule.S
index a368f5d6..5f600c7d 100644
--- a/ports_arch/ARMv7-M/threadx/ac6/src/tx_thread_schedule.S
+++ b/ports_arch/ARMv7-M/threadx/ac6/src/tx_thread_schedule.S
@@ -8,7 +8,7 @@
*
* SPDX-License-Identifier: MIT
**************************************************************************/
-// Some portions generated by Codex (GPT-5).
+// Portions of this file were generated with AI assistance.
/**************************************************************************/
@@ -268,9 +268,19 @@ __tx_ts_wait:
#endif
#ifdef TX_ENABLE_WFI
+#ifdef TX_PORT_USE_BASEPRI
+ CPSID i // Mask every interrupt with PRIMASK, which WFI ignores
+ MOV r1, #0 // Clear BASEPRI so that an interrupt masked by it
+ MSR BASEPRI, r1 // is still able to wake the processor
+#endif
DSB // Ensure no outstanding memory transactions
WFI // Wait for interrupt
ISB // Ensure pipeline is flushed
+#ifdef TX_PORT_USE_BASEPRI
+ LDR r1, =TX_PORT_BASEPRI // Restore the BASEPRI mask
+ MSR BASEPRI, r1
+ CPSIE i // Clear PRIMASK; a pending interrupt is taken here
+#endif
#endif
#ifdef TX_LOW_POWER
diff --git a/ports_arch/ARMv7-M/threadx/ac6/src/tx_thread_system_return.S b/ports_arch/ARMv7-M/threadx/ac6/src/tx_thread_system_return.S
index 75d51813..efa4e03f 100644
--- a/ports_arch/ARMv7-M/threadx/ac6/src/tx_thread_system_return.S
+++ b/ports_arch/ARMv7-M/threadx/ac6/src/tx_thread_system_return.S
@@ -9,6 +9,8 @@
* SPDX-License-Identifier: MIT
**************************************************************************/
+// Portions of this file were generated with AI assistance.
+
/**************************************************************************/
/**************************************************************************/
@@ -73,6 +75,8 @@ _tx_thread_system_return:
MOV r0, #0x10000000 // Load PENDSVSET bit
MOV r1, #0xE000E000 // Load NVIC base
STR r0, [r1, #0xD04] // Set PENDSVBIT in ICSR
+ DSB #0xF // Ensure memory access is complete
+ ISB #0xF // Flush pipeline
MRS r0, IPSR // Pickup IPSR
CMP r0, #0 // Is it a thread returning?
BNE _isr_context // If ISR, skip interrupt enable
@@ -81,10 +85,12 @@ _tx_thread_system_return:
MOV r0, #0
MSR BASEPRI, r0 // Enable interrupts
MSR BASEPRI, r1 // Restore original interrupt posture
+ ISB #0xF // Flush pipeline
#else
MRS r1, PRIMASK // Thread context returning, pickup PRIMASK
CPSIE i // Enable interrupts
MSR PRIMASK, r1 // Restore original interrupt posture
+ ISB #0xF // Flush pipeline
#endif
_isr_context:
BX lr // Return to caller
diff --git a/ports_arch/ARMv7-M/threadx/ghs/example_build/tx_initialize_low_level.arm b/ports_arch/ARMv7-M/threadx/ghs/example_build/tx_initialize_low_level.arm
index fc6e19fe..7c2b80ab 100644
--- a/ports_arch/ARMv7-M/threadx/ghs/example_build/tx_initialize_low_level.arm
+++ b/ports_arch/ARMv7-M/threadx/ghs/example_build/tx_initialize_low_level.arm
@@ -1,5 +1,6 @@
/***************************************************************************
* Copyright (c) 2024 Microsoft Corporation
+ * Copyright (c) 2026-present Eclipse ThreadX contributors
*
* This program and the accompanying materials are made available under the
* terms of the MIT License which is available at
@@ -7,6 +8,7 @@
*
* SPDX-License-Identifier: MIT
**************************************************************************/
+; Portions of this file were generated with AI assistance.
/**************************************************************************/
@@ -75,13 +77,6 @@ _tx_initialize_low_level:
CPSID i ; Disable interrupts
- /* Save the system stack pointer. */
- /* _tx_thread_system_stack_ptr = (VOID_PTR) (sp); */
-
- LDR r1,=_tx_thread_system_stack_ptr ; Pickup address of system stack ptr
- STR sp, [r1] ; Save system stack
-
-
/* Save the first available memory address. */
/* _tx_initialize_unused_memory = (VOID_PTR) __ghsbegin_free_mem; */
@@ -98,15 +93,9 @@ _tx_initialize_low_level:
STR r1, [r0] ; Enable the cycle count register
- /* Setup Vector Table Offset Register. */
-
- MOV r0, 0xE000E000 ; Build address of NVIC registers
- LDR r1, =__vectors ; Pickup address of vector table
- STR r1, [r0, 0xD08] ; Set vector table address
-
-
/* Configure SysTick for 100Hz clock, or 16384 cycles if no reference. */
+ MOV r0, 0xE000E000 ; Build address of NVIC registers
MOV r1, 0 ; Build value for SysTick reset
STR r1, [r0, 0x10] ; Reset SysTick Control
STR r1, [r0, 0x18] ; Reset SysTick Counter Value
diff --git a/ports_arch/ARMv7-M/threadx/ghs/inc/tx_port.h b/ports_arch/ARMv7-M/threadx/ghs/inc/tx_port.h
index 41b32b43..b28ef5c5 100644
--- a/ports_arch/ARMv7-M/threadx/ghs/inc/tx_port.h
+++ b/ports_arch/ARMv7-M/threadx/ghs/inc/tx_port.h
@@ -387,7 +387,7 @@ void tx_thread_fpu_disable(void);
#ifdef TX_THREAD_INIT
CHAR _tx_version_id[] =
- "(c) 2024 Microsoft Corp. (c) 2026-present Eclipse ThreadX contributors. * ThreadX ARMv7-M Version 6.5.1.202602a *";
+ "(c) 2024 Microsoft Corp. (c) 2026-present Eclipse ThreadX contributors. * ThreadX ARMv7-M Version 6.5.2.202603 *";
#else
#ifdef TX_MISRA_ENABLE
extern CHAR _tx_version_id[100];
diff --git a/ports_arch/ARMv7-M/threadx/gnu/CMakeLists.txt b/ports_arch/ARMv7-M/threadx/gnu/CMakeLists.txt
index ab9464d2..4abc1c06 100644
--- a/ports_arch/ARMv7-M/threadx/gnu/CMakeLists.txt
+++ b/ports_arch/ARMv7-M/threadx/gnu/CMakeLists.txt
@@ -13,6 +13,8 @@ target_sources(${PROJECT_NAME} PRIVATE
# {{END_TARGET_SOURCES}}
)
-target_include_directories(${PROJECT_NAME} PUBLIC
+target_include_directories(${PROJECT_NAME}
+ SYSTEM
+ PUBLIC
${CMAKE_CURRENT_LIST_DIR}/inc
)
diff --git a/ports_arch/ARMv7-M/threadx/gnu/example_build/tx_initialize_low_level.S b/ports_arch/ARMv7-M/threadx/gnu/example_build/tx_initialize_low_level.S
index 41cde163..a8bb445b 100644
--- a/ports_arch/ARMv7-M/threadx/gnu/example_build/tx_initialize_low_level.S
+++ b/ports_arch/ARMv7-M/threadx/gnu/example_build/tx_initialize_low_level.S
@@ -8,6 +8,7 @@
*
* SPDX-License-Identifier: MIT
**************************************************************************/
+// Portions of this file were generated with AI assistance.
/**************************************************************************/
@@ -20,12 +21,10 @@
/**************************************************************************/
/**************************************************************************/
- .global _tx_thread_system_stack_ptr
.global _tx_initialize_unused_memory
.global __RAM_segment_used_end__
.global _tx_timer_interrupt
.global __main
- .global _vectors
.global __tx_NMIHandler // NMI
.global __tx_BadHandler // HardFault
.global __tx_SVCallHandler // SVCall
@@ -90,17 +89,6 @@ _tx_initialize_low_level:
ADD r1, r1, #4 //
STR r1, [r0] // Setup first unused memory pointer
- /* Setup Vector Table Offset Register. */
- MOV r0, #0xE000E000 // Build address of NVIC registers
- LDR r1, =_vectors // Pickup address of vector table
- STR r1, [r0, #0xD08] // Set vector table address
-
- /* Set system stack pointer from vector value. */
- LDR r0, =_tx_thread_system_stack_ptr // Build address of system stack pointer
- LDR r1, =_vectors // Pickup address of vector table
- LDR r1, [r1] // Pickup reset stack pointer
- STR r1, [r0] // Save system stack pointer
-
#ifndef TX_NO_TIMER
/* Configure SysTick. */
MOV r0, #0xE000E000 // Build address of NVIC registers
diff --git a/ports_arch/ARMv7-M/threadx/gnu/src/tx_thread_schedule.S b/ports_arch/ARMv7-M/threadx/gnu/src/tx_thread_schedule.S
index d70a7b00..182eb81a 100644
--- a/ports_arch/ARMv7-M/threadx/gnu/src/tx_thread_schedule.S
+++ b/ports_arch/ARMv7-M/threadx/gnu/src/tx_thread_schedule.S
@@ -8,7 +8,7 @@
*
* SPDX-License-Identifier: MIT
**************************************************************************/
-// Some portions generated by Codex (GPT-5).
+// Portions of this file were generated with AI assistance.
/**************************************************************************/
@@ -266,9 +266,19 @@ __tx_ts_wait:
#endif
#ifdef TX_ENABLE_WFI
+#ifdef TX_PORT_USE_BASEPRI
+ CPSID i // Mask every interrupt with PRIMASK, which WFI ignores
+ MOV r1, #0 // Clear BASEPRI so that an interrupt masked by it
+ MSR BASEPRI, r1 // is still able to wake the processor
+#endif
DSB // Ensure no outstanding memory transactions
WFI // Wait for interrupt
ISB // Ensure pipeline is flushed
+#ifdef TX_PORT_USE_BASEPRI
+ LDR r1, =TX_PORT_BASEPRI // Restore the BASEPRI mask
+ MSR BASEPRI, r1
+ CPSIE i // Clear PRIMASK; a pending interrupt is taken here
+#endif
#endif
#ifdef TX_LOW_POWER
diff --git a/ports_arch/ARMv7-M/threadx/gnu/src/tx_thread_system_return.S b/ports_arch/ARMv7-M/threadx/gnu/src/tx_thread_system_return.S
index 8b681747..ab050566 100644
--- a/ports_arch/ARMv7-M/threadx/gnu/src/tx_thread_system_return.S
+++ b/ports_arch/ARMv7-M/threadx/gnu/src/tx_thread_system_return.S
@@ -9,6 +9,8 @@
* SPDX-License-Identifier: MIT
**************************************************************************/
+// Portions of this file were generated with AI assistance.
+
/**************************************************************************/
/**************************************************************************/
@@ -73,6 +75,8 @@ _tx_thread_system_return:
MOV r0, #0x10000000 // Load PENDSVSET bit
MOV r1, #0xE000E000 // Load NVIC base
STR r0, [r1, #0xD04] // Set PENDSVBIT in ICSR
+ DSB #0xF // Ensure memory access is complete
+ ISB #0xF // Flush pipeline
MRS r0, IPSR // Pickup IPSR
CMP r0, #0 // Is it a thread returning?
BNE _isr_context // If ISR, skip interrupt enable
@@ -81,10 +85,12 @@ _tx_thread_system_return:
MOV r0, #0
MSR BASEPRI, r0 // Enable interrupts
MSR BASEPRI, r1 // Restore original interrupt posture
+ ISB #0xF // Flush pipeline
#else
MRS r1, PRIMASK // Thread context returning, pickup PRIMASK
CPSIE i // Enable interrupts
MSR PRIMASK, r1 // Restore original interrupt posture
+ ISB #0xF // Flush pipeline
#endif
_isr_context:
BX lr // Return to caller
diff --git a/ports_arch/ARMv7-M/threadx/iar/example_build/tx.ewp b/ports_arch/ARMv7-M/threadx/iar/example_build/tx.ewp
index cccb9a9a..15b9ab10 100644
--- a/ports_arch/ARMv7-M/threadx/iar/example_build/tx.ewp
+++ b/ports_arch/ARMv7-M/threadx/iar/example_build/tx.ewp
@@ -1047,7 +1047,7 @@
</option>
<option>
<name>IarchiveOutput</name>
- <state>C:\Users\sclarson\repos\tx_m\ports\armv7-m\iar\sample_cortex_m4\Debug\Exe\tx.a</state>
+ <state>###Unitialized###</state>
</option>
</data>
</settings>
diff --git a/ports_arch/ARMv7-M/threadx/iar/example_build/tx_initialize_low_level.s b/ports_arch/ARMv7-M/threadx/iar/example_build/tx_initialize_low_level.s
index dd4bfce4..54aa4231 100644
--- a/ports_arch/ARMv7-M/threadx/iar/example_build/tx_initialize_low_level.s
+++ b/ports_arch/ARMv7-M/threadx/iar/example_build/tx_initialize_low_level.s
@@ -8,6 +8,7 @@
*
* SPDX-License-Identifier: MIT
**************************************************************************/
+// Portions of this file were generated with AI assistance.
/**************************************************************************/
@@ -20,10 +21,8 @@
/**************************************************************************/
/**************************************************************************/
- EXTERN _tx_thread_system_stack_ptr
EXTERN _tx_initialize_unused_memory
EXTERN _tx_timer_interrupt
- EXTERN __vector_table
EXTERN _tx_execution_isr_enter
EXTERN _tx_execution_isr_exit
@@ -84,17 +83,6 @@ _tx_initialize_low_level:
LDR r2, =_tx_initialize_unused_memory // Build address of unused memory pointer
STR r0, [r2, #0] // Save first free memory address
- /* Setup Vector Table Offset Register. */
- MOV r0, #0xE000E000 // Build address of NVIC registers
- LDR r1, =__vector_table // Pickup address of vector table
- STR r1, [r0, #0xD08] // Set vector table address
-
- /* Set system stack pointer from vector value. */
- LDR r0, =_tx_thread_system_stack_ptr // Build address of system stack pointer
- LDR r1, =__vector_table // Pickup address of vector table
- LDR r1, [r1] // Pickup reset stack pointer
- STR r1, [r0] // Save system stack pointer
-
#ifndef TX_NO_TIMER
/* Configure SysTick. */
MOV r0, #0xE000E000 // Build address of NVIC registers
diff --git a/ports_arch/ARMv7-M/threadx/iar/src/tx_iar.c b/ports_arch/ARMv7-M/threadx/iar/src/tx_iar.c
index 238b485e..ab6c209c 100644
--- a/ports_arch/ARMv7-M/threadx/iar/src/tx_iar.c
+++ b/ports_arch/ARMv7-M/threadx/iar/src/tx_iar.c
@@ -9,6 +9,7 @@
* SPDX-License-Identifier: MIT
**************************************************************************/
+// Portions of this file were generated with AI assistance.
/**************************************************************************/
/**************************************************************************/
@@ -270,7 +271,7 @@ TX_MUTEX *mutex_ptr;
mutex_ptr = &__tx_iar_file_lock_mutexes[__tx_iar_file_lock_next_free_mutex++];
/* Check for wrap-around on the next free mutex. */
- if (__tx_iar_file_lock_next_free_mutex >= _MAX_LOCK)
+ if (__tx_iar_file_lock_next_free_mutex >= _MAX_FLOCK)
{
/* Yes, set the free index back to 0. */
@@ -287,7 +288,7 @@ TX_MUTEX *mutex_ptr;
}
/* Determine if a free mutex was found. */
- if (i >= _MAX_LOCK)
+ if (i >= _MAX_FLOCK)
{
/* Error! No more free mutexes! */
@@ -678,7 +679,7 @@ TX_MUTEX *mutex_ptr;
mutex_ptr = &__tx_iar_file_lock_mutexes[__tx_iar_file_lock_next_free_mutex++];
/* Check for wrap-around on the next free mutex. */
- if (__tx_iar_file_lock_next_free_mutex >= _MAX_LOCK)
+ if (__tx_iar_file_lock_next_free_mutex >= _MAX_FLOCK)
{
/* Yes, set the free index back to 0. */
@@ -695,7 +696,7 @@ TX_MUTEX *mutex_ptr;
}
/* Determine if a free mutex was found. */
- if (i >= _MAX_LOCK)
+ if (i >= _MAX_FLOCK)
{
/* Error! No more free mutexes! */
diff --git a/ports_arch/ARMv7-M/threadx/iar/src/tx_thread_schedule.s b/ports_arch/ARMv7-M/threadx/iar/src/tx_thread_schedule.s
index d38774b8..f33e6277 100644
--- a/ports_arch/ARMv7-M/threadx/iar/src/tx_thread_schedule.s
+++ b/ports_arch/ARMv7-M/threadx/iar/src/tx_thread_schedule.s
@@ -9,6 +9,8 @@
* SPDX-License-Identifier: MIT
**************************************************************************/
+// Portions of this file were generated with AI assistance.
+
/**************************************************************************/
/**************************************************************************/
@@ -132,7 +134,7 @@ __tx_ts_handler:
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)
+ MOV r0, #0 // Disable BASEPRI masking (enable interrupts)
MSR BASEPRI, r0
#else
CPSIE i // Enable interrupts
@@ -260,9 +262,19 @@ __tx_ts_wait:
#endif
#ifdef TX_ENABLE_WFI
+#ifdef TX_PORT_USE_BASEPRI
+ CPSID i // Mask every interrupt with PRIMASK, which WFI ignores
+ MOV r1, #0 // Clear BASEPRI so that an interrupt masked by it
+ MSR BASEPRI, r1 // is still able to wake the processor
+#endif
DSB // Ensure no outstanding memory transactions
WFI // Wait for interrupt
ISB // Ensure pipeline is flushed
+#ifdef TX_PORT_USE_BASEPRI
+ LDR r1, =TX_PORT_BASEPRI // Restore the BASEPRI mask
+ MSR BASEPRI, r1
+ CPSIE i // Clear PRIMASK; a pending interrupt is taken here
+#endif
#endif
#ifdef TX_LOW_POWER
diff --git a/ports_arch/ARMv7-M/threadx/iar/src/tx_thread_system_return.s b/ports_arch/ARMv7-M/threadx/iar/src/tx_thread_system_return.s
index 65bec5a5..58be8f72 100644
--- a/ports_arch/ARMv7-M/threadx/iar/src/tx_thread_system_return.s
+++ b/ports_arch/ARMv7-M/threadx/iar/src/tx_thread_system_return.s
@@ -1,16 +1,19 @@
-/***************************************************************************
- * Copyright (c) 2024 Microsoft Corporation
- * Copyright (c) 2026-present Eclipse ThreadX contributors
- *
- * This program and the accompanying materials are made available under the
- * terms of the MIT License which is available at
- * https://opensource.org/licenses/MIT.
- *
- * SPDX-License-Identifier: MIT
- **************************************************************************/
+;***************************************************************************
+;* Copyright (c) 2024 Microsoft Corporation
+;* Copyright (c) 2026-present Eclipse ThreadX contributors
+;*
+;* This program and the accompanying materials are made available under the
+;* terms of the MIT License which is available at
+;* https://opensource.org/licenses/MIT.
+;*
+;* SPDX-License-Identifier: MIT
+;**************************************************************************
+; Portions of this file were generated with AI assistance.
+
+
+;**************************************************************************
-/**************************************************************************/
/**************************************************************************/
/** */
/** ThreadX Component */
@@ -70,6 +73,8 @@ _tx_thread_system_return:
MOV r0, #0x10000000 // Load PENDSVSET bit
MOV r1, #0xE000E000 // Load NVIC base
STR r0, [r1, #0xD04] // Set PENDSVBIT in ICSR
+ DSB SY // Ensure memory access is complete
+ ISB SY // Flush pipeline
MRS r0, IPSR // Pickup IPSR
CMP r0, #0 // Is it a thread returning?
BNE _isr_context // If ISR, skip interrupt enable
@@ -78,10 +83,12 @@ _tx_thread_system_return:
MOV r0, #0
MSR BASEPRI, r0 // Enable interrupts
MSR BASEPRI, r1 // Restore original interrupt posture
+ ISB SY // Flush pipeline
#else
MRS r1, PRIMASK // Thread context returning, pickup PRIMASK
CPSIE i // Enable interrupts
MSR PRIMASK, r1 // Restore original interrupt posture
+ ISB SY // Flush pipeline
#endif
_isr_context:
BX lr // Return to caller
diff --git a/ports_arch/ARMv7-M/threadx/inc/tx_port.h b/ports_arch/ARMv7-M/threadx/inc/tx_port.h
index ac21ab55..d3d4771c 100644
--- a/ports_arch/ARMv7-M/threadx/inc/tx_port.h
+++ b/ports_arch/ARMv7-M/threadx/inc/tx_port.h
@@ -9,6 +9,8 @@
* SPDX-License-Identifier: MIT
**************************************************************************/
+// Portions of this file were generated with AI assistance.
+
/**************************************************************************/
/**************************************************************************/
@@ -539,8 +541,9 @@ unsigned int posture;
#ifdef TX_PORT_USE_BASEPRI
__attribute__( ( always_inline ) ) static inline void __set_basepri_value(unsigned int basepri_value)
{
- __asm__ volatile ("MSR BASEPRI,%0 ": : "r" (basepri_value));
+ __asm__ volatile ("MSR BASEPRI,%0 ": : "r" (basepri_value) : "memory");
}
+
#else
__attribute__( ( always_inline ) ) static inline void __enable_interrupts(void)
{
@@ -552,7 +555,7 @@ __attribute__( ( always_inline ) ) static inline void __restore_interrupt(unsign
{
#ifdef TX_PORT_USE_BASEPRI
__set_basepri_value(int_posture);
- //__asm__ volatile ("MSR BASEPRI,%0": : "r" (int_posture): "memory");
+ __asm__ volatile ("" : : : "memory");
#else
__asm__ volatile ("MSR PRIMASK,%0": : "r" (int_posture): "memory");
#endif
@@ -578,6 +581,7 @@ unsigned int interrupt_save;
/* Set PendSV to invoke ThreadX scheduler. */
*((volatile ULONG *) 0xE000ED04) = ((ULONG) 0x10000000);
+ __asm__ volatile ("dsb sy \n isb sy " : : : "memory");
if (__get_ipsr_value() == 0)
{
interrupt_save = __get_interrupt_posture();
@@ -587,6 +591,7 @@ unsigned int interrupt_save;
__enable_interrupts();
#endif
__restore_interrupt(interrupt_save);
+ __asm__ volatile ("isb sy " : : : "memory");
}
}
@@ -699,7 +704,7 @@ void tx_thread_fpu_disable(void);
#ifdef TX_THREAD_INIT
CHAR _tx_version_id[] =
- "(c) 2024 Microsoft Corp. (c) 2026-present Eclipse ThreadX contributors. * ThreadX Cortex-Mx Version 6.5.1.202602a *";
+ "(c) 2024 Microsoft Corp. (c) 2026-present Eclipse ThreadX contributors. * ThreadX Cortex-Mx Version 6.5.2.202603 *";
#else
#ifdef TX_MISRA_ENABLE
extern CHAR _tx_version_id[100];