diff options
Diffstat (limited to 'ports/cortex_r5/gnu/src')
8 files changed, 114 insertions, 20 deletions
diff --git a/ports/cortex_r5/gnu/src/tx_port_offset_check.c b/ports/cortex_r5/gnu/src/tx_port_offset_check.c new file mode 100644 index 00000000..44dfd1a8 --- /dev/null +++ b/ports/cortex_r5/gnu/src/tx_port_offset_check.c @@ -0,0 +1,87 @@ +/*************************************************************************** + * Copyright (C) 2026 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. + * + * AI Disclosure: This file was largely AI-generated by Claude Code (Opus 5). + * The AI-generated portions may be considered public domain (CC0-1.0) + * and not subject to the project's licence. The human contributor has + * reviewed and verified that the code is correct. + * + * SPDX-License-Identifier: MIT and CC0-1.0 + **************************************************************************/ + +/**************************************************************************/ +/**************************************************************************/ +/** */ +/** ThreadX Component */ +/** */ +/** Port Specific */ +/** */ +/**************************************************************************/ +/**************************************************************************/ + +/**************************************************************************/ +/* */ +/* PORT SPECIFIC C INFORMATION RELEASE */ +/* */ +/* tx_port_offset_check.c Cortex-R5/GNU */ +/* */ +/* DESCRIPTION */ +/* */ +/* Compile-time verification of the TX_THREAD structure offsets that */ +/* this port's assembly reaches by hard-coded displacement. The file */ +/* emits no code; it exists purely so that a layout change becomes a */ +/* build failure. */ +/* */ +/* Why this is needed: tx_thread_schedule.S, */ +/* tx_thread_system_return.S and tx_thread_context_restore.S read and */ +/* write the per-thread VFP enable flag as [thread, #144]. Nothing in */ +/* the toolchain connects that literal to the C structure, so adding a */ +/* member, enabling an option that adds one, or reordering the port */ +/* extensions would silently retarget those accesses at an unrelated */ +/* field -- corrupting thread state in a way that is extremely hard to */ +/* diagnose from the symptom. The offset was measured at 144 for the */ +/* default build and is asserted here. */ +/* */ +/* NOTE: this port has no CMake build of its own, so this file takes */ +/* effect only in builds that compile everything under src/. It is */ +/* still worthwhile: it emits no code, costs nothing, and protects every */ +/* build that does pick it up. */ +/* */ +/* A negative array dimension is used rather than _Static_assert */ +/* because this project targets C99, where _Static_assert does not */ +/* exist. If an assertion below fails, the compiler reports a negative */ +/* or zero-sized array for the named typedef. */ +/* */ +/**************************************************************************/ + +#include "tx_api.h" +#include <stddef.h> + +/* Offset of the VFP enable flag as encoded in this port's assembly. + Overridable only so that the assertion itself can be tested. */ + +#ifndef TX_PORT_VFP_ENABLE_OFFSET +#define TX_PORT_VFP_ENABLE_OFFSET 144 +#endif + +typedef char +tx_port_assert_vfp_enable_offset_is_144[ + (offsetof(TX_THREAD, tx_thread_vfp_enable) == TX_PORT_VFP_ENABLE_OFFSET) + ? 1 : -1]; + +/* The stack pointer is read as [thread, #8] by tx_thread_schedule.S and + written by tx_thread_system_return.S, and the run counter as + [thread, #4]. Assert those too, since they are on the context-switch + critical path. */ + +typedef char +tx_port_assert_stack_ptr_offset_is_8[ + (offsetof(TX_THREAD, tx_thread_stack_ptr) == 8) ? 1 : -1]; + +typedef char +tx_port_assert_run_count_offset_is_4[ + (offsetof(TX_THREAD, tx_thread_run_count) == 4) ? 1 : -1]; diff --git a/ports/cortex_r5/gnu/src/tx_thread_context_restore.S b/ports/cortex_r5/gnu/src/tx_thread_context_restore.S index c8c28acb..296c12c2 100644 --- a/ports/cortex_r5/gnu/src/tx_thread_context_restore.S +++ b/ports/cortex_r5/gnu/src/tx_thread_context_restore.S @@ -1,5 +1,6 @@ @/*************************************************************************** @ * Copyright (c) 2024 Microsoft Corporation +@ * Copyright (c) 2026 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. @ @ @/**************************************************************************/ @@ -95,7 +97,7 @@ _tx_thread_context_restore: CPSID i @ Disable IRQ interrupts #endif -#ifdef TX_ENABLE_EXECUTION_CHANGE_NOTIFY +#if defined(TX_ENABLE_EXECUTION_CHANGE_NOTIFY) || defined(TX_EXECUTION_PROFILE_ENABLE) @ @ /* Call the ISR exit function to indicate an ISR is complete. */ @ @@ -239,4 +241,3 @@ __tx_thread_idle_system_restore: @} - diff --git a/ports/cortex_r5/gnu/src/tx_thread_context_save.S b/ports/cortex_r5/gnu/src/tx_thread_context_save.S index 12434186..655a8c9d 100644 --- a/ports/cortex_r5/gnu/src/tx_thread_context_save.S +++ b/ports/cortex_r5/gnu/src/tx_thread_context_save.S @@ -1,5 +1,6 @@ @/*************************************************************************** @ * Copyright (c) 2024 Microsoft Corporation +@ * Copyright (c) 2026 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. @ @ @/**************************************************************************/ @@ -105,7 +107,7 @@ _tx_thread_context_save: @ MOV r10, #0 @ Clear stack limit -#ifdef TX_ENABLE_EXECUTION_CHANGE_NOTIFY +#if defined(TX_ENABLE_EXECUTION_CHANGE_NOTIFY) || defined(TX_EXECUTION_PROFILE_ENABLE) @ @ /* Call the ISR enter function to indicate an ISR is executing. */ @ @@ -145,7 +147,7 @@ __tx_thread_not_nested_save: @ MOV r10, #0 @ Clear stack limit -#ifdef TX_ENABLE_EXECUTION_CHANGE_NOTIFY +#if defined(TX_ENABLE_EXECUTION_CHANGE_NOTIFY) || defined(TX_EXECUTION_PROFILE_ENABLE) @ @ /* Call the ISR enter function to indicate an ISR is executing. */ @ @@ -169,7 +171,7 @@ __tx_thread_idle_system_save: @ MOV r10, #0 @ Clear stack limit -#ifdef TX_ENABLE_EXECUTION_CHANGE_NOTIFY +#if defined(TX_ENABLE_EXECUTION_CHANGE_NOTIFY) || defined(TX_EXECUTION_PROFILE_ENABLE) @ @ /* Call the ISR enter function to indicate an ISR is executing. */ @ @@ -185,4 +187,3 @@ __tx_thread_idle_system_save: @} - diff --git a/ports/cortex_r5/gnu/src/tx_thread_fiq_context_restore.S b/ports/cortex_r5/gnu/src/tx_thread_fiq_context_restore.S index 5ebe4ac4..dc6326f4 100644 --- a/ports/cortex_r5/gnu/src/tx_thread_fiq_context_restore.S +++ b/ports/cortex_r5/gnu/src/tx_thread_fiq_context_restore.S @@ -1,5 +1,6 @@ @/*************************************************************************** @ * Copyright (c) 2024 Microsoft Corporation +@ * Copyright (c) 2026 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. @ @ @/**************************************************************************/ @@ -89,7 +91,7 @@ _tx_thread_fiq_context_restore: @ CPSID if @ Disable IRQ and FIQ interrupts -#ifdef TX_ENABLE_EXECUTION_CHANGE_NOTIFY +#if defined(TX_ENABLE_EXECUTION_CHANGE_NOTIFY) || defined(TX_EXECUTION_PROFILE_ENABLE) @ @ /* Call the ISR exit function to indicate an ISR is complete. */ @ @@ -229,4 +231,3 @@ __tx_thread_fiq_idle_system_restore: B _tx_thread_schedule @ Return to scheduler @ @} - diff --git a/ports/cortex_r5/gnu/src/tx_thread_fiq_context_save.S b/ports/cortex_r5/gnu/src/tx_thread_fiq_context_save.S index ccd30f3d..1161b21c 100644 --- a/ports/cortex_r5/gnu/src/tx_thread_fiq_context_save.S +++ b/ports/cortex_r5/gnu/src/tx_thread_fiq_context_save.S @@ -1,5 +1,6 @@ @/*************************************************************************** @ * Copyright (c) 2024 Microsoft Corporation +@ * Copyright (c) 2026 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. @ @ @/**************************************************************************/ @@ -102,7 +104,7 @@ _tx_thread_fiq_context_save: @ MOV r10, #0 @ Clear stack limit -#ifdef TX_ENABLE_EXECUTION_CHANGE_NOTIFY +#if defined(TX_ENABLE_EXECUTION_CHANGE_NOTIFY) || defined(TX_EXECUTION_PROFILE_ENABLE) @ @ /* Call the ISR enter function to indicate an ISR is executing. */ @ @@ -146,7 +148,7 @@ __tx_thread_fiq_not_nested_save: @ MOV r10, #0 @ Clear stack limit -#ifdef TX_ENABLE_EXECUTION_CHANGE_NOTIFY +#if defined(TX_ENABLE_EXECUTION_CHANGE_NOTIFY) || defined(TX_EXECUTION_PROFILE_ENABLE) @ @ /* Call the ISR enter function to indicate an ISR is executing. */ @ @@ -165,7 +167,7 @@ __tx_thread_fiq_idle_system_save: @ @ /* Interrupt occurred in the scheduling loop. */ @ -#ifdef TX_ENABLE_EXECUTION_CHANGE_NOTIFY +#if defined(TX_ENABLE_EXECUTION_CHANGE_NOTIFY) || defined(TX_EXECUTION_PROFILE_ENABLE) @ @ /* Call the ISR enter function to indicate an ISR is executing. */ @ @@ -187,4 +189,3 @@ __tx_thread_fiq_idle_system_save: @ @ } @} - diff --git a/ports/cortex_r5/gnu/src/tx_thread_schedule.S b/ports/cortex_r5/gnu/src/tx_thread_schedule.S index e19265f5..0b3a4ff1 100644 --- a/ports/cortex_r5/gnu/src/tx_thread_schedule.S +++ b/ports/cortex_r5/gnu/src/tx_thread_schedule.S @@ -1,5 +1,6 @@ @/*************************************************************************** @ * Copyright (c) 2024 Microsoft Corporation +@ * Copyright (c) 2026 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. @ @ @/**************************************************************************/ @@ -145,7 +147,7 @@ __tx_thread_schedule_loop: @ /* Switch to the thread's stack. */ @ sp = _tx_thread_execute_ptr -> tx_thread_stack_ptr; @ -#ifdef TX_ENABLE_EXECUTION_CHANGE_NOTIFY +#if defined(TX_ENABLE_EXECUTION_CHANGE_NOTIFY) || defined(TX_EXECUTION_PROFILE_ENABLE) @ @ /* Call the thread entry function to indicate the thread is executing. */ @ @@ -232,4 +234,3 @@ __tx_no_thread_to_disable: MSR CPSR_cxsf, r2 @ Recover CPSR BX LR @ Return to caller #endif - diff --git a/ports/cortex_r5/gnu/src/tx_thread_system_return.S b/ports/cortex_r5/gnu/src/tx_thread_system_return.S index 0144b037..6237c15a 100644 --- a/ports/cortex_r5/gnu/src/tx_thread_system_return.S +++ b/ports/cortex_r5/gnu/src/tx_thread_system_return.S @@ -1,5 +1,6 @@ @/*************************************************************************** @ * Copyright (c) 2024 Microsoft Corporation +@ * Copyright (c) 2026 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. @ @ @/**************************************************************************/ @@ -120,7 +122,7 @@ _tx_skip_solicited_vfp_save: STMDB sp!, {r0-r1} @ Save type and CPSR @ @ -#ifdef TX_ENABLE_EXECUTION_CHANGE_NOTIFY +#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. */ @ @@ -161,4 +163,3 @@ __tx_thread_dont_save_ts: B _tx_thread_schedule @ Jump to scheduler! @ @} - diff --git a/ports/cortex_r5/gnu/src/tx_thread_vectored_context_save.S b/ports/cortex_r5/gnu/src/tx_thread_vectored_context_save.S index e985f24f..8c036445 100644 --- a/ports/cortex_r5/gnu/src/tx_thread_vectored_context_save.S +++ b/ports/cortex_r5/gnu/src/tx_thread_vectored_context_save.S @@ -1,5 +1,6 @@ @/*************************************************************************** @ * Copyright (c) 2024 Microsoft Corporation +@ * Copyright (c) 2026 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. @ @ @/**************************************************************************/ @@ -99,7 +101,7 @@ _tx_thread_vectored_context_save: @ MOV r10, #0 @ Clear stack limit -#ifdef TX_ENABLE_EXECUTION_CHANGE_NOTIFY +#if defined(TX_ENABLE_EXECUTION_CHANGE_NOTIFY) || defined(TX_EXECUTION_PROFILE_ENABLE) @ @ /* Call the ISR enter function to indicate an ISR is executing. */ @ @@ -135,7 +137,7 @@ __tx_thread_not_nested_save: @ MOV r10, #0 @ Clear stack limit -#ifdef TX_ENABLE_EXECUTION_CHANGE_NOTIFY +#if defined(TX_ENABLE_EXECUTION_CHANGE_NOTIFY) || defined(TX_EXECUTION_PROFILE_ENABLE) @ @ /* Call the ISR enter function to indicate an ISR is executing. */ @ @@ -159,7 +161,7 @@ __tx_thread_idle_system_save: @ MOV r10, #0 @ Clear stack limit -#ifdef TX_ENABLE_EXECUTION_CHANGE_NOTIFY +#if defined(TX_ENABLE_EXECUTION_CHANGE_NOTIFY) || defined(TX_EXECUTION_PROFILE_ENABLE) @ @ /* Call the ISR enter function to indicate an ISR is executing. */ @ @@ -173,4 +175,3 @@ __tx_thread_idle_system_save: @ @ } @} - |
