Introduce cmake-based rewrite of KBuild

Introducing CMake is an important step in a larger effort to make
Zephyr easy to use for application developers working on different
platforms with different development environment needs.

Simplified, this change retains Kconfig as-is, and replaces all
Makefiles with CMakeLists.txt. The DSL-like Make language that KBuild
offers is replaced by a set of CMake extentions. These extentions have
either provided simple one-to-one translations of KBuild features or
introduced new concepts that replace KBuild concepts.

This is a breaking change for existing test infrastructure and build
scripts that are maintained out-of-tree. But for FW itself, no porting
should be necessary.

For users that just want to continue their work with minimal
disruption the following should suffice:

Install CMake 3.8.2+

Port any out-of-tree Makefiles to CMake.

Learn the absolute minimum about the new command line interface:

$ cd samples/hello_world
$ mkdir build && cd build
$ cmake -DBOARD=nrf52_pca10040 ..

$ cd build
$ make

PR: zephyrproject-rtos#4692
docs: http://docs.zephyrproject.org/getting_started/getting_started.html

Signed-off-by: Sebastian Boe <sebastian.boe@nordicsemi.no>
This commit is contained in:
Sebastian Bøe 2017-10-27 15:43:34 +02:00 committed by Anas Nashif
parent 8bffcda547
commit 12f8f76165
644 changed files with 7815 additions and 0 deletions

731
CMakeLists.txt Normal file
View file

@ -0,0 +1,731 @@
project(Zephyr-Kernel VERSION ${PROJECT_VERSION})
enable_language(C CXX ASM)
# *DOCUMENTATION*
#
# Note that this is *NOT* the top-level CMakeLists.txt. That's in the
# application. See the Application Development Primer documentation
# for details.
#
# To see a list of typical targets execute "make usage"
# More info can be located in ./README.rst
# Comments in this file are targeted only to the developer, do not
# expect to learn how to build the kernel reading this file.
# Verify that the toolchain can compile a dummy file, if it is not we
# won't be able to test for compatiblity with certain C flags.
check_c_compiler_flag("" toolchain_is_ok)
assert(toolchain_is_ok "The toolchain is unable to build a dummy C file. See CMakeError.log.")
# Do not generate make install target.
set(CMAKE_SKIP_INSTALL_RULES ON)
set(CMAKE_EXECUTABLE_SUFFIX .elf)
set(SOC_NAME ${CONFIG_SOC})
set(SOC_SERIES ${CONFIG_SOC_SERIES})
set(SOC_FAMILY ${CONFIG_SOC_FAMILY})
if("${SOC_SERIES}" STREQUAL "")
set(SOC_PATH ${SOC_NAME})
else()
set(SOC_PATH ${SOC_FAMILY}/${SOC_SERIES})
endif()
if(NOT PROPERTY_LINKER_SCRIPT_DEFINES)
set_property(GLOBAL PROPERTY PROPERTY_LINKER_SCRIPT_DEFINES -D__GCC_LINKER_CMD__)
endif()
define_property(GLOBAL PROPERTY PROPERTY_OUTPUT_FORMAT BRIEF_DOCS " " FULL_DOCS " ")
set_property( GLOBAL PROPERTY PROPERTY_OUTPUT_FORMAT elf32-little${ARCH})
# zephyr_interface is a source-less library that has all the global
# compiler options needed by all source files. All zephyr libraries,
# including the library named "zephyr" link with this library to
# obtain these flags.
add_library(zephyr_interface INTERFACE)
# zephyr is a catchall CMake library for source files that can be
# built purely with the include paths, defines, and other compiler
# flags that come with zephyr_interface.
zephyr_library_named(zephyr)
zephyr_include_directories(
kernel/include
arch/${ARCH}/include
arch/${ARCH}/soc/${SOC_PATH}
arch/${ARCH}/soc/${SOC_PATH}/include
arch/${ARCH}/soc/${SOC_FAMILY}/include
${BOARD_DIR}
include
include/drivers
${PROJECT_BINARY_DIR}/include/generated
${USERINCLUDE}
${STDINCLUDE}
)
zephyr_compile_definitions(
KERNEL
__ZEPHYR__=1
_FORTIFY_SOURCE=2
)
# We need to set an optimization level.
# Default to -Os
# unless CONFIG_DEBUG is set, then it is -Og
#
# also, some toolchain's break with -Os, and some toolchain's break
# with -Og so allow them to override what flag to use
#
# Finally, the user can use Kconfig to add compiler options that will
# come after these options and override them
set_ifndef(OPTIMIZE_FOR_SIZE_FLAG "-Os")
set_ifndef(OPTIMIZE_FOR_DEBUG_FLAG "-Og")
if(CONFIG_DEBUG)
set(OPTIMIZATION_FLAG ${OPTIMIZE_FOR_DEBUG_FLAG})
else()
set(OPTIMIZATION_FLAG ${OPTIMIZE_FOR_SIZE_FLAG}) # Default
endif()
zephyr_compile_options(
${OPTIMIZATION_FLAG} # Usually -Os
-g # TODO: build configuration enough?
-Wall
-Wformat
-Wformat-security
-Wno-format-zero-length
-Wno-main
-ffreestanding
-include ${AUTOCONF_H}
)
zephyr_compile_options(
$<$<COMPILE_LANGUAGE:C>:-std=c99>
$<$<COMPILE_LANGUAGE:CXX>:-std=c++11>
$<$<COMPILE_LANGUAGE:CXX>:-fcheck-new>
$<$<COMPILE_LANGUAGE:CXX>:-ffunction-sections>
$<$<COMPILE_LANGUAGE:CXX>:-fdata-sections>
$<$<COMPILE_LANGUAGE:CXX>:-fno-rtti>
$<$<COMPILE_LANGUAGE:CXX>:-fno-exceptions>
$<$<COMPILE_LANGUAGE:ASM>:-xassembler-with-cpp>
$<$<COMPILE_LANGUAGE:ASM>:-D_ASMLANGUAGE>
)
zephyr_ld_options(
-nostartfiles
-nodefaultlibs
-nostdlib
-static
-no-pie
)
# ==========================================================================
#
# cmake -DW=... settings
#
# W=1 - warnings that may be relevant and does not occur too often
# W=2 - warnings that occur quite often but may still be relevant
# W=3 - the more obscure warnings, can most likely be ignored
# ==========================================================================
if(W MATCHES "1")
zephyr_compile_options(
-Wextra
-Wunused
-Wno-unused-parameter
-Wmissing-declarations
-Wmissing-format-attribute
-Wold-style-definition
)
zephyr_cc_option(
-Wmissing-prototypes
-Wmissing-include-dirs
-Wunused-but-set-variable
-Wno-missing-field-initializers
)
endif()
if(W MATCHES "2")
zephyr_compile_options(
-Waggregate-return
-Wcast-align
-Wdisabled-optimization
-Wnested-externs
-Wshadow
)
zephyr_cc_option(
-Wlogical-op
-Wmissing-field-initializers
)
endif()
if(W MATCHES "3")
zephyr_compile_options(
-Wbad-function-cast
-Wcast-qual
-Wconversion
-Wpacked
-Wpadded
-Wpointer-arith
-Wredundant-decls
-Wswitch-default
)
zephyr_cc_option(
-Wpacked-bitfield-compat
-Wvla
)
endif()
# Allow the user to inject options when calling cmake, e.g.
# 'cmake -DEXTRA_CFLAGS="-Werror -Wno-deprecated-declarations" ..'
separate_arguments(EXTRA_CPPFLAGS_AS_LIST UNIX_COMMAND ${EXTRA_CPPFLAGS})
separate_arguments(EXTRA_LD_FLAGS_AS_LIST UNIX_COMMAND ${EXTRA_LD_FLAGS})
separate_arguments(EXTRA_CFLAGS_AS_LIST UNIX_COMMAND ${EXTRA_CFLAGS})
separate_arguments(EXTRA_CXXFLAGS_AS_LIST UNIX_COMMAND ${EXTRA_CXXFLAGS})
separate_arguments(EXTRA_AFLAGS_AS_LIST UNIX_COMMAND ${EXTRA_AFLAGS})
if(EXTRA_CPPFLAGS)
zephyr_compile_definitions(${EXTRA_CPPFLAGS_AS_LIST})
endif()
if(EXTRA_LDFLAGS)
zephyr_link_libraries(${EXTRA_LDFLAGS_AS_LIST})
endif()
if(EXTRA_CFLAGS)
foreach(F ${EXTRA_CFLAGS_AS_LIST})
zephyr_compile_options($<$<COMPILE_LANGUAGE:C>:${F}>)
endforeach()
endif()
if(EXTRA_CXXFLAGS)
foreach(F ${EXTRA_CXXFLAGS_AS_LIST})
zephyr_compile_options($<$<COMPILE_LANGUAGE:CXX>:${F}>)
endforeach()
endif()
if(EXTRA_AFLAGS)
foreach(F ${EXTRA_AFLAGS_AS_LIST})
zephyr_compile_options($<$<COMPILE_LANGUAGE:ASM>:${F}>)
endforeach()
endif()
if(CONFIG_READABLE_ASM)
zephyr_cc_option(-fno-reorder-blocks)
zephyr_cc_option(-fno-ipa-cp-clone)
zephyr_cc_option(-fno-partial-inlining)
endif()
zephyr_cc_option(-fno-asynchronous-unwind-tables)
zephyr_cc_option(-fno-pie)
zephyr_cc_option(-fno-pic)
zephyr_cc_option(-fno-strict-overflow)
zephyr_cc_option(-Wno-pointer-sign)
if(CONFIG_STACK_CANARIES)
zephyr_cc_option(-fstack-protector-all)
else()
zephyr_cc_option(-fno-stack-protector)
endif()
if(CONFIG_OVERRIDE_FRAME_POINTER_DEFAULT)
if(CONFIG_OMIT_FRAME_POINTER)
zephyr_cc_option(-fomit-frame-pointer)
else()
zephyr_cc_option(-fno-omit-frame-pointer)
endif()
endif()
zephyr_compile_options(${CONFIG_COMPILER_OPT})
# TODO: Include arch compiler options at this point.
# TODO: This Clang check is broken
if(CMAKE_C_COMPILER_ID STREQUAL "Clang")
zephyr_cc_option(
-Wno-unknown-warning-option
-Wno-unused-variable
-Wno-format-invalid-specifier
-Wno-gnu
# comparison of unsigned expression < 0 is always false
-Wno-tautological-compare
)
else() # GCC assumed
zephyr_cc_option(
-Wno-unused-but-set-variable
-fno-reorder-functions
)
if(NOT ${ZEPHYR_GCC_VARIANT} STREQUAL "xcc")
zephyr_cc_option(-fno-defer-pop)
endif()
endif()
zephyr_cc_option_ifdef(CONFIG_DEBUG_SECTION_MISMATCH -fno-inline-functions-called-once)
zephyr_cc_option_ifdef(CONFIG_STACK_USAGE -fstack-usage)
zephyr_compile_options(-nostdinc)
zephyr_system_include_directories(${NOSTDINC})
# Force an error when things like SYS_INIT(foo, ...) occur with a missing header.
zephyr_cc_option(-Werror=implicit-int)
# Prohibit date/time macros, which would make the build non-deterministic
# cc-option(-Werror=date-time)
# TODO: Archiver arguments
# ar_option(D)
if(IS_TEST)
add_subdirectory(cmake/test)
endif()
set_ifndef(LINKERFLAGPREFIX -Wl)
zephyr_ld_options(
${LINKERFLAGPREFIX},-X
${LINKERFLAGPREFIX},-N
${LINKERFLAGPREFIX},--gc-sections
${LINKERFLAGPREFIX},--build-id=none
)
if(CONFIG_HAVE_CUSTOM_LINKER_SCRIPT)
set(LINKER_SCRIPT ${APPLICATION_SOURCE_DIR}/${CONFIG_CUSTOM_LINKER_SCRIPT})
if(NOT EXISTS LINKER_SCRIPT)
set(LINKER_SCRIPT ${CONFIG_CUSTOM_LINKER_SCRIPT})
if(NOT EXISTS LINKER_SCRIPT)
message(FATAL_ERROR "CONFIG_HAVE_CUSTOM_LINKER_SCRIPT was set, but no linker script was found at '${CONFIG_CUSTOM_LINKER_SCRIPT}'")
endif()
endif()
else()
# Try a board specific linker file
set(LINKER_SCRIPT ${BOARD_DIR}/linker.ld)
if(NOT EXISTS ${LINKER_SCRIPT})
# If not available, try an SoC specific linker file
set(LINKER_SCRIPT $ENV{ZEPHYR_BASE}/arch/${ARCH}/soc/${SOC_PATH}/linker.ld)
endif()
endif()
if(NOT EXISTS ${LINKER_SCRIPT})
message(FATAL_ERROR "Could not find linker script: '${LINKER_SCRIPT}'. Corrupted configuration?")
endif()
configure_file(version.h.in ${PROJECT_BINARY_DIR}/include/generated/version.h)
add_subdirectory(lib)
add_subdirectory(misc)
# We use include instead of add_subdirectory to avoid creating a new directory scope.
# This is because source file properties are directory scoped, including the GENERATED
# property which is set implicitly for custom command outputs
include(misc/generated/CMakeLists.txt)
add_subdirectory(boards)
add_subdirectory(ext)
add_subdirectory(subsys)
add_subdirectory(arch)
add_subdirectory(drivers)
add_subdirectory(tests)
# Generate offsets.c.obj from offsets.c
# Generate offsets.h from offsets.c.obj
set(OFFSETS_C_PATH $ENV{ZEPHYR_BASE}/arch/${ARCH}/core/offsets/offsets.c)
set(OFFSETS_O_PATH ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/offsets.dir/arch/${ARCH}/core/offsets/offsets.c.obj)
set(OFFSETS_H_PATH ${PROJECT_BINARY_DIR}/include/generated/offsets.h)
add_library(offsets STATIC ${OFFSETS_C_PATH})
target_link_libraries(offsets zephyr_interface)
add_custom_command(
OUTPUT ${OFFSETS_H_PATH}
COMMAND ${PYTHON_EXECUTABLE} $ENV{ZEPHYR_BASE}/scripts/gen_offset_header.py
-i ${OFFSETS_O_PATH}
-o ${OFFSETS_H_PATH}
DEPENDS offsets
)
add_custom_target(offsets_h DEPENDS ${OFFSETS_H_PATH})
zephyr_include_directories(${TOOLCHAIN_INCLUDES})
zephyr_get_include_directories(ZEPHYR_INCLUDES)
add_subdirectory(kernel)
# Read list content
get_property(ZEPHYR_LIBS_PROPERTY GLOBAL PROPERTY ZEPHYR_LIBS)
foreach(zephyr_lib ${ZEPHYR_LIBS_PROPERTY})
# TODO: Could this become an INTERFACE property of zephyr_interface?
add_dependencies(${zephyr_lib} offsets_h)
endforeach()
get_property(OUTPUT_FORMAT GLOBAL PROPERTY PROPERTY_OUTPUT_FORMAT)
# Run the pre-processor on the linker script
#
# Deal with the un-preprocessed linker scripts differently with
# different generators.
if(CMAKE_GENERATOR STREQUAL "Unix Makefiles")
# Note that the IMPLICIT_DEPENDS option is currently supported only
# for Makefile generators and will be ignored by other generators.
set(LINKER_SCRIPT_DEP IMPLICIT_DEPENDS C ${LINKER_SCRIPT})
elseif(CMAKE_GENERATOR STREQUAL "Ninja")
# Using DEPFILE with other generators than Ninja is an error.
set(LINKER_SCRIPT_DEP DEPFILE ${PROJECT_BINARY_DIR}/linker.cmd.dep)
else()
# TODO: How would the linker script dependencies work for non-linker
# script generators.
message(STATUS "Warning; this generator is not well supported. The
Linker script may not be regenerated when it should.")
set(LINKER_SCRIPT_DEP "")
endif()
get_property(LINKER_SCRIPT_DEFINES GLOBAL PROPERTY PROPERTY_LINKER_SCRIPT_DEFINES)
if(CONFIG_APPLICATION_MEMORY)
# Objects default to being in kernel space, and then we exclude
# certain items.
set(kernel_object_file_list
${ZEPHYR_LIBS_PROPERTY}
kernel
)
list(
REMOVE_ITEM
kernel_object_file_list
app
)
# The zephyr libraries in zephyr/lib/ and zephyr/test/ belong in
# userspace.
# NB: The business logic for determing what source files are in
# kernel space and what source files are in user space is
# fragile. Fix ASAP.
#
# The intended design is that certain directories are designated as
# containing userspace code and others for kernel space code. The
# implementation we have however is not working on directories of
# code, it is working on zephyr libraries. It is exploiting the fact
# that zephyr libraries follow a naming scheme as described in
# extensions.cmake:zephyr_library_get_current_dir_lib_name
#
# But code from test/ and lib/ that is placed in the "zephyr"
# library (with zephyr_sources()) will not be in a library that is
# prefixed with lib__ or test__ and will end up in the wrong address
# space.
set(application_space_dirs
lib
tests
)
foreach(f ${kernel_object_file_list})
foreach(app_dir ${application_space_dirs})
if(${f} MATCHES "^${app_dir}__") # Begins with ${app_dir}__, e.g. lib__libc
list(
REMOVE_ITEM
kernel_object_file_list
${f}
)
endif()
endforeach()
endforeach()
# Create a list ks, with relative paths to kernel space libs.
foreach(f ${kernel_object_file_list})
get_target_property(target_name ${f} NAME)
get_target_property(target_binary_dir ${f} BINARY_DIR)
string(REPLACE
${PROJECT_BINARY_DIR}
""
fixed_path
${target_binary_dir}
)
# Append / if not empty
if(fixed_path)
set(fixed_path "${fixed_path}/")
endif()
# Cut off leading / if present
if(fixed_path MATCHES "^/.+")
string(SUBSTRING ${fixed_path} 1 -1 fixed_path)
endif()
list(APPEND ks "${fixed_path}lib${target_name}.a")
endforeach()
# We are done constructing kernel_object_file_list, now we inject this
# information into the linker script through -D's
list(LENGTH kernel_object_file_list NUM_KERNEL_OBJECT_FILES)
list(APPEND LINKER_SCRIPT_DEFINES -DNUM_KERNEL_OBJECT_FILES=${NUM_KERNEL_OBJECT_FILES})
set(i 0)
foreach(f ${ks})
list(APPEND LINKER_SCRIPT_DEFINES -DKERNEL_OBJECT_FILE_${i}=${f})
math(EXPR i "${i}+1")
endforeach()
endif() # CONFIG_APPLICATION_MEMORY
get_filename_component(BASE_NAME ${CMAKE_CURRENT_BINARY_DIR} NAME)
add_custom_command(
OUTPUT linker.cmd
DEPENDS ${LINKER_SCRIPT}
${LINKER_SCRIPT_DEP}
# NB: This COMMAND is copy-pasted to generate linker_pass2.cmd
# TODO: Remove duplication
COMMAND ${CMAKE_C_COMPILER}
-x assembler-with-cpp
-nostdinc
-undef
-MD -MF linker.cmd.dep -MT ${BASE_NAME}/linker.cmd
${ZEPHYR_INCLUDES}
${LINKER_SCRIPT_DEFINES}
-E ${LINKER_SCRIPT} -P
-o linker.cmd
VERBATIM
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
)
add_custom_target(
linker_script
DEPENDS
linker.cmd
offsets_h
)
set(zephyr_lnk
${LINKERFLAGPREFIX},-Map=${PROJECT_BINARY_DIR}/${KERNEL_MAP_NAME}
-u_OffsetAbsSyms
-u_ConfigAbsSyms
-e__start
${LINKERFLAGPREFIX},--start-group
${LINKERFLAGPREFIX},--whole-archive
${ZEPHYR_LIBS_PROPERTY}
${LINKERFLAGPREFIX},--no-whole-archive
kernel
${OFFSETS_O_PATH}
${LINKERFLAGPREFIX},--end-group
${LIB_INCLUDE_DIR}
-L${PROJECT_BINARY_DIR}
${TOOLCHAIN_LIBS}
)
if(CONFIG_GEN_ISR_TABLES)
# isr_tables.c is generated from zephyr_prebuilt by
# gen_isr_tables.py
add_custom_command(
OUTPUT isr_tables.c
COMMAND ${CMAKE_OBJCOPY}
-I ${OUTPUT_FORMAT}
-O binary
--only-section=.intList
$<TARGET_FILE:zephyr_prebuilt>
isrList.bin
COMMAND ${PYTHON_EXECUTABLE}
$ENV{ZEPHYR_BASE}/arch/common/gen_isr_tables.py
--output-source isr_tables.c
--intlist isrList.bin
--debug
--sw-isr-table
--vector-table
DEPENDS zephyr_prebuilt
)
set_property(GLOBAL APPEND PROPERTY GENERATED_KERNEL_SOURCE_FILES isr_tables.c)
endif()
if(CONFIG_USERSPACE)
set(GEN_KOBJ_LIST $ENV{ZEPHYR_BASE}/scripts/gen_kobject_list.py)
set(PROCESS_GPERF $ENV{ZEPHYR_BASE}/scripts/process_gperf.py)
set(OBJ_LIST kobject_hash.gperf)
set(OUTPUT_SRC_PRE kobject_hash_preprocessed.c)
set(OUTPUT_SRC kobject_hash.c)
set(OUTPUT_OBJ kobject_hash.c.obj)
set(OUTPUT_OBJ_RENAMED kobject_hash_renamed.o)
# Essentially what we are doing here is extracting some information
# out of the nearly finished elf file, generating the source code
# for a hash table based on that information, and then compiling and
# linking the hash table back into a now even more nearly finished
# elf file.
# Use the script GEN_KOBJ_LIST to scan the kernel binary's
# (zephyr_prebuilt) DWARF information to produce a table of kernel
# objects (OBJ_LIST) which we will then pass to gperf
add_custom_command(
OUTPUT ${OBJ_LIST}
COMMAND
${PYTHON_EXECUTABLE}
${GEN_KOBJ_LIST}
--kernel $<TARGET_FILE:zephyr_prebuilt>
--output ${OBJ_LIST}
$<$<BOOL:${CMAKE_VERBOSE_MAKEFILE}>:--verbose>
DEPENDS zephyr_prebuilt
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)
add_custom_target(obj_list DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${OBJ_LIST})
# Use gperf to generate C code (OUTPUT_SRC_PRE) which implements a
# perfect hashtable based on OBJ_LIST
add_custom_command(
OUTPUT ${OUTPUT_SRC_PRE}
COMMAND
${GPERF}
--output-file ${OUTPUT_SRC_PRE}
${OBJ_LIST}
DEPENDS obj_list
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)
add_custom_target(output_src_pre DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${OUTPUT_SRC_PRE})
# For our purposes the code/data generated by gperf is not optimal.
#
# The script PROCESS_GPERF creates a new c file OUTPUT_SRC based on
# OUTPUT_SRC_PRE to greatly reduce the amount of code/data generated
# since we know we are always working with pointer values
add_custom_command(
OUTPUT ${OUTPUT_SRC}
COMMAND
${PROCESS_GPERF}
-i ${OUTPUT_SRC_PRE}
-o ${OUTPUT_SRC}
$<$<BOOL:${CMAKE_VERBOSE_MAKEFILE}>:--verbose>
DEPENDS output_src_pre
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)
add_custom_target(output_src DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${OUTPUT_SRC})
# We need precise control of where generated text/data ends up in the final
# kernel image. Disable function/data sections and use objcopy to move
# generated data into special section names
add_library(output_lib STATIC
${CMAKE_CURRENT_BINARY_DIR}/${OUTPUT_SRC}
)
target_link_libraries(output_lib zephyr_interface)
# Turn off -ffunction-sections, etc.
# NB: Using a library instead of target_compile_options(output_lib
# [...]) because a library's options have precedence
add_library(output_lib_interface INTERFACE)
target_compile_options(output_lib_interface INTERFACE
-fno-function-sections
-fno-data-sections
)
target_link_libraries(output_lib output_lib_interface)
set(OUTPUT_OBJ_PATH ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/output_lib.dir/${OUTPUT_OBJ})
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${OUTPUT_OBJ_RENAMED}
COMMAND
${CMAKE_OBJCOPY}
--rename-section .data=.kobject_data.data
--rename-section .text=.kobject_data.text
--rename-section .rodata=.kobject_data.rodata
${OUTPUT_OBJ_PATH}
${OUTPUT_OBJ_RENAMED}
DEPENDS output_lib
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)
add_custom_target(output_obj_renamed DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${OUTPUT_OBJ_RENAMED})
add_library(output_obj_renamed_lib STATIC IMPORTED GLOBAL)
set_property(
TARGET output_obj_renamed_lib
PROPERTY
IMPORTED_LOCATION ${CMAKE_CURRENT_BINARY_DIR}/${OUTPUT_OBJ_RENAMED}
)
add_dependencies(
output_obj_renamed_lib
output_obj_renamed
)
set_property(GLOBAL APPEND PROPERTY GENERATED_KERNEL_OBJECT_FILES output_obj_renamed_lib)
endif()
# Read global variables into local variables
get_property(GKOF GLOBAL PROPERTY GENERATED_KERNEL_OBJECT_FILES)
get_property(GKSF GLOBAL PROPERTY GENERATED_KERNEL_SOURCE_FILES)
# FIXME: Is there any way to get rid of empty_file.c?
add_executable( zephyr_prebuilt misc/empty_file.c)
target_link_libraries(zephyr_prebuilt -T${PROJECT_BINARY_DIR}/linker.cmd ${zephyr_lnk})
set_property(TARGET zephyr_prebuilt PROPERTY LINK_DEPENDS ${PROJECT_BINARY_DIR}/linker.cmd)
add_dependencies( zephyr_prebuilt linker_script offsets)
if(GKOF OR GKSF)
set(logical_target_for_zephyr_elf kernel_elf)
# The second linker pass uses the same source linker script of the
# first pass (LINKER_SCRIPT), but this time preprocessed with the
# define LINKER_PASS2.
add_custom_command(
OUTPUT linker_pass2.cmd
DEPENDS ${LINKER_SCRIPT}
${LINKER_SCRIPT_DEP}
COMMAND ${CMAKE_C_COMPILER}
-x assembler-with-cpp
-nostdinc
-undef
-MD -MF linker_pass2.cmd.dep -MT ${BASE_NAME}/linker_pass2.cmd
${ZEPHYR_INCLUDES}
${LINKER_SCRIPT_DEFINES}
-DLINKER_PASS2
-E ${LINKER_SCRIPT} -P
-o linker_pass2.cmd
VERBATIM
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
)
add_custom_target(
linker_pass2_script
DEPENDS
linker_pass2.cmd
offsets_h
)
add_executable( kernel_elf misc/empty_file.c ${GKSF})
target_link_libraries(kernel_elf ${GKOF} -T${PROJECT_BINARY_DIR}/linker_pass2.cmd ${zephyr_lnk})
set_property(TARGET kernel_elf PROPERTY LINK_DEPENDS ${PROJECT_BINARY_DIR}/linker_pass2.cmd)
add_dependencies( kernel_elf linker_pass2_script)
else()
set(logical_target_for_zephyr_elf zephyr_prebuilt)
# Use the prebuilt elf as the final elf since we don't have a
# generation stage.
endif()
# To avoid having the same logical target name for the zephyr lib and
# the zephyr elf, we set the kernel_elf file name to zephyr.elf.
set_target_properties(${logical_target_for_zephyr_elf} PROPERTIES OUTPUT_NAME ${KERNEL_NAME})
add_custom_command(
TARGET ${logical_target_for_zephyr_elf}
POST_BUILD
COMMAND ${PYTHON_EXECUTABLE} $ENV{ZEPHYR_BASE}/scripts/check_link_map.py ${KERNEL_MAP_NAME}
COMMAND ${CMAKE_OBJCOPY} -S -Oihex -R .comment -R COMMON -R .eh_frame ${KERNEL_ELF_NAME} ${KERNEL_HEX_NAME}
COMMAND ${CMAKE_OBJCOPY} -S -Obinary -R .comment -R COMMON -R .eh_frame ${KERNEL_ELF_NAME} ${KERNEL_BIN_NAME}
COMMAND ${CMAKE_OBJCOPY} --srec-len 1 --output-target=srec ${KERNEL_ELF_NAME} ${KERNEL_S19_NAME}
COMMAND ${CMAKE_OBJDUMP} -S ${KERNEL_ELF_NAME} > ${KERNEL_LST_NAME}
COMMAND ${CMAKE_READELF} -e ${KERNEL_ELF_NAME} > ${KERNEL_STAT_NAME}
COMMAND ${CMAKE_STRIP} --strip-all ${KERNEL_ELF_NAME} -o ${KERNEL_STRIP_NAME}
COMMENT "Generating zephyr.{hex,bin,lst,strip,stat,s19} from zephyr.elf for board: ${BOARD}"
# NB: COMMENT only works for some CMake-Generators
)
add_subdirectory(cmake/qemu)
add_subdirectory(cmake/flash)
add_subdirectory(cmake/usage)
add_subdirectory(cmake/reports)
include(cmake/ccache.cmake)
if(CONFIG_ASSERT)
message(WARNING "
------------------------------------------------------------
--- WARNING: __ASSERT() statements are globally ENABLED ---
--- The kernel will run more slowly and uses more memory ---
------------------------------------------------------------"
)
endif()
if(CONFIG_BOARD_DEPRECATED)
message(WARNING "
WARNING: The board '${BOARD}' is deprecated and will be
removed in version ${CONFIG_BOARD_DEPRECATED}"
)
endif()

2
arch/CMakeLists.txt Normal file
View file

@ -0,0 +1,2 @@
add_subdirectory(common)
add_subdirectory(${ARCH})

14
arch/arc/CMakeLists.txt Normal file
View file

@ -0,0 +1,14 @@
# Enable debug support in mdb
# Dwarf version 2 can be recognized by mdb
# The default dwarf version in gdb is not recognized by mdb
zephyr_cc_option(-g3 -gdwarf-2)
# Without this (poorly named) option, compiler may generate undefined
# references to abort().
# See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63691
zephyr_cc_option(-fno-delete-null-pointer-checks)
zephyr_cc_option_ifdef (CONFIG_LTO -flto)
add_subdirectory(soc/${SOC_PATH})
add_subdirectory(core)

View file

@ -0,0 +1,23 @@
zephyr_sources(
thread.c
thread_entry_wrapper.S
cpu_idle.S
fast_irq.S
fatal.c
fault.c
fault_s.S
irq_manage.c
cache.c
timestamp.c
isr_wrapper.S
regular_irq.S
swap.S
sys_fatal_error_handler.c
prep_c.c
reset.S
vector_table.c
)
zephyr_sources_if_kconfig(irq_offload.c)
zephyr_sources_ifdef(CONFIG_ATOMIC_OPERATIONS_CUSTOM atomic.c)
add_subdirectory_ifdef(CONFIG_CPU_HAS_MPU mpu)

View file

@ -0,0 +1,2 @@
zephyr_sources_if_kconfig(arc_core_mpu.c)
zephyr_sources_if_kconfig(arc_mpu.c)

View file

@ -0,0 +1,14 @@
zephyr_library_include_directories(${PROJECT_SOURCE_DIR}/drivers)
zephyr_cc_option(-mcpu=em4_fpuda -mno-sdata -mdiv-rem -mswap -mnorm)
zephyr_cc_option(-mmpy-option=6 -mbarrel-shifter)
zephyr_cc_option(--param l1-cache-size=16384)
zephyr_cc_option(--param l1-cache-line-size=32)
zephyr_cc_option_ifdef(CONFIG_CODE_DENSITY -mcode-density)
zephyr_cc_option_ifdef(CONFIG_FLOAT -mfpu=fpuda_all)
zephyr_sources(
soc.c
soc_config.c
)

View file

@ -0,0 +1,21 @@
zephyr_library_include_directories(${PROJECT_SOURCE_DIR}/drivers)
zephyr_cc_option(-mcpu=-mcpu=em4_dmips -mno-sdata)
zephyr_cc_option(-mdiv-rem -mswap -mnorm)
zephyr_cc_option(-mmpy-option=6 -mbarrel-shifter)
zephyr_cc_option(--param l1-cache-size=16384)
zephyr_cc_option(--param l1-cache-line-size=32)
zephyr_cc_option_ifdef(CONFIG_CODE_DENSITY -mcode-density)
if(CONFIG_BOARD_EM_STARTERKIT_R23)
message(FATAL "em7d from em starterkit 2.3 is not supported")
endif()
zephyr_sources(
soc.c
soc_config.c
)
zephyr_source_ifdef(CONFIG_ARC_MPU_ENABLE arc_mpu_regions.c)

View file

@ -0,0 +1,14 @@
zephyr_library_include_directories(${PROJECT_SOURCE_DIR}/drivers)
zephyr_cc_option(-mcpu=em4_fpus -mno-sdata -mdiv-rem -mswap -mnorm)
zephyr_cc_option(-mdiv-rem -mswap -mnorm)
zephyr_cc_option(-mmpy-option=6 -mbarrel-shifter)
zephyr_cc_option_ifdef(CONFIG_CODE_DENSITY -mcode-density)
zephyr_cc_option_ifdef(CONFIG_FLOAT -mfpu=fpuda_all)
zephyr_sources(
soc.c
soc_config.c
)

View file

@ -0,0 +1,17 @@
zephyr_library_include_directories(${PROJECT_SOURCE_DIR}/drivers)
zephyr_include_directories(${PROJECT_SOURCE_DIR}/arch/x86/soc/intel_quark)
zephyr_cc_option(-mcpu=quarkse_em -mno-sdata)
zephyr_compile_definitions_ifdef(
CONFIG_SOC_QUARK_SE_C1000_SS
QM_SENSOR=1
SOC_SERIES=quark_se
)
zephyr_sources(
soc.c
soc_config.c
power.c
soc_power.S
)

