2017-10-27 21:43:34 +08:00
|
|
|
|
|
|
|
# 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()
|
|
|
|
|
2018-07-31 20:32:10 +08:00
|
|
|
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")
|
|
|
|
else()
|
|
|
|
set_property(GLOBAL PROPERTY PROPERTY_OUTPUT_ARCH "i386")
|
|
|
|
set_property(GLOBAL PROPERTY PROPERTY_OUTPUT_FORMAT "elf32-i386")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
2018-06-22 10:45:15 +08:00
|
|
|
|
2017-10-27 21:43:34 +08:00
|
|
|
if(CMAKE_C_COMPILER_ID STREQUAL "Clang")
|
|
|
|
if(CONFIG_X86_IAMCU)
|
2018-06-22 10:45:15 +08:00
|
|
|
zephyr_compile_options(-miamcu)
|
2017-10-27 21:43:34 +08:00
|
|
|
else()
|
2018-06-22 10:45:15 +08:00
|
|
|
zephyr_compile_options(-Qunused-arguments)
|
2017-10-27 21:43:34 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
zephyr_cc_option(
|
|
|
|
-m32
|
|
|
|
-gdwarf-2
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
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()
|
|
|
|
|
2019-02-25 03:12:50 +08:00
|
|
|
set(GENIDT ${ZEPHYR_BASE}/arch/x86/gen_idt.py)
|
2017-10-27 21:43:34 +08:00
|
|
|
|
|
|
|
define_property(GLOBAL PROPERTY PROPERTY_OUTPUT_ARCH BRIEF_DOCS " " FULL_DOCS " ")
|
|
|
|
|
2018-10-31 07:55:38 +08:00
|
|
|
# Use gen_idt.py and objcopy to generate irq_int_vector_map.o,
|
2019-01-14 23:31:02 +08:00
|
|
|
# irq_vectors_alloc.o, and staticIdt.o from the elf file ${ZEPHYR_PREBUILT_EXECUTABLE}
|
2017-10-27 21:43:34 +08:00
|
|
|
set(gen_idt_output_files
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/irq_int_vector_map.bin
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/staticIdt.bin
|
2018-10-31 07:55:38 +08:00
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/irq_vectors_alloc.bin
|
2017-10-27 21:43:34 +08:00
|
|
|
)
|
|
|
|
add_custom_target(
|
|
|
|
gen_idt_output
|
|
|
|
DEPENDS
|
|
|
|
${gen_idt_output_files}
|
|
|
|
)
|
|
|
|
add_custom_command(
|
2018-10-31 07:55:38 +08:00
|
|
|
OUTPUT irq_int_vector_map.bin staticIdt.bin irq_vectors_alloc.bin
|
2017-10-27 21:43:34 +08:00
|
|
|
COMMAND
|
|
|
|
${PYTHON_EXECUTABLE}
|
|
|
|
${GENIDT}
|
2019-01-14 23:31:02 +08:00
|
|
|
--kernel $<TARGET_FILE:${ZEPHYR_PREBUILT_EXECUTABLE}>
|
2017-10-27 21:43:34 +08:00
|
|
|
--output-idt staticIdt.bin
|
|
|
|
--vector-map irq_int_vector_map.bin
|
2018-10-31 07:55:38 +08:00
|
|
|
--output-vectors-alloc irq_vectors_alloc.bin
|
2017-10-27 21:43:34 +08:00
|
|
|
${GENIDT_EXTRA_ARGS}
|
2019-01-14 23:31:02 +08:00
|
|
|
DEPENDS ${ZEPHYR_PREBUILT_EXECUTABLE}
|
2017-10-27 21:43:34 +08:00
|
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
|
|
|
)
|
|
|
|
|
2018-05-23 15:55:24 +08:00
|
|
|
# Must be last so that soc/ can override default exception handlers
|
2017-10-27 21:43:34 +08:00
|
|
|
add_subdirectory(core)
|
|
|
|
|
|
|
|
get_property(OUTPUT_ARCH GLOBAL PROPERTY PROPERTY_OUTPUT_ARCH)
|
|
|
|
get_property(OUTPUT_FORMAT GLOBAL PROPERTY PROPERTY_OUTPUT_FORMAT)
|
|
|
|
|
2019-02-12 23:29:16 +08:00
|
|
|
# Convert the .bin file argument to a .o file, create a wrapper
|
|
|
|
# library for the .o file, and register the library as a generated
|
|
|
|
# file that is to be linked in after the first link.
|
|
|
|
function(add_bin_file_to_the_next_link target_dependency bin)
|
|
|
|
add_custom_command(
|
|
|
|
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${bin}.o
|
|
|
|
COMMAND
|
|
|
|
${CMAKE_OBJCOPY}
|
|
|
|
-I binary
|
|
|
|
-B ${OUTPUT_ARCH}
|
|
|
|
-O ${OUTPUT_FORMAT}
|
|
|
|
--rename-section .data=${bin}
|
|
|
|
${bin}.bin
|
|
|
|
${bin}.o
|
|
|
|
DEPENDS ${target_dependency} ${bin}.bin
|
|
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
|
|
|
)
|
|
|
|
add_custom_target(${bin}_o DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${bin}.o)
|
|
|
|
add_library(${bin} STATIC IMPORTED GLOBAL)
|
|
|
|
set_property(TARGET ${bin} PROPERTY IMPORTED_LOCATION ${CMAKE_CURRENT_BINARY_DIR}/${bin}.o)
|
|
|
|
add_dependencies(${bin} ${bin}_o)
|
|
|
|
set_property(GLOBAL APPEND PROPERTY GENERATED_KERNEL_OBJECT_FILES ${bin})
|
|
|
|
endfunction()
|
2017-10-27 21:43:34 +08:00
|
|
|
|
2019-02-12 23:29:16 +08:00
|
|
|
add_bin_file_to_the_next_link(gen_idt_output staticIdt)
|
|
|
|
add_bin_file_to_the_next_link(gen_idt_output irq_int_vector_map)
|
|
|
|
add_bin_file_to_the_next_link(gen_idt_output irq_vectors_alloc)
|
2017-10-27 21:43:34 +08:00
|
|
|
|
|
|
|
if(CONFIG_X86_MMU)
|
2019-02-20 23:22:32 +08:00
|
|
|
if(CONFIG_X86_KPTI)
|
|
|
|
set(user_mmu_tables_bin user_mmu_tables.bin)
|
|
|
|
endif()
|
|
|
|
|
2019-02-12 23:25:20 +08:00
|
|
|
add_custom_target(
|
|
|
|
mmu_tables_bin_target
|
|
|
|
DEPENDS
|
2019-02-20 23:22:32 +08:00
|
|
|
mmu_tables.bin
|
|
|
|
${user_mmu_tables_bin}
|
2019-02-12 23:25:20 +08:00
|
|
|
)
|
2017-10-27 21:43:34 +08:00
|
|
|
add_custom_command(
|
2019-02-20 23:22:32 +08:00
|
|
|
OUTPUT
|
|
|
|
mmu_tables.bin
|
|
|
|
${user_mmu_tables_bin}
|
2017-10-27 21:43:34 +08:00
|
|
|
COMMAND
|
|
|
|
${PYTHON_EXECUTABLE}
|
2019-02-25 03:12:50 +08:00
|
|
|
${ZEPHYR_BASE}/arch/x86/gen_mmu_x86.py
|
2019-01-14 23:31:02 +08:00
|
|
|
-k $<TARGET_FILE:${ZEPHYR_PREBUILT_EXECUTABLE}>
|
2017-10-27 21:43:34 +08:00
|
|
|
-o mmu_tables.bin
|
2019-02-12 02:12:25 +08:00
|
|
|
-u user_mmu_tables.bin
|
2017-10-27 21:43:34 +08:00
|
|
|
$<$<BOOL:${CMAKE_VERBOSE_MAKEFILE}>:-v>
|
|
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
2019-01-14 23:31:02 +08:00
|
|
|
DEPENDS ${ZEPHYR_PREBUILT_EXECUTABLE}
|
2017-10-27 21:43:34 +08:00
|
|
|
)
|
2019-02-12 02:12:25 +08:00
|
|
|
|
2019-02-12 23:29:16 +08:00
|
|
|
add_bin_file_to_the_next_link( mmu_tables_bin_target mmu_tables)
|
2019-02-12 02:12:25 +08:00
|
|
|
if(CONFIG_X86_KPTI)
|
2019-02-12 23:29:16 +08:00
|
|
|
add_bin_file_to_the_next_link(mmu_tables_bin_target user_mmu_tables)
|
2019-02-12 02:12:25 +08:00
|
|
|
endif()
|
2017-10-27 21:43:34 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(CONFIG_GDT_DYNAMIC)
|
|
|
|
# Use gen_gdt.py and objcopy to generate gdt.o from from the elf
|
2019-01-14 23:31:02 +08:00
|
|
|
# file ${ZEPHYR_PREBUILT_EXECUTABLE}, creating the temp file gdt.bin along the
|
2017-10-27 21:43:34 +08:00
|
|
|
# way.
|
|
|
|
#
|
2019-01-14 23:31:02 +08:00
|
|
|
# ${ZEPHYR_PREBUILT_EXECUTABLE}.elf -> gdt.bin -> gdt.o
|
2019-02-12 23:25:20 +08:00
|
|
|
add_custom_target(
|
|
|
|
gdt_bin_target
|
|
|
|
DEPENDS
|
|
|
|
gdt.bin
|
|
|
|
)
|
2017-10-27 21:43:34 +08:00
|
|
|
add_custom_command(
|
|
|
|
OUTPUT gdt.bin
|
|
|
|
COMMAND
|
|
|
|
${PYTHON_EXECUTABLE}
|
2019-02-25 03:12:50 +08:00
|
|
|
${ZEPHYR_BASE}/arch/x86/gen_gdt.py
|
2019-01-14 23:31:02 +08:00
|
|
|
--kernel $<TARGET_FILE:${ZEPHYR_PREBUILT_EXECUTABLE}>
|
2017-10-27 21:43:34 +08:00
|
|
|
--output-gdt gdt.bin
|
|
|
|
$<$<BOOL:${CMAKE_VERBOSE_MAKEFILE}>:--verbose>
|
2019-01-14 23:31:02 +08:00
|
|
|
DEPENDS ${ZEPHYR_PREBUILT_EXECUTABLE}
|
2017-10-27 21:43:34 +08:00
|
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
|
|
|
)
|
|
|
|
|
2019-02-12 23:29:16 +08:00
|
|
|
add_bin_file_to_the_next_link(gdt_bin_target gdt)
|
2017-10-27 21:43:34 +08:00
|
|
|
endif()
|