Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
6dee013
docs: resolve merge conflicts in RISC-V 32-bit GNU port files
Winstonllllai Mar 10, 2026
85d0626
feat: implement Lazy FPU Stacking and Vector Table
Winstonllllai Mar 10, 2026
aad13e8
Implement WFI for Idle Loops and Enforce Shadow Stack Alignment
Winstonllllai Jan 8, 2026
633629d
feat: add RISC-V QEMU demo support and fix assembly implementation
Winstonllllai Mar 10, 2026
fedd124
Add RISC-V QEMU functional test runner and FPU verification
Winstonllllai Jan 18, 2026
ae13c5b
feat: use macros for stack offsets and enhance verification framework
Winstonllllai Mar 10, 2026
39ede67
Enable GP Relaxation optimization
Winstonllllai Jan 22, 2026
a1b2457
Optimize stack management and update QEMU port
Winstonllllai Mar 13, 2026
4425c5b
fix preemption logic and interrupt context restore
Winstonllllai Mar 13, 2026
fa9b870
build: stop tracking build_qemu directory and update copyright headers
Winstonllllai Mar 13, 2026
ae2aa03
delete output log file
Winstonllllai Mar 13, 2026
e3d4e9f
cleanup: address RISC-V32 QEMU demo review feedback
Winstonllllai Apr 25, 2026
08d2bea
test: relocate and harden RISC-V32 QEMU functional runner
Winstonllllai Apr 25, 2026
7e31dc6
feat: restore Lazy FPU stacking without assembly macros
Winstonllllai Apr 25, 2026
89cc6fb
Remove redundant comments and fix indentation
Winstonllllai May 19, 2026
7d816f3
Fixed lazy FPU stacking in schedule.S, cmake conflict, and comment style
fdesbiens May 25, 2026
79b1ebb
Merge branch 'dev' into rv32-fix-feature
fdesbiens May 25, 2026
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
.tmp/
_deps/
build/
build_qemu/
Debug/
CMakeFiles/
CMakeScripts/
Expand Down
2 changes: 1 addition & 1 deletion cmake/riscv32_gnu.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ 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")
set(ARCH_FLAGS "-g -march=rv32gc -mabi=ilp32d -mcmodel=medany -mrelax")
endif()
set(CFLAGS "${ARCH_FLAGS}")
set(ASFLAGS "${ARCH_FLAGS}")
Expand Down
4 changes: 4 additions & 0 deletions ports/risc-v32/gnu/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,7 @@ target_include_directories(${PROJECT_NAME}
PUBLIC
${CMAKE_CURRENT_LIST_DIR}/inc
)

if(EXISTS ${CMAKE_CURRENT_LIST_DIR}/example_build/qemu_virt/CMakeLists.txt)
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/example_build/qemu_virt)
endif()
45 changes: 45 additions & 0 deletions ports/risc-v32/gnu/example_build/qemu_virt/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
set(QEMU_DEMO_DIR ${CMAKE_CURRENT_LIST_DIR})

add_executable(kernel.elf EXCLUDE_FROM_ALL
${QEMU_DEMO_DIR}/demo_threadx.c
${QEMU_DEMO_DIR}/entry.s
${QEMU_DEMO_DIR}/uart.c
${QEMU_DEMO_DIR}/plic.c
${QEMU_DEMO_DIR}/hwtimer.c
${QEMU_DEMO_DIR}/trap.c
${QEMU_DEMO_DIR}/board.c
${QEMU_DEMO_DIR}/tx_initialize_low_level.S
)

target_link_libraries(kernel.elf PRIVATE threadx)

target_include_directories(kernel.elf PRIVATE
${CMAKE_SOURCE_DIR}/common/inc
${CMAKE_SOURCE_DIR}/ports/${THREADX_ARCH}/${THREADX_TOOLCHAIN}/inc
${QEMU_DEMO_DIR}
)

target_link_options(kernel.elf PRIVATE
-T${QEMU_DEMO_DIR}/link.lds
-nostartfiles
-Wl,-Map=kernel.map
)

# QEMU/GDB functional test runner. Optional: skipped silently if the
# host has no Python 3 interpreter on PATH.
find_package(Python3 COMPONENTS Interpreter)
if(Python3_FOUND)
add_custom_target(check-functional-riscv32
COMMAND ${Python3_EXECUTABLE}
${QEMU_DEMO_DIR}/test/azrtos_test_tx_gnu_riscv32_qemu.py
--elf $<TARGET_FILE:kernel.elf>
--qemu qemu-system-riscv32
--gdb gdb
DEPENDS kernel.elf
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Running RISC-V32 QEMU/GDB functional test runner..."
)
else()
message(STATUS
"Python3 not found; check-functional-riscv32 target unavailable.")
endif()
5 changes: 4 additions & 1 deletion ports/risc-v32/gnu/example_build/qemu_virt/demo_threadx.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#define DEMO_BYTE_POOL_SIZE 9120
#define DEMO_BLOCK_POOL_SIZE 100
#define DEMO_QUEUE_SIZE 100
float fpu_test_val = 0.0f;

char *_to_str(ULONG val)
{
Expand Down Expand Up @@ -201,7 +202,7 @@ UINT status;
thread_0_counter++;

/* Sleep for 10 ticks. */
tx_thread_sleep(10);
tx_thread_sleep(1);

/* Set event flag 0 to wakeup thread 5. */
status = tx_event_flags_set(&event_flags_0, 0x1, TX_OR);
Expand Down Expand Up @@ -363,6 +364,8 @@ UINT status;
if (status != TX_SUCCESS)
break;

/* FPU Test */
fpu_test_val += 1.1f;
/* Get the mutex again with suspension. This shows
that an owning thread may retrieve the mutex it
owns multiple times. */
Expand Down
7 changes: 5 additions & 2 deletions ports/risc-v32/gnu/example_build/qemu_virt/entry.s
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

.section .text
.section .text.boot, "ax"
.align 4
.global _start
.extern main
Expand All @@ -11,7 +11,10 @@ _start:
bne t0, zero, 1f
li x1, 0
li x2, 0
li x3, 0
.option push
.option norelax
la gp, __global_pointer$ /* x3 = gp; norelax keeps this load absolute */
.option pop
Comment on lines +14 to +17

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

x3 register is missing. also I'm not sure why we need to change .text to .init.

li x4, 0
li x5, 0
li x6, 0
Expand Down
4 changes: 4 additions & 0 deletions ports/risc-v32/gnu/example_build/qemu_virt/link.lds
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ SECTIONS
. = 0x80000000;

.text : {
KEEP(*(.text.boot)) /* entry.s _start — must be first at 0x80000000 */
*(.text .text.*)
. = ALIGN(0x1000);
PROVIDE(etext = .);
Expand All @@ -24,6 +25,9 @@ SECTIONS

.data : {
. = ALIGN(16);
/* Centre __global_pointer$ in the small-data window so the +/-2 KiB
reach of GP-relative addressing covers the .sdata/.sbss area. */
PROVIDE( __global_pointer$ = . + 0x800 );
*(.sdata .sdata.*) /* do not need to distinguish this from .data */
. = ALIGN(16);
*(.data .data.*)
Expand Down
Loading