1# SPDX-License-Identifier: Apache-2.0
2
3zephyr_library()
4
5zephyr_library_sources(
6  cpu_idle.S
7  early_mem_funcs.S
8  fatal.c
9  irq_init.c
10  irq_manage.c
11  prep_c.c
12  reset.S
13  reset.c
14  switch.S
15  thread.c
16  vector_table.S
17)
18
19# Use large code model for addresses larger than 32 bits,
20# This is 10 characters long (0x12345678). We can't use a
21# simple numeric comparison because these values may be
22# beyond the numeric range of integers for cmake.
23
24string(LENGTH "x${CONFIG_SRAM_BASE_ADDRESS}" SRAM_LENGTH)
25string(LENGTH "x${CONFIG_KERNEL_VM_BASE}" KERNEL_VM_LENGTH)
26
27if(${SRAM_LENGTH} GREATER 11 OR ${KERNEL_VM_LENGTH} GREATER 11)
28  zephyr_cc_option(-mcmodel=large)
29endif()
30
31zephyr_library_sources_ifdef(CONFIG_FPU_SHARING fpu.c fpu.S)
32zephyr_library_sources_ifdef(CONFIG_ARM_MMU mmu.c mmu.S)
33zephyr_library_sources_ifdef(CONFIG_ARM_MPU cortex_r/arm_mpu.c)
34zephyr_library_sources_ifdef(CONFIG_USERSPACE userspace.S)
35zephyr_library_sources_ifdef(CONFIG_GEN_SW_ISR_TABLE isr_wrapper.S)
36zephyr_library_sources_ifdef(CONFIG_IRQ_OFFLOAD irq_offload.c)
37zephyr_library_sources_ifdef(CONFIG_THREAD_LOCAL_STORAGE tls.c)
38zephyr_library_sources_ifdef(CONFIG_HAS_ARM_SMCCC smccc-call.S)
39zephyr_library_sources_ifdef(CONFIG_AARCH64_IMAGE_HEADER header.S)
40zephyr_library_sources_ifdef(CONFIG_SEMIHOST semihost.c)
41zephyr_library_sources_ifdef(CONFIG_DEBUG_COREDUMP coredump.c)
42if ((CONFIG_MP_MAX_NUM_CPUS GREATER 1) OR (CONFIG_SMP))
43  zephyr_library_sources(smp.c)
44endif ()
45
46zephyr_cc_option_ifdef(CONFIG_USERSPACE -mno-outline-atomics)
47zephyr_cc_option_ifdef(CONFIG_FRAME_POINTER -mno-omit-leaf-frame-pointer)
48
49# GCC may generate ldp/stp instructions with the Advanced SIMD Qn registers for
50# consecutive 32-byte loads and stores. Saving and restoring the Advanced SIMD
51# context is very expensive, and it is preferable to keep it turned off by not
52# emitting these instructions for better context switching performance.
53
54if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
55  zephyr_cc_option(-moverride=tune=no_ldp_stp_qregs)
56endif()
57
58add_subdirectory_ifdef(CONFIG_XEN xen)
59
60if(CONFIG_GEN_SW_ISR_TABLE)
61  if(CONFIG_DYNAMIC_INTERRUPTS)
62    zephyr_linker_sources(RWDATA swi_tables.ld)
63  else()
64    zephyr_linker_sources(RODATA swi_tables.ld)
65  endif()
66endif()
67