2019-06-13 05:30:14 +08:00
|
|
|
# Copyright (c) 2019 Intel Corp.
|
2019-04-06 21:08:09 +08:00
|
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
2020-06-18 03:33:20 +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},CONTENTS,ALLOC,LOAD,READONLY,DATA
|
|
|
|
${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()
|
|
|
|
|
2019-10-25 03:57:57 +08:00
|
|
|
if(CONFIG_X86_64)
|
2019-06-26 00:36:17 +08:00
|
|
|
include(intel64.cmake)
|
2017-10-27 21:43:34 +08:00
|
|
|
else()
|
2019-06-13 05:30:14 +08:00
|
|
|
include(ia32.cmake)
|
2017-10-27 21:43:34 +08:00
|
|
|
endif()
|
2020-06-18 03:33:20 +08:00
|
|
|
|
|
|
|
# Always set for 64-bit (long mode requires page tables), optional for 32-bit
|
|
|
|
if (CONFIG_MMU)
|
|
|
|
set(GEN_MMU ${ZEPHYR_BASE}/arch/x86/gen_mmu.py)
|
|
|
|
|
2021-03-06 06:54:27 +08:00
|
|
|
if(DEFINED X86_EXTRA_GEN_MMU_ARGUMENTS)
|
|
|
|
# Make the string into a list, or else it will be passed to ${GEN_MMU}
|
|
|
|
# as a quoted string, which is then parsed as one item by Python's
|
|
|
|
# argparse.
|
|
|
|
string(REPLACE " " ";"
|
|
|
|
X86_EXTRA_GEN_MMU_ARGUMENTS
|
|
|
|
"${X86_EXTRA_GEN_MMU_ARGUMENTS}")
|
|
|
|
else()
|
|
|
|
set(X86_EXTRA_GEN_MMU_ARGUMENTS "")
|
|
|
|
endif()
|
|
|
|
|
2020-06-18 03:33:20 +08:00
|
|
|
add_custom_target(
|
|
|
|
pagetables_bin_target
|
|
|
|
DEPENDS
|
|
|
|
pagetables.bin
|
|
|
|
)
|
|
|
|
add_custom_command(
|
|
|
|
OUTPUT pagetables.bin
|
|
|
|
COMMAND
|
|
|
|
${PYTHON_EXECUTABLE}
|
|
|
|
${GEN_MMU}
|
|
|
|
--kernel $<TARGET_FILE:${ZEPHYR_PREBUILT_EXECUTABLE}>
|
|
|
|
--output pagetables.bin
|
|
|
|
$<$<BOOL:${CMAKE_VERBOSE_MAKEFILE}>:--verbose>
|
2021-03-06 06:54:27 +08:00
|
|
|
${X86_EXTRA_GEN_MMU_ARGUMENTS}
|
2020-06-18 03:33:20 +08:00
|
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
|
|
|
DEPENDS ${ZEPHYR_PREBUILT_EXECUTABLE} ${GEN_MMU}
|
|
|
|
)
|
|
|
|
|
|
|
|
add_bin_file_to_the_next_link(pagetables_bin_target pagetables)
|
|
|
|
endif()
|
2020-08-25 22:00:48 +08:00
|
|
|
|
|
|
|
if(CONFIG_ARCH_HAS_TIMING_FUNCTIONS AND
|
|
|
|
NOT CONFIG_SOC_HAS_TIMING_FUNCTIONS AND
|
|
|
|
NOT CONFIG_BOARD_HAS_TIMING_FUNCTIONS)
|
|
|
|
zephyr_library_sources_ifdef(CONFIG_TIMING_FUNCTIONS timing.c)
|
|
|
|
endif()
|