From 46f4a24d59d1ad443d242104dfa375369b8d65e5 Mon Sep 17 00:00:00 2001 From: Yanfeng Liu Date: Sun, 14 Jul 2024 08:48:37 +0800 Subject: [PATCH] riscv/qemu: add CMake for PROTECTED This adds CMake support for PROTECTED build mode on rv-virt target. Signed-off-by: Yanfeng Liu --- arch/risc-v/src/qemu-rv/CMakeLists.txt | 4 ++++ boards/risc-v/qemu-rv/rv-virt/CMakeLists.txt | 7 +++++++ .../qemu-rv/rv-virt/kernel/CMakeLists.txt | 21 +++++++++++++++++++ .../risc-v/qemu-rv/rv-virt/src/CMakeLists.txt | 9 ++++---- 4 files changed, 37 insertions(+), 4 deletions(-) create mode 100644 boards/risc-v/qemu-rv/rv-virt/kernel/CMakeLists.txt diff --git a/arch/risc-v/src/qemu-rv/CMakeLists.txt b/arch/risc-v/src/qemu-rv/CMakeLists.txt index 397069bae8..a666c4ad0d 100644 --- a/arch/risc-v/src/qemu-rv/CMakeLists.txt +++ b/arch/risc-v/src/qemu-rv/CMakeLists.txt @@ -39,4 +39,8 @@ if(CONFIG_MM_PGALLOC) list(APPEND SRCS qemu_rv_pgalloc.c) endif() +if(CONFIG_BUILD_PROTECTED) + list(APPEND SRCS qemu_rv_userspace.c) +endif() + target_sources(arch PRIVATE ${SRCS}) diff --git a/boards/risc-v/qemu-rv/rv-virt/CMakeLists.txt b/boards/risc-v/qemu-rv/rv-virt/CMakeLists.txt index 6f5e40d723..a7c54dabdb 100644 --- a/boards/risc-v/qemu-rv/rv-virt/CMakeLists.txt +++ b/boards/risc-v/qemu-rv/rv-virt/CMakeLists.txt @@ -19,3 +19,10 @@ # ############################################################################## add_subdirectory(src) + +if(CONFIG_BUILD_PROTECTED) + add_subdirectory(kernel) + set_property( + GLOBAL PROPERTY LD_SCRIPT_USER + ${CMAKE_CURRENT_LIST_DIR}/scripts/ld-userland.script) +endif() diff --git a/boards/risc-v/qemu-rv/rv-virt/kernel/CMakeLists.txt b/boards/risc-v/qemu-rv/rv-virt/kernel/CMakeLists.txt new file mode 100644 index 0000000000..82638d9cc0 --- /dev/null +++ b/boards/risc-v/qemu-rv/rv-virt/kernel/CMakeLists.txt @@ -0,0 +1,21 @@ +# ############################################################################## +# boards/risc-v/qemu-rv/rv-virt/kernel/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. +# +# ############################################################################## + +target_sources(nuttx_user PRIVATE rv_virt_userspace.c) diff --git a/boards/risc-v/qemu-rv/rv-virt/src/CMakeLists.txt b/boards/risc-v/qemu-rv/rv-virt/src/CMakeLists.txt index 58e2e55687..46e760f6cc 100644 --- a/boards/risc-v/qemu-rv/rv-virt/src/CMakeLists.txt +++ b/boards/risc-v/qemu-rv/rv-virt/src/CMakeLists.txt @@ -31,11 +31,12 @@ endif() target_sources(board PRIVATE ${SRCS}) if(CONFIG_ARCH_CHIP_QEMU_RV) - if(CONFIG_BUILD_KERNEL) + if(CONFIG_NUTTSBI) + set(LDFILE ld-nuttsbi.script) + elseif(CONFIG_BUILD_KERNEL) set(LDFILE ld-kernel.script) - if(CONFIG_NUTTSBI) - set(LDFILE ld-nuttsbi.script) - endif() + elseif(CONFIG_BUILD_PROTECTED) + set(LDFILE ld-protected.script) else() set(LDFILE ld.script) endif()