From 8bee39edffbfc889db5beeb33e76fc05b8c48414 Mon Sep 17 00:00:00 2001 From: Gerard Marull-Paretas Date: Wed, 14 Jun 2023 12:10:40 +0200 Subject: [PATCH] device: s/device_handles/device_deps/ in linker scripts Use the "device_deps" naming scheme to emphasize we are storing device dependencies. The fact we are using device handles to store them is an implementation detail. Signed-off-by: Gerard Marull-Paretas --- CMakeLists.txt | 4 ++-- cmake/linker_script/common/common-rom.cmake | 6 +++--- include/zephyr/device.h | 2 +- include/zephyr/linker/common-ram.ld | 4 ++-- .../linker/common-rom/common-rom-kernel-devices.ld | 4 ++-- include/zephyr/linker/device-deps.ld | 13 +++++++++++++ include/zephyr/linker/device-handles.ld | 13 ------------- scripts/build/gen_device_deps.py | 2 +- scripts/build/gen_relocate_app.py | 2 +- 9 files changed, 25 insertions(+), 25 deletions(-) create mode 100644 include/zephyr/linker/device-deps.ld delete mode 100644 include/zephyr/linker/device-handles.ld diff --git a/CMakeLists.txt b/CMakeLists.txt index 11a9dff03bb..d295a0cf006 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -942,8 +942,8 @@ if(CONFIG_HAS_DTS) ) set_property(GLOBAL APPEND PROPERTY GENERATED_APP_SOURCE_FILES device_deps.c) - # gen_device_deps runs on `__device_handles_pass1` so pass this info to the linker script generator - list(APPEND LINKER_PASS_${ZEPHYR_CURRENT_LINKER_PASS}_DEFINE "LINKER_DEVICE_HANDLES_PASS1") + # gen_device_deps runs on `__device_deps_pass1` so pass this info to the linker script generator + list(APPEND LINKER_PASS_${ZEPHYR_CURRENT_LINKER_PASS}_DEFINE "LINKER_DEVICE_DEPS_PASS1") endif() if(CONFIG_CODE_DATA_RELOCATION) diff --git a/cmake/linker_script/common/common-rom.cmake b/cmake/linker_script/common/common-rom.cmake index 811a681a8c2..4417d108136 100644 --- a/cmake/linker_script/common/common-rom.cmake +++ b/cmake/linker_script/common/common-rom.cmake @@ -185,9 +185,9 @@ zephyr_iterable_section(NAME tracing_backend KVMA RAM_REGION GROUP RODATA_REGION zephyr_linker_section(NAME zephyr_dbg_info KVMA RAM_REGION GROUP RODATA_REGION NOINPUT ${XIP_ALIGN_WITH_INPUT}) zephyr_linker_section_configure(SECTION zephyr_dbg_info INPUT ".zephyr_dbg_info" KEEP) -zephyr_linker_section(NAME device_handles KVMA RAM_REGION GROUP RODATA_REGION NOINPUT ${XIP_ALIGN_WITH_INPUT} ENDALIGN 16) -zephyr_linker_section_configure(SECTION device_handles INPUT .__device_handles_pass1* KEEP SORT NAME PASS LINKER_DEVICE_HANDLES_PASS1) -zephyr_linker_section_configure(SECTION device_handles INPUT .__device_handles_pass2* KEEP SORT NAME PASS NOT LINKER_DEVICE_HANDLES_PASS1) +zephyr_linker_section(NAME device_deps KVMA RAM_REGION GROUP RODATA_REGION NOINPUT ${XIP_ALIGN_WITH_INPUT} ENDALIGN 16) +zephyr_linker_section_configure(SECTION device_deps INPUT .__device_deps_pass1* KEEP SORT NAME PASS LINKER_DEVICE_DEPS_PASS1) +zephyr_linker_section_configure(SECTION device_deps INPUT .__device_deps_pass2* KEEP SORT NAME PASS NOT LINKER_DEVICE_DEPS_PASS1) zephyr_iterable_section(NAME _static_thread_data KVMA RAM_REGION GROUP RODATA_REGION SUBALIGN 4) diff --git a/include/zephyr/device.h b/include/zephyr/device.h index 53a97710773..0b487449914 100644 --- a/include/zephyr/device.h +++ b/include/zephyr/device.h @@ -778,7 +778,7 @@ static inline bool z_impl_device_is_ready(const struct device *dev) /** @brief Linker section were device handles are placed. */ #define Z_DEVICE_HANDLES_SECTION \ - __attribute__((__section__(".__device_handles_pass1"))) + __attribute__((__section__(".__device_deps_pass1"))) #ifdef __cplusplus #define Z_DEVICE_HANDLES_EXTERN extern diff --git a/include/zephyr/linker/common-ram.ld b/include/zephyr/linker/common-ram.ld index a2983930630..269d56be46e 100644 --- a/include/zephyr/linker/common-ram.ld +++ b/include/zephyr/linker/common-ram.ld @@ -43,9 +43,9 @@ #endif #if defined(CONFIG_HAS_DYNAMIC_DEVICE_HANDLES) - SECTION_DATA_PROLOGUE(device_handles,,) + SECTION_DATA_PROLOGUE(device_deps,,) { -#include "device-handles.ld" +#include "device-deps.ld" } GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION) #endif /* CONFIG_HAS_DYNAMIC_DEVICE_HANDLES */ diff --git a/include/zephyr/linker/common-rom/common-rom-kernel-devices.ld b/include/zephyr/linker/common-rom/common-rom-kernel-devices.ld index 3c677cd0bad..b7acb08d90c 100644 --- a/include/zephyr/linker/common-rom/common-rom-kernel-devices.ld +++ b/include/zephyr/linker/common-rom/common-rom-kernel-devices.ld @@ -65,8 +65,8 @@ #endif /* CONFIG_PCIE */ #if !defined(CONFIG_HAS_DYNAMIC_DEVICE_HANDLES) - SECTION_DATA_PROLOGUE(device_handles,,) + SECTION_DATA_PROLOGUE(device_deps,,) { -#include +#include } GROUP_ROM_LINK_IN(RAMABLE_REGION, ROMABLE_REGION) #endif /* !CONFIG_HAS_DYNAMIC_DEVICE_HANDLES */ diff --git a/include/zephyr/linker/device-deps.ld b/include/zephyr/linker/device-deps.ld new file mode 100644 index 00000000000..f3d848b92df --- /dev/null +++ b/include/zephyr/linker/device-deps.ld @@ -0,0 +1,13 @@ +/* + * Copyright (c) 2021 Intel Corporation. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +__device_deps_start = .; +#ifdef LINKER_DEVICE_DEPS_PASS1 +KEEP(*(SORT(.__device_deps_pass1*))); +#else +KEEP(*(SORT(.__device_deps_pass2*))); +#endif /* LINKER_DEVICE_DEPS_PASS1 */ +__device_deps_end = .; diff --git a/include/zephyr/linker/device-handles.ld b/include/zephyr/linker/device-handles.ld deleted file mode 100644 index aed858981c5..00000000000 --- a/include/zephyr/linker/device-handles.ld +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Copyright (c) 2021 Intel Corporation. - * - * SPDX-License-Identifier: Apache-2.0 - */ - -__device_handles_start = .; -#ifdef LINKER_DEVICE_HANDLES_PASS1 -KEEP(*(SORT(.__device_handles_pass1*))); -#else -KEEP(*(SORT(.__device_handles_pass2*))); -#endif /* LINKER_DEVICE_HANDLES_PASS1 */ -__device_handles_end = .; diff --git a/scripts/build/gen_device_deps.py b/scripts/build/gen_device_deps.py index 799b9139171..bbebb554dd1 100755 --- a/scripts/build/gen_device_deps.py +++ b/scripts/build/gen_device_deps.py @@ -107,7 +107,7 @@ def c_handle_array(dev, handles, dynamic_handles, extra_support_handles=0): ] ctype = ( '{:s}Z_DECL_ALIGN(device_handle_t) ' - '__attribute__((__section__(".__device_handles_pass2")))' + '__attribute__((__section__(".__device_deps_pass2")))' ).format('const ' if not dynamic_handles else '') return [ # The `extern` line pretends this was first declared in some .h diff --git a/scripts/build/gen_relocate_app.py b/scripts/build/gen_relocate_app.py index 1e3067c3431..9082b62f8fd 100644 --- a/scripts/build/gen_relocate_app.py +++ b/scripts/build/gen_relocate_app.py @@ -74,7 +74,7 @@ class SectionKind(Enum): >>> SectionKind.for_section_with_name(".rodata.str1.4") - >>> SectionKind.for_section_with_name(".device_handles") + >>> SectionKind.for_section_with_name(".device_deps") None """ if ".text." in name: