Compare commits
18 Commits
27438ef6a5
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 5b8c72cd9d | |||
| 91632bcdee | |||
| 5b2da239d2 | |||
| 1165785154 | |||
| ba39d23a18 | |||
| d97e71ca83 | |||
| 4c15a3e15f | |||
| 68057507c9 | |||
| 32df317b38 | |||
| 12ae01cda2 | |||
| ff0f81e9c0 | |||
| f989e21bad | |||
| e3a7a9ccaf | |||
| c717297b30 | |||
| b16a0ed956 | |||
| 21f95341af | |||
| 86025e020d | |||
| 764ccd4a52 |
+13
-26
@@ -4,43 +4,44 @@ cmake_minimum_required(VERSION 3.21)
|
|||||||
set(BUILD_SHARED_LIBS OFF)
|
set(BUILD_SHARED_LIBS OFF)
|
||||||
include(${CMAKE_TOOLCHAIN_FILE})
|
include(${CMAKE_TOOLCHAIN_FILE})
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
add_subdirectory(port/moonlight)
|
||||||
|
set(TARGET_MEM "ram" CACHE STRING "memory map to use")
|
||||||
|
###############################################################################
|
||||||
# Adds picolibc
|
# Adds picolibc
|
||||||
#set(CMAKE_SYSTEM_PROCESSOR riscv)
|
#set(CMAKE_SYSTEM_PROCESSOR riscv)
|
||||||
set(__THREAD_LOCAL_STORAGE OFF)
|
set(__THREAD_LOCAL_STORAGE OFF)
|
||||||
add_subdirectory(third-party/picolibc)
|
add_subdirectory(third-party/picolibc)
|
||||||
#add_subdirectory(picolibc/semihost)
|
#add_subdirectory(picolibc/semihost)
|
||||||
target_link_libraries(c PUBLIC gcc)
|
target_sources(c PRIVATE ${CMAKE_CURRENT_LIST_DIR}/port/picolibc/port.c)
|
||||||
|
target_link_libraries(c PUBLIC moonlight gcc)
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# Adds threadx
|
# Adds threadx
|
||||||
set(THREADX_CUSTOM_PORT ${CMAKE_CURRENT_LIST_DIR}/port/threadx)
|
set(THREADX_CUSTOM_PORT ${CMAKE_CURRENT_LIST_DIR}/port/threadx)
|
||||||
add_subdirectory(third-party/threadx)
|
add_subdirectory(third-party/threadx)
|
||||||
target_link_libraries(threadx PUBLIC c)
|
target_link_libraries(threadx PUBLIC c moonlight)
|
||||||
#Adds threadx_smp
|
#Adds threadx_smp
|
||||||
add_subdirectory(port/threadx_smp)
|
add_subdirectory(port/threadx_smp)
|
||||||
target_link_libraries(threadx_smp PUBLIC c)
|
target_link_libraries(threadx_smp PUBLIC c moonlight)
|
||||||
# Adds netxduo
|
# Adds netxduo
|
||||||
set(NETXDUO_CUSTOM_PORT ${CMAKE_CURRENT_LIST_DIR}/port/threadx)
|
set(NETXDUO_CUSTOM_PORT ${CMAKE_CURRENT_LIST_DIR}/port/netxduo)
|
||||||
set(NXD_ENABLE_FILE_SERVERS OFF)
|
set(NXD_ENABLE_FILE_SERVERS OFF)
|
||||||
set(NX_USER_FILE ${CMAKE_CURRENT_LIST_DIR}/port/threadx/inc/nx_user.h)
|
|
||||||
add_subdirectory(third-party/netxduo)
|
add_subdirectory(third-party/netxduo)
|
||||||
target_link_libraries(netxduo PUBLIC c)
|
|
||||||
if(NX_DEBUG)
|
if(NX_DEBUG)
|
||||||
target_compile_definitions(netxduo PRIVATE NX_DEBUG NX_DEBUG_PACKET NX_ENABLE_PACKET_DEBUG_INFO)
|
target_compile_definitions(netxduo PRIVATE NX_DEBUG NX_DEBUG_PACKET NX_ENABLE_PACKET_DEBUG_INFO)
|
||||||
endif()
|
endif()
|
||||||
if(TX_TRACE)
|
if(TX_TRACE)
|
||||||
|
target_compile_definitions(threadx PUBLIC TX_ENABLE_EVENT_TRACE)
|
||||||
|
target_compile_definitions(threadx_smp PUBLIC TX_ENABLE_EVENT_TRACE)
|
||||||
target_compile_definitions(netxduo PUBLIC TX_ENABLE_EVENT_TRACE)
|
target_compile_definitions(netxduo PUBLIC TX_ENABLE_EVENT_TRACE)
|
||||||
endif()
|
endif()
|
||||||
###############################################################################
|
###############################################################################
|
||||||
project(threadx_demo C ASM)
|
project(threadx_demo C ASM)
|
||||||
option(NX_DEBUG "compile netxduo debug output in" OFF)
|
option(NX_DEBUG "compile netxduo debug output in" OFF)
|
||||||
set(TARGET_MEM "ram" CACHE STRING "memory map to use")
|
option(TX_TRACE "Enable dump of traces to be read by TraceX" OFF)
|
||||||
set(CMAKE_EXECUTABLE_SUFFIX_C ".elf")
|
set(CMAKE_EXECUTABLE_SUFFIX_C ".elf")
|
||||||
|
|
||||||
add_subdirectory(port/moonlight)
|
|
||||||
|
|
||||||
function(setup_target TARGET)
|
function(setup_target TARGET)
|
||||||
set(options)
|
set(options)
|
||||||
set(oneValueArgs PLATFORM_TARGET)
|
|
||||||
set(multiValueArgs LIBRARIES SOURCES)
|
set(multiValueArgs LIBRARIES SOURCES)
|
||||||
cmake_parse_arguments(ST "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
cmake_parse_arguments(ST "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||||
if(ST_UNPARSED_ARGUMENTS)
|
if(ST_UNPARSED_ARGUMENTS)
|
||||||
@@ -51,16 +52,6 @@ function(setup_target TARGET)
|
|||||||
set_target_properties(${TARGET} PROPERTIES
|
set_target_properties(${TARGET} PROPERTIES
|
||||||
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}
|
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||||
)
|
)
|
||||||
if(ST_PLATFORM_TARGET)
|
|
||||||
target_add_moonlight_platform(${TARGET} PLATFORM_TARGET ${ST_PLATFORM_TARGET})
|
|
||||||
else()
|
|
||||||
target_add_moonlight_platform(${TARGET})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if("netxduo" IN_LIST ST_LIBRARIES)
|
|
||||||
target_add_moonlight_network_driver(${TARGET})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(ST_SOURCES)
|
if(ST_SOURCES)
|
||||||
target_sources(${TARGET} PRIVATE ${ST_SOURCES})
|
target_sources(${TARGET} PRIVATE ${ST_SOURCES})
|
||||||
endif()
|
endif()
|
||||||
@@ -70,10 +61,6 @@ function(setup_target TARGET)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_link_options(${TARGET} PRIVATE
|
target_link_options(${TARGET} PRIVATE
|
||||||
-nostartfiles
|
|
||||||
-nostdlib
|
|
||||||
-T ${CMAKE_SOURCE_DIR}/src/${TARGET_MEM}.lds
|
|
||||||
-Wl,--gc-sections
|
|
||||||
-Wl,-Map=${CMAKE_BINARY_DIR}/${TARGET}.map)
|
-Wl,-Map=${CMAKE_BINARY_DIR}/${TARGET}.map)
|
||||||
|
|
||||||
add_custom_command(TARGET ${TARGET} POST_BUILD
|
add_custom_command(TARGET ${TARGET} POST_BUILD
|
||||||
@@ -86,5 +73,5 @@ function(setup_target TARGET)
|
|||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
setup_target(thread_demo LIBRARIES threadx SOURCES src/thread_demo/main.c)
|
setup_target(thread_demo LIBRARIES threadx SOURCES src/thread_demo/main.c)
|
||||||
setup_target(tcp_demo LIBRARIES threadx netxduo SOURCES src/tcp_demo/main.c)
|
setup_target(tcp_demo LIBRARIES netxduo threadx SOURCES src/tcp_demo/main.c)
|
||||||
setup_target(smp_demo PLATFORM_TARGET moonlight_platform_common_smp LIBRARIES threadx_smp SOURCES src/thread_demo/main.c)
|
setup_target(smp_demo LIBRARIES threadx_smp SOURCES src/thread_demo/main.c)
|
||||||
|
|||||||
@@ -1,91 +1,41 @@
|
|||||||
set(MOONLIGHT_ROOT ${CMAKE_CURRENT_LIST_DIR})
|
cmake_minimum_required(VERSION 3.21)
|
||||||
set(THREADX4TGFS_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../..)
|
project(moonlight LANGUAGES C)
|
||||||
set(MOONLIGHT_SRC_DIR ${MOONLIGHT_ROOT}/src)
|
|
||||||
set(MOONLIGHT_INC_DIR ${MOONLIGHT_ROOT}/inc)
|
|
||||||
|
|
||||||
if(NOT DEFINED MOONLIGHT_TRAP_SOURCE) # Hook to use vectored traps, also used in regression testing
|
|
||||||
|
set(MOONLIGHT_ROOT ${CMAKE_CURRENT_LIST_DIR})
|
||||||
|
set(MOONLIGHT_INC_DIR ${MOONLIGHT_ROOT}/inc)
|
||||||
|
set(MOONLIGHT_SRC_DIR ${MOONLIGHT_ROOT}/src)
|
||||||
|
set(MOONLIGHT_LDS_DIR ${MOONLIGHT_ROOT}/lds)
|
||||||
|
|
||||||
|
if(NOT DEFINED TARGET_MEM)
|
||||||
|
set(TARGET_MEM "ram" CACHE STRING "memory map to use")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT DEFINED MOONLIGHT_TRAP_SOURCE)
|
||||||
set(MOONLIGHT_TRAP_SOURCE ${MOONLIGHT_SRC_DIR}/trap_non_vectored.c)
|
set(MOONLIGHT_TRAP_SOURCE ${MOONLIGHT_SRC_DIR}/trap_non_vectored.c)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(MOONLIGHT_PLATFORM_SOURCES
|
add_library(moonlight STATIC
|
||||||
${THREADX4TGFS_ROOT}/port/picolibc/port.c
|
|
||||||
${MOONLIGHT_SRC_DIR}/bootup.c
|
|
||||||
${MOONLIGHT_SRC_DIR}/board.c
|
${MOONLIGHT_SRC_DIR}/board.c
|
||||||
${MOONLIGHT_TRAP_SOURCE}
|
${MOONLIGHT_SRC_DIR}/bootup.c
|
||||||
${MOONLIGHT_SRC_DIR}/exception.c
|
${MOONLIGHT_SRC_DIR}/exception.c
|
||||||
${MOONLIGHT_SRC_DIR}/vector_table.c)
|
${MOONLIGHT_TRAP_SOURCE}
|
||||||
|
)
|
||||||
|
|
||||||
# define a basic library containing all generic board components
|
target_include_directories(moonlight PUBLIC ${MOONLIGHT_INC_DIR})
|
||||||
add_library(moonlight_platform_defaults INTERFACE)
|
target_link_directories(moonlight INTERFACE ${MOONLIGHT_LDS_DIR})
|
||||||
target_include_directories(moonlight_platform_defaults INTERFACE
|
|
||||||
${MOONLIGHT_INC_DIR}
|
target_compile_options(moonlight
|
||||||
${THREADX4TGFS_ROOT}/src)
|
PUBLIC
|
||||||
target_compile_options(moonlight_platform_defaults INTERFACE
|
|
||||||
-ffreestanding
|
-ffreestanding
|
||||||
-fno-builtin
|
-fno-builtin
|
||||||
-fdata-sections
|
-fdata-sections
|
||||||
-ffunction-sections)
|
-ffunction-sections
|
||||||
target_link_directories(moonlight_platform_defaults INTERFACE
|
)
|
||||||
${THREADX4TGFS_ROOT}/src)
|
|
||||||
if(NX_DEBUG)
|
|
||||||
target_compile_definitions(moonlight_platform_defaults INTERFACE
|
|
||||||
NX_DEBUG
|
|
||||||
NX_DEBUG_PACKET)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# helper to tie in different threadx runtimes
|
target_link_options(moonlight
|
||||||
function(moonlight_define_platform TARGET THREADX_TARGET)
|
INTERFACE
|
||||||
add_library(${TARGET} OBJECT
|
-nostartfiles
|
||||||
${MOONLIGHT_PLATFORM_SOURCES})
|
-T ${MOONLIGHT_LDS_DIR}/${TARGET_MEM}.lds
|
||||||
target_link_libraries(${TARGET} PUBLIC
|
-Wl,--gc-sections
|
||||||
moonlight_platform_defaults
|
)
|
||||||
c
|
|
||||||
${THREADX_TARGET})
|
|
||||||
endfunction()
|
|
||||||
|
|
||||||
if(TARGET threadx)
|
|
||||||
moonlight_define_platform(moonlight_platform_common threadx)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(TARGET threadx_smp)
|
|
||||||
moonlight_define_platform(moonlight_platform_common_smp threadx_smp)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(DEFINED NETXDUO_CUSTOM_PORT)
|
|
||||||
add_library(moonlight_network_driver OBJECT
|
|
||||||
${MOONLIGHT_SRC_DIR}/mnrs_network_driver.c)
|
|
||||||
target_link_libraries(moonlight_network_driver PUBLIC
|
|
||||||
moonlight_platform_defaults
|
|
||||||
c
|
|
||||||
threadx
|
|
||||||
netxduo)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# helper for consumers to inject moonlight as a dependency into a target
|
|
||||||
function(target_add_moonlight_platform TARGET)
|
|
||||||
set(options)
|
|
||||||
set(oneValueArgs PLATFORM_TARGET)
|
|
||||||
cmake_parse_arguments(TAMP "${options}" "${oneValueArgs}" "" ${ARGN})
|
|
||||||
|
|
||||||
if(TAMP_UNPARSED_ARGUMENTS)
|
|
||||||
message(FATAL_ERROR "target_add_moonlight_platform(${TARGET} ...): unknown args: ${TAMP_UNPARSED_ARGUMENTS}")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(NOT TAMP_PLATFORM_TARGET)
|
|
||||||
if(NOT TARGET moonlight_platform_common)
|
|
||||||
message(FATAL_ERROR "moonlight_platform_common is not available in this build; pass PLATFORM_TARGET explicitly")
|
|
||||||
endif()
|
|
||||||
set(TAMP_PLATFORM_TARGET moonlight_platform_common)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
target_link_libraries(${TARGET} PRIVATE ${TAMP_PLATFORM_TARGET})
|
|
||||||
endfunction()
|
|
||||||
|
|
||||||
# helper to inject the network driver into a target
|
|
||||||
function(target_add_moonlight_network_driver TARGET)
|
|
||||||
if(NOT TARGET moonlight_network_driver)
|
|
||||||
message(FATAL_ERROR "moonlight_network_driver requires netxduo to be available in this build")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
target_link_libraries(${TARGET} PRIVATE moonlight_network_driver)
|
|
||||||
endfunction()
|
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
int uart_putc(int ch);
|
||||||
|
int uart_getc(void);
|
||||||
|
int board_init(void);
|
||||||
|
int register_irq_handler(unsigned irq_num, void (*handler)());
|
||||||
@@ -33,4 +33,8 @@ static inline uint8_t uart_read(volatile uart_t* reg)
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline int uart_init(void)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
#endif /* _DEVICES_UART_H */
|
#endif /* _DEVICES_UART_H */
|
||||||
|
|||||||
@@ -2,8 +2,6 @@
|
|||||||
#include "csr.h"
|
#include "csr.h"
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
#include "uart.h"
|
#include "uart.h"
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdarg.h>
|
|
||||||
|
|
||||||
// needed by picolibc/port.c
|
// needed by picolibc/port.c
|
||||||
int uart_putc(int ch) {
|
int uart_putc(int ch) {
|
||||||
@@ -22,11 +20,6 @@ int uart_getc(void) {
|
|||||||
return ch;
|
return ch;
|
||||||
}
|
}
|
||||||
|
|
||||||
int uart_init(void) {
|
|
||||||
puts("[UART0] : Uart Init Done, this is Test output!");
|
|
||||||
return 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
int board_init(void) {
|
int board_init(void) {
|
||||||
int ret;
|
int ret;
|
||||||
ret = uart_init();
|
ret = uart_init();
|
||||||
|
|||||||
+11
-59
@@ -6,20 +6,15 @@
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <picotls.h>
|
|
||||||
#include <aclint_ipi.h>
|
|
||||||
#include <tx_port.h>
|
|
||||||
#include <riscv-csr.h>
|
#include <riscv-csr.h>
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
#define EXTERN_C extern "C"
|
#define EXTERN_C extern "C"
|
||||||
#else
|
#else
|
||||||
#define EXTERN_C extern
|
#define EXTERN_C extern
|
||||||
#endif
|
#endif
|
||||||
#if defined(TX_THREAD_SMP_MAX_CORES) && (TX_THREAD_SMP_MAX_CORES > 1)
|
|
||||||
#define BOOTUP_SMP_ENABLED
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Generic C function pointer.
|
// Generic C function pointer.
|
||||||
typedef void(*function_t)(void) ;
|
typedef void(*function_t)(void) ;
|
||||||
@@ -49,56 +44,15 @@ EXTERN_C void _start(void) __attribute__ ((naked,section(".text.boot")));
|
|||||||
|
|
||||||
// Entry and exit points as C functions.
|
// Entry and exit points as C functions.
|
||||||
EXTERN_C void _initialize(void) __attribute__ ((noreturn,section(".text.boot")));
|
EXTERN_C void _initialize(void) __attribute__ ((noreturn,section(".text.boot")));
|
||||||
EXTERN_C void _secondary_sleep_forever(void) __attribute__ ((noreturn,section(".text.boot")));
|
EXTERN_C void _secondary_initialize(void) __attribute__ ((noreturn,section(".text.boot"),weak));
|
||||||
EXTERN_C void _exit(int exit_code) __attribute__ ((noreturn,noinline,weak));
|
EXTERN_C void _exit(int exit_code) __attribute__ ((noreturn,noinline,weak));
|
||||||
|
EXTERN_C void bootup_wake_secondary_cores(void) __attribute__ ((weak));
|
||||||
|
|
||||||
// Standard entry point, no arguments.
|
// Standard entry point, no arguments.
|
||||||
extern int main(void);
|
extern int main(void);
|
||||||
|
|
||||||
#if defined BOOTUP_SMP_ENABLED
|
#ifdef __THREAD_LOCAL_STORAGE
|
||||||
EXTERN_C void _secondary_initialize(void) __attribute__ ((noreturn,section(".text.boot")));
|
EXTERN_C void _set_tls(uint8_t*) __attribute__ ((noreturn,section(".text.boot")));
|
||||||
EXTERN_C void _secondary_ipi_trap(void) __attribute__ ((naked,noreturn,section(".text.boot")));
|
|
||||||
EXTERN_C void _tx_thread_smp_initialize_wait(void) __attribute__ ((noreturn));
|
|
||||||
|
|
||||||
void _secondary_initialize(void) {
|
|
||||||
csr_write_mtvec((uint_xlen_t)_secondary_ipi_trap);
|
|
||||||
csr_set_bits_mie(MIE_MSI_BIT_MASK);
|
|
||||||
csr_set_bits_mstatus(MSTATUS_MIE_BIT_MASK);
|
|
||||||
|
|
||||||
__asm__ volatile ("wfi");
|
|
||||||
|
|
||||||
csr_clr_bits_mstatus(MSTATUS_MIE_BIT_MASK);
|
|
||||||
|
|
||||||
_tx_thread_smp_initialize_wait();
|
|
||||||
}
|
|
||||||
|
|
||||||
void _secondary_ipi_trap(void) {
|
|
||||||
#if __riscv_xlen == 64
|
|
||||||
__asm__ volatile ("addi sp, sp, -16;"
|
|
||||||
"sd ra, 8(sp);"
|
|
||||||
"call bootup_ipi_clear_handler;"
|
|
||||||
"ld ra, 8(sp);"
|
|
||||||
"addi sp, sp, 16;"
|
|
||||||
"mret");
|
|
||||||
#else
|
|
||||||
__asm__ volatile ("addi sp, sp, -8;"
|
|
||||||
"sw ra, 4(sp);"
|
|
||||||
"call bootup_ipi_clear_handler;"
|
|
||||||
"lw ra, 4(sp);"
|
|
||||||
"addi sp, sp, 8;"
|
|
||||||
"mret");
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
static void bootup_wake_secondary_cores(void) {
|
|
||||||
for (UINT core = 1; core < TX_THREAD_SMP_MAX_CORES; ++core) {
|
|
||||||
send_ipi(core);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
__attribute__((used)) void bootup_ipi_clear_handler(void) {
|
|
||||||
set_aclint_msip(aclint, csr_read_mhartid(), 0);
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// The linker script will place this in the reset entry point.
|
// The linker script will place this in the reset entry point.
|
||||||
@@ -133,11 +87,7 @@ void _start(void) {
|
|||||||
"j 1b;"
|
"j 1b;"
|
||||||
"2:;"
|
"2:;"
|
||||||
"beqz t0, 3f;"
|
"beqz t0, 3f;"
|
||||||
#ifdef BOOTUP_SMP_ENABLED
|
|
||||||
"jal zero, _secondary_initialize;"
|
"jal zero, _secondary_initialize;"
|
||||||
#else
|
|
||||||
"jal zero, _secondary_sleep_forever;"
|
|
||||||
#endif
|
|
||||||
"3:;"
|
"3:;"
|
||||||
"jal zero, _initialize;"
|
"jal zero, _initialize;"
|
||||||
: /* output: none %0 */
|
: /* output: none %0 */
|
||||||
@@ -163,9 +113,7 @@ void _initialize(void) {
|
|||||||
++entry) {
|
++entry) {
|
||||||
(*entry)();
|
(*entry)();
|
||||||
}
|
}
|
||||||
#ifdef BOOTUP_SMP_ENABLED
|
|
||||||
bootup_wake_secondary_cores();
|
bootup_wake_secondary_cores();
|
||||||
#endif
|
|
||||||
#ifdef __THREAD_LOCAL_STORAGE
|
#ifdef __THREAD_LOCAL_STORAGE
|
||||||
_set_tls(__tls_base)
|
_set_tls(__tls_base)
|
||||||
#endif
|
#endif
|
||||||
@@ -179,7 +127,8 @@ void _initialize(void) {
|
|||||||
_exit(rc);
|
_exit(rc);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _secondary_sleep_forever(void) {
|
void _secondary_initialize(void) {
|
||||||
|
// sleep forever
|
||||||
csr_clr_bits_mie(MIE_MTI_BIT_MASK);
|
csr_clr_bits_mie(MIE_MTI_BIT_MASK);
|
||||||
csr_clr_bits_mstatus(MSTATUS_MIE_BIT_MASK);
|
csr_clr_bits_mstatus(MSTATUS_MIE_BIT_MASK);
|
||||||
while (1) {
|
while (1) {
|
||||||
@@ -187,6 +136,9 @@ void _secondary_sleep_forever(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void bootup_wake_secondary_cores(void) {
|
||||||
|
}
|
||||||
|
|
||||||
// This should never be called. Report the exit code through HTIF and idle the CPU.
|
// This should never be called. Report the exit code through HTIF and idle the CPU.
|
||||||
void _exit(int exit_code) {
|
void _exit(int exit_code) {
|
||||||
uintptr_t htif_exit_code = (((uintptr_t)(unsigned int)exit_code) << 1) | 1u;
|
uintptr_t htif_exit_code = (((uintptr_t)(unsigned int)exit_code) << 1) | 1u;
|
||||||
@@ -197,4 +149,4 @@ void _exit(int exit_code) {
|
|||||||
while (1) {
|
while (1) {
|
||||||
__asm__ volatile ("wfi");
|
__asm__ volatile ("wfi");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,8 +3,6 @@
|
|||||||
#include "riscv-traps.h"
|
#include "riscv-traps.h"
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <tx_api.h>
|
|
||||||
#include <tx_port.h>
|
|
||||||
|
|
||||||
#if __riscv_xlen == 64
|
#if __riscv_xlen == 64
|
||||||
#define INTERRUPT_BIT 0x8000000000000000ull
|
#define INTERRUPT_BIT 0x8000000000000000ull
|
||||||
@@ -16,7 +14,6 @@
|
|||||||
#define OS_IS_SOFT_INT(mcause) (mcause == (0x3 | INTERRUPT_BIT))
|
#define OS_IS_SOFT_INT(mcause) (mcause == (0x3 | INTERRUPT_BIT))
|
||||||
#define OS_IS_EXT_INT(mcause) (mcause == (0xb | INTERRUPT_BIT))
|
#define OS_IS_EXT_INT(mcause) (mcause == (0xb | INTERRUPT_BIT))
|
||||||
|
|
||||||
extern void _tx_timer_interrupt(void);
|
|
||||||
extern uintptr_t exception(uintptr_t mcause, uintptr_t mepc, uintptr_t mtval);
|
extern uintptr_t exception(uintptr_t mcause, uintptr_t mepc, uintptr_t mtval);
|
||||||
|
|
||||||
void (*irq_handler[__riscv_xlen])();
|
void (*irq_handler[__riscv_xlen])();
|
||||||
@@ -33,23 +30,6 @@ void trap_handler(uintptr_t mcause, uintptr_t mepc, uintptr_t mtval) {
|
|||||||
if(OS_IS_INTERRUPT(mcause)) {
|
if(OS_IS_INTERRUPT(mcause)) {
|
||||||
unsigned irq_id = mcause&(__riscv_xlen-1);
|
unsigned irq_id = mcause&(__riscv_xlen-1);
|
||||||
switch(irq_id){
|
switch(irq_id){
|
||||||
case RISCV_INT_MTI:
|
|
||||||
#ifdef NX_DEBUG
|
|
||||||
printf("Timer interrupt being handled (pc=%lx)\n", mepc);
|
|
||||||
#endif
|
|
||||||
hwtimer_handler();
|
|
||||||
_tx_timer_interrupt();
|
|
||||||
break;
|
|
||||||
#ifdef TX_THREAD_SMP_INTER_CORE_INTERRUPT
|
|
||||||
case RISCV_INT_MSI:
|
|
||||||
set_aclint_msip(aclint, csr_read_mhartid(), 0);
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
case RISCV_INT_MEI:
|
|
||||||
puts("[INTERRUPT]: handler ext irq error!\n");
|
|
||||||
while(1)
|
|
||||||
;
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
if(irq_handler[irq_id])
|
if(irq_handler[irq_id])
|
||||||
irq_handler[irq_id]();
|
irq_handler[irq_id]();
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
|
||||||
|
target_sources(${PROJECT_NAME}
|
||||||
|
PRIVATE
|
||||||
|
# {{BEGIN_TARGET_SOURCES}}
|
||||||
|
${CMAKE_CURRENT_LIST_DIR}/src/mnrs_network_driver.c
|
||||||
|
# {{END_TARGET_SOURCES}}
|
||||||
|
)
|
||||||
|
|
||||||
|
target_include_directories(${PROJECT_NAME}
|
||||||
|
PUBLIC
|
||||||
|
${CMAKE_CURRENT_LIST_DIR}/inc
|
||||||
|
)
|
||||||
@@ -56,6 +56,9 @@
|
|||||||
|
|
||||||
#include "nx_user.h"
|
#include "nx_user.h"
|
||||||
#endif
|
#endif
|
||||||
|
#include "tx_port.h"
|
||||||
|
typedef unsigned int UINT32;
|
||||||
|
_Static_assert(sizeof(UINT32) == 4, "UINT32 must be 4 bytes");
|
||||||
|
|
||||||
/* Default to little endian, since this is what most RISC-V targets are. */
|
/* Default to little endian, since this is what most RISC-V targets are. */
|
||||||
|
|
||||||
@@ -63,10 +66,10 @@
|
|||||||
|
|
||||||
/* Define macros that swap the endian for little endian ports. */
|
/* Define macros that swap the endian for little endian ports. */
|
||||||
#ifdef NX_LITTLE_ENDIAN
|
#ifdef NX_LITTLE_ENDIAN
|
||||||
#define NX_CHANGE_ULONG_ENDIAN(arg) \
|
#define NX_CHANGE_UINT32_ENDIAN(arg) \
|
||||||
{ \
|
{ \
|
||||||
ULONG _i; \
|
UINT32 _i; \
|
||||||
ULONG _tmp; \
|
UINT32 _tmp; \
|
||||||
_i = (UINT)arg; \
|
_i = (UINT)arg; \
|
||||||
/* _i = A, B, C, D */ \
|
/* _i = A, B, C, D */ \
|
||||||
_tmp = _i ^ (((_i) >> 16) | (_i << 16)); \
|
_tmp = _i ^ (((_i) >> 16) | (_i << 16)); \
|
||||||
@@ -82,11 +85,11 @@
|
|||||||
#define NX_CHANGE_USHORT_ENDIAN(a) (a = (((a >> 8) | (a << 8)) & 0xFFFF))
|
#define NX_CHANGE_USHORT_ENDIAN(a) (a = (((a >> 8) | (a << 8)) & 0xFFFF))
|
||||||
|
|
||||||
#ifndef htonl
|
#ifndef htonl
|
||||||
#define htonl(val) NX_CHANGE_ULONG_ENDIAN(val)
|
#define htonl(val) NX_CHANGE_UINT32_ENDIAN(val)
|
||||||
#endif /* htonl */
|
#endif /* htonl */
|
||||||
|
|
||||||
#ifndef ntohl
|
#ifndef ntohl
|
||||||
#define ntohl(val) NX_CHANGE_ULONG_ENDIAN(val)
|
#define ntohl(val) NX_CHANGE_UINT32_ENDIAN(val)
|
||||||
#endif /* ntohl */
|
#endif /* ntohl */
|
||||||
|
|
||||||
#ifndef htons
|
#ifndef htons
|
||||||
@@ -99,7 +102,7 @@
|
|||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#define NX_CHANGE_ULONG_ENDIAN(a)
|
#define NX_CHANGE_UINT32_ENDIAN(a)
|
||||||
#define NX_CHANGE_USHORT_ENDIAN(a)
|
#define NX_CHANGE_USHORT_ENDIAN(a)
|
||||||
|
|
||||||
#ifndef htons
|
#ifndef htons
|
||||||
@@ -138,8 +138,7 @@
|
|||||||
/* Disable IPv6 processing in NetX Duo. */
|
/* Disable IPv6 processing in NetX Duo. */
|
||||||
/*
|
/*
|
||||||
#define NX_DISABLE_IPV6
|
#define NX_DISABLE_IPV6
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Define the number of entries in IPv6 address pool. */
|
/* Define the number of entries in IPv6 address pool. */
|
||||||
/*
|
/*
|
||||||
#ifdef NX_MAX_PHYSICAL_INTERFACES
|
#ifdef NX_MAX_PHYSICAL_INTERFACES
|
||||||
@@ -66,8 +66,8 @@ extern int register_irq_handler(unsigned irq_num, void (*handler)());
|
|||||||
/* For the ethernet driver, physical addresses are allocated starting
|
/* For the ethernet driver, physical addresses are allocated starting
|
||||||
at the preset value and then incremented before the next allocation. */
|
at the preset value and then incremented before the next allocation. */
|
||||||
// Locally Administered Addresses that can be assigned by network, range is 02-00-00 to 02-00-5E
|
// Locally Administered Addresses that can be assigned by network, range is 02-00-00 to 02-00-5E
|
||||||
const ULONG mnrs_mac_address_msw = 0x0200;
|
const UINT32 mnrs_mac_address_msw = 0x0200;
|
||||||
const ULONG mnrs_mac_address_lsw = 0x00334450;
|
const UINT32 mnrs_mac_address_lsw = 0x00334450;
|
||||||
|
|
||||||
/* Define driver prototypes. */
|
/* Define driver prototypes. */
|
||||||
VOID nx_mnrs_network_driver(NX_IP_DRIVER* driver_req_ptr);
|
VOID nx_mnrs_network_driver(NX_IP_DRIVER* driver_req_ptr);
|
||||||
@@ -81,8 +81,8 @@ static VOID _nx_mnrs_eth_recv_packet_eth1(VOID);
|
|||||||
#define NX_MNRS_DRIVER_MAX_MCAST_ADDRESSES 3
|
#define NX_MNRS_DRIVER_MAX_MCAST_ADDRESSES 3
|
||||||
typedef struct MAC_ADDRESS_STRUCT
|
typedef struct MAC_ADDRESS_STRUCT
|
||||||
{
|
{
|
||||||
ULONG nx_mac_address_msw;
|
UINT32 nx_mac_address_msw;
|
||||||
ULONG nx_mac_address_lsw;
|
UINT32 nx_mac_address_lsw;
|
||||||
} MAC_ADDRESS;
|
} MAC_ADDRESS;
|
||||||
|
|
||||||
/* Define an application-specific data structure that holds internal
|
/* Define an application-specific data structure that holds internal
|
||||||
@@ -173,7 +173,7 @@ VOID nx_mnrs_network_driver(NX_IP_DRIVER* driver_req_ptr)
|
|||||||
UINT interface_index;
|
UINT interface_index;
|
||||||
USHORT ether_type;
|
USHORT ether_type;
|
||||||
#ifndef NX_ENABLE_VLAN
|
#ifndef NX_ENABLE_VLAN
|
||||||
ULONG* ethernet_frame_ptr;
|
UINT32* ethernet_frame_ptr;
|
||||||
#endif /* NX_ENABLE_VLAN */
|
#endif /* NX_ENABLE_VLAN */
|
||||||
|
|
||||||
/* Setup the IP pointer from the driver request. */
|
/* Setup the IP pointer from the driver request. */
|
||||||
@@ -408,7 +408,7 @@ VOID nx_mnrs_network_driver(NX_IP_DRIVER* driver_req_ptr)
|
|||||||
/* Setup the ethernet frame pointer to build the ethernet frame. Backup another 2
|
/* Setup the ethernet frame pointer to build the ethernet frame. Backup another 2
|
||||||
bytes to get 32-bit word alignment. */
|
bytes to get 32-bit word alignment. */
|
||||||
/*lint -e{927} -e{826} suppress cast of pointer to pointer, since it is necessary */
|
/*lint -e{927} -e{826} suppress cast of pointer to pointer, since it is necessary */
|
||||||
ethernet_frame_ptr = (ULONG*)(packet_ptr->nx_packet_prepend_ptr - 2);
|
ethernet_frame_ptr = (UINT32*)(packet_ptr->nx_packet_prepend_ptr - 2);
|
||||||
/* Build the ethernet frame. */
|
/* Build the ethernet frame. */
|
||||||
*ethernet_frame_ptr = driver_req_ptr->nx_ip_driver_physical_address_msw;
|
*ethernet_frame_ptr = driver_req_ptr->nx_ip_driver_physical_address_msw;
|
||||||
*(ethernet_frame_ptr + 1) = driver_req_ptr->nx_ip_driver_physical_address_lsw;
|
*(ethernet_frame_ptr + 1) = driver_req_ptr->nx_ip_driver_physical_address_lsw;
|
||||||
@@ -416,10 +416,10 @@ VOID nx_mnrs_network_driver(NX_IP_DRIVER* driver_req_ptr)
|
|||||||
(interface_ptr->nx_interface_physical_address_lsw >> 16);
|
(interface_ptr->nx_interface_physical_address_lsw >> 16);
|
||||||
*(ethernet_frame_ptr + 3) = (interface_ptr->nx_interface_physical_address_lsw << 16) | ether_type;
|
*(ethernet_frame_ptr + 3) = (interface_ptr->nx_interface_physical_address_lsw << 16) | ether_type;
|
||||||
/* Endian swapping if NX_LITTLE_ENDIAN is defined. */
|
/* Endian swapping if NX_LITTLE_ENDIAN is defined. */
|
||||||
NX_CHANGE_ULONG_ENDIAN(*(ethernet_frame_ptr));
|
NX_CHANGE_UINT32_ENDIAN(*(ethernet_frame_ptr));
|
||||||
NX_CHANGE_ULONG_ENDIAN(*(ethernet_frame_ptr + 1));
|
NX_CHANGE_UINT32_ENDIAN(*(ethernet_frame_ptr + 1));
|
||||||
NX_CHANGE_ULONG_ENDIAN(*(ethernet_frame_ptr + 2));
|
NX_CHANGE_UINT32_ENDIAN(*(ethernet_frame_ptr + 2));
|
||||||
NX_CHANGE_ULONG_ENDIAN(*(ethernet_frame_ptr + 3));
|
NX_CHANGE_UINT32_ENDIAN(*(ethernet_frame_ptr + 3));
|
||||||
#endif /* NX_ENABLE_VLAN */
|
#endif /* NX_ENABLE_VLAN */
|
||||||
#ifdef NX_DEBUG_PACKET
|
#ifdef NX_DEBUG_PACKET
|
||||||
printf("NetX MNRS ETH Driver Packet Send - %s\n", ip_ptr->nx_ip_name);
|
printf("NetX MNRS ETH Driver Packet Send - %s\n", ip_ptr->nx_ip_name);
|
||||||
@@ -840,11 +840,11 @@ void _nx_mnrs_network_driver_receive(NX_IP* ip_ptr, NX_PACKET* packet_ptr, UINT
|
|||||||
|
|
||||||
UINT _nx_mnrs_eth_send_packet(NX_PACKET* packet_ptr, volatile ethmac_t* ethmac)
|
UINT _nx_mnrs_eth_send_packet(NX_PACKET* packet_ptr, volatile ethmac_t* ethmac)
|
||||||
{
|
{
|
||||||
ULONG size = 0;
|
UINT32 size = 0;
|
||||||
UCHAR* data;
|
UCHAR* data;
|
||||||
UINT i;
|
UINT i;
|
||||||
ULONG buffer;
|
UINT32 buffer;
|
||||||
ULONG words;
|
UINT32 words;
|
||||||
|
|
||||||
/* Make sure the data length is less than MTU. */
|
/* Make sure the data length is less than MTU. */
|
||||||
if (packet_ptr->nx_packet_length > NX_MAX_PACKET_SIZE)
|
if (packet_ptr->nx_packet_length > NX_MAX_PACKET_SIZE)
|
||||||
@@ -967,7 +967,7 @@ VOID _nx_mnrs_eth_recv_packet(UINT i)
|
|||||||
|
|
||||||
VOID _nx_mnrs_eth_recv_packet_eth0(VOID)
|
VOID _nx_mnrs_eth_recv_packet_eth0(VOID)
|
||||||
{
|
{
|
||||||
ULONG old_threshold;
|
UINT32 old_threshold;
|
||||||
|
|
||||||
if (get_ethmac_mac_ctrl_rx_pending(ethmac0))
|
if (get_ethmac_mac_ctrl_rx_pending(ethmac0))
|
||||||
{
|
{
|
||||||
@@ -986,7 +986,7 @@ VOID _nx_mnrs_eth_recv_packet_eth0(VOID)
|
|||||||
|
|
||||||
VOID _nx_mnrs_eth_recv_packet_eth1(VOID)
|
VOID _nx_mnrs_eth_recv_packet_eth1(VOID)
|
||||||
{
|
{
|
||||||
ULONG old_threshold;
|
UINT32 old_threshold;
|
||||||
|
|
||||||
if (get_ethmac_mac_ctrl_rx_pending(ethmac1))
|
if (get_ethmac_mac_ctrl_rx_pending(ethmac1))
|
||||||
{
|
{
|
||||||
@@ -1,8 +1,6 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
#include "board.h"
|
||||||
extern void uart_putc(char c);
|
|
||||||
extern int uart_getc(void);
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
board_putc(char c, FILE *file)
|
board_putc(char c, FILE *file)
|
||||||
|
|||||||
@@ -1,8 +1,14 @@
|
|||||||
|
#required for tests to hook into the ISR path
|
||||||
|
if(NOT DEFINED THREADX_LOW_LEVEL_INIT_SOURCE)
|
||||||
|
set(THREADX_LOW_LEVEL_INIT_SOURCE
|
||||||
|
${CMAKE_CURRENT_LIST_DIR}/src/tx_initialize_low_level.c)
|
||||||
|
endif()
|
||||||
|
|
||||||
target_sources(${PROJECT_NAME}
|
target_sources(${PROJECT_NAME}
|
||||||
PRIVATE
|
PRIVATE
|
||||||
# {{BEGIN_TARGET_SOURCES}}
|
# {{BEGIN_TARGET_SOURCES}}
|
||||||
${CMAKE_CURRENT_LIST_DIR}/src/tx_initialize_low_level.S
|
${CMAKE_CURRENT_LIST_DIR}/src/trap_entry.S
|
||||||
|
${THREADX_LOW_LEVEL_INIT_SOURCE}
|
||||||
${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_context_restore.S
|
${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_context_restore.S
|
||||||
${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_context_save.S
|
${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_context_save.S
|
||||||
${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_interrupt_control.S
|
${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_interrupt_control.S
|
||||||
|
|||||||
@@ -77,7 +77,6 @@
|
|||||||
/* Yes, include the user defines in tx_user.h. The defines in this file may
|
/* Yes, include the user defines in tx_user.h. The defines in this file may
|
||||||
alternately be defined on the command line. */
|
alternately be defined on the command line. */
|
||||||
|
|
||||||
#include "nx_user.h"
|
|
||||||
#include "tx_user.h"
|
#include "tx_user.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -7,12 +7,9 @@
|
|||||||
*
|
*
|
||||||
* SPDX-License-Identifier: MIT
|
* SPDX-License-Identifier: MIT
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
#include "csr.h"
|
|
||||||
#include "tx_port.h"
|
|
||||||
|
|
||||||
.section .text
|
.section .text
|
||||||
.align 4
|
.align 4
|
||||||
|
#include "tx_port.h"
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
/* */
|
/* */
|
||||||
/* FUNCTION RELEASE */
|
/* FUNCTION RELEASE */
|
||||||
@@ -89,75 +86,4 @@
|
|||||||
trap_handler:
|
trap_handler:
|
||||||
1:
|
1:
|
||||||
j 1b
|
j 1b
|
||||||
.section .text
|
.section .text
|
||||||
/**************************************************************************/
|
|
||||||
/* */
|
|
||||||
/* FUNCTION RELEASE */
|
|
||||||
/* */
|
|
||||||
/* _tx_initialize_low_level RISC-V64/GNU */
|
|
||||||
/* 6.2.1 */
|
|
||||||
/* AUTHOR */
|
|
||||||
/* */
|
|
||||||
/* Scott Larson, Microsoft Corporation */
|
|
||||||
/* */
|
|
||||||
/* DESCRIPTION */
|
|
||||||
/* */
|
|
||||||
/* This function is responsible for any low-level processor */
|
|
||||||
/* initialization, including setting up interrupt vectors, setting */
|
|
||||||
/* up a periodic timer interrupt source, saving the system stack */
|
|
||||||
/* pointer for use in ISR processing later, and finding the first */
|
|
||||||
/* available RAM memory address for tx_application_define. */
|
|
||||||
/* */
|
|
||||||
/* INPUT */
|
|
||||||
/* */
|
|
||||||
/* None */
|
|
||||||
/* */
|
|
||||||
/* OUTPUT */
|
|
||||||
/* */
|
|
||||||
/* None */
|
|
||||||
/* */
|
|
||||||
/* CALLS */
|
|
||||||
/* */
|
|
||||||
/* None */
|
|
||||||
/* */
|
|
||||||
/* CALLED BY */
|
|
||||||
/* */
|
|
||||||
/* _tx_initialize_kernel_enter ThreadX entry function */
|
|
||||||
/* */
|
|
||||||
/* RELEASE HISTORY */
|
|
||||||
/* */
|
|
||||||
/* DATE NAME DESCRIPTION */
|
|
||||||
/* */
|
|
||||||
/* 03-08-2023 Scott Larson Initial Version 6.2.1 */
|
|
||||||
/* */
|
|
||||||
/**************************************************************************/
|
|
||||||
/* VOID _tx_initialize_low_level(VOID)
|
|
||||||
*/
|
|
||||||
.global _tx_initialize_low_level
|
|
||||||
.weak _tx_initialize_low_level
|
|
||||||
.extern __heap_start
|
|
||||||
.extern board_init
|
|
||||||
_tx_initialize_low_level:
|
|
||||||
STORE sp, _tx_thread_system_stack_ptr, t0 // Save system stack pointer
|
|
||||||
|
|
||||||
la t0, __heap_start // Pickup first free address
|
|
||||||
STORE t0, _tx_initialize_unused_memory, t1 // Save unused memory address
|
|
||||||
li t0, MSTATUS_MIE
|
|
||||||
csrrc zero, mstatus, t0 // clear MSTATUS_MIE bit
|
|
||||||
li t0, (MSTATUS_MPP_M | MSTATUS_MPIE )
|
|
||||||
csrrs zero, mstatus, t0 // set MSTATUS_MPP, MPIE bit
|
|
||||||
li t0, (MIE_MTIE | MIE_MSIE | MIE_MEIE)
|
|
||||||
csrrs zero, mie, t0 // set mie
|
|
||||||
#ifdef __riscv_flen
|
|
||||||
li t0, MSTATUS_FS
|
|
||||||
csrrs zero, mstatus, t0 // set MSTATUS_FS bit to open f/d isa in riscv
|
|
||||||
fscsr x0
|
|
||||||
#endif
|
|
||||||
addi sp, sp, -8
|
|
||||||
STORE ra, 0(sp)
|
|
||||||
call board_init
|
|
||||||
LOAD ra, 0(sp)
|
|
||||||
addi sp, sp, 8
|
|
||||||
la t0, trap_entry
|
|
||||||
csrw mtvec, t0
|
|
||||||
ret
|
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
|
||||||
|
#include "board.h"
|
||||||
|
#include "csr.h"
|
||||||
|
#include "hwtimer.h"
|
||||||
|
#include "riscv-traps.h"
|
||||||
|
#include "tx_port.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
extern CHAR __heap_start;
|
||||||
|
extern void trap_entry(void);
|
||||||
|
extern void _tx_timer_interrupt(void);
|
||||||
|
|
||||||
|
extern ULONG* _tx_thread_system_stack_ptr;
|
||||||
|
extern ULONG* _tx_initialize_unused_memory;
|
||||||
|
|
||||||
|
void handle_RISCV_INT_MTI(void)
|
||||||
|
{
|
||||||
|
hwtimer_handler();
|
||||||
|
_tx_timer_interrupt();
|
||||||
|
}
|
||||||
|
void handle_RISCV_INT_MEI()
|
||||||
|
{
|
||||||
|
puts("[INTERRUPT]: handler ext irq error!\n");
|
||||||
|
while (1)
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID _tx_initialize_low_level(VOID)
|
||||||
|
{
|
||||||
|
_tx_thread_system_stack_ptr = (VOID*)(ULONG)riscv_get_sp();
|
||||||
|
_tx_initialize_unused_memory = (VOID*)&__heap_start;
|
||||||
|
|
||||||
|
// disable interrupts
|
||||||
|
asm volatile("csrrc zero, mstatus, %0" : : "r"(MSTATUS_MIE));
|
||||||
|
// set previous interrupt enable and previous priv mode to be set when executing "mret"
|
||||||
|
asm volatile("csrrs zero, mstatus, %0" : : "r"(MSTATUS_MPP_M | MSTATUS_MPIE));
|
||||||
|
// enable timer, software and external interrupts
|
||||||
|
asm volatile("csrrs zero, mie, %0" : : "r"(MIE_MTIE | MIE_MSIE | MIE_MEIE));
|
||||||
|
|
||||||
|
#ifdef __riscv_flen
|
||||||
|
// enable f extension and reset state
|
||||||
|
asm volatile("csrrs zero, mstatus, %0" : : "r"(MSTATUS_FS));
|
||||||
|
asm volatile("fscsr x0");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
board_init();
|
||||||
|
register_irq_handler(RISCV_INT_MTI, handle_RISCV_INT_MTI);
|
||||||
|
register_irq_handler(RISCV_INT_MEI, handle_RISCV_INT_MEI);
|
||||||
|
|
||||||
|
asm volatile("csrw mtvec, %0" : : "r"((uintptr_t)trap_entry));
|
||||||
|
}
|
||||||
@@ -10,8 +10,16 @@ set(THREADX_SMP_CUSTOM_INC
|
|||||||
${CMAKE_CURRENT_SOURCE_DIR}/inc
|
${CMAKE_CURRENT_SOURCE_DIR}/inc
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/../moonlight/inc # needed for Moonlight SMP support headers
|
${CMAKE_CURRENT_SOURCE_DIR}/../moonlight/inc # needed for Moonlight SMP support headers
|
||||||
)
|
)
|
||||||
|
|
||||||
|
#required for tests to hook into the ISR path
|
||||||
|
if(NOT DEFINED THREADX_LOW_LEVEL_INIT_SOURCE)
|
||||||
|
set(THREADX_LOW_LEVEL_INIT_SOURCE
|
||||||
|
${CMAKE_CURRENT_LIST_DIR}/src/tx_initialize_low_level.c)
|
||||||
|
endif()
|
||||||
|
|
||||||
set(THREADX_SMP_CUSTOM_SRC
|
set(THREADX_SMP_CUSTOM_SRC
|
||||||
src/tx_initialize_low_level.S
|
src/trap_entry.S
|
||||||
|
${THREADX_LOW_LEVEL_INIT_SOURCE}
|
||||||
src/tx_thread_context_restore.S
|
src/tx_thread_context_restore.S
|
||||||
src/tx_thread_context_save.S
|
src/tx_thread_context_save.S
|
||||||
src/tx_thread_interrupt_control.S
|
src/tx_thread_interrupt_control.S
|
||||||
|
|||||||
+10
-85
@@ -7,12 +7,9 @@
|
|||||||
*
|
*
|
||||||
* SPDX-License-Identifier: MIT
|
* SPDX-License-Identifier: MIT
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
#include "csr.h"
|
|
||||||
#include "tx_port.h"
|
|
||||||
|
|
||||||
.section .text
|
.section .text
|
||||||
.align 4
|
.align 4
|
||||||
|
#include "tx_port.h"
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
/* */
|
/* */
|
||||||
/* FUNCTION RELEASE */
|
/* FUNCTION RELEASE */
|
||||||
@@ -73,92 +70,20 @@
|
|||||||
|
|
||||||
STORE x1, 28*REGBYTES(sp) // Store RA, 28*REGBYTES(because call will override ra [ra is a calle register in riscv])
|
STORE x1, 28*REGBYTES(sp) // Store RA, 28*REGBYTES(because call will override ra [ra is a calle register in riscv])
|
||||||
|
|
||||||
call _tx_thread_context_save
|
call _tx_thread_context_save
|
||||||
|
|
||||||
csrr a0, mcause
|
csrr a0, mcause
|
||||||
csrr a1, mepc
|
csrr a1, mepc
|
||||||
csrr a2, mtval
|
csrr a2, mtval
|
||||||
addi sp, sp, -8
|
addi sp, sp, -8
|
||||||
STORE ra, 0(sp)
|
STORE ra, 0(sp)
|
||||||
call trap_handler
|
call trap_handler
|
||||||
LOAD ra, 0(sp)
|
LOAD ra, 0(sp)
|
||||||
addi sp, sp, 8
|
addi sp, sp, 8
|
||||||
call _tx_thread_context_restore
|
call _tx_thread_context_restore
|
||||||
// it will nerver return
|
// it will nerver return
|
||||||
.weak trap_handler
|
.weak trap_handler
|
||||||
trap_handler:
|
trap_handler:
|
||||||
1:
|
1:
|
||||||
j 1b
|
j 1b
|
||||||
|
.section .text
|
||||||
.section .text
|
|
||||||
/**************************************************************************/
|
|
||||||
/* */
|
|
||||||
/* FUNCTION RELEASE */
|
|
||||||
/* */
|
|
||||||
/* _tx_initialize_low_level RISC-V64/GNU */
|
|
||||||
/* 6.2.1 */
|
|
||||||
/* AUTHOR */
|
|
||||||
/* */
|
|
||||||
/* Scott Larson, Microsoft Corporation */
|
|
||||||
/* */
|
|
||||||
/* DESCRIPTION */
|
|
||||||
/* */
|
|
||||||
/* This function is responsible for any low-level processor */
|
|
||||||
/* initialization, including setting up interrupt vectors, setting */
|
|
||||||
/* up a periodic timer interrupt source, saving the system stack */
|
|
||||||
/* pointer for use in ISR processing later, and finding the first */
|
|
||||||
/* available RAM memory address for tx_application_define. */
|
|
||||||
/* */
|
|
||||||
/* INPUT */
|
|
||||||
/* */
|
|
||||||
/* None */
|
|
||||||
/* */
|
|
||||||
/* OUTPUT */
|
|
||||||
/* */
|
|
||||||
/* None */
|
|
||||||
/* */
|
|
||||||
/* CALLS */
|
|
||||||
/* */
|
|
||||||
/* None */
|
|
||||||
/* */
|
|
||||||
/* CALLED BY */
|
|
||||||
/* */
|
|
||||||
/* _tx_initialize_kernel_enter ThreadX entry function */
|
|
||||||
/* */
|
|
||||||
/* RELEASE HISTORY */
|
|
||||||
/* */
|
|
||||||
/* DATE NAME DESCRIPTION */
|
|
||||||
/* */
|
|
||||||
/* 03-08-2023 Scott Larson Initial Version 6.2.1 */
|
|
||||||
/* */
|
|
||||||
/**************************************************************************/
|
|
||||||
/* VOID _tx_initialize_low_level(VOID)
|
|
||||||
*/
|
|
||||||
.global _tx_initialize_low_level
|
|
||||||
.weak _tx_initialize_low_level
|
|
||||||
.extern __heap_start
|
|
||||||
.extern board_init
|
|
||||||
_tx_initialize_low_level:
|
|
||||||
STORE sp, _tx_thread_system_stack_ptr, t0 // Save system stack pointer
|
|
||||||
|
|
||||||
la t0, __heap_start // Pickup first free address
|
|
||||||
STORE t0, _tx_initialize_unused_memory, t1 // Save unused memory address
|
|
||||||
li t0, MSTATUS_MIE
|
|
||||||
csrrc zero, mstatus, t0 // clear MSTATUS_MIE bit
|
|
||||||
li t0, (MSTATUS_MPP_M | MSTATUS_MPIE )
|
|
||||||
csrrs zero, mstatus, t0 // set MSTATUS_MPP, MPIE bit
|
|
||||||
li t0, (MIE_MTIE | MIE_MSIE | MIE_MEIE)
|
|
||||||
csrrs zero, mie, t0 // set mie
|
|
||||||
#ifdef __riscv_flen
|
|
||||||
li t0, MSTATUS_FS
|
|
||||||
csrrs zero, mstatus, t0 // set MSTATUS_FS bit to open f/d isa in riscv
|
|
||||||
fscsr x0
|
|
||||||
#endif
|
|
||||||
addi sp, sp, -8
|
|
||||||
STORE ra, 0(sp)
|
|
||||||
call board_init
|
|
||||||
LOAD ra, 0(sp)
|
|
||||||
addi sp, sp, 8
|
|
||||||
la t0, trap_entry
|
|
||||||
csrw mtvec, t0
|
|
||||||
ret
|
|
||||||
@@ -0,0 +1,113 @@
|
|||||||
|
|
||||||
|
#include "aclint.h"
|
||||||
|
#include "aclint_ipi.h"
|
||||||
|
#include "board.h"
|
||||||
|
#include "csr.h"
|
||||||
|
#include "hwtimer.h"
|
||||||
|
#include "riscv-csr.h"
|
||||||
|
#include "riscv-traps.h"
|
||||||
|
#include "tx_port.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
extern CHAR __heap_start;
|
||||||
|
extern void trap_entry(void);
|
||||||
|
extern void _tx_timer_interrupt(void);
|
||||||
|
|
||||||
|
extern ULONG* _tx_thread_system_stack_ptr;
|
||||||
|
extern ULONG* _tx_initialize_unused_memory;
|
||||||
|
extern void _tx_thread_smp_initialize_wait(void) __attribute__((noreturn));
|
||||||
|
|
||||||
|
void handle_RISCV_INT_MTI(void)
|
||||||
|
{
|
||||||
|
hwtimer_handler();
|
||||||
|
_tx_timer_interrupt();
|
||||||
|
}
|
||||||
|
|
||||||
|
void handle_RISCV_INT_MEI()
|
||||||
|
{
|
||||||
|
puts("[INTERRUPT]: handler ext irq error!\n");
|
||||||
|
while (1)
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef TX_THREAD_SMP_INTER_CORE_INTERRUPT
|
||||||
|
void handle_RISCV_INT_MSI()
|
||||||
|
{
|
||||||
|
set_aclint_msip(aclint, csr_read_mhartid(), 0);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static void __attribute__((used)) bootup_ipi_clear_handler(void)
|
||||||
|
{
|
||||||
|
set_aclint_msip(aclint, csr_read_mhartid(), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _secondary_ipi_trap(void) __attribute__((naked, noreturn, section(".text.boot")));
|
||||||
|
void _secondary_initialize(void) __attribute__((noreturn, section(".text.boot")));
|
||||||
|
void bootup_wake_secondary_cores(void);
|
||||||
|
|
||||||
|
void _secondary_initialize(void)
|
||||||
|
{
|
||||||
|
csr_write_mtvec((uint_xlen_t)_secondary_ipi_trap);
|
||||||
|
csr_set_bits_mie(MIE_MSI_BIT_MASK);
|
||||||
|
csr_set_bits_mstatus(MSTATUS_MIE_BIT_MASK);
|
||||||
|
|
||||||
|
__asm__ volatile("wfi");
|
||||||
|
|
||||||
|
csr_clr_bits_mstatus(MSTATUS_MIE_BIT_MASK);
|
||||||
|
|
||||||
|
_tx_thread_smp_initialize_wait();
|
||||||
|
}
|
||||||
|
|
||||||
|
void _secondary_ipi_trap(void)
|
||||||
|
{
|
||||||
|
#if __riscv_xlen == 64
|
||||||
|
__asm__ volatile("addi sp, sp, -16;"
|
||||||
|
"sd ra, 8(sp);"
|
||||||
|
"call bootup_ipi_clear_handler;"
|
||||||
|
"ld ra, 8(sp);"
|
||||||
|
"addi sp, sp, 16;"
|
||||||
|
"mret");
|
||||||
|
#else
|
||||||
|
__asm__ volatile("addi sp, sp, -8;"
|
||||||
|
"sw ra, 4(sp);"
|
||||||
|
"call bootup_ipi_clear_handler;"
|
||||||
|
"lw ra, 4(sp);"
|
||||||
|
"addi sp, sp, 8;"
|
||||||
|
"mret");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void bootup_wake_secondary_cores(void)
|
||||||
|
{
|
||||||
|
for (UINT core = 1; core < TX_THREAD_SMP_MAX_CORES; ++core) {
|
||||||
|
send_ipi(core);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID _tx_initialize_low_level(VOID)
|
||||||
|
{
|
||||||
|
_tx_thread_system_stack_ptr = (VOID*)(ULONG)riscv_get_sp();
|
||||||
|
_tx_initialize_unused_memory = (VOID*)&__heap_start;
|
||||||
|
|
||||||
|
// disable interrupts
|
||||||
|
asm volatile("csrrc zero, mstatus, %0" : : "r"(MSTATUS_MIE));
|
||||||
|
// set previous interrupt enable and previous priv mode to be set when executing "mret"
|
||||||
|
asm volatile("csrrs zero, mstatus, %0" : : "r"(MSTATUS_MPP_M | MSTATUS_MPIE));
|
||||||
|
// enable timer, software and external interrupts
|
||||||
|
asm volatile("csrrs zero, mie, %0" : : "r"(MIE_MTIE | MIE_MSIE | MIE_MEIE));
|
||||||
|
|
||||||
|
#ifdef __riscv_flen
|
||||||
|
// enable f extension and reset state
|
||||||
|
asm volatile("csrrs zero, mstatus, %0" : : "r"(MSTATUS_FS));
|
||||||
|
asm volatile("fscsr x0");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
board_init();
|
||||||
|
register_irq_handler(RISCV_INT_MTI, handle_RISCV_INT_MTI);
|
||||||
|
register_irq_handler(RISCV_INT_MEI, handle_RISCV_INT_MEI);
|
||||||
|
#ifdef TX_THREAD_SMP_INTER_CORE_INTERRUPT
|
||||||
|
register_irq_handler(RISCV_INT_MSI, handle_RISCV_INT_MSI);
|
||||||
|
#endif
|
||||||
|
asm volatile("csrw mtvec, %0" : : "r"((uintptr_t)trap_entry));
|
||||||
|
}
|
||||||
+4
-4
@@ -137,11 +137,11 @@ void thread_0_entry(ULONG thread_input)
|
|||||||
|
|
||||||
UINT status;
|
UINT status;
|
||||||
NX_PACKET* my_packet;
|
NX_PACKET* my_packet;
|
||||||
ULONG length;
|
UINT32 length;
|
||||||
|
|
||||||
NXD_ADDRESS server_ipv4_address;
|
NXD_ADDRESS server_ipv4_address;
|
||||||
NXD_ADDRESS peer_address;
|
NXD_ADDRESS peer_address;
|
||||||
ULONG peer_port;
|
UINT32 peer_port;
|
||||||
|
|
||||||
NX_PARAMETER_NOT_USED(thread_input);
|
NX_PARAMETER_NOT_USED(thread_input);
|
||||||
|
|
||||||
@@ -259,7 +259,7 @@ void thread_1_entry(ULONG thread_input)
|
|||||||
|
|
||||||
UINT status;
|
UINT status;
|
||||||
NX_PACKET* packet_ptr;
|
NX_PACKET* packet_ptr;
|
||||||
ULONG actual_status;
|
UINT32 actual_status;
|
||||||
|
|
||||||
NX_PARAMETER_NOT_USED(thread_input);
|
NX_PARAMETER_NOT_USED(thread_input);
|
||||||
|
|
||||||
@@ -331,7 +331,7 @@ void thread_1_entry(ULONG thread_input)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
char buffer[64];
|
char buffer[64];
|
||||||
ULONG size;
|
UINT32 size;
|
||||||
nx_packet_data_extract_offset(packet_ptr, 0, buffer, 64, &size);
|
nx_packet_data_extract_offset(packet_ptr, 0, buffer, 64, &size);
|
||||||
buffer[size] = 0;
|
buffer[size] = 0;
|
||||||
printf("Received packet %lu with %s\n", thread_1_counter, buffer);
|
printf("Received packet %lu with %s\n", thread_1_counter, buffer);
|
||||||
|
|||||||
@@ -184,6 +184,9 @@ void tx_application_define(void* first_unused_memory)
|
|||||||
|
|
||||||
/* Release the block back to the pool. */
|
/* Release the block back to the pool. */
|
||||||
tx_block_release(pointer);
|
tx_block_release(pointer);
|
||||||
|
|
||||||
|
/* Enable tracing */
|
||||||
|
tx_trace_enable((void*)0x31000000, 0x100000, 256);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Define the test threads. */
|
/* Define the test threads. */
|
||||||
|
|||||||
+18
-28
@@ -37,32 +37,32 @@ set(__THREAD_LOCAL_STORAGE OFF)
|
|||||||
add_subdirectory(${THREADX4TGFS_ROOT}/third-party/picolibc ${CMAKE_BINARY_DIR}/picolibc)
|
add_subdirectory(${THREADX4TGFS_ROOT}/third-party/picolibc ${CMAKE_BINARY_DIR}/picolibc)
|
||||||
target_link_libraries(c PUBLIC gcc)
|
target_link_libraries(c PUBLIC gcc)
|
||||||
|
|
||||||
add_subdirectory(${THREADX4TGFS_ROOT}/port/threadx_smp ${CMAKE_BINARY_DIR}/port/threadx_smp)
|
set(THREADX_LOW_LEVEL_INIT_SOURCE_INPUT
|
||||||
target_link_libraries(threadx_smp PUBLIC c)
|
${THREADX4TGFS_ROOT}/port/threadx_smp/src/tx_initialize_low_level.c)
|
||||||
target_compile_definitions(threadx_smp PUBLIC TX_REGRESSION_TEST TX_THREAD_SMP_ONLY_CORE_0_DEFAULT TX_SMP_NOT_POSSIBLE)
|
set(THREADX_LOW_LEVEL_INIT_SOURCE
|
||||||
|
${CMAKE_BINARY_DIR}/generated/tx_initialize_low_level.c)
|
||||||
set(MOONLIGHT_TRAP_SOURCE_INPUT ${THREADX4TGFS_ROOT}/port/moonlight/src/trap_non_vectored.c)
|
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS
|
||||||
set(MOONLIGHT_TRAP_SOURCE ${CMAKE_BINARY_DIR}/generated/trap_non_vectored.c)
|
${THREADX_LOW_LEVEL_INIT_SOURCE_INPUT}
|
||||||
add_custom_command(
|
${THREADX4TGFS_ROOT}/test/threadx/generate_trap_file.sh)
|
||||||
OUTPUT ${MOONLIGHT_TRAP_SOURCE}
|
execute_process(
|
||||||
COMMAND bash ${THREADX4TGFS_ROOT}/test/threadx/generate_trap_file.sh
|
COMMAND bash ${THREADX4TGFS_ROOT}/test/threadx/generate_trap_file.sh
|
||||||
${MOONLIGHT_TRAP_SOURCE_INPUT}
|
${THREADX_LOW_LEVEL_INIT_SOURCE_INPUT}
|
||||||
${MOONLIGHT_TRAP_SOURCE}
|
${THREADX_LOW_LEVEL_INIT_SOURCE}
|
||||||
DEPENDS ${MOONLIGHT_TRAP_SOURCE_INPUT}
|
RESULT_VARIABLE THREADX_LOW_LEVEL_INIT_GENERATE_RESULT
|
||||||
${THREADX4TGFS_ROOT}/test/threadx/generate_trap_file.sh
|
COMMAND_ERROR_IS_FATAL ANY
|
||||||
VERBATIM
|
|
||||||
)
|
)
|
||||||
add_custom_target(threadx_regression_generated_trap DEPENDS ${MOONLIGHT_TRAP_SOURCE})
|
|
||||||
set_source_files_properties(${MOONLIGHT_TRAP_SOURCE} PROPERTIES GENERATED TRUE)
|
|
||||||
|
|
||||||
add_subdirectory(${THREADX4TGFS_ROOT}/port/moonlight ${CMAKE_BINARY_DIR}/port/moonlight)
|
add_subdirectory(${THREADX4TGFS_ROOT}/port/moonlight ${CMAKE_BINARY_DIR}/port/moonlight)
|
||||||
add_dependencies(moonlight_platform_common_smp threadx_regression_generated_trap)
|
target_sources(c PRIVATE ${THREADX4TGFS_ROOT}/port/picolibc/port.c)
|
||||||
|
target_link_libraries(c PUBLIC moonlight gcc)
|
||||||
|
add_subdirectory(${THREADX4TGFS_ROOT}/port/threadx_smp ${CMAKE_BINARY_DIR}/port/threadx_smp)
|
||||||
|
target_link_libraries(threadx_smp PUBLIC moonlight c)
|
||||||
|
target_compile_definitions(threadx_smp PUBLIC TX_REGRESSION_TEST TX_THREAD_SMP_ONLY_CORE_0_DEFAULT TX_SMP_NOT_POSSIBLE)
|
||||||
|
|
||||||
function(setup_target TARGET)
|
function(setup_target TARGET)
|
||||||
set(options)
|
set(options)
|
||||||
set(oneValueArgs PLATFORM_TARGET)
|
|
||||||
set(multiValueArgs LIBRARIES SOURCES)
|
set(multiValueArgs LIBRARIES SOURCES)
|
||||||
cmake_parse_arguments(ST "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
cmake_parse_arguments(ST "${options}" "" "${multiValueArgs}" ${ARGN})
|
||||||
if(ST_UNPARSED_ARGUMENTS)
|
if(ST_UNPARSED_ARGUMENTS)
|
||||||
message(FATAL_ERROR "setup_target(${TARGET} ...): unknown args: ${ST_UNPARSED_ARGUMENTS}")
|
message(FATAL_ERROR "setup_target(${TARGET} ...): unknown args: ${ST_UNPARSED_ARGUMENTS}")
|
||||||
endif()
|
endif()
|
||||||
@@ -71,11 +71,6 @@ function(setup_target TARGET)
|
|||||||
set_target_properties(${TARGET} PROPERTIES
|
set_target_properties(${TARGET} PROPERTIES
|
||||||
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}
|
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||||
)
|
)
|
||||||
if(ST_PLATFORM_TARGET)
|
|
||||||
target_add_moonlight_platform(${TARGET} PLATFORM_TARGET ${ST_PLATFORM_TARGET})
|
|
||||||
else()
|
|
||||||
target_add_moonlight_platform(${TARGET})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(ST_SOURCES)
|
if(ST_SOURCES)
|
||||||
target_sources(${TARGET} PRIVATE ${ST_SOURCES})
|
target_sources(${TARGET} PRIVATE ${ST_SOURCES})
|
||||||
@@ -86,10 +81,6 @@ function(setup_target TARGET)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_link_options(${TARGET} PRIVATE
|
target_link_options(${TARGET} PRIVATE
|
||||||
-nostartfiles
|
|
||||||
-nostdlib
|
|
||||||
-T ${THREADX4TGFS_ROOT}/src/${TARGET_MEM}.lds
|
|
||||||
-Wl,--gc-sections
|
|
||||||
-Wl,-Map=${CMAKE_BINARY_DIR}/${TARGET}.map)
|
-Wl,-Map=${CMAKE_BINARY_DIR}/${TARGET}.map)
|
||||||
|
|
||||||
add_custom_command(TARGET ${TARGET} POST_BUILD
|
add_custom_command(TARGET ${TARGET} POST_BUILD
|
||||||
@@ -246,7 +237,6 @@ function(add_threadx_regression_test TEST_SOURCE)
|
|||||||
|
|
||||||
setup_target(
|
setup_target(
|
||||||
${TEST_NAME}
|
${TEST_NAME}
|
||||||
PLATFORM_TARGET moonlight_platform_common_smp
|
|
||||||
LIBRARIES ${test_libraries}
|
LIBRARIES ${test_libraries}
|
||||||
SOURCES ${TEST_SOURCE}
|
SOURCES ${TEST_SOURCE}
|
||||||
)
|
)
|
||||||
|
|||||||
+151
-159
@@ -37,33 +37,34 @@ set(__THREAD_LOCAL_STORAGE OFF)
|
|||||||
add_subdirectory(${THREADX4TGFS_ROOT}/third-party/picolibc ${CMAKE_BINARY_DIR}/picolibc)
|
add_subdirectory(${THREADX4TGFS_ROOT}/third-party/picolibc ${CMAKE_BINARY_DIR}/picolibc)
|
||||||
target_link_libraries(c PUBLIC gcc)
|
target_link_libraries(c PUBLIC gcc)
|
||||||
|
|
||||||
set(THREADX_CUSTOM_PORT ${THREADX4TGFS_ROOT}/port/threadx)
|
set(THREADX_LOW_LEVEL_INIT_SOURCE_INPUT
|
||||||
add_subdirectory(${THREADX4TGFS_ROOT}/third-party/threadx ${CMAKE_BINARY_DIR}/threadx)
|
${THREADX4TGFS_ROOT}/port/threadx/src/tx_initialize_low_level.c)
|
||||||
target_link_libraries(threadx PUBLIC c)
|
set(THREADX_LOW_LEVEL_INIT_SOURCE
|
||||||
target_compile_definitions(threadx PUBLIC TX_REGRESSION_TEST)
|
${CMAKE_BINARY_DIR}/generated/tx_initialize_low_level.c)
|
||||||
|
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS
|
||||||
set(MOONLIGHT_TRAP_SOURCE_INPUT ${THREADX4TGFS_ROOT}/port/moonlight/src/trap_non_vectored.c)
|
${THREADX_LOW_LEVEL_INIT_SOURCE_INPUT}
|
||||||
set(MOONLIGHT_TRAP_SOURCE ${CMAKE_BINARY_DIR}/generated/trap_non_vectored.c)
|
${CMAKE_CURRENT_LIST_DIR}/generate_trap_file.sh)
|
||||||
add_custom_command(
|
execute_process(
|
||||||
OUTPUT ${MOONLIGHT_TRAP_SOURCE}
|
|
||||||
COMMAND bash ${CMAKE_CURRENT_LIST_DIR}/generate_trap_file.sh
|
COMMAND bash ${CMAKE_CURRENT_LIST_DIR}/generate_trap_file.sh
|
||||||
${MOONLIGHT_TRAP_SOURCE_INPUT}
|
${THREADX_LOW_LEVEL_INIT_SOURCE_INPUT}
|
||||||
${MOONLIGHT_TRAP_SOURCE}
|
${THREADX_LOW_LEVEL_INIT_SOURCE}
|
||||||
DEPENDS ${MOONLIGHT_TRAP_SOURCE_INPUT}
|
RESULT_VARIABLE THREADX_LOW_LEVEL_INIT_GENERATE_RESULT
|
||||||
${CMAKE_CURRENT_LIST_DIR}/generate_trap_file.sh
|
COMMAND_ERROR_IS_FATAL ANY
|
||||||
VERBATIM
|
|
||||||
)
|
)
|
||||||
add_custom_target(threadx_regression_generated_trap DEPENDS ${MOONLIGHT_TRAP_SOURCE})
|
|
||||||
set_source_files_properties(${MOONLIGHT_TRAP_SOURCE} PROPERTIES GENERATED TRUE)
|
|
||||||
|
|
||||||
add_subdirectory(${THREADX4TGFS_ROOT}/port/moonlight ${CMAKE_BINARY_DIR}/port/moonlight)
|
add_subdirectory(${THREADX4TGFS_ROOT}/port/moonlight ${CMAKE_BINARY_DIR}/port/moonlight)
|
||||||
add_dependencies(moonlight_platform_common threadx_regression_generated_trap)
|
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)
|
||||||
|
target_compile_definitions(threadx PUBLIC TX_REGRESSION_TEST)
|
||||||
|
|
||||||
function(setup_target TARGET)
|
function(setup_target TARGET)
|
||||||
set(options)
|
set(options)
|
||||||
set(oneValueArgs PLATFORM_TARGET)
|
|
||||||
set(multiValueArgs LIBRARIES SOURCES)
|
set(multiValueArgs LIBRARIES SOURCES)
|
||||||
cmake_parse_arguments(ST "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
cmake_parse_arguments(ST "${options}" "" "${multiValueArgs}" ${ARGN})
|
||||||
if(ST_UNPARSED_ARGUMENTS)
|
if(ST_UNPARSED_ARGUMENTS)
|
||||||
message(FATAL_ERROR "setup_target(${TARGET} ...): unknown args: ${ST_UNPARSED_ARGUMENTS}")
|
message(FATAL_ERROR "setup_target(${TARGET} ...): unknown args: ${ST_UNPARSED_ARGUMENTS}")
|
||||||
endif()
|
endif()
|
||||||
@@ -72,11 +73,6 @@ function(setup_target TARGET)
|
|||||||
set_target_properties(${TARGET} PROPERTIES
|
set_target_properties(${TARGET} PROPERTIES
|
||||||
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}
|
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||||
)
|
)
|
||||||
if(ST_PLATFORM_TARGET)
|
|
||||||
target_add_moonlight_platform(${TARGET} PLATFORM_TARGET ${ST_PLATFORM_TARGET})
|
|
||||||
else()
|
|
||||||
target_add_moonlight_platform(${TARGET})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(ST_SOURCES)
|
if(ST_SOURCES)
|
||||||
target_sources(${TARGET} PRIVATE ${ST_SOURCES})
|
target_sources(${TARGET} PRIVATE ${ST_SOURCES})
|
||||||
@@ -87,10 +83,6 @@ function(setup_target TARGET)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_link_options(${TARGET} PRIVATE
|
target_link_options(${TARGET} PRIVATE
|
||||||
-nostartfiles
|
|
||||||
-nostdlib
|
|
||||||
-T ${THREADX4TGFS_ROOT}/src/${TARGET_MEM}.lds
|
|
||||||
-Wl,--gc-sections
|
|
||||||
-Wl,-Map=${CMAKE_BINARY_DIR}/${TARGET}.map)
|
-Wl,-Map=${CMAKE_BINARY_DIR}/${TARGET}.map)
|
||||||
|
|
||||||
add_custom_command(TARGET ${TARGET} POST_BUILD
|
add_custom_command(TARGET ${TARGET} POST_BUILD
|
||||||
@@ -101,161 +93,161 @@ function(setup_target TARGET)
|
|||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
set(TX_REGRESSION_DIR
|
set(TX_REGRESSION_DIR
|
||||||
${THREADX4TGFS_ROOT}/third-party/threadx/test/tx/regression
|
${THREADX4TGFS_ROOT}/third-party/threadx/test/tx/regression
|
||||||
)
|
)
|
||||||
set(TX_CMAKE_DIR
|
set(TX_CMAKE_DIR
|
||||||
${THREADX4TGFS_ROOT}/third-party/threadx/test/tx/cmake
|
${THREADX4TGFS_ROOT}/third-party/threadx/test/tx/cmake
|
||||||
)
|
)
|
||||||
|
|
||||||
set(TX_REGRESSION_CASES
|
set(TX_REGRESSION_CASES
|
||||||
${TX_REGRESSION_DIR}/threadx_block_memory_basic_test.c
|
${TX_REGRESSION_DIR}/threadx_block_memory_basic_test.c
|
||||||
${TX_REGRESSION_DIR}/threadx_block_memory_error_detection_test.c
|
${TX_REGRESSION_DIR}/threadx_block_memory_error_detection_test.c
|
||||||
${TX_REGRESSION_DIR}/threadx_block_memory_information_test.c
|
${TX_REGRESSION_DIR}/threadx_block_memory_information_test.c
|
||||||
${TX_REGRESSION_DIR}/threadx_block_memory_prioritize_test.c
|
${TX_REGRESSION_DIR}/threadx_block_memory_prioritize_test.c
|
||||||
${TX_REGRESSION_DIR}/threadx_block_memory_suspension_test.c
|
${TX_REGRESSION_DIR}/threadx_block_memory_suspension_test.c
|
||||||
${TX_REGRESSION_DIR}/threadx_block_memory_suspension_timeout_test.c
|
${TX_REGRESSION_DIR}/threadx_block_memory_suspension_timeout_test.c
|
||||||
${TX_REGRESSION_DIR}/threadx_block_memory_thread_terminate_test.c
|
${TX_REGRESSION_DIR}/threadx_block_memory_thread_terminate_test.c
|
||||||
${TX_REGRESSION_DIR}/threadx_byte_memory_basic_test.c
|
${TX_REGRESSION_DIR}/threadx_byte_memory_basic_test.c
|
||||||
${TX_REGRESSION_DIR}/threadx_byte_memory_information_test.c
|
${TX_REGRESSION_DIR}/threadx_byte_memory_information_test.c
|
||||||
${TX_REGRESSION_DIR}/threadx_byte_memory_prioritize_test.c
|
${TX_REGRESSION_DIR}/threadx_byte_memory_prioritize_test.c
|
||||||
${TX_REGRESSION_DIR}/threadx_byte_memory_suspension_test.c
|
${TX_REGRESSION_DIR}/threadx_byte_memory_suspension_test.c
|
||||||
${TX_REGRESSION_DIR}/threadx_byte_memory_suspension_timeout_test.c
|
${TX_REGRESSION_DIR}/threadx_byte_memory_suspension_timeout_test.c
|
||||||
${TX_REGRESSION_DIR}/threadx_byte_memory_thread_contention_test.c
|
${TX_REGRESSION_DIR}/threadx_byte_memory_thread_contention_test.c
|
||||||
${TX_REGRESSION_DIR}/threadx_byte_memory_thread_terminate_test.c
|
${TX_REGRESSION_DIR}/threadx_byte_memory_thread_terminate_test.c
|
||||||
${TX_REGRESSION_DIR}/threadx_event_flag_basic_test.c
|
${TX_REGRESSION_DIR}/threadx_event_flag_basic_test.c
|
||||||
${TX_REGRESSION_DIR}/threadx_event_flag_information_test.c
|
${TX_REGRESSION_DIR}/threadx_event_flag_information_test.c
|
||||||
${TX_REGRESSION_DIR}/threadx_event_flag_isr_set_clear_test.c
|
${TX_REGRESSION_DIR}/threadx_event_flag_isr_set_clear_test.c
|
||||||
${TX_REGRESSION_DIR}/threadx_event_flag_isr_wait_abort_test.c
|
${TX_REGRESSION_DIR}/threadx_event_flag_isr_wait_abort_test.c
|
||||||
${TX_REGRESSION_DIR}/threadx_event_flag_single_thread_terminate_test.c
|
${TX_REGRESSION_DIR}/threadx_event_flag_single_thread_terminate_test.c
|
||||||
${TX_REGRESSION_DIR}/threadx_event_flag_suspension_consume_test.c
|
${TX_REGRESSION_DIR}/threadx_event_flag_suspension_consume_test.c
|
||||||
${TX_REGRESSION_DIR}/threadx_event_flag_suspension_different_bits_consume_test.c
|
${TX_REGRESSION_DIR}/threadx_event_flag_suspension_different_bits_consume_test.c
|
||||||
${TX_REGRESSION_DIR}/threadx_event_flag_suspension_different_bits_test.c
|
${TX_REGRESSION_DIR}/threadx_event_flag_suspension_different_bits_test.c
|
||||||
${TX_REGRESSION_DIR}/threadx_event_flag_suspension_test.c
|
${TX_REGRESSION_DIR}/threadx_event_flag_suspension_test.c
|
||||||
${TX_REGRESSION_DIR}/threadx_event_flag_suspension_timeout_test.c
|
${TX_REGRESSION_DIR}/threadx_event_flag_suspension_timeout_test.c
|
||||||
${TX_REGRESSION_DIR}/threadx_event_flag_thread_terminate_test.c
|
${TX_REGRESSION_DIR}/threadx_event_flag_thread_terminate_test.c
|
||||||
${TX_REGRESSION_DIR}/threadx_interrupt_control_test.c
|
${TX_REGRESSION_DIR}/threadx_interrupt_control_test.c
|
||||||
${TX_REGRESSION_DIR}/threadx_mutex_basic_test.c
|
${TX_REGRESSION_DIR}/threadx_mutex_basic_test.c
|
||||||
${TX_REGRESSION_DIR}/threadx_mutex_delete_test.c
|
${TX_REGRESSION_DIR}/threadx_mutex_delete_test.c
|
||||||
${TX_REGRESSION_DIR}/threadx_mutex_information_test.c
|
${TX_REGRESSION_DIR}/threadx_mutex_information_test.c
|
||||||
${TX_REGRESSION_DIR}/threadx_mutex_nested_priority_inheritance_test.c
|
${TX_REGRESSION_DIR}/threadx_mutex_nested_priority_inheritance_test.c
|
||||||
${TX_REGRESSION_DIR}/threadx_mutex_no_preemption_test.c
|
${TX_REGRESSION_DIR}/threadx_mutex_no_preemption_test.c
|
||||||
${TX_REGRESSION_DIR}/threadx_mutex_preemption_test.c
|
${TX_REGRESSION_DIR}/threadx_mutex_preemption_test.c
|
||||||
${TX_REGRESSION_DIR}/threadx_mutex_priority_inheritance_test.c
|
${TX_REGRESSION_DIR}/threadx_mutex_priority_inheritance_test.c
|
||||||
${TX_REGRESSION_DIR}/threadx_mutex_proritize_test.c
|
${TX_REGRESSION_DIR}/threadx_mutex_proritize_test.c
|
||||||
${TX_REGRESSION_DIR}/threadx_mutex_suspension_timeout_test.c
|
${TX_REGRESSION_DIR}/threadx_mutex_suspension_timeout_test.c
|
||||||
${TX_REGRESSION_DIR}/threadx_mutex_thread_terminate_test.c
|
${TX_REGRESSION_DIR}/threadx_mutex_thread_terminate_test.c
|
||||||
${TX_REGRESSION_DIR}/threadx_queue_basic_eight_word_test.c
|
${TX_REGRESSION_DIR}/threadx_queue_basic_eight_word_test.c
|
||||||
${TX_REGRESSION_DIR}/threadx_queue_basic_four_word_test.c
|
${TX_REGRESSION_DIR}/threadx_queue_basic_four_word_test.c
|
||||||
${TX_REGRESSION_DIR}/threadx_queue_basic_one_word_test.c
|
${TX_REGRESSION_DIR}/threadx_queue_basic_one_word_test.c
|
||||||
${TX_REGRESSION_DIR}/threadx_queue_basic_sixteen_word_test.c
|
${TX_REGRESSION_DIR}/threadx_queue_basic_sixteen_word_test.c
|
||||||
${TX_REGRESSION_DIR}/threadx_queue_basic_two_word_test.c
|
${TX_REGRESSION_DIR}/threadx_queue_basic_two_word_test.c
|
||||||
${TX_REGRESSION_DIR}/threadx_queue_basic_max_message_size_test.c
|
${TX_REGRESSION_DIR}/threadx_queue_basic_max_message_size_test.c
|
||||||
${TX_REGRESSION_DIR}/threadx_queue_empty_suspension_test.c
|
${TX_REGRESSION_DIR}/threadx_queue_empty_suspension_test.c
|
||||||
${TX_REGRESSION_DIR}/threadx_queue_flush_no_suspension_test.c
|
${TX_REGRESSION_DIR}/threadx_queue_flush_no_suspension_test.c
|
||||||
${TX_REGRESSION_DIR}/threadx_queue_flush_test.c
|
${TX_REGRESSION_DIR}/threadx_queue_flush_test.c
|
||||||
${TX_REGRESSION_DIR}/threadx_queue_front_send_test.c
|
${TX_REGRESSION_DIR}/threadx_queue_front_send_test.c
|
||||||
${TX_REGRESSION_DIR}/threadx_queue_full_suspension_test.c
|
${TX_REGRESSION_DIR}/threadx_queue_full_suspension_test.c
|
||||||
${TX_REGRESSION_DIR}/threadx_queue_information_test.c
|
${TX_REGRESSION_DIR}/threadx_queue_information_test.c
|
||||||
${TX_REGRESSION_DIR}/threadx_queue_prioritize.c
|
${TX_REGRESSION_DIR}/threadx_queue_prioritize.c
|
||||||
${TX_REGRESSION_DIR}/threadx_queue_suspension_timeout_test.c
|
${TX_REGRESSION_DIR}/threadx_queue_suspension_timeout_test.c
|
||||||
${TX_REGRESSION_DIR}/threadx_queue_thread_terminate_test.c
|
${TX_REGRESSION_DIR}/threadx_queue_thread_terminate_test.c
|
||||||
${TX_REGRESSION_DIR}/threadx_semaphore_basic_test.c
|
${TX_REGRESSION_DIR}/threadx_semaphore_basic_test.c
|
||||||
${TX_REGRESSION_DIR}/threadx_semaphore_ceiling_put_test.c
|
${TX_REGRESSION_DIR}/threadx_semaphore_ceiling_put_test.c
|
||||||
${TX_REGRESSION_DIR}/threadx_semaphore_delete_test.c
|
${TX_REGRESSION_DIR}/threadx_semaphore_delete_test.c
|
||||||
${TX_REGRESSION_DIR}/threadx_semaphore_information_test.c
|
${TX_REGRESSION_DIR}/threadx_semaphore_information_test.c
|
||||||
${TX_REGRESSION_DIR}/threadx_semaphore_non_preemption_test.c
|
${TX_REGRESSION_DIR}/threadx_semaphore_non_preemption_test.c
|
||||||
${TX_REGRESSION_DIR}/threadx_semaphore_preemption_test.c
|
${TX_REGRESSION_DIR}/threadx_semaphore_preemption_test.c
|
||||||
${TX_REGRESSION_DIR}/threadx_semaphore_prioritize.c
|
${TX_REGRESSION_DIR}/threadx_semaphore_prioritize.c
|
||||||
${TX_REGRESSION_DIR}/threadx_semaphore_thread_terminate_test.c
|
${TX_REGRESSION_DIR}/threadx_semaphore_thread_terminate_test.c
|
||||||
${TX_REGRESSION_DIR}/threadx_semaphore_timeout_test.c
|
${TX_REGRESSION_DIR}/threadx_semaphore_timeout_test.c
|
||||||
${TX_REGRESSION_DIR}/threadx_thread_basic_execution_test.c
|
${TX_REGRESSION_DIR}/threadx_thread_basic_execution_test.c
|
||||||
${TX_REGRESSION_DIR}/threadx_thread_basic_time_slice_test.c
|
${TX_REGRESSION_DIR}/threadx_thread_basic_time_slice_test.c
|
||||||
${TX_REGRESSION_DIR}/threadx_thread_completed_test.c
|
${TX_REGRESSION_DIR}/threadx_thread_completed_test.c
|
||||||
${TX_REGRESSION_DIR}/threadx_thread_create_preemption_threshold_test.c
|
${TX_REGRESSION_DIR}/threadx_thread_create_preemption_threshold_test.c
|
||||||
${TX_REGRESSION_DIR}/threadx_thread_delayed_suspension_test.c
|
${TX_REGRESSION_DIR}/threadx_thread_delayed_suspension_test.c
|
||||||
${TX_REGRESSION_DIR}/threadx_thread_information_test.c
|
${TX_REGRESSION_DIR}/threadx_thread_information_test.c
|
||||||
${TX_REGRESSION_DIR}/threadx_thread_multi_level_preemption_threshold_test.c
|
${TX_REGRESSION_DIR}/threadx_thread_multi_level_preemption_threshold_test.c
|
||||||
${TX_REGRESSION_DIR}/threadx_thread_multiple_non_current_test.c
|
${TX_REGRESSION_DIR}/threadx_thread_multiple_non_current_test.c
|
||||||
${TX_REGRESSION_DIR}/threadx_thread_multiple_sleep_test.c
|
${TX_REGRESSION_DIR}/threadx_thread_multiple_sleep_test.c
|
||||||
${TX_REGRESSION_DIR}/threadx_thread_multiple_suspension_test.c
|
${TX_REGRESSION_DIR}/threadx_thread_multiple_suspension_test.c
|
||||||
${TX_REGRESSION_DIR}/threadx_thread_multiple_time_slice_test.c
|
${TX_REGRESSION_DIR}/threadx_thread_multiple_time_slice_test.c
|
||||||
${TX_REGRESSION_DIR}/threadx_thread_preemptable_suspension_test.c
|
${TX_REGRESSION_DIR}/threadx_thread_preemptable_suspension_test.c
|
||||||
${TX_REGRESSION_DIR}/threadx_thread_preemption_change_test.c
|
${TX_REGRESSION_DIR}/threadx_thread_preemption_change_test.c
|
||||||
${TX_REGRESSION_DIR}/threadx_thread_priority_change.c
|
${TX_REGRESSION_DIR}/threadx_thread_priority_change.c
|
||||||
${TX_REGRESSION_DIR}/threadx_thread_relinquish_test.c
|
${TX_REGRESSION_DIR}/threadx_thread_relinquish_test.c
|
||||||
${TX_REGRESSION_DIR}/threadx_thread_reset_test.c
|
${TX_REGRESSION_DIR}/threadx_thread_reset_test.c
|
||||||
${TX_REGRESSION_DIR}/threadx_thread_simple_sleep_non_clear_test.c
|
${TX_REGRESSION_DIR}/threadx_thread_simple_sleep_non_clear_test.c
|
||||||
${TX_REGRESSION_DIR}/threadx_thread_simple_sleep_test.c
|
${TX_REGRESSION_DIR}/threadx_thread_simple_sleep_test.c
|
||||||
${TX_REGRESSION_DIR}/threadx_thread_simple_suspend_test.c
|
${TX_REGRESSION_DIR}/threadx_thread_simple_suspend_test.c
|
||||||
${TX_REGRESSION_DIR}/threadx_thread_sleep_for_100ticks_test.c
|
${TX_REGRESSION_DIR}/threadx_thread_sleep_for_100ticks_test.c
|
||||||
${TX_REGRESSION_DIR}/threadx_thread_sleep_terminate_test.c
|
${TX_REGRESSION_DIR}/threadx_thread_sleep_terminate_test.c
|
||||||
${TX_REGRESSION_DIR}/threadx_thread_stack_checking_test.c
|
${TX_REGRESSION_DIR}/threadx_thread_stack_checking_test.c
|
||||||
${TX_REGRESSION_DIR}/threadx_thread_terminate_delete_test.c
|
${TX_REGRESSION_DIR}/threadx_thread_terminate_delete_test.c
|
||||||
${TX_REGRESSION_DIR}/threadx_thread_time_slice_change_test.c
|
${TX_REGRESSION_DIR}/threadx_thread_time_slice_change_test.c
|
||||||
${TX_REGRESSION_DIR}/threadx_thread_wait_abort_and_isr_test.c
|
${TX_REGRESSION_DIR}/threadx_thread_wait_abort_and_isr_test.c
|
||||||
${TX_REGRESSION_DIR}/threadx_thread_wait_abort_test.c
|
${TX_REGRESSION_DIR}/threadx_thread_wait_abort_test.c
|
||||||
${TX_REGRESSION_DIR}/threadx_time_get_set_test.c
|
${TX_REGRESSION_DIR}/threadx_time_get_set_test.c
|
||||||
${TX_REGRESSION_DIR}/threadx_timer_activate_deactivate_test.c
|
${TX_REGRESSION_DIR}/threadx_timer_activate_deactivate_test.c
|
||||||
${TX_REGRESSION_DIR}/threadx_timer_deactivate_accuracy_test.c
|
${TX_REGRESSION_DIR}/threadx_timer_deactivate_accuracy_test.c
|
||||||
${TX_REGRESSION_DIR}/threadx_timer_information_test.c
|
${TX_REGRESSION_DIR}/threadx_timer_information_test.c
|
||||||
${TX_REGRESSION_DIR}/threadx_timer_large_timer_accuracy_test.c
|
${TX_REGRESSION_DIR}/threadx_timer_large_timer_accuracy_test.c
|
||||||
${TX_REGRESSION_DIR}/threadx_timer_multiple_accuracy_test.c
|
${TX_REGRESSION_DIR}/threadx_timer_multiple_accuracy_test.c
|
||||||
${TX_REGRESSION_DIR}/threadx_timer_multiple_test.c
|
${TX_REGRESSION_DIR}/threadx_timer_multiple_test.c
|
||||||
${TX_REGRESSION_DIR}/threadx_timer_simple_test.c
|
${TX_REGRESSION_DIR}/threadx_timer_simple_test.c
|
||||||
${TX_REGRESSION_DIR}/threadx_trace_basic_test.c
|
${TX_REGRESSION_DIR}/threadx_trace_basic_test.c
|
||||||
${TX_REGRESSION_DIR}/threadx_initialize_kernel_setup_test.c
|
${TX_REGRESSION_DIR}/threadx_initialize_kernel_setup_test.c
|
||||||
)
|
)
|
||||||
|
|
||||||
set(TX_REGRESSION_TARGETS)
|
set(TX_REGRESSION_TARGETS)
|
||||||
|
|
||||||
add_library(
|
add_library(
|
||||||
threadx_regression_support STATIC
|
threadx_regression_support STATIC
|
||||||
${TX_REGRESSION_DIR}/testcontrol.c
|
${TX_REGRESSION_DIR}/testcontrol.c
|
||||||
${TX_CMAKE_DIR}/samples/fake.c
|
${TX_CMAKE_DIR}/samples/fake.c
|
||||||
)
|
)
|
||||||
target_link_libraries(threadx_regression_support PUBLIC threadx c)
|
target_link_libraries(threadx_regression_support PUBLIC threadx c)
|
||||||
target_compile_definitions(
|
target_compile_definitions(
|
||||||
threadx_regression_support
|
threadx_regression_support
|
||||||
PUBLIC
|
PUBLIC
|
||||||
TX_REGRESSION_TEST
|
TX_REGRESSION_TEST
|
||||||
CTEST
|
CTEST
|
||||||
BATCH_TEST
|
BATCH_TEST
|
||||||
TEST_STACK_SIZE_PRINTF=4096
|
TEST_STACK_SIZE_PRINTF=4096
|
||||||
)
|
)
|
||||||
|
|
||||||
function(add_threadx_regression_test TEST_SOURCE)
|
function(add_threadx_regression_test TEST_SOURCE)
|
||||||
get_filename_component(TEST_NAME ${TEST_SOURCE} NAME_WE)
|
get_filename_component(TEST_NAME ${TEST_SOURCE} NAME_WE)
|
||||||
|
|
||||||
if(TEST_NAME STREQUAL "threadx_initialize_kernel_setup_test")
|
if(TEST_NAME STREQUAL "threadx_initialize_kernel_setup_test")
|
||||||
set(test_libraries threadx)
|
set(test_libraries threadx)
|
||||||
else()
|
else()
|
||||||
set(test_libraries threadx_regression_support)
|
set(test_libraries threadx_regression_support)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
setup_target(
|
setup_target(
|
||||||
${TEST_NAME}
|
${TEST_NAME}
|
||||||
LIBRARIES ${test_libraries}
|
LIBRARIES ${test_libraries}
|
||||||
SOURCES ${TEST_SOURCE}
|
SOURCES ${TEST_SOURCE}
|
||||||
)
|
)
|
||||||
|
|
||||||
list(APPEND TX_REGRESSION_TARGETS ${TEST_NAME})
|
list(APPEND TX_REGRESSION_TARGETS ${TEST_NAME})
|
||||||
set(TX_REGRESSION_TARGETS ${TX_REGRESSION_TARGETS} PARENT_SCOPE)
|
set(TX_REGRESSION_TARGETS ${TX_REGRESSION_TARGETS} PARENT_SCOPE)
|
||||||
|
|
||||||
add_test(
|
add_test(
|
||||||
NAME ${TEST_NAME}
|
NAME ${TEST_NAME}
|
||||||
COMMAND ${THREADX_TEST_SIMULATOR}
|
COMMAND ${THREADX_TEST_SIMULATOR}
|
||||||
--isa=${THREADX_TEST_ISA}
|
--isa=${THREADX_TEST_ISA}
|
||||||
-f $<TARGET_FILE:${TEST_NAME}>
|
-f $<TARGET_FILE:${TEST_NAME}>
|
||||||
-m 60s
|
-m 60s
|
||||||
)
|
)
|
||||||
set_tests_properties(${TEST_NAME} PROPERTIES TIMEOUT 60)
|
set_tests_properties(${TEST_NAME} PROPERTIES TIMEOUT 60)
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
foreach(test_case ${TX_REGRESSION_CASES})
|
foreach(test_case ${TX_REGRESSION_CASES})
|
||||||
add_threadx_regression_test(${test_case})
|
add_threadx_regression_test(${test_case})
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
add_custom_target(
|
add_custom_target(
|
||||||
threadx_regression_build
|
threadx_regression_build
|
||||||
DEPENDS ${TX_REGRESSION_TARGETS}
|
DEPENDS ${TX_REGRESSION_TARGETS}
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ tmp1="${dst}.tmp1"
|
|||||||
|
|
||||||
line=$(grep -n -F "$extern_anchor" "$src" | head -n 1 | cut -d: -f1)
|
line=$(grep -n -F "$extern_anchor" "$src" | head -n 1 | cut -d: -f1)
|
||||||
if [ -z "$line" ]; then
|
if [ -z "$line" ]; then
|
||||||
echo "failed to find _tx_timer_interrupt declaration anchor in trap source" >&2
|
echo "failed to find _tx_timer_interrupt declaration anchor in input source" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
sed "${line}a\\
|
sed "${line}a\\
|
||||||
@@ -20,7 +20,7 @@ void test_interrupt_dispatch(void) __attribute__((weak));\nvoid test_interrupt_d
|
|||||||
|
|
||||||
line=$(grep -n -F "$call_anchor" "$tmp1" | head -n 1 | cut -d: -f1)
|
line=$(grep -n -F "$call_anchor" "$tmp1" | head -n 1 | cut -d: -f1)
|
||||||
if [ -z "$line" ]; then
|
if [ -z "$line" ]; then
|
||||||
echo "failed to find _tx_timer_interrupt call anchor in trap source" >&2
|
echo "failed to find _tx_timer_interrupt call anchor in input source" >&2
|
||||||
rm -f "$tmp1"
|
rm -f "$tmp1"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|||||||
Vendored
+1
-1
Submodule third-party/netxduo updated: b54bf01801...949c0f235c
Reference in New Issue
Block a user