21
arch/arm/CMakeLists.txt Normal file
View file

@ -0,0 +1,21 @@
zephyr_cc_option_ifdef(CONFIG_LTO -flto)
set(ARCH_FOR_cortex-m0 armv6-m )
set(ARCH_FOR_cortex-m0plus armv6-m )
set(ARCH_FOR_cortex-m3 armv7-m )
set(ARCH_FOR_cortex-m4 armv7e-m )
set(ARCH_FOR_cortex-m23 armv8-m.base)
set(ARCH_FOR_cortex-m33 armv8-m.main)
if(${ARCH_FOR_${GCC_M_CPU}})
set(ARCH_FLAG -march=${ARCH_FOR_${GCC_M_CPU}})
endif()
zephyr_compile_options(
-mabi=aapcs
${TOOLCHAIN_C_FLAGS}
${ARCH_FLAG}
)
add_subdirectory(soc)
add_subdirectory(core)

View file

@ -0,0 +1,20 @@
zephyr_sources(
exc_exit.S
irq_init.c
swap.S
fault.c
irq_manage.c
thread.c
cpu_idle.S
fault_s.S
fatal.c
sys_fatal_error_handler.c
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)
add_subdirectory_ifdef(CONFIG_CPU_CORTEX_M cortex_m)
add_subdirectory_ifdef(CONFIG_CPU_HAS_MPU cortex_m/mpu)

View file

@ -0,0 +1,9 @@
zephyr_sources(
vector_table.S
reset.S
nmi_on_reset.S
prep_c.c
scb.c
nmi.c
exc_manage.c
)

View file

@ -0,0 +1,3 @@
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)

View file

@ -0,0 +1,6 @@
if(SOC_FAMILY)
add_subdirectory(${SOC_FAMILY})
else()
add_subdirectory(${SOC_NAME})
endif()

View file

@ -0,0 +1 @@
add_subdirectory(${SOC_SERIES})

View file

@ -0,0 +1,5 @@
zephyr_sources(
soc.c
power.c
)
zephyr_sources_ifdef(CONFIG_ARM_MPU_ENABLE arm_mpu_regions.c)

View file

@ -0,0 +1,3 @@
zephyr_sources(
soc.c
)

View file

@ -0,0 +1,8 @@
# Makefile - Atmel SAM MCU family
#
# Copyright (c) 2016 Piotr Mienkowski
# SPDX-License-Identifier: Apache-2.0
#
add_subdirectory(${SOC_SERIES})
add_subdirectory_ifdef(CONFIG_ASF common)

View file

@ -0,0 +1,5 @@
zephyr_include_directories(.)
zephyr_sources(
soc_pmc.c
soc_gpio.c
)

View file

@ -0,0 +1,3 @@
zephyr_sources(
soc.c
)

View file

@ -0,0 +1,3 @@
zephyr_sources(
soc.c
)

View file

@ -0,0 +1,4 @@
zephyr_sources(
soc.c
soc_config.c
)

View file

@ -0,0 +1,5 @@
zephyr_include_directories(
include
)
add_subdirectory(${SOC_SERIES})

View file

@ -0,0 +1,9 @@
zephyr_compile_definitions_ifdef(
CONFIG_SOC_SERIES_NRF51X
NRF51
NRF51822
)
zephyr_sources(
soc.c
)

View file

@ -0,0 +1,8 @@
zephyr_compile_definitions_ifdef(CONFIG_SOC_NRF52832 NRF52832_XXAA)
zephyr_compile_definitions_ifdef(CONFIG_SOC_NRF52840 NRF52840_XXAA)
zephyr_sources(
mpu_regions.c
power.c
soc.c
)

View file

@ -0,0 +1 @@
add_subdirectory(${SOC_SERIES})

View file

@ -0,0 +1,8 @@
zephyr_sources(
soc.c
wdog.S
)
zephyr_sources_ifdef(
CONFIG_HAS_SYSMPU
nxp_mpu_regions.c
)

View file

@ -0,0 +1 @@
zephyr_sources(soc.c)

View file

@ -0,0 +1,4 @@
zephyr_sources_ifdef(CONFIG_SOC_MKW24D5 wdog.S soc_kw2xd.c)
zephyr_sources_ifdef(CONFIG_SOC_MKW22D5 wdog.S soc_kw2xd.c)
zephyr_sources_ifdef(CONFIG_SOC_MKW41Z4 soc_kw4xz.c)
zephyr_sources_ifdef(CONFIG_SOC_MKW40Z4 soc_kw4xz.c)

View file

@ -0,0 +1,2 @@
add_subdirectory(${SOC_SERIES})
add_subdirectory(common)

View file

@ -0,0 +1 @@
zephyr_sources(soc_gpio.c)

View file

@ -0,0 +1 @@
zephyr_sources(soc.c)

View file

@ -0,0 +1,2 @@
add_subdirectory(${SOC_SERIES})
add_subdirectory(common)

View file

@ -0,0 +1 @@
zephyr_sources_ifdef(CONFIG_STM32_ARM_MPU_ENABLE arm_mpu_regions.c)

View file

@ -0,0 +1,3 @@
zephyr_include_directories($ENV{ZEPHYR_BASE}/drivers)
zephyr_sources(soc.c)
zephyr_sources_ifdef(CONFIG_GPIO soc_gpio.c)

View file

@ -0,0 +1,5 @@
zephyr_include_directories($ENV{ZEPHYR_BASE}/drivers)
zephyr_sources(
soc.c
)
zephyr_sources_ifdef(CONFIG_GPIO soc_gpio.c)

View file

@ -0,0 +1,5 @@
zephyr_include_directories($ENV{ZEPHYR_BASE}/drivers)
zephyr_sources(
soc.c
)
zephyr_sources_ifdef(CONFIG_GPIO soc_gpio.c)

View file

@ -0,0 +1,5 @@
zephyr_include_directories($ENV{ZEPHYR_BASE}/drivers)
zephyr_sources(
soc.c
)
zephyr_sources_ifdef(CONFIG_GPIO soc_gpio.c)

View file

@ -0,0 +1,5 @@
zephyr_include_directories($ENV{ZEPHYR_BASE}/drivers)
zephyr_sources(
soc.c
)
zephyr_sources_ifdef(CONFIG_GPIO soc_gpio.c)

View file

@ -0,0 +1,4 @@
zephyr_sources(
soc.c
soc_config.c
)

View file

@ -0,0 +1 @@
add_subdirectory(${SOC_SERIES})

View file

@ -0,0 +1 @@
zephyr_sources(soc.c)

View file

@ -0,0 +1 @@
zephyr_sources(soc.c)

View file

@ -0,0 +1,2 @@
zephyr_compile_definitions(-D__MSP432P401R__)
zephyr_sources(soc.c)

View file

@ -0,0 +1,13 @@
# Put functions and data in their own binary sections so that ld can
# garbage collect them
zephyr_cc_option(-ffunction-sections -fdata-sections)
zephyr_sources_ifdef(
CONFIG_GEN_ISR_TABLES
isr_tables.c
)
zephyr_sources_ifdef(
CONFIG_EXECUTION_BENCHMARKING
timing_info_bench.c
)

37
arch/nios2/CMakeLists.txt Normal file
View file

@ -0,0 +1,37 @@
if(CONFIG_GP_NONE)
set(gpopt none)
elseif(CONFIG_GP_LOCAL)
set(gpopt local)
elseif(CONFIG_GP_GLOBAL)
set(gpopt global)
elseif(CONFIG_GP_ALL_DATA)
set(gpopt data)
endif()
# Set Global Pointer option based on Kconfig.
zephyr_cc_option(-mgpopt=${gpopt})
# TODO Find a way to pull this out of system.h somehow
# instead of having Kconfig for it
if(CONFIG_HAS_MUL_INSTRUCTION)
zephyr_cc_option(-mhw-mul)
else()
zephyr_cc_option(-mno-hw-mul)
endif()
if(CONFIG_HAS_MULX_INSTRUCTION)
zephyr_cc_option(-mhw-mulx)
else()
zephyr_cc_option(-mno-hw-mulx)
endif()
if(CONFIG_HAS_DIV_INSTRUCTION)
zephyr_cc_option(-mhw-div)
else()
zephyr_cc_option(-mno-hw-div)
endif()
add_subdirectory(soc/${SOC_PATH})
add_subdirectory(core)

View file

