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_<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>
This commit is contained in:
Adithya Baglody 2018-03-28 15:30:20 +05:30 committed by Anas Nashif
commit 5ab3960c75
7 changed files with 38 additions and 24 deletions

View file

@ -1,2 +1,4 @@
add_definitions(-D__ZEPHYR_SUPERVISOR__)
add_subdirectory(common)
add_subdirectory(${ARCH})

View file

@ -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)

View file

@ -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)

View file

@ -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)

View file

@ -1,4 +1,6 @@
zephyr_sources(
zephyr_library()
zephyr_library_sources(
vector_table.S
reset.S
nmi_on_reset.S

View file

@ -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)

View file

@ -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 $<$<COMPILE_LANGUAGE:ASM>:-no-integrated-as>)
@ -5,7 +7,7 @@ endif()
zephyr_compile_options($<$<COMPILE_LANGUAGE:ASM>:-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)