diff --git a/CMakeLists.txt b/CMakeLists.txt index f01e5ca00d..ab6a9efa9c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -550,11 +550,15 @@ endif() # Add apps/ to the build (if present) -if(EXISTS ${NUTTX_APPS_DIR}/CMakeLists.txt) - add_subdirectory(${NUTTX_APPS_DIR} apps) -else() - message( - STATUS "Application directory not found at ${NUTTX_APPS_DIR}, skipping") +if(NOT CONFIG_BUILD_KERNEL) + + if(EXISTS ${NUTTX_APPS_DIR}/CMakeLists.txt) + add_subdirectory(${NUTTX_APPS_DIR} apps) + else() + message( + STATUS "Application directory not found at ${NUTTX_APPS_DIR}, skipping") + endif() + endif() # Link step ################################################################## @@ -597,11 +601,15 @@ endif() file(TOUCH ${CMAKE_BINARY_DIR}/nuttx.manifest) get_property(nuttx_kernel_libs GLOBAL PROPERTY NUTTX_KERNEL_LIBRARIES) +get_property(nuttx_extra_libs GLOBAL PROPERTY NUTTX_EXTRA_LIBRARIES) + if(CONFIG_BUILD_FLAT) get_property(nuttx_system_libs GLOBAL PROPERTY NUTTX_SYSTEM_LIBRARIES) endif() -get_property(nuttx_apps_libs GLOBAL PROPERTY NUTTX_APPS_LIBRARIES) -get_property(nuttx_extra_libs GLOBAL PROPERTY NUTTX_EXTRA_LIBRARIES) + +if(NOT CONFIG_BUILD_KERNEL) + get_property(nuttx_apps_libs GLOBAL PROPERTY NUTTX_APPS_LIBRARIES) +endif() set(nuttx_libs ${nuttx_kernel_libs} ${nuttx_system_libs} ${nuttx_apps_libs}) @@ -734,7 +742,7 @@ endif() # Userspace portion ########################################################## -if(NOT CONFIG_BUILD_FLAT) +if(CONFIG_BUILD_PROTECTED) add_executable(nuttx_user) get_property(nuttx_system_libs GLOBAL PROPERTY NUTTX_SYSTEM_LIBRARIES) @@ -779,3 +787,8 @@ if(NOT CONFIG_BUILD_FLAT) # TODO: could also merge elf binaries endif() + +if(CONFIG_BUILD_KERNEL) + # TODO: generate nuttx-export-xxx.tar.gz for userland development + +endif() diff --git a/arch/CMakeLists.txt b/arch/CMakeLists.txt index ac8f147493..41b790a83b 100644 --- a/arch/CMakeLists.txt +++ b/arch/CMakeLists.txt @@ -25,7 +25,7 @@ nuttx_add_kernel_library(arch) target_include_directories(arch PRIVATE ${CMAKE_SOURCE_DIR}/sched) -if(NOT CONFIG_BUILD_FLAT) +if(CONFIG_BUILD_PROTECTED) nuttx_add_system_library(arch_interface) target_include_directories(arch_interface PRIVATE ${CMAKE_SOURCE_DIR}/sched) endif() diff --git a/arch/risc-v/src/CMakeLists.txt b/arch/risc-v/src/CMakeLists.txt index 8dda0f61b0..6aaeb2bd65 100644 --- a/arch/risc-v/src/CMakeLists.txt +++ b/arch/risc-v/src/CMakeLists.txt @@ -21,11 +21,16 @@ add_subdirectory(${NUTTX_CHIP_ABS_DIR} EXCLUDE_FROM_ALL exclude_chip) add_subdirectory(common) +if(CONFIG_BUILD_KERNEL) + add_subdirectory(nuttsbi) + target_include_directories(arch BEFORE PUBLIC ${NUTTX_CHIP_ABS_DIR} nuttsbi) +endif() + # Include directories (before system ones) as PUBLIC so that it can be exposed # to libboard target_include_directories(arch BEFORE PUBLIC ${NUTTX_CHIP_ABS_DIR} common) -if(NOT CONFIG_BUILD_FLAT) +if(CONFIG_BUILD_PROTECTED) target_include_directories(arch_interface BEFORE PUBLIC ${NUTTX_CHIP_ABS_DIR} common) endif() diff --git a/arch/risc-v/src/common/CMakeLists.txt b/arch/risc-v/src/common/CMakeLists.txt index f704b210d0..a240435682 100644 --- a/arch/risc-v/src/common/CMakeLists.txt +++ b/arch/risc-v/src/common/CMakeLists.txt @@ -91,7 +91,7 @@ if(CONFIG_ARCH_USE_MMU) endif() if(CONFIG_ARCH_KERNEL_STACK) - list(APPEND SRCS riscv_addrenv_kstack.c) + list(APPEND SRCS riscv_addrenv_kstack.c riscv_ksp.c) endif() if(CONFIG_ARCH_ADDRENV) @@ -99,4 +99,9 @@ if(CONFIG_ARCH_ADDRENV) list(APPEND SRCS riscv_addrenv_utils.c riscv_addrenv_shm.c) endif() +if(CONFIG_BUILD_KERNEL) + list(APPEND SRCS riscv_percpu.c) + add_subdirectory(supervisor) +endif() + target_sources(arch PRIVATE ${SRCS}) diff --git a/arch/risc-v/src/common/supervisor/CMakeLists.txt b/arch/risc-v/src/common/supervisor/CMakeLists.txt new file mode 100644 index 0000000000..018b76e887 --- /dev/null +++ b/arch/risc-v/src/common/supervisor/CMakeLists.txt @@ -0,0 +1,29 @@ +# ############################################################################## +# arch/arm/src/common/supervisor/CMakeLists.txt +# +# Licensed to the Apache Software Foundation (ASF) under one or more contributor +# license agreements. See the NOTICE file distributed with this work for +# additional information regarding copyright ownership. The ASF licenses this +# file to you under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. +# +# ############################################################################## + +if(CONFIG_BUILD_KERNEL) + + set(SRCS) + + list(APPEND SRCS riscv_syscall.S riscv_perform_syscall.c riscv_sbi.c) + + target_sources(arch PRIVATE ${SRCS}) + +endif() diff --git a/arch/risc-v/src/k230/CMakeLists.txt b/arch/risc-v/src/k230/CMakeLists.txt index ccb4a1e49a..b66ff3650f 100644 --- a/arch/risc-v/src/k230/CMakeLists.txt +++ b/arch/risc-v/src/k230/CMakeLists.txt @@ -18,17 +18,9 @@ # # ############################################################################## -set(SRCS k230_head.S) +set(SRCS k230_head.S k230_start.c k230_irq.c k230_irq_dispatch.c) -list( - APPEND - SRCS - k230_start.c - k230_irq_dispatch.c - k230_irq.c - k230_hart.c - k230_timerisr.c - k230_allocateheap.c) +list(APPEND SRCS k230_timerisr.c k230_allocateheap.c k230_hart.c) if(CONFIG_BUILD_KERNEL) list(APPEND SRCS k230_mm_init.c) @@ -40,4 +32,12 @@ if(CONFIG_MM_PGALLOC) list(APPEND SRCS k230_pgalloc.c) endif() +if(CONFIG_K230_IPI) + list(APPEND SRCS k230_ipi.c) +endif() + +if(CONFIG_RPTUN) + list(APPEND SRCS k230_rptun.c) +endif() + target_sources(arch PRIVATE ${SRCS}) diff --git a/arch/risc-v/src/nuttsbi/CMakeLists.txt b/arch/risc-v/src/nuttsbi/CMakeLists.txt new file mode 100644 index 0000000000..2894037f11 --- /dev/null +++ b/arch/risc-v/src/nuttsbi/CMakeLists.txt @@ -0,0 +1,29 @@ +# ############################################################################## +# arch/risc-v/src/nuttsbi/CMakeLists.txt +# +# Licensed to the Apache Software Foundation (ASF) under one or more contributor +# license agreements. See the NOTICE file distributed with this work for +# additional information regarding copyright ownership. The ASF licenses this +# file to you under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. +# +# ############################################################################## + +if(CONFIG_NUTTSBI) + + set(SRCS sbi_head.S sbi_mtrap.S sbi_vectors.S sbi_start.c) + + list(APPEND SRCS sbi_mtimer.c sbi_mexception.c sbi_mcall.c sbi_mscratch.c) + + target_sources(arch PRIVATE ${SRCS}) + +endif() diff --git a/boards/risc-v/k230/canmv230/src/CMakeLists.txt b/boards/risc-v/k230/canmv230/src/CMakeLists.txt index 8a442380e0..4cef81e673 100644 --- a/boards/risc-v/k230/canmv230/src/CMakeLists.txt +++ b/boards/risc-v/k230/canmv230/src/CMakeLists.txt @@ -32,8 +32,12 @@ target_sources(board PRIVATE ${SRCS}) if(CONFIG_ARCH_CHIP_K230) if(CONFIG_BUILD_KERNEL) - if(CONFIG_ARCH_NUTTSBI) - set(LDFILE ld-nuttsbi.script) + if(CONFIG_NUTTSBI) + if(CONFIG_RPTUN) + set(LDFILE ld-rptun.script) + else() + set(LDFILE ld-nuttsbi.script) + endif() else() set(LDFILE ld-kernel.script) endif() diff --git a/syscall/CMakeLists.txt b/syscall/CMakeLists.txt index 53fdbb1768..5ad019828e 100644 --- a/syscall/CMakeLists.txt +++ b/syscall/CMakeLists.txt @@ -22,6 +22,14 @@ file(STRINGS syscall.csv SYSCALLS) list(TRANSFORM SYSCALLS REPLACE "^\"([^,]+)\",.+" "\\1") list(TRANSFORM SYSCALLS APPEND ".c") +# generate the host tool + +add_custom_target( + mksyscall + COMMAND cmake -B ${CMAKE_BINARY_DIR}/bin -S ${CMAKE_SOURCE_DIR}/tools && cmake + --build ${CMAKE_BINARY_DIR}/bin --target mksyscall + SOURCES ${CMAKE_SOURCE_DIR}/tools/mksyscall.c) + if(CONFIG_LIB_SYSCALL) add_subdirectory(proxies) add_subdirectory(stubs) diff --git a/syscall/proxies/CMakeLists.txt b/syscall/proxies/CMakeLists.txt index a36a285284..80f9dec52d 100644 --- a/syscall/proxies/CMakeLists.txt +++ b/syscall/proxies/CMakeLists.txt @@ -27,7 +27,7 @@ add_custom_command( COMMAND ${CMAKE_BINARY_DIR}/bin/mksyscall -p ${CMAKE_CURRENT_LIST_DIR}/../syscall.csv WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - DEPENDS nuttx_host_tools) + DEPENDS mksyscall) # add sources to target target_sources(proxies PRIVATE ${SYSCALLS}) diff --git a/syscall/stubs/CMakeLists.txt b/syscall/stubs/CMakeLists.txt index b3ce6d8b89..69341b4203 100644 --- a/syscall/stubs/CMakeLists.txt +++ b/syscall/stubs/CMakeLists.txt @@ -27,7 +27,7 @@ add_custom_command( COMMAND ${CMAKE_BINARY_DIR}/bin/mksyscall -s ${CMAKE_CURRENT_LIST_DIR}/../syscall.csv WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - DEPENDS nuttx_host_tools) + DEPENDS mksyscall) # add sources to target target_sources(stubs PRIVATE ${SYSCALLS})