Skip to content

Commit

Permalink
arch: Cmake: Add __ZEPHYR_SUPERVISOR__ macro for arch files.
Browse files Browse the repository at this point in the history
Normally a syscall would check the current privilege level and then
decide to go to _impl_<syscall> directly or go through a
_handler_<syscall>.
__ZEPHYR_SUPERVISOR__ is a compiler optimization flag which will
make all the system calls from the arch files directly link
to the _impl_<syscall>. 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 <adithya.nagaraj.baglody@intel.com>
  • Loading branch information
AdithyaBaglody authored and Anas Nashif committed May 15, 2018
1 parent 8618716 commit 5ab3960
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 24 deletions.
2 changes: 2 additions & 0 deletions arch/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
add_definitions(-D__ZEPHYR_SUPERVISOR__)

add_subdirectory(common)
add_subdirectory(${ARCH})
12 changes: 7 additions & 5 deletions arch/arc/core/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
zephyr_sources(
zephyr_library()

zephyr_library_sources(
thread.c
thread_entry_wrapper.S
cpu_idle.S
Expand All @@ -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)
6 changes: 4 additions & 2 deletions arch/arc/core/mpu/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
14 changes: 8 additions & 6 deletions arch/arm/core/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
zephyr_sources(
zephyr_library()

zephyr_library_sources(
exc_exit.S
irq_init.c
swap.c
Expand All @@ -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)
4 changes: 3 additions & 1 deletion arch/arm/core/cortex_m/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
zephyr_sources(
zephyr_library()

zephyr_library_sources(
vector_table.S
reset.S
nmi_on_reset.S
Expand Down
8 changes: 5 additions & 3 deletions arch/arm/core/cortex_m/mpu/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
16 changes: 9 additions & 7 deletions arch/x86/core/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
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 $<$<COMPILE_LANGUAGE:ASM>:-no-integrated-as>)
endif()

zephyr_compile_options($<$<COMPILE_LANGUAGE:ASM>:-Wa,--divide>)

zephyr_sources(
zephyr_library_sources(
cache.c
cache_s.S
cpuhalt.c
Expand All @@ -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)

0 comments on commit 5ab3960

Please sign in to comment.