Skip to content

Added opt-in pointer callback mode and pointer creation APIs - #819

Merged
fdesbiens merged 5 commits into
eclipse-threadx:devfrom
Dev10-sys:feature/pointer-callback-mode
Nov 26, 2026
Merged

fdesbiens merged 5 commits into
eclipse-threadx:devfrom
Dev10-sys:feature/pointer-callback-mode

Conversation

@Dev10-sys

@Dev10-sys Dev10-sys commented Oct 22, 2026 •

Copy link
Copy Markdown

Fixes #771

On ports with 64-bit addresses and a 32-bit ULONG, passing a pointer through the scalar argument to a thread entry or timer callback can truncate the address.

Added tx_thread_create_ptr and tx_timer_create_ptr for ThreadX, ThreadX SMP, and loadable modules. Set TX_ENABLE_POINTER_CONTEXT consistently when building the kernel, applications, and modules. The option appends callback storage and preserves the offsets used by port assembly. Module thread reset restores the saved module stack and user mode.

Cortex-M3 and Cortex-M4 passed 20/20 QEMU tests, including ISR timer processing. A host test verified full-width arguments using the A35 module ABI. Coverage was 146/146 changed lines and 56/56 branches in the shared kernel code, and 83/83 lines and 16/16 branches in the shared module code. All nine CI workflows passed.

@Dev10-sys
Dev10-sys force-pushed the feature/pointer-callback-mode branch from 64d91fb to 47344b9 Compare October 23, 2026 05:41
@fdesbiens

Copy link
Copy Markdown
Contributor

Thanks @Dev10-sys. I will look into it next week.

…-threadx#771, eclipse-threadx#772)

Support passing full pointer-width context arguments to thread and timer
callbacks on 64-bit architectures without truncation, while maintaining
full backward compatibility for existing 32-bit ULONG callbacks.

- Added tx_thread_create_ptr and tx_timer_create_ptr APIs for direct
  pointer context callbacks.
- Added pointer entry and timeout fields in thread and timer control
  blocks with automatic dispatch in shell entry and timer threads.
- Added TX_ENABLE_POINTER_CALLBACKS configuration option to allow
  transparent pointer passing with standard create APIs.
- Preserved existing ULONG callback signatures across all ports and
  module manager interfaces.
- Added regression tests covering 64-bit pointer argument transmission,
  error detection paths, and backward compatibility in both standard
  and SMP builds.

Signed-off-by: Dev10-sys <kalpanagola9897@gmail.com>
@Dev10-sys
Dev10-sys force-pushed the feature/pointer-callback-mode branch from 47344b9 to 688f56a Compare October 24, 2026 07:01
Adding callback fields inside the thread and internal timer control blocks
moved fields used by existing port assembly. Build-wide API aliases also
changed signatures used by middleware.

Kept the explicit native pointer APIs under TX_ENABLE_POINTER_CONTEXT.
It appends storage to TX_THREAD and TX_TIMER, preserving member offsets and
the internal timer layout. The default build retains the legacy sizes.
Timer processing snapshots the typed callback and context before unlocking.

Six Linux pointer tests passed across 32-bit and 64-bit UP and SMP, including
timer-thread and ISR processing. Cortex-M4 passed 4/4 module QEMU tests in
each configuration. The default M4 manager instructions and relocations
matched dev. Cortex-R52 passed the assembly-offset checks in both builds.

Assisted-by: Codex (GPT-6.2-Sol) <noreply@openai.com>
Signed-off-by: Frédéric Desbiens <frederic.desbiens@eclipse-foundation.org>
A module thread can complete while its kernel stack is active. Resetting
it used that stack and the privileged mode left by the kernel call.

Restored the saved module stack and configured mode, and rebuilt the
initial frame using the original module entry information.

The Cortex-M3 and Cortex-M4 QEMU lifecycle tests completed and restarted
protected workers with the original scalar argument and user mode.

Assisted-by: Codex (GPT-6.2-Sol) <noreply@openai.com>
Signed-off-by: Frédéric Desbiens <frederic.desbiens@eclipse-foundation.org>
Fixes eclipse-threadx#771

The pointer creation services had native entry points only. Modules
need to carry the callback and context through the manager dispatch ABI
and run the callback in module context.

Added module requests for both services. The module thread shell calls
the typed entry with its original argument. The timer path snapshots the
callback and context and queues delivery to the module callback thread.
The option preserves existing member offsets and increases the sizes of
enabled thread, timer, and module entry structures.

Linux covered 146/146 changed kernel lines and 56/56 branches. Cortex-M4
QEMU covered 83/83 changed shared module lines and 16/16 branches.
Cortex-M3/M4 passed 20/20 QEMU tests, including M4 ISR timers. Cortex-R52
and Cortex-A35 UP/SMP manager builds passed. FreeRTOS passed 6/6 tests
across both option settings.

Assisted-by: Codex (GPT-6.2-Sol) <noreply@openai.com>
Signed-off-by: Frédéric Desbiens <frederic.desbiens@eclipse-foundation.org>
The generated Cortex-M3, M4, and M7 module shells dispatched pointer
thread entries, but the ARMv7-M sources still used the scalar call.

Applied the same dispatch to the four toolchain sources. Regenerating
the 12 ports with the module copy script produced identical files.

Assisted-by: Codex (GPT-6.2-Sol) <noreply@openai.com>
Signed-off-by: Frédéric Desbiens <frederic.desbiens@eclipse-foundation.org>
@fdesbiens

Copy link
Copy Markdown
Contributor

@Dev10-sys Thanks for adding the pointer-context APIs. I kept tx_thread_create_ptr and tx_timer_create_ptr under TX_ENABLE_POINTER_CONTEXT and extended them to loadable modules. I placed the new fields at the ends of the control blocks to preserve the offsets used by port assembly. I also fixed module thread reset to restore the saved module stack and user mode.

I left the build-wide aliases in #772 for separate evaluation. The aliases caused compile errors at five FreeRTOS compatibility call sites that use ULONG callbacks. The explicit APIs let applications migrate one call at a time.

All nine CI workflows passed on 290606a8, including module QEMU and Cortex-R52 FVP.

@fdesbiens
fdesbiens merged commit 227586c into eclipse-threadx:dev Nov 26, 2026
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants