Migrates plain ThreadX to the upstream RISC-V ports
Keeps the Moonlight startup objects local to the board. Updates the plain and SMP VP regression harnesses for the new ThreadX revision and replaces generated ISR hooks with direct callbacks.
This commit is contained in:
1 parent
26fd407a1e
commit
d404e17e5a
22 files changed
+148
-2311
No files matched your search
+17
-22
@@ -37,21 +37,6 @@ set(__THREAD_LOCAL_STORAGE OFF)
|
||||
add_subdirectory(${THREADX4TGFS_ROOT}/third-party/picolibc ${CMAKE_BINARY_DIR}/picolibc)
|
||||
target_link_libraries(c PUBLIC gcc)
|
||||
|
||||
set(THREADX_LOW_LEVEL_INIT_SOURCE_INPUT
|
||||
${THREADX4TGFS_ROOT}/port/threadx_smp/src/tx_initialize_low_level.c)
|
||||
set(THREADX_LOW_LEVEL_INIT_SOURCE
|
||||
${CMAKE_BINARY_DIR}/generated/tx_initialize_low_level.c)
|
||||
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS
|
||||
${THREADX_LOW_LEVEL_INIT_SOURCE_INPUT}
|
||||
${THREADX4TGFS_ROOT}/test/threadx/generate_trap_file.sh)
|
||||
execute_process(
|
||||
COMMAND bash ${THREADX4TGFS_ROOT}/test/threadx/generate_trap_file.sh
|
||||
${THREADX_LOW_LEVEL_INIT_SOURCE_INPUT}
|
||||
${THREADX_LOW_LEVEL_INIT_SOURCE}
|
||||
RESULT_VARIABLE THREADX_LOW_LEVEL_INIT_GENERATE_RESULT
|
||||
COMMAND_ERROR_IS_FATAL ANY
|
||||
)
|
||||
|
||||
add_subdirectory(${THREADX4TGFS_ROOT}/port/moonlight ${CMAKE_BINARY_DIR}/port/moonlight)
|
||||
target_sources(c PRIVATE ${THREADX4TGFS_ROOT}/port/picolibc/port.c)
|
||||
target_link_libraries(c PUBLIC moonlight gcc)
|
||||
@@ -94,9 +79,6 @@ endfunction()
|
||||
set(TX_REGRESSION_DIR
|
||||
${THREADX4TGFS_ROOT}/third-party/threadx/test/smp/regression
|
||||
)
|
||||
set(TX_CMAKE_DIR
|
||||
${THREADX4TGFS_ROOT}/third-party/threadx/test/tx/cmake
|
||||
)
|
||||
|
||||
set(TX_REGRESSION_CASES
|
||||
${TX_REGRESSION_DIR}/threadx_block_memory_basic_test.c
|
||||
@@ -169,8 +151,8 @@ set(TX_REGRESSION_CASES
|
||||
${TX_REGRESSION_DIR}/threadx_smp_random_resume_suspend_test.c
|
||||
${TX_REGRESSION_DIR}/threadx_smp_rebalance_exclusion_test.c
|
||||
${TX_REGRESSION_DIR}/threadx_smp_relinquish_test.c
|
||||
${TX_REGRESSION_DIR}/threadx_smp_resume_suspend_accending_order_test.c
|
||||
${TX_REGRESSION_DIR}/threadx_smp_resume_suspend_decending_order_test.c
|
||||
${TX_REGRESSION_DIR}/threadx_smp_resume_suspend_ascending_order_test.c
|
||||
${TX_REGRESSION_DIR}/threadx_smp_resume_suspend_descending_order_test.c
|
||||
${TX_REGRESSION_DIR}/threadx_smp_time_slice_test.c
|
||||
${TX_REGRESSION_DIR}/threadx_smp_two_threads_one_core_test.c
|
||||
${TX_REGRESSION_DIR}/threadx_thread_basic_execution_test.c
|
||||
@@ -213,7 +195,7 @@ set(TX_REGRESSION_CASES
|
||||
add_library(
|
||||
threadx_smp_regression_support STATIC
|
||||
${TX_REGRESSION_DIR}/testcontrol.c
|
||||
${TX_CMAKE_DIR}/samples/fake.c
|
||||
../threadx/vp_time.c
|
||||
)
|
||||
target_link_libraries(threadx_smp_regression_support PUBLIC threadx_smp c)
|
||||
target_compile_definitions(
|
||||
@@ -227,6 +209,10 @@ target_compile_definitions(
|
||||
TEST_STACK_SIZE_PRINTF=4096
|
||||
)
|
||||
|
||||
add_library(threadx_smp_regression_weak_defaults OBJECT
|
||||
${THREADX4TGFS_ROOT}/third-party/threadx/test/shared/regression/testcontrol_weak_defaults.c
|
||||
)
|
||||
|
||||
function(add_threadx_regression_test TEST_SOURCE)
|
||||
get_filename_component(TEST_NAME ${TEST_SOURCE} NAME_WE)
|
||||
|
||||
@@ -238,9 +224,18 @@ function(add_threadx_regression_test TEST_SOURCE)
|
||||
|
||||
setup_target(
|
||||
${TEST_NAME}
|
||||
LIBRARIES ${test_libraries}
|
||||
LIBRARIES threadx_smp_regression_weak_defaults ${test_libraries}
|
||||
SOURCES ${TEST_SOURCE}
|
||||
)
|
||||
target_include_directories(${TEST_NAME} PRIVATE ${THREADX4TGFS_ROOT}/third-party/threadx/test/tx/regression)
|
||||
|
||||
# These tests need the timer ISR to land in a narrow ThreadX code window.
|
||||
if(TEST_NAME STREQUAL "threadx_event_flag_isr_set_clear_test" OR
|
||||
TEST_NAME STREQUAL "threadx_event_flag_isr_wait_abort_test" OR
|
||||
TEST_NAME STREQUAL "threadx_thread_delayed_suspension_test")
|
||||
target_sources(${TEST_NAME} PRIVATE ../threadx/vp_timer_jitter.c)
|
||||
target_link_options(${TEST_NAME} PRIVATE -Wl,--wrap=_tx_timer_interrupt)
|
||||
endif()
|
||||
|
||||
list(APPEND TX_REGRESSION_TARGETS ${TEST_NAME})
|
||||
set(TX_REGRESSION_TARGETS ${TX_REGRESSION_TARGETS} PARENT_SCOPE)
|
||||
|
||||
+22
-27
@@ -37,29 +37,15 @@ set(__THREAD_LOCAL_STORAGE OFF)
|
||||
add_subdirectory(${THREADX4TGFS_ROOT}/third-party/picolibc ${CMAKE_BINARY_DIR}/picolibc)
|
||||
target_link_libraries(c PUBLIC gcc)
|
||||
|
||||
set(THREADX_LOW_LEVEL_INIT_SOURCE_INPUT
|
||||
${THREADX4TGFS_ROOT}/port/threadx/src/tx_initialize_low_level.c)
|
||||
set(THREADX_LOW_LEVEL_INIT_SOURCE
|
||||
${CMAKE_BINARY_DIR}/generated/tx_initialize_low_level.c)
|
||||
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS
|
||||
${THREADX_LOW_LEVEL_INIT_SOURCE_INPUT}
|
||||
${CMAKE_CURRENT_LIST_DIR}/generate_trap_file.sh)
|
||||
execute_process(
|
||||
COMMAND bash ${CMAKE_CURRENT_LIST_DIR}/generate_trap_file.sh
|
||||
${THREADX_LOW_LEVEL_INIT_SOURCE_INPUT}
|
||||
${THREADX_LOW_LEVEL_INIT_SOURCE}
|
||||
RESULT_VARIABLE THREADX_LOW_LEVEL_INIT_GENERATE_RESULT
|
||||
COMMAND_ERROR_IS_FATAL ANY
|
||||
)
|
||||
|
||||
add_subdirectory(${THREADX4TGFS_ROOT}/port/moonlight ${CMAKE_BINARY_DIR}/port/moonlight)
|
||||
target_sources(c PRIVATE ${THREADX4TGFS_ROOT}/port/picolibc/port.c)
|
||||
target_link_libraries(c PUBLIC moonlight gcc)
|
||||
|
||||
set(THREADX_CUSTOM_PORT ${THREADX4TGFS_ROOT}/port/threadx)
|
||||
add_subdirectory(${THREADX4TGFS_ROOT}/third-party/threadx ${CMAKE_BINARY_DIR}/threadx)
|
||||
target_link_libraries(threadx PUBLIC moonlight c)
|
||||
add_subdirectory(${THREADX4TGFS_ROOT}/port/threadx ${CMAKE_BINARY_DIR}/port/threadx)
|
||||
target_compile_definitions(threadx PUBLIC TX_REGRESSION_TEST)
|
||||
if(THREADX_ARCH STREQUAL "risc-v64")
|
||||
target_compile_definitions(threadx PRIVATE $<$<COMPILE_LANGUAGE:ASM>:TX_USE_WFI_IDLE>)
|
||||
endif()
|
||||
|
||||
function(setup_target TARGET)
|
||||
set(options)
|
||||
@@ -96,9 +82,6 @@ endfunction()
|
||||
set(TX_REGRESSION_DIR
|
||||
${THREADX4TGFS_ROOT}/third-party/threadx/test/tx/regression
|
||||
)
|
||||
set(TX_CMAKE_DIR
|
||||
${THREADX4TGFS_ROOT}/third-party/threadx/test/tx/cmake
|
||||
)
|
||||
|
||||
set(TX_REGRESSION_CASES
|
||||
${TX_REGRESSION_DIR}/threadx_block_memory_basic_test.c
|
||||
@@ -204,25 +187,28 @@ set(TX_REGRESSION_TARGETS)
|
||||
add_library(
|
||||
threadx_regression_support STATIC
|
||||
${TX_REGRESSION_DIR}/testcontrol.c
|
||||
${TX_CMAKE_DIR}/samples/fake.c
|
||||
vp_time.c
|
||||
)
|
||||
target_link_libraries(threadx_regression_support PUBLIC threadx c)
|
||||
target_compile_options(threadx_regression_support PRIVATE -include stdlib.h)
|
||||
target_compile_definitions(
|
||||
threadx_regression_support
|
||||
PUBLIC
|
||||
TX_REGRESSION_TEST
|
||||
CTEST
|
||||
BATCH_TEST
|
||||
TEST_STACK_SIZE_PRINTF=4096
|
||||
)
|
||||
|
||||
add_library(threadx_regression_weak_defaults OBJECT
|
||||
${THREADX4TGFS_ROOT}/third-party/threadx/test/shared/regression/testcontrol_weak_defaults.c
|
||||
)
|
||||
|
||||
function(add_threadx_regression_test TEST_SOURCE)
|
||||
get_filename_component(TEST_NAME ${TEST_SOURCE} NAME_WE)
|
||||
|
||||
if(TEST_NAME STREQUAL "threadx_initialize_kernel_setup_test")
|
||||
set(test_libraries threadx)
|
||||
else()
|
||||
set(test_libraries threadx_regression_support)
|
||||
set(test_libraries moonlight_threadx threadx_regression_weak_defaults)
|
||||
if(NOT TEST_NAME STREQUAL "threadx_initialize_kernel_setup_test")
|
||||
list(APPEND test_libraries threadx_regression_support)
|
||||
endif()
|
||||
|
||||
setup_target(
|
||||
@@ -230,6 +216,11 @@ function(add_threadx_regression_test TEST_SOURCE)
|
||||
LIBRARIES ${test_libraries}
|
||||
SOURCES ${TEST_SOURCE}
|
||||
)
|
||||
target_compile_options(${TEST_NAME} PRIVATE -include stdlib.h)
|
||||
if(TEST_NAME STREQUAL "threadx_thread_basic_execution_test")
|
||||
target_sources(${TEST_NAME} PRIVATE vp_timer_jitter.c)
|
||||
target_link_options(${TEST_NAME} PRIVATE -Wl,--wrap=_tx_timer_interrupt)
|
||||
endif()
|
||||
|
||||
list(APPEND TX_REGRESSION_TARGETS ${TEST_NAME})
|
||||
set(TX_REGRESSION_TARGETS ${TX_REGRESSION_TARGETS} PARENT_SCOPE)
|
||||
@@ -248,6 +239,10 @@ foreach(test_case ${TX_REGRESSION_CASES})
|
||||
add_threadx_regression_test(${test_case})
|
||||
endforeach()
|
||||
|
||||
# This case waits for repeated hits in a short interrupt window, which can
|
||||
# take longer to simulate on an unoptimized VP build.
|
||||
set_tests_properties(threadx_event_flag_isr_wait_abort_test PROPERTIES TIMEOUT 120)
|
||||
|
||||
add_custom_target(
|
||||
threadx_regression_build
|
||||
DEPENDS ${TX_REGRESSION_TARGETS}
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
#!/bin/bash
|
||||
set -eu
|
||||
|
||||
src="$1"
|
||||
dst="$2"
|
||||
|
||||
extern_anchor='extern void _tx_timer_interrupt(void);'
|
||||
call_anchor='_tx_timer_interrupt();'
|
||||
|
||||
mkdir -p "$(dirname "$dst")"
|
||||
tmp1="${dst}.tmp1"
|
||||
|
||||
line=$(grep -n -F "$extern_anchor" "$src" | head -n 1 | cut -d: -f1)
|
||||
if [ -z "$line" ]; then
|
||||
echo "failed to find _tx_timer_interrupt declaration anchor in input source" >&2
|
||||
exit 1
|
||||
fi
|
||||
sed "${line}a\\
|
||||
void test_interrupt_dispatch(void) __attribute__((weak));\nvoid test_interrupt_dispatch(void) {}" "$src" > "$tmp1"
|
||||
|
||||
line=$(grep -n -F "$call_anchor" "$tmp1" | head -n 1 | cut -d: -f1)
|
||||
if [ -z "$line" ]; then
|
||||
echo "failed to find _tx_timer_interrupt call anchor in input source" >&2
|
||||
rm -f "$tmp1"
|
||||
exit 1
|
||||
fi
|
||||
sed "${line}i\\
|
||||
test_interrupt_dispatch();" "$tmp1" > "$dst"
|
||||
rm -f "$tmp1"
|
||||
@@ -0,0 +1,10 @@
|
||||
#include "hwtimer.h"
|
||||
#include <time.h>
|
||||
|
||||
time_t time(time_t *result)
|
||||
{
|
||||
time_t now = (time_t)(get_aclint_mtime(aclint) / TICKNUM_PER_SECOND);
|
||||
if (result)
|
||||
*result = now;
|
||||
return now;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
#include "hwtimer.h"
|
||||
|
||||
void __real__tx_timer_interrupt(void);
|
||||
|
||||
void __wrap__tx_timer_interrupt(void)
|
||||
{
|
||||
static uint32_t sequence = 1;
|
||||
|
||||
/* Vary each interval by one ACLINT count so the periodic ISR samples
|
||||
different points in the test thread's preemption-disable loop. */
|
||||
sequence = sequence * 1664525u + 1013904223u;
|
||||
uint64_t next = get_aclint_mtimecmp(aclint);
|
||||
set_aclint_mtimecmp(aclint, (sequence >> 31) ? next + 1 : next - 1);
|
||||
|
||||
__real__tx_timer_interrupt();
|
||||
}
|
||||
Reference in new issue
Block a user