From 5ab3960c757acda015d8c0f1de8e6da8809cdef1 Mon Sep 17 00:00:00 2001 From: Adithya Baglody Date: Wed, 28 Mar 2018 15:30:20 +0530 Subject: [PATCH] arch: Cmake: Add __ZEPHYR_SUPERVISOR__ macro for arch files. Normally a syscall would check the current privilege level and then decide to go to _impl_ directly or go through a _handler_. __ZEPHYR_SUPERVISOR__ is a compiler optimization flag which will make all the system calls from the arch files directly link to the _impl_. Thereby reducing the overhead of checking the privileges. In the previous implementation all the source files would be compiled by zephyr_source() rule. This means that zephyr_* is a catchall CMake library for source files that can be built purely with the include paths, defines, and other compiler flags that all zephyr source files uses. This states that adding one extra compiler flag for only one complete directory would fail. This limitation can be overcome by using zephyr_libray* APIs. This creates a library for the required directories and it also supports directory level properties. Hence we use zephyr_library* to create a new library with macro _ZEPHYR_SUPERVISOR_ for the optimization. Signed-off-by: Adithya Baglody --- arch/CMakeLists.txt | 2 ++ arch/arc/core/CMakeLists.txt | 12 +++++++----- arch/arc/core/mpu/CMakeLists.txt | 6 ++++-- arch/arm/core/CMakeLists.txt | 14 ++++++++------ arch/arm/core/cortex_m/CMakeLists.txt | 4 +++- arch/arm/core/cortex_m/mpu/CMakeLists.txt | 8 +++++--- arch/x86/core/CMakeLists.txt | 16 +++++++++------- 7 files changed, 38 insertions(+), 24 deletions(-) diff --git a/arch/CMakeLists.txt b/arch/CMakeLists.txt index 00e3e0035bb..1d96abbfe6e 100644 --- a/arch/CMakeLists.txt +++ b/arch/CMakeLists.txt @@ -1,2 +1,4 @@ +add_definitions(-D__ZEPHYR_SUPERVISOR__) + add_subdirectory(common) add_subdirectory(${ARCH}) diff --git a/arch/arc/core/CMakeLists.txt b/arch/arc/core/CMakeLists.txt index 1427e063218..135c4df9011 100644 --- a/arch/arc/core/CMakeLists.txt +++ b/arch/arc/core/CMakeLists.txt @@ -1,4 +1,6 @@ -zephyr_sources( +zephyr_library() + +zephyr_library_sources( thread.c thread_entry_wrapper.S cpu_idle.S @@ -17,9 +19,9 @@ zephyr_sources( vector_table.c ) -zephyr_sources_ifdef(CONFIG_ARC_FIRQ fast_irq.S) +zephyr_library_sources_ifdef(CONFIG_ARC_FIRQ fast_irq.S) -zephyr_sources_if_kconfig(irq_offload.c) -zephyr_sources_ifdef(CONFIG_ATOMIC_OPERATIONS_CUSTOM atomic.c) +zephyr_library_sources_if_kconfig(irq_offload.c) +zephyr_library_sources_ifdef(CONFIG_ATOMIC_OPERATIONS_CUSTOM atomic.c) add_subdirectory_ifdef(CONFIG_CPU_HAS_MPU mpu) -zephyr_sources_ifdef(CONFIG_USERSPACE userspace.S) +zephyr_library_sources_ifdef(CONFIG_USERSPACE userspace.S) diff --git a/arch/arc/core/mpu/CMakeLists.txt b/arch/arc/core/mpu/CMakeLists.txt index 1bc394ffa23..f8ef61dc787 100644 --- a/arch/arc/core/mpu/CMakeLists.txt +++ b/arch/arc/core/mpu/CMakeLists.txt @@ -1,2 +1,4 @@ -zephyr_sources_if_kconfig(arc_core_mpu.c) -zephyr_sources_if_kconfig(arc_mpu.c) +zephyr_library_ifdef(CONFIG_ARC_CORE_MPU) + +zephyr_library_sources_if_kconfig(arc_core_mpu.c) +zephyr_library_sources_if_kconfig(arc_mpu.c) diff --git a/arch/arm/core/CMakeLists.txt b/arch/arm/core/CMakeLists.txt index 4e0ecfcf53e..7d20b1a0991 100644 --- a/arch/arm/core/CMakeLists.txt +++ b/arch/arm/core/CMakeLists.txt @@ -1,4 +1,6 @@ -zephyr_sources( +zephyr_library() + +zephyr_library_sources( exc_exit.S irq_init.c swap.c @@ -13,11 +15,11 @@ zephyr_sources( thread_abort.c ) -zephyr_sources_ifdef(CONFIG_GEN_SW_ISR_TABLE isr_wrapper.S) -zephyr_sources_ifdef(CONFIG_CPLUSPLUS __aeabi_atexit.c) -zephyr_sources_ifdef(CONFIG_IRQ_OFFLOAD irq_offload.c) -zephyr_sources_ifdef(CONFIG_CPU_CORTEX_M0 irq_relay.S) -zephyr_sources_ifdef(CONFIG_USERSPACE userspace.S) +zephyr_library_sources_ifdef(CONFIG_GEN_SW_ISR_TABLE isr_wrapper.S) +zephyr_library_sources_ifdef(CONFIG_CPLUSPLUS __aeabi_atexit.c) +zephyr_library_sources_ifdef(CONFIG_IRQ_OFFLOAD irq_offload.c) +zephyr_library_sources_ifdef(CONFIG_CPU_CORTEX_M0 irq_relay.S) +zephyr_library_sources_ifdef(CONFIG_USERSPACE userspace.S) add_subdirectory_ifdef(CONFIG_CPU_CORTEX_M cortex_m) add_subdirectory_ifdef(CONFIG_CPU_HAS_MPU cortex_m/mpu) diff --git a/arch/arm/core/cortex_m/CMakeLists.txt b/arch/arm/core/cortex_m/CMakeLists.txt index 6a14d26b6b4..adf8e9a281e 100644 --- a/arch/arm/core/cortex_m/CMakeLists.txt +++ b/arch/arm/core/cortex_m/CMakeLists.txt @@ -1,4 +1,6 @@ -zephyr_sources( +zephyr_library() + +zephyr_library_sources( vector_table.S reset.S nmi_on_reset.S diff --git a/arch/arm/core/cortex_m/mpu/CMakeLists.txt b/arch/arm/core/cortex_m/mpu/CMakeLists.txt index 3a7d2d1719b..5598375c045 100644 --- a/arch/arm/core/cortex_m/mpu/CMakeLists.txt +++ b/arch/arm/core/cortex_m/mpu/CMakeLists.txt @@ -1,3 +1,5 @@ -zephyr_sources_ifdef(CONFIG_ARM_CORE_MPU arm_core_mpu.c) -zephyr_sources_if_kconfig( arm_mpu.c) -zephyr_sources_if_kconfig( nxp_mpu.c) +zephyr_library_ifdef(CONFIG_ARM_CORE_MPU) + +zephyr_library_sources_ifdef(CONFIG_ARM_CORE_MPU arm_core_mpu.c) +zephyr_library_sources_if_kconfig( arm_mpu.c) +zephyr_library_sources_if_kconfig( nxp_mpu.c) diff --git a/arch/x86/core/CMakeLists.txt b/arch/x86/core/CMakeLists.txt index 3fd44567e0e..7fef31b0dc3 100644 --- a/arch/x86/core/CMakeLists.txt +++ b/arch/x86/core/CMakeLists.txt @@ -1,3 +1,5 @@ +zephyr_library() + if (COMPILER STREQUAL "clang") # We rely on GAS for assembling, so don't use the integrated assembler zephyr_compile_options_ifndef(CONFIG_X86_IAMCU $<$:-no-integrated-as>) @@ -5,7 +7,7 @@ endif() zephyr_compile_options($<$:-Wa,--divide>) -zephyr_sources( +zephyr_library_sources( cache.c cache_s.S cpuhalt.c @@ -19,11 +21,11 @@ zephyr_sources( thread.c ) -zephyr_sources_if_kconfig( irq_offload.c) -zephyr_sources_if_kconfig( x86_mmu.c) -zephyr_sources_if_kconfig( reboot_rst_cnt.c) -zephyr_sources_ifdef(CONFIG_FP_SHARING float.c) -zephyr_sources_ifdef(CONFIG_X86_USERSPACE userspace.S) +zephyr_library_sources_if_kconfig( irq_offload.c) +zephyr_library_sources_if_kconfig( x86_mmu.c) +zephyr_library_sources_if_kconfig( reboot_rst_cnt.c) +zephyr_library_sources_ifdef(CONFIG_FP_SHARING float.c) +zephyr_library_sources_ifdef(CONFIG_X86_USERSPACE userspace.S) # Last since we declare default exception handlers here -zephyr_sources(fatal.c) +zephyr_library_sources(fatal.c)