Skip to content

tricore: Add fpu init and fpucmp support.#18908

Merged
xiaoxiang781216 merged 3 commits into
apache:masterfrom
zyfeier:tricore/add-fpu-init
May 21, 2026
Merged

tricore: Add fpu init and fpucmp support.#18908
xiaoxiang781216 merged 3 commits into
apache:masterfrom
zyfeier:tricore/add-fpu-init

Conversation

@zyfeier
Copy link
Copy Markdown
Contributor

@zyfeier zyfeier commented May 20, 2026

Summary

  • Why: TriCore TC4xx FPU needs initialization to enable flush-to-zero trap, and ostest requires up_fpucmp() for FPU context comparison.
  • What: arch/tricore FPU initialization, trap reporting, and context comparison.
  • How: Add tricore_fpuinit() to enable FZ trap via FPU_SYNC_TRAP_CON register, add up_fpucmp() to compare D8-D15 in the upper CSA context, add FPU trap reporting in trap handler, add iLLD patch for CoprocessorTrapSynchronousError enum.

Impact

  • Is new feature added? YES - FPU initialization and fpucmp support for TriCore TC4xx.
  • Impact on user (will user need to adapt to change)? NO
  • Impact on build (will build process change)? NO
  • Impact on hardware (will arch(s) / board(s) / driver(s) change)? YES - tricore arch only, enabled via ARCH_HAVE_FPU.
  • Impact on documentation (is update required / provided)? NO
  • Impact on security (any sort of implications)? NO
  • Impact on compatibility (backward/forward/interoperability)? NO

Testing

I confirm that changes are verified on local setup and works as intended:

  • Build Host(s): Linux x86_64, GCC 11.3.1 (tricore-elf-gcc)
  • Target(s): tricore, triboard_tc4x9_com:nsh (CONFIG_ARCH_FPU=y)

Testing logs (runtime, ostest FPU on TC4D9 EVB):

  user_main: FPU test
  Starting task FPU#1
  fpu_test: Started task FPU#1 at PID=6
  FPU#1: pass 1
  Starting task FPU#2
  fpu_test: Started task FPU#2 at PID=7
  FPU#2: pass 1
  FPU#1: pass 2
  FPU#2: pass 2
  FPU#1: pass 3
  FPU#2: pass 3
  FPU#1: pass 4
  FPU#2: pass 4
  FPU#1: pass 5
  FPU#2: pass 5
  FPU#1: pass 6
  FPU#2: pass 6
  FPU#1: pass 7
  FPU#2: pass 7
  FPU#1: pass 8
  FPU#2: pass 8
  FPU#1: pass 9
  FPU#2: pass 9
  FPU#1: pass 10
  FPU#2: pass 10
  FPU#1: pass 11
  FPU#2: pass 11
  FPU#1: pass 12
  FPU#2: pass 12
  FPU#1: pass 13
  FPU#2: pass 13
  FPU#1: pass 14
  FPU#2: pass 14
  FPU#1: pass 15
  FPU#2: pass 15
  FPU#1: pass 16
  FPU#2: pass 16
  FPU#1: Succeeded
  FPU#2: Succeeded
  fpu_test: Returning

@github-actions github-actions Bot added Arch: tricore Issues related to the TriCore architecture from Infineon Size: S The size of the change in this PR is small labels May 20, 2026
@zyfeier zyfeier marked this pull request as draft May 20, 2026 03:27
@zyfeier zyfeier force-pushed the tricore/add-fpu-init branch 2 times, most recently from 01ad9e9 to f5465b6 Compare May 20, 2026 06:29
@github-actions github-actions Bot added Size: M The size of the change in this PR is medium and removed Size: S The size of the change in this PR is small labels May 20, 2026
@zyfeier zyfeier force-pushed the tricore/add-fpu-init branch 2 times, most recently from 5538e9f to 45e4f9d Compare May 20, 2026 07:44
@zyfeier zyfeier changed the title tricore: add fpu init to open FZ trap tricore: Add fpu init and fpucmp support. May 20, 2026
zyfeier and others added 3 commits May 20, 2026 20:06
Initialize the FPU and enable the FZ (flush-to-zero) trap for
TriCore TC4xx processors. This ensures floating-point divide-by-zero
exceptions are properly caught and reported via the trap handler.

Signed-off-by: zhangyuan29 <zhangyuan29@xiaomi.com>
Implement up_fpucmp to compare FPU register state between two
saved contexts. This is used by the ostest FPU test to verify
that FPU registers are properly preserved across context switches.

Signed-off-by: zhangyu117 <zhangyu117@xiaomi.com>
up_fpucmp was comparing lower CSA registers (offset 0) using upper CSA
register definitions (REG_D8-D15). Since up_saveusercontext stores:
  - Lower CSA at saveregs[0..15]
  - Upper CSA at saveregs[16..31]

The fix adds TC_CONTEXT_REGS offset to point to the upper CSA and
compares only D8-D15 which are the FPU data registers on TriCore.

Signed-off-by: zhangyu117 <zhangyu117@xiaomi.com>
@zyfeier zyfeier force-pushed the tricore/add-fpu-init branch from 45e4f9d to b3a9173 Compare May 20, 2026 12:37
@zyfeier zyfeier marked this pull request as ready for review May 20, 2026 12:44
@xiaoxiang781216 xiaoxiang781216 merged commit 356f7c7 into apache:master May 21, 2026
41 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Arch: tricore Issues related to the TriCore architecture from Infineon Size: M The size of the change in this PR is medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants