Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions ports/cortex_a12/ac6/src/tx_port_offset_check.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/***************************************************************************
* 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
**************************************************************************/

/* Verify TX_THREAD offsets used by the ARMv7-A assembly.

The assembly uses fixed byte offsets to access TX_THREAD fields.
These checks prevent changes to the C structure layout from
silently breaking the assembly's assumptions. */

#include "tx_api.h"
#include <stddef.h>

/* Offset of the VFP enable flag as encoded in the ARMv7-A 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

/* TX_THREAD offsets hard-coded by the ARMv7-A assembly:

tx_thread_schedule.S:
run_count #4, stack_ptr #8, time_slice #24, vfp_enable #144

tx_thread_stack_build.S:
stack_ptr #8, stack_start #12, stack_end #16

tx_thread_context_restore.S, tx_thread_fiq_context_restore.S,
tx_thread_system_return.S:
stack_ptr #8, time_slice #24, vfp_enable #144 */

typedef char
tx_port_assert_run_count_offset_is_4[
(offsetof(TX_THREAD, tx_thread_run_count) == 4) ? 1 : -1];

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_stack_start_offset_is_12[
(offsetof(TX_THREAD, tx_thread_stack_start) == 12) ? 1 : -1];

typedef char
tx_port_assert_stack_end_offset_is_16[
(offsetof(TX_THREAD, tx_thread_stack_end) == 16) ? 1 : -1];

typedef char
tx_port_assert_time_slice_offset_is_24[
(offsetof(TX_THREAD, tx_thread_time_slice) == 24) ? 1 : -1];

typedef char
tx_port_assert_vfp_enable_offset_is_144[
(offsetof(TX_THREAD, tx_thread_vfp_enable) == TX_PORT_VFP_ENABLE_OFFSET)
? 1 : -1];
1 change: 1 addition & 0 deletions ports/cortex_a12/gnu/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ target_sources(${PROJECT_NAME}
${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_system_return.S
${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_vectored_context_save.S
${CMAKE_CURRENT_LIST_DIR}/src/tx_timer_interrupt.S
${CMAKE_CURRENT_LIST_DIR}/src/tx_port_offset_check.c
# {{END_TARGET_SOURCES}}
)

Expand Down
62 changes: 62 additions & 0 deletions ports/cortex_a12/gnu/src/tx_port_offset_check.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/***************************************************************************
* 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
**************************************************************************/

/* Verify TX_THREAD offsets used by the ARMv7-A assembly.

The assembly uses fixed byte offsets to access TX_THREAD fields.
These checks prevent changes to the C structure layout from
silently breaking the assembly's assumptions. */

#include "tx_api.h"
#include <stddef.h>

/* Offset of the VFP enable flag as encoded in the ARMv7-A 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

/* TX_THREAD offsets hard-coded by the ARMv7-A assembly:

tx_thread_schedule.S:
run_count #4, stack_ptr #8, time_slice #24, vfp_enable #144

tx_thread_stack_build.S:
stack_ptr #8, stack_start #12, stack_end #16

tx_thread_context_restore.S, tx_thread_fiq_context_restore.S,
tx_thread_system_return.S:
stack_ptr #8, time_slice #24, vfp_enable #144 */

typedef char
tx_port_assert_run_count_offset_is_4[
(offsetof(TX_THREAD, tx_thread_run_count) == 4) ? 1 : -1];

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_stack_start_offset_is_12[
(offsetof(TX_THREAD, tx_thread_stack_start) == 12) ? 1 : -1];

typedef char
tx_port_assert_stack_end_offset_is_16[
(offsetof(TX_THREAD, tx_thread_stack_end) == 16) ? 1 : -1];

typedef char
tx_port_assert_time_slice_offset_is_24[
(offsetof(TX_THREAD, tx_thread_time_slice) == 24) ? 1 : -1];

typedef char
tx_port_assert_vfp_enable_offset_is_144[
(offsetof(TX_THREAD, tx_thread_vfp_enable) == TX_PORT_VFP_ENABLE_OFFSET)
? 1 : -1];
62 changes: 62 additions & 0 deletions ports/cortex_a15/ac6/src/tx_port_offset_check.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/***************************************************************************
* 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
**************************************************************************/

/* Verify TX_THREAD offsets used by the ARMv7-A assembly.

The assembly uses fixed byte offsets to access TX_THREAD fields.
These checks prevent changes to the C structure layout from
silently breaking the assembly's assumptions. */

#include "tx_api.h"
#include <stddef.h>

/* Offset of the VFP enable flag as encoded in the ARMv7-A 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

/* TX_THREAD offsets hard-coded by the ARMv7-A assembly:

tx_thread_schedule.S:
run_count #4, stack_ptr #8, time_slice #24, vfp_enable #144

tx_thread_stack_build.S:
stack_ptr #8, stack_start #12, stack_end #16

tx_thread_context_restore.S, tx_thread_fiq_context_restore.S,
tx_thread_system_return.S:
stack_ptr #8, time_slice #24, vfp_enable #144 */

typedef char
tx_port_assert_run_count_offset_is_4[
(offsetof(TX_THREAD, tx_thread_run_count) == 4) ? 1 : -1];

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_stack_start_offset_is_12[
(offsetof(TX_THREAD, tx_thread_stack_start) == 12) ? 1 : -1];

typedef char
tx_port_assert_stack_end_offset_is_16[
(offsetof(TX_THREAD, tx_thread_stack_end) == 16) ? 1 : -1];

typedef char
tx_port_assert_time_slice_offset_is_24[
(offsetof(TX_THREAD, tx_thread_time_slice) == 24) ? 1 : -1];

typedef char
tx_port_assert_vfp_enable_offset_is_144[
(offsetof(TX_THREAD, tx_thread_vfp_enable) == TX_PORT_VFP_ENABLE_OFFSET)
? 1 : -1];
1 change: 1 addition & 0 deletions ports/cortex_a15/gnu/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ target_sources(${PROJECT_NAME}
${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_system_return.S
${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_vectored_context_save.S
${CMAKE_CURRENT_LIST_DIR}/src/tx_timer_interrupt.S
${CMAKE_CURRENT_LIST_DIR}/src/tx_port_offset_check.c
# {{END_TARGET_SOURCES}}
)

Expand Down
62 changes: 62 additions & 0 deletions ports/cortex_a15/gnu/src/tx_port_offset_check.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/***************************************************************************
* 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
**************************************************************************/

/* Verify TX_THREAD offsets used by the ARMv7-A assembly.

The assembly uses fixed byte offsets to access TX_THREAD fields.
These checks prevent changes to the C structure layout from
silently breaking the assembly's assumptions. */

#include "tx_api.h"
#include <stddef.h>

/* Offset of the VFP enable flag as encoded in the ARMv7-A 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

/* TX_THREAD offsets hard-coded by the ARMv7-A assembly:

tx_thread_schedule.S:
run_count #4, stack_ptr #8, time_slice #24, vfp_enable #144

tx_thread_stack_build.S:
stack_ptr #8, stack_start #12, stack_end #16

tx_thread_context_restore.S, tx_thread_fiq_context_restore.S,
tx_thread_system_return.S:
stack_ptr #8, time_slice #24, vfp_enable #144 */

typedef char
tx_port_assert_run_count_offset_is_4[
(offsetof(TX_THREAD, tx_thread_run_count) == 4) ? 1 : -1];

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_stack_start_offset_is_12[
(offsetof(TX_THREAD, tx_thread_stack_start) == 12) ? 1 : -1];

typedef char
tx_port_assert_stack_end_offset_is_16[
(offsetof(TX_THREAD, tx_thread_stack_end) == 16) ? 1 : -1];

typedef char
tx_port_assert_time_slice_offset_is_24[
(offsetof(TX_THREAD, tx_thread_time_slice) == 24) ? 1 : -1];

typedef char
tx_port_assert_vfp_enable_offset_is_144[
(offsetof(TX_THREAD, tx_thread_vfp_enable) == TX_PORT_VFP_ENABLE_OFFSET)
? 1 : -1];
62 changes: 62 additions & 0 deletions ports/cortex_a17/ac6/src/tx_port_offset_check.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/***************************************************************************
* 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
**************************************************************************/

/* Verify TX_THREAD offsets used by the ARMv7-A assembly.

The assembly uses fixed byte offsets to access TX_THREAD fields.
These checks prevent changes to the C structure layout from
silently breaking the assembly's assumptions. */

#include "tx_api.h"
#include <stddef.h>

/* Offset of the VFP enable flag as encoded in the ARMv7-A 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

/* TX_THREAD offsets hard-coded by the ARMv7-A assembly:

tx_thread_schedule.S:
run_count #4, stack_ptr #8, time_slice #24, vfp_enable #144

tx_thread_stack_build.S:
stack_ptr #8, stack_start #12, stack_end #16

tx_thread_context_restore.S, tx_thread_fiq_context_restore.S,
tx_thread_system_return.S:
stack_ptr #8, time_slice #24, vfp_enable #144 */

typedef char
tx_port_assert_run_count_offset_is_4[
(offsetof(TX_THREAD, tx_thread_run_count) == 4) ? 1 : -1];

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_stack_start_offset_is_12[
(offsetof(TX_THREAD, tx_thread_stack_start) == 12) ? 1 : -1];

typedef char
tx_port_assert_stack_end_offset_is_16[
(offsetof(TX_THREAD, tx_thread_stack_end) == 16) ? 1 : -1];

typedef char
tx_port_assert_time_slice_offset_is_24[
(offsetof(TX_THREAD, tx_thread_time_slice) == 24) ? 1 : -1];

typedef char
tx_port_assert_vfp_enable_offset_is_144[
(offsetof(TX_THREAD, tx_thread_vfp_enable) == TX_PORT_VFP_ENABLE_OFFSET)
? 1 : -1];
1 change: 1 addition & 0 deletions ports/cortex_a17/gnu/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ target_sources(${PROJECT_NAME}
${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_system_return.S
${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_vectored_context_save.S
${CMAKE_CURRENT_LIST_DIR}/src/tx_timer_interrupt.S
${CMAKE_CURRENT_LIST_DIR}/src/tx_port_offset_check.c
# {{END_TARGET_SOURCES}}
)

Expand Down
Loading