@ -0,0 +1,14 @@
zephyr_sources(
thread.c
cpu_idle.c
fatal.c
irq_manage.c
swap.S
prep_c.c
reset.S
cache.c
exception.S
crt0.S
)
zephyr_sources_if_kconfig(irq_offload.c)

View file

View file

@ -0,0 +1,2 @@
set($ENV{NIOS2_CPU_SOF} $ENV{ZEPHYR_BASE}/arch/nios2/soc/nios2f-zephyr/cpu/ghrd_10m50da.sof)

View file

@ -0,0 +1,4 @@
add_subdirectory(soc)
add_subdirectory(core)
set_property(GLOBAL PROPERTY PROPERTY_OUTPUT_FORMAT elf32-littleriscv)

View file

@ -0,0 +1,11 @@
zephyr_sources(
cpu_idle.c
fatal.c
irq_manage.c
irq_offload.c
isr.S
prep_c.c
reset.S
swap.S
thread.c
)

View file

@ -0,0 +1,6 @@
if(SOC_FAMILY)
add_subdirectory(${SOC_FAMILY})
else()
add_subdirectory(${SOC_NAME})
endif()

View file

@ -0,0 +1,13 @@
zephyr_include_directories(.)
zephyr_compile_options_ifndef(
CONFIG_RISCV_GENERIC_TOOLCHAIN
-march=IMXpulpv2
)
zephyr_sources(
soc_irq.S
vector.S
pulpino_irq.c
pulpino_idle.c
)

View file

@ -0,0 +1,2 @@
add_subdirectory(common)
add_subdirectory(${SOC_SERIES})

View file

@ -0,0 +1,6 @@
zephyr_include_directories(.)
zephyr_sources(
soc_irq.S
soc_common_irq.c
)

View file

@ -0,0 +1,4 @@
zephyr_sources(
vector.S
fe310_idle.c
)

View file

@ -0,0 +1,4 @@
zephyr_sources(
qemu_irq.S
vector.S
)

203
arch/x86/CMakeLists.txt Normal file
View file

@ -0,0 +1,203 @@
# Find out if we are optimizing for size
get_target_property(zephyr_COMPILE_OPTIONS zephyr_interface INTERFACE_COMPILE_OPTIONS)
if ("-Os" IN_LIST zephyr_COMPILE_OPTIONS)
zephyr_cc_option(-mpreferred-stack-boundary=2)
else()
zephyr_compile_definitions(PERF_OPT)
endif()
if(CMAKE_C_COMPILER_ID STREQUAL "Clang")
if(CONFIG_X86_IAMCU)
zephyr_cc_option(-Qunused-arguments)
else()
zephyr_cc_option(-mmcu)
endif()
zephyr_cc_option(
-m32
-gdwarf-2
)
endif()
zephyr_cc_option_ifdef (CONFIG_LTO -flto)
zephyr_cc_option_ifndef(CONFIG_SSE_FP_MATH -mno-sse)
if(CMAKE_VERBOSE_MAKEFILE)
set(GENIDT_EXTRA_ARGS --verbose)
else()
set(GENIDT_EXTRA_ARGS "")
endif()
set(GENIDT ${PROJECT_SOURCE_DIR}/scripts/gen_idt.py)
define_property(GLOBAL PROPERTY PROPERTY_OUTPUT_ARCH BRIEF_DOCS " " FULL_DOCS " ")
set_property(GLOBAL PROPERTY PROPERTY_OUTPUT_ARCH "i386")
set_property(GLOBAL PROPERTY PROPERTY_OUTPUT_FORMAT "elf32-i386")
# Use gen_idt.py and objcopy to generate irq_int_vector_map.o and
# staticIdt.o from the elf file zephyr_prebuilt
set(gen_idt_output_files
${CMAKE_CURRENT_BINARY_DIR}/irq_int_vector_map.bin
${CMAKE_CURRENT_BINARY_DIR}/staticIdt.bin
)
add_custom_target(
gen_idt_output
DEPENDS
${gen_idt_output_files}
)
add_custom_command(
OUTPUT irq_int_vector_map.bin staticIdt.bin
COMMAND
${PYTHON_EXECUTABLE}
${GENIDT}
--kernel $<TARGET_FILE:zephyr_prebuilt>
--output-idt staticIdt.bin
--vector-map irq_int_vector_map.bin
${GENIDT_EXTRA_ARGS}
DEPENDS zephyr_prebuilt
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)
add_subdirectory_ifdef(CONFIG_GDB_SERVER debug)
add_subdirectory(soc/${SOC_PATH})
# Must be last so that debug/ or soc/ can override default exception
# handlers
add_subdirectory(core)
get_property(OUTPUT_ARCH GLOBAL PROPERTY PROPERTY_OUTPUT_ARCH)
get_property(OUTPUT_FORMAT GLOBAL PROPERTY PROPERTY_OUTPUT_FORMAT)
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/irq_int_vector_map.o
COMMAND
${CMAKE_OBJCOPY}
-I binary
-B ${OUTPUT_ARCH}
-O ${OUTPUT_FORMAT}
--rename-section .data=irq_int_vector_map
irq_int_vector_map.bin
irq_int_vector_map.o
DEPENDS gen_idt_output irq_int_vector_map.bin
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/staticIdt.o
COMMAND
${CMAKE_OBJCOPY}
-I binary
-B ${OUTPUT_ARCH}
-O ${OUTPUT_FORMAT}
--rename-section .data=staticIdt
staticIdt.bin
staticIdt.o
DEPENDS gen_idt_output staticIdt.bin
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)
add_custom_target(irq_int_vector_map_o DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/irq_int_vector_map.o)
add_custom_target(staticIdt_o DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/staticIdt.o)
add_library(irq_int_vector_map STATIC IMPORTED GLOBAL)
add_library(staticIdt STATIC IMPORTED GLOBAL)
set_property(TARGET irq_int_vector_map PROPERTY IMPORTED_LOCATION ${CMAKE_CURRENT_BINARY_DIR}/irq_int_vector_map.o)
set_property(TARGET staticIdt PROPERTY IMPORTED_LOCATION ${CMAKE_CURRENT_BINARY_DIR}/staticIdt.o)
add_dependencies(irq_int_vector_map irq_int_vector_map_o)
add_dependencies(staticIdt staticIdt_o)
set_property(GLOBAL APPEND PROPERTY GENERATED_KERNEL_OBJECT_FILES irq_int_vector_map)
set_property(GLOBAL APPEND PROPERTY GENERATED_KERNEL_OBJECT_FILES staticIdt)
if(CONFIG_X86_MMU)
# Use gen_mmu.py and objcopy to generate mmu_tables.o from from the
# elf file zephyr_prebuilt, creating the temp files mmu_tables.bin
# and mmulist.bin along the way.
#
# zephyr_prebuilt.elf -> mmulist.bin -> mmu_tables.bin -> mmu_tables.o
add_custom_command(
OUTPUT mmulist.bin
COMMAND
${CMAKE_OBJCOPY}
-I ${OUTPUT_FORMAT}
-O binary
-j mmulist
$<TARGET_FILE:zephyr_prebuilt>
mmulist.bin
DEPENDS zephyr_prebuilt
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)
add_custom_command(
OUTPUT mmu_tables.bin
COMMAND
${PYTHON_EXECUTABLE}
${PROJECT_SOURCE_DIR}/scripts/gen_mmu_x86.py
-i mmulist.bin
-k $<TARGET_FILE:zephyr_prebuilt>
-o mmu_tables.bin
$<$<BOOL:${CMAKE_VERBOSE_MAKEFILE}>:-v>
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
DEPENDS mmulist.bin
DEPENDS zephyr_prebuilt
)
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/mmu_tables.o
COMMAND
${CMAKE_OBJCOPY}
-I binary
-B ${OUTPUT_ARCH}
-O ${OUTPUT_FORMAT}
--rename-section .data=.mmu_data
mmu_tables.bin
mmu_tables.o
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
DEPENDS mmu_tables.bin
)
add_custom_target( mmu_tables_o DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/mmu_tables.o)
add_library( mmu_tables STATIC IMPORTED GLOBAL)
set_property(TARGET mmu_tables PROPERTY IMPORTED_LOCATION ${CMAKE_CURRENT_BINARY_DIR}/mmu_tables.o)
add_dependencies( mmu_tables mmu_tables_o)
set_property(GLOBAL APPEND PROPERTY GENERATED_KERNEL_OBJECT_FILES mmu_tables)
endif()
if(CONFIG_GDT_DYNAMIC)
# Use gen_gdt.py and objcopy to generate gdt.o from from the elf
# file zephyr_prebuilt, creating the temp file gdt.bin along the
# way.
#
# zephyr_prebuilt.elf -> gdt.bin -> gdt.o
add_custom_command(
OUTPUT gdt.bin
COMMAND
${PYTHON_EXECUTABLE}
${PROJECT_SOURCE_DIR}/scripts/gen_gdt.py
--kernel $<TARGET_FILE:zephyr_prebuilt>
--output-gdt gdt.bin
$<$<BOOL:${CMAKE_VERBOSE_MAKEFILE}>:--verbose>
DEPENDS zephyr_prebuilt
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/gdt.o
COMMAND
${CMAKE_OBJCOPY}
-I binary
-B ${OUTPUT_ARCH}
-O ${OUTPUT_FORMAT}
--rename-section .data=gdt_ram_data
gdt.bin
gdt.o
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
DEPENDS gdt.bin
)
add_custom_target( gdt_o DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/gdt.o)
add_library( gdt STATIC IMPORTED GLOBAL)
set_property(TARGET gdt PROPERTY IMPORTED_LOCATION ${CMAKE_CURRENT_BINARY_DIR}/gdt.o)
add_dependencies( gdt gdt_o)
set_property(GLOBAL APPEND PROPERTY GENERATED_KERNEL_OBJECT_FILES gdt)
endif()

