mirror of
https://github.com/eclipse-threadx/threadx.git
synced 2026-08-17 17:43:54 +08:00
This PR adds three functional improvements to the RISC-V 32-bit GNU port. Lazy FPU stacking (tx_thread_context_save.S, tx_thread_context_restore.S, tx_thread_schedule.S): FP register save/restore is now skipped whenmstatus.FS is Off, reducing context switch overhead for threads that do not use floating point. GP relaxation (cmake/riscv32_gnu.cmake, entry.s, link.lds): Enables the -mrelax compiler flag and defines __global_pointer$ in the linker script.The entry stub initializes gp at startup. gp is not saved or restored during context switches. WFI in idle loop (tx_thread_schedule.S): The scheduler issues wfi when no thread is ready, replacing busy-waiting with a low-power sleep. A Python/QEMU/GDB functional test runner is added under ports/risc-v32/gnu/example_build/qemu_virt/test/. It validates context switching, FPUcontext preservation, timer interrupts, and preemption. To run: cd ports/risc-v32/gnu/example_build/qemu_virt make check-functional-riscv32 Tested on QEMU virt machine (rv32gc). Co-authored-by: Wei-Chen Lai Winstonllllai@users.noreply.github.com Co-authored-by: Frédéric Desbiens frederic.desbiens@eclipse-foundation.org Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com
17 lines
518 B
CMake
17 lines
518 B
CMake
# Name of the target
|
|
set(CMAKE_SYSTEM_NAME Generic)
|
|
set(CMAKE_SYSTEM_PROCESSOR risc-v32)
|
|
set(THREADX_ARCH "risc-v32")
|
|
set(THREADX_TOOLCHAIN "gnu")
|
|
if(DEFINED SOFT_FLOAT)
|
|
set(ARCH_FLAGS "-g -march=rv32ima_zicsr -mabi=ilp32 -mcmodel=medany")
|
|
set(CACHE{SOFT_FLOAT} FORCE 1)
|
|
else()
|
|
set(ARCH_FLAGS "-g -march=rv32gc -mabi=ilp32d -mcmodel=medany -mrelax")
|
|
endif()
|
|
set(CFLAGS "${ARCH_FLAGS}")
|
|
set(ASFLAGS "${ARCH_FLAGS}")
|
|
set(LDFLAGS "${ARCH_FLAGS}")
|
|
|
|
include(${CMAKE_CURRENT_LIST_DIR}/riscv32-unknown-elf.cmake)
|