Skip to content

Commit

Permalink
Add ports_smp cmake build support
Browse files Browse the repository at this point in the history
make ports_smp can be build with cmake.

set THREADX_SMP to "smp" and build like others ports.

Signed-off-by: Du Huanpeng <[email protected]>
  • Loading branch information
hodcarrier committed Jun 20, 2023
1 parent 90bd681 commit c15c975
Show file tree
Hide file tree
Showing 4 changed files with 272 additions and 4 deletions.
11 changes: 7 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ endif()
if(NOT DEFINED THREADX_TOOLCHAIN)
message(FATAL_ERROR "Error: THREADX_TOOLCHAIN not defined")
endif()

set(SMP _smp)

message(STATUS "THREADX_ARCH: ${THREADX_ARCH}")
message(STATUS "THREADX_TOOLCHAIN: ${THREADX_TOOLCHAIN}")

Expand All @@ -25,11 +28,11 @@ set(CUSTOM_INC_DIR ${CMAKE_CURRENT_BINARY_DIR}/custom_inc)
if(DEFINED THREADX_CUSTOM_PORT)
add_subdirectory(${THREADX_CUSTOM_PORT} threadx_port)
else()
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/ports/${THREADX_ARCH}/${THREADX_TOOLCHAIN})
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/ports${SMP}/${THREADX_ARCH}${SMP}/${THREADX_TOOLCHAIN})
endif()

# Pick up the common stuff
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/common)
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/common${SMP})

# Define the FreeRTOS adaptation layer
add_library(freertos-threadx EXCLUDE_FROM_ALL)
Expand All @@ -46,7 +49,7 @@ target_link_libraries(freertos-threadx PUBLIC threadx)
# If the user provided an override, copy it to the custom directory
if (NOT TX_USER_FILE)
message(STATUS "Using default tx_user.h file")
set(TX_USER_FILE ${CMAKE_CURRENT_LIST_DIR}/common/inc/tx_user_sample.h)
set(TX_USER_FILE ${CMAKE_CURRENT_LIST_DIR}/common${SMP}/inc/tx_user_sample.h)
else()
message(STATUS "Using custom tx_user.h file from ${TX_USER_FILE}")
endif()
Expand All @@ -69,4 +72,4 @@ set(CPACK_SOURCE_IGNORE_FILES
".*~$"
)
set(CPACK_VERBATIM_VARIABLES YES)
include(CPack)
include(CPack)
13 changes: 13 additions & 0 deletions cmake/cortex_a9.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Name of the target
set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_SYSTEM_PROCESSOR cortex-a9)

set(THREADX_ARCH "cortex_a9")
set(THREADX_TOOLCHAIN "gnu")

set(MCPU_FLAGS "-marm -mcpu=cortex-a9")
set(VFP_FLAGS "")
set(SPEC_FLAGS "--specs=nosys.specs")
# set(LD_FLAGS "-nostartfiles")

include(${CMAKE_CURRENT_LIST_DIR}/arm-none-eabi.cmake)
220 changes: 220 additions & 0 deletions common_smp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,220 @@
function(target_sources_if_not_overridden filename)
list(FIND TX_SRC_OVERRIDES ${filename} OVERRIDE_FOUND)
if( OVERRIDE_FOUND EQUAL -1 )
# message(STATUS "** Using original ${filename} from common${SMP}/src **")
target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_LIST_DIR}/src/${filename})
endif()
endfunction()

# These files can be overridden by setting them in the variable list named TX_SRC_OVERRIDES
target_sources_if_not_overridden("tx_thread_delete.c")
target_sources_if_not_overridden("tx_thread_reset.c")

target_sources(${PROJECT_NAME}
PRIVATE
# {{BEGIN_TARGET_SOURCES}}
${CMAKE_CURRENT_LIST_DIR}/src/tx_block_allocate.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_block_pool_cleanup.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_block_pool_create.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_block_pool_delete.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_block_pool_info_get.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_block_pool_initialize.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_block_pool_performance_info_get.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_block_pool_performance_system_info_get.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_block_pool_prioritize.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_block_release.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_byte_allocate.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_byte_pool_cleanup.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_byte_pool_create.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_byte_pool_delete.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_byte_pool_info_get.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_byte_pool_initialize.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_byte_pool_performance_info_get.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_byte_pool_performance_system_info_get.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_byte_pool_prioritize.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_byte_pool_search.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_byte_release.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_event_flags_cleanup.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_event_flags_create.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_event_flags_delete.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_event_flags_get.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_event_flags_info_get.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_event_flags_initialize.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_event_flags_performance_info_get.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_event_flags_performance_system_info_get.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_event_flags_set.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_event_flags_set_notify.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_initialize_high_level.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_initialize_kernel_enter.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_initialize_kernel_setup.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_misra.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_mutex_cleanup.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_mutex_create.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_mutex_delete.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_mutex_get.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_mutex_info_get.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_mutex_initialize.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_mutex_performance_info_get.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_mutex_performance_system_info_get.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_mutex_prioritize.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_mutex_priority_change.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_mutex_put.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_queue_cleanup.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_queue_create.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_queue_delete.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_queue_flush.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_queue_front_send.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_queue_info_get.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_queue_initialize.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_queue_performance_info_get.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_queue_performance_system_info_get.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_queue_prioritize.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_queue_receive.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_queue_send.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_queue_send_notify.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_semaphore_ceiling_put.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_semaphore_cleanup.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_semaphore_create.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_semaphore_delete.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_semaphore_get.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_semaphore_info_get.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_semaphore_initialize.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_semaphore_performance_info_get.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_semaphore_performance_system_info_get.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_semaphore_prioritize.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_semaphore_put.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_semaphore_put_notify.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_create.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_delete.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_entry_exit_notify.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_identify.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_info_get.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_initialize.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_performance_info_get.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_performance_system_info_get.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_preemption_change.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_priority_change.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_relinquish.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_reset.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_resume.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_shell_entry.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_sleep.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_smp_core_exclude.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_smp_core_exclude_get.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_smp_current_state_set.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_smp_debug_entry_insert.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_smp_high_level_initialize.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_smp_rebalance_execute_list.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_smp_utilities.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_stack_analyze.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_stack_error_handler.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_stack_error_notify.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_suspend.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_system_preempt_check.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_system_resume.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_system_suspend.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_terminate.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_time_slice.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_time_slice_change.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_timeout.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_wait_abort.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_time_get.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_time_set.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_timer_activate.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_timer_change.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_timer_create.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_timer_deactivate.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_timer_delete.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_timer_expiration_process.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_timer_info_get.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_timer_initialize.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_timer_performance_info_get.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_timer_performance_system_info_get.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_timer_smp_core_exclude.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_timer_smp_core_exclude_get.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_timer_system_activate.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_timer_system_deactivate.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_timer_thread_entry.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_trace_buffer_full_notify.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_trace_disable.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_trace_enable.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_trace_event_filter.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_trace_event_unfilter.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_trace_initialize.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_trace_interrupt_control.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_trace_isr_enter_insert.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_trace_isr_exit_insert.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_trace_object_register.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_trace_object_unregister.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_trace_user_event_insert.c
${CMAKE_CURRENT_LIST_DIR}/src/txe_block_allocate.c
${CMAKE_CURRENT_LIST_DIR}/src/txe_block_pool_create.c
${CMAKE_CURRENT_LIST_DIR}/src/txe_block_pool_delete.c
${CMAKE_CURRENT_LIST_DIR}/src/txe_block_pool_info_get.c
${CMAKE_CURRENT_LIST_DIR}/src/txe_block_pool_prioritize.c
${CMAKE_CURRENT_LIST_DIR}/src/txe_block_release.c
${CMAKE_CURRENT_LIST_DIR}/src/txe_byte_allocate.c
${CMAKE_CURRENT_LIST_DIR}/src/txe_byte_pool_create.c
${CMAKE_CURRENT_LIST_DIR}/src/txe_byte_pool_delete.c
${CMAKE_CURRENT_LIST_DIR}/src/txe_byte_pool_info_get.c
${CMAKE_CURRENT_LIST_DIR}/src/txe_byte_pool_prioritize.c
${CMAKE_CURRENT_LIST_DIR}/src/txe_byte_release.c
${CMAKE_CURRENT_LIST_DIR}/src/txe_event_flags_create.c
${CMAKE_CURRENT_LIST_DIR}/src/txe_event_flags_delete.c
${CMAKE_CURRENT_LIST_DIR}/src/txe_event_flags_get.c
${CMAKE_CURRENT_LIST_DIR}/src/txe_event_flags_info_get.c
${CMAKE_CURRENT_LIST_DIR}/src/txe_event_flags_set.c
${CMAKE_CURRENT_LIST_DIR}/src/txe_event_flags_set_notify.c
${CMAKE_CURRENT_LIST_DIR}/src/txe_mutex_create.c
${CMAKE_CURRENT_LIST_DIR}/src/txe_mutex_delete.c
${CMAKE_CURRENT_LIST_DIR}/src/txe_mutex_get.c
${CMAKE_CURRENT_LIST_DIR}/src/txe_mutex_info_get.c
${CMAKE_CURRENT_LIST_DIR}/src/txe_mutex_prioritize.c
${CMAKE_CURRENT_LIST_DIR}/src/txe_mutex_put.c
${CMAKE_CURRENT_LIST_DIR}/src/txe_queue_create.c
${CMAKE_CURRENT_LIST_DIR}/src/txe_queue_delete.c
${CMAKE_CURRENT_LIST_DIR}/src/txe_queue_flush.c
${CMAKE_CURRENT_LIST_DIR}/src/txe_queue_front_send.c
${CMAKE_CURRENT_LIST_DIR}/src/txe_queue_info_get.c
${CMAKE_CURRENT_LIST_DIR}/src/txe_queue_prioritize.c
${CMAKE_CURRENT_LIST_DIR}/src/txe_queue_receive.c
${CMAKE_CURRENT_LIST_DIR}/src/txe_queue_send.c
${CMAKE_CURRENT_LIST_DIR}/src/txe_queue_send_notify.c
${CMAKE_CURRENT_LIST_DIR}/src/txe_semaphore_ceiling_put.c
${CMAKE_CURRENT_LIST_DIR}/src/txe_semaphore_create.c
${CMAKE_CURRENT_LIST_DIR}/src/txe_semaphore_delete.c
${CMAKE_CURRENT_LIST_DIR}/src/txe_semaphore_get.c
${CMAKE_CURRENT_LIST_DIR}/src/txe_semaphore_info_get.c
${CMAKE_CURRENT_LIST_DIR}/src/txe_semaphore_prioritize.c
${CMAKE_CURRENT_LIST_DIR}/src/txe_semaphore_put.c
${CMAKE_CURRENT_LIST_DIR}/src/txe_semaphore_put_notify.c
${CMAKE_CURRENT_LIST_DIR}/src/txe_thread_create.c
${CMAKE_CURRENT_LIST_DIR}/src/txe_thread_delete.c
${CMAKE_CURRENT_LIST_DIR}/src/txe_thread_entry_exit_notify.c
${CMAKE_CURRENT_LIST_DIR}/src/txe_thread_info_get.c
${CMAKE_CURRENT_LIST_DIR}/src/txe_thread_preemption_change.c
${CMAKE_CURRENT_LIST_DIR}/src/txe_thread_priority_change.c
${CMAKE_CURRENT_LIST_DIR}/src/txe_thread_relinquish.c
${CMAKE_CURRENT_LIST_DIR}/src/txe_thread_reset.c
${CMAKE_CURRENT_LIST_DIR}/src/txe_thread_resume.c
${CMAKE_CURRENT_LIST_DIR}/src/txe_thread_suspend.c
${CMAKE_CURRENT_LIST_DIR}/src/txe_thread_terminate.c
${CMAKE_CURRENT_LIST_DIR}/src/txe_thread_time_slice_change.c
${CMAKE_CURRENT_LIST_DIR}/src/txe_thread_wait_abort.c
${CMAKE_CURRENT_LIST_DIR}/src/txe_timer_activate.c
${CMAKE_CURRENT_LIST_DIR}/src/txe_timer_change.c
${CMAKE_CURRENT_LIST_DIR}/src/txe_timer_create.c
${CMAKE_CURRENT_LIST_DIR}/src/txe_timer_deactivate.c
${CMAKE_CURRENT_LIST_DIR}/src/txe_timer_delete.c
${CMAKE_CURRENT_LIST_DIR}/src/txe_timer_info_get.c

# {{END_TARGET_SOURCES}}
)

# Add the Common/inc directory to the project include list
target_include_directories(${PROJECT_NAME}
SYSTEM
PUBLIC
${CMAKE_CURRENT_LIST_DIR}/inc
)

32 changes: 32 additions & 0 deletions ports_smp/cortex_a9_smp/gnu/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@

target_sources(${PROJECT_NAME}
PRIVATE
# {{BEGIN_TARGET_SOURCES}}
${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_interrupt_control.S
${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_interrupt_disable.S
${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_interrupt_restore.S
${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_irq_nesting_end.S
${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_irq_nesting_start.S
${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_schedule.S
${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_smp_core_get.S
${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_smp_core_preempt.S
${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_smp_current_state_get.S
${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_smp_current_thread_get.S
${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_smp_initialize_wait.S
${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_smp_low_level_initialize.S
${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_smp_protect.S
${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_smp_time_get.S
${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_smp_unprotect.S
${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_stack_build.S
${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_system_return.S
${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_vectored_context_save.S
${CMAKE_CURRENT_LIST_DIR}/src/tx_timer_interrupt.S
# {{END_TARGET_SOURCES}}
)

target_include_directories(${PROJECT_NAME}
PUBLIC
${CMAKE_CURRENT_LIST_DIR}/inc
)

0 comments on commit c15c975

Please sign in to comment.