View file

@ -0,0 +1,31 @@
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>)
add_subdirectory_ifdef(CONFIG_DEBUG_INFO debug)
zephyr_sources(
cache.c
cache_s.S
cpuhalt.c
crt0.S
excstub.S
intstub.S
irq_manage.c
msr.c
swap.S
sys_fatal_error_handler.c
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)
# Last since we declare default exception handlers here
zephyr_sources(fatal.c)

View file

@ -0,0 +1,7 @@
zephyr_library()
zephyr_library_include_directories(${PROJECT_SOURCE_DIR}/drivers)
zephyr_cc_option(-march=atom)
zephyr_cc_option_fallback(-mtune=atom -mtune=generic)
zephyr_library_sources(soc.c)

View file

@ -0,0 +1,13 @@
zephyr_library()
zephyr_library_include_directories(${PROJECT_SOURCE_DIR}/drivers)
zephyr_cc_option(-march=pentium)
if(CONFIG_X86_IAMCU)
set_property(GLOBAL APPEND PROPERTY PROPERTY_LINKER_SCRIPT_DEFINES -D__IAMCU)
set_property(GLOBAL PROPERTY PROPERTY_OUTPUT_FORMAT "elf32-iamcu")
set_property(GLOBAL PROPERTY PROPERTY_OUTPUT_ARCH "iamcu:intel")
zephyr_cc_option(-msoft-float)
endif()
zephyr_library_sources(soc.c)

View file

@ -0,0 +1,15 @@
zephyr_library_include_directories(${PROJECT_SOURCE_DIR}/drivers)
zephyr_compile_definitions_ifdef(
CONFIG_SOC_QUARK_D2000
QM_LAKEMONT
SOC_SERIES=quark_d2000
)
zephyr_cc_option(-march=lakemont -mtune=lakemont -msoft-float)
if(CONFIG_X86_IAMCU)
set_property(GLOBAL APPEND PROPERTY PROPERTY_LINKER_SCRIPT_DEFINES -D__IAMCU)
set_property(GLOBAL PROPERTY PROPERTY_OUTPUT_FORMAT "elf32-iamcu")
set_property(GLOBAL PROPERTY PROPERTY_OUTPUT_ARCH "iamcu:intel")
endif()

View file

@ -0,0 +1,23 @@
zephyr_library_include_directories(${PROJECT_SOURCE_DIR}/drivers)
zephyr_compile_definitions_ifdef(
CONFIG_SOC_QUARK_SE_C1000
QM_LAKEMONT
SOC_SERIES=quark_se
)
zephyr_cc_option(-march=lakemont -mtune=lakemont -msoft-float)
if(CONFIG_X86_IAMCU)
set_property(GLOBAL APPEND PROPERTY PROPERTY_LINKER_SCRIPT_DEFINES -D__IAMCU)
set_property(GLOBAL PROPERTY PROPERTY_OUTPUT_FORMAT "elf32-iamcu")
set_property(GLOBAL PROPERTY PROPERTY_OUTPUT_ARCH "iamcu:intel")
endif()
zephyr_sources(
soc.c
soc_config.c
eoi.c
power.c
soc_power.S
)

View file

@ -0,0 +1,6 @@
zephyr_library_include_directories(${PROJECT_SOURCE_DIR}/drivers)
zephyr_cc_option(-march=lakemont -mtune=lakemont -msoft-float)
zephyr_sources(soc.c)

View file

@ -0,0 +1,10 @@
set_property(GLOBAL PROPERTY PROPERTY_OUTPUT_FORMAT elf32-xtensa-le)
if(SOC_FAMILY)
add_subdirectory(soc/${SOC_FAMILY})
else()
add_subdirectory(soc/${SOC_PATH})
endif()
add_subdirectory(core)

View file

@ -0,0 +1,22 @@
zephyr_cc_option(-mlongcalls)
zephyr_sources(
cpu_idle.c
fatal.c
irq_manage.c
swap.S
thread.c
xtensa_context.S
xtensa_intr_asm.S
xtensa_intr.c
xtensa_vectors.S
xt_zephyr.S
)
zephyr_sources_ifndef(CONFIG_ATOMIC_OPERATIONS_C atomic.S)
zephyr_sources_ifdef(CONFIG_XTENSA_USE_CORE_CRT1
crt1.S
)
zephyr_sources_ifdef(CONFIG_IRQ_OFFLOAD
irq_offload.c
)
add_subdirectory(startup)

View file

@ -0,0 +1,13 @@
if(CONFIG_XTENSA_RESET_VECTOR)
zephyr_library()
zephyr_library_cc_option(
-c
-mtext-section-literals
-mlongcalls
)
zephyr_library_sources(
reset-vector.S
)
endif()

View file

@ -0,0 +1,3 @@
zephyr_sources(
soc.c
)

6
boards/CMakeLists.txt Normal file
View file

@ -0,0 +1,6 @@
# To avoid a lot of empty CMakeLists.txt files we assume it is not an
# error if it is missing
if(EXISTS ${BOARD_DIR}/CMakeLists.txt)
add_subdirectory(${BOARD_DIR})
endif()

View file

@ -0,0 +1,20 @@
if(DEFINED ENV{ZEPHYR_FLASH_OVER_DFU})
set(FLASH_SCRIPT dfuutil.sh)
set_property(GLOBAL APPEND PROPERTY FLASH_SCRIPT_ENV_VARS
DFUUTIL_PID=8087:0aba
DFUUTIL_ALT=sensor_core
DFUUTIL_IMG=${PROJECT_BINARY_DIR}/${KERNEL_BIN_NAME}
)
else()
set(FLASH_SCRIPT openocd.sh)
endif()
set(DEBUG_SCRIPT openocd.sh)
set_property(GLOBAL APPEND PROPERTY FLASH_SCRIPT_ENV_VARS
OPENOCD_PRE_CMD="targets 1"
OPENOCD_LOAD_CMD="load_image ${PROJECT_BINARY_DIR}/${KERNEL_BIN_NAME} ${CONFIG_FLASH_BASE_ADDRESS}"
OPENOCD_VERIFY_CMD="verify_image ${PROJECT_BINARY_DIR}/${KERNEL_BIN_NAME} ${CONFIG_FLASH_BASE_ADDRESS}"
GDB_PORT=3334
)

View file

@ -0,0 +1,7 @@
set(FLASH_SCRIPT arc_debugger.sh)
set(DEBUG_SCRIPT arc_debugger.sh)
set_property(GLOBAL APPEND PROPERTY FLASH_SCRIPT_ENV_VARS
OPENOCD_LOAD_CMD="load_image ${PROJECT_BINARY_DIR}/${KERNEL_ELF_NAME} ${CONFIG_FLASH_BASE_ADDRESS}"
OPENOCD_VERIFY_CMD="verify_image ${PROJECT_BINARY_DIR}/${KERNEL_ELF_NAME} ${CONFIG_FLASH_BASE_ADDRESS}"
)

View file

@ -0,0 +1,5 @@
include($ENV{ZEPHYR_BASE}/boards/common/openocd.board.cmake)
set_property(GLOBAL APPEND PROPERTY FLASH_SCRIPT_ENV_VARS
OPENOCD_PRE_CMD="targets 1"
)

View file

@ -0,0 +1,5 @@
include($ENV{ZEPHYR_BASE}/boards/common/openocd.board.cmake)
set_property(GLOBAL APPEND PROPERTY FLASH_SCRIPT_ENV_VARS
OPENOCD_PRE_CMD="targets 1"
)

View file

@ -0,0 +1,3 @@
zephyr_library()
zephyr_library_sources(pinmux.c)
zephyr_library_include_directories(${PROJECT_SOURCE_DIR}/drivers)

View file

@ -0,0 +1,8 @@
set(FLASH_SCRIPT dfuutil.sh)
set_property(GLOBAL APPEND PROPERTY FLASH_SCRIPT_ENV_VARS
DFUUTIL_PID=0483:df11
DFUUTIL_ALT=0
DFUUTIL_IMG=${PROJECT_BINARY_DIR}/${KERNEL_BIN_NAME}
DFUUTIL_DFUSE_ADDR=${CONFIG_FLASH_BASE_ADDRESS}
)

View file

@ -0,0 +1,3 @@
zephyr_library()
zephyr_library_sources(pinmux.c)
zephyr_library_include_directories(${PROJECT_SOURCE_DIR}/drivers)

View file

@ -0,0 +1,6 @@
set(FLASH_SCRIPT pyocd.sh)
set(DEBUG_SCRIPT pyocd.sh)
set_property(GLOBAL APPEND PROPERTY FLASH_SCRIPT_ENV_VARS
PYOCD_TARGET=nrf52
)

View file

@ -0,0 +1,9 @@
if(DEFINED ENV{ZEPHYR_FLASH_OVER_DFU})
set(FLASH_SCRIPT dfuutil.sh)
set_property(GLOBAL APPEND PROPERTY FLASH_SCRIPT_ENV_VARS
DFUUTIL_PID=8087:0aba
DFUUTIL_ALT=ble_core
DFUUTIL_IMG=${PROJECT_BINARY_DIR}/${KERNEL_BIN_NAME}
)
endif()

View file

@ -0,0 +1,3 @@
zephyr_library()
zephyr_library_include_directories(${PROJECT_SOURCE_DIR}/drivers)
zephyr_library_sources_if_kconfig(pinmux.c)

View file

@ -0,0 +1 @@
set(FLASH_SCRIPT bossa-flash.sh)

View file

@ -0,0 +1,6 @@
set(FLASH_SCRIPT pyocd.sh)
set(DEBUG_SCRIPT pyocd.sh)
set_property(GLOBAL APPEND PROPERTY FLASH_SCRIPT_ENV_VARS
PYOCD_TARGET=nrf51
)

View file

@ -0,0 +1 @@
zephyr_sources_if_kconfig(pinmux.c)

View file

@ -0,0 +1,4 @@
zephyr_sources(
pinmux.c
dbghdr.c
)

View file

@ -0,0 +1,3 @@
zephyr_library()
zephyr_library_sources(pinmux.c)
zephyr_library_include_directories(${PROJECT_SOURCE_DIR}/drivers)

View file

@ -0,0 +1 @@
include($ENV{ZEPHYR_BASE}/boards/common/openocd.board.cmake)

View file

@ -0,0 +1,5 @@
if(CONFIG_UART_GECKO)
zephyr_library()
zephyr_library_sources(board.c)
zephyr_library_include_directories(${PROJECT_SOURCE_DIR}/drivers)
endif()

View file

@ -0,0 +1,5 @@
if(CONFIG_PINMUX_MCUX)
zephyr_library()
zephyr_library_include_directories(${PROJECT_SOURCE_DIR}/drivers)
zephyr_library_sources(pinmux.c)
endif()

View file

@ -0,0 +1,15 @@
set_ifndef(OPENSDA_FW daplink)
if(OPENSDA_FW STREQUAL jlink)
set_ifndef(DEBUG_SCRIPT jlink.sh)
elseif(OPENSDA_FW STREQUAL daplink)
set_ifndef(DEBUG_SCRIPT pyocd.sh)
set_ifndef(FLASH_SCRIPT pyocd.sh)
endif()
set_property(GLOBAL APPEND PROPERTY FLASH_SCRIPT_ENV_VARS
JLINK_DEVICE=MK64FN1M0xxx12
PYOCD_TARGET=k64f
OPENOCD_LOAD_CMD="flash write_image erase ${PROJECT_BINARY_DIR}/${KERNEL_BIN_NAME} ${CONFIG_FLASH_BASE_ADDRESS}"
OPENOCD_VERIFY_CMD="verify_image ${PROJECT_BINARY_DIR}/${KERNEL_BIN_NAME} ${CONFIG_FLASH_BASE_ADDRESS}"
)

View file

@ -0,0 +1,5 @@
if(CONFIG_PINMUX_MCUX)
zephyr_library()
zephyr_library_include_directories(${PROJECT_SOURCE_DIR}/drivers)
zephyr_library_sources(pinmux.c)
endif()

View file

@ -0,0 +1,13 @@
set_ifndef(OPENSDA_FW daplink)
if(OPENSDA_FW STREQUAL jlink)
set_ifndef(DEBUG_SCRIPT jlink.sh)
elseif(OPENSDA_FW STREQUAL daplink)
set_ifndef(DEBUG_SCRIPT pyocd.sh)
set_ifndef(FLASH_SCRIPT pyocd.sh)
endif()
set_property(GLOBAL APPEND PROPERTY FLASH_SCRIPT_ENV_VARS
JLINK_DEVICE=MKL25Z128xxx4
PYOCD_TARGET=kl25z
)

View file

@ -0,0 +1,3 @@
zephyr_library()
zephyr_library_sources(pinmux.c)
zephyr_library_include_directories(${PROJECT_SOURCE_DIR}/drivers)

View file

@ -0,0 +1,13 @@
set_ifndef(OPENSDA_FW jlink)
if(OPENSDA_FW STREQUAL jlink)
set_ifndef(DEBUG_SCRIPT jlink.sh)
elseif(OPENSDA_FW STREQUAL daplink)
set_ifndef(DEBUG_SCRIPT pyocd.sh)
set_ifndef(FLASH_SCRIPT pyocd.sh)
endif()
set_property(GLOBAL APPEND PROPERTY FLASH_SCRIPT_ENV_VARS
JLINK_DEVICE=MKW41Z512xxx4
PYOCD_TARGET=kw41z4
)

View file

@ -0,0 +1,3 @@
zephyr_library()
zephyr_library_sources(pinmux.c)
zephyr_library_include_directories(${PROJECT_SOURCE_DIR}/drivers)

View file

@ -0,0 +1,13 @@
set_ifndef(OPENSDA_FW daplink)
if(OPENSDA_FW STREQUAL jlink)
set_ifndef(DEBUG_SCRIPT jlink.sh)
elseif(OPENSDA_FW STREQUAL daplink)
set_ifndef(DEBUG_SCRIPT pyocd.sh)
set_ifndef(FLASH_SCRIPT pyocd.sh)
endif()
set_property(GLOBAL APPEND PROPERTY FLASH_SCRIPT_ENV_VARS
JLINK_DEVICE=MK64FN1M0xxx12
PYOCD_TARGET=k64f
)

View file

@ -0,0 +1,3 @@
zephyr_library()
zephyr_library_sources(pinmux.c)
zephyr_library_include_directories(${PROJECT_SOURCE_DIR}/drivers)

View file

@ -0,0 +1,13 @@
set_ifndef(OPENSDA_FW jlink)
if(OPENSDA_FW STREQUAL jlink)
set_ifndef(DEBUG_SCRIPT jlink.sh)
elseif(OPENSDA_FW STREQUAL daplink)
set_ifndef(DEBUG_SCRIPT pyocd.sh)
set_ifndef(FLASH_SCRIPT pyocd.sh)
endif()
set_property(GLOBAL APPEND PROPERTY FLASH_SCRIPT_ENV_VARS
JLINK_DEVICE=MKW40Z160xxx4
PYOCD_TARGET=kw40z4
)

View file

@ -0,0 +1,3 @@
zephyr_library()
zephyr_library_sources(pinmux.c)
zephyr_library_include_directories(${PROJECT_SOURCE_DIR}/drivers)

View file

@ -0,0 +1,4 @@
set(FLASH_SCRIPT nrf_flash.sh)
set_property(GLOBAL APPEND PROPERTY FLASH_SCRIPT_ENV_VARS
NRF_FAMILY=NRF51
)

View file

@ -0,0 +1,6 @@
set(FLASH_SCRIPT pyocd.sh)
set(DEBUG_SCRIPT pyocd.sh)
set_property(GLOBAL APPEND PROPERTY FLASH_SCRIPT_ENV_VARS
PYOCD_TARGET=nrf51
)

Some files were not shown because too many files have changed in this diff Show more