From 5e783859bfc70c4f250fc386b7fd804d04ef9210 Mon Sep 17 00:00:00 2001 From: Pieter De Gendt Date: Mon, 16 Dec 2024 11:15:33 +0100 Subject: [PATCH] net: Add tags to network iterable ROM sections Add __iterable_section_rom to network struct types and remove ld/cmake entries. Signed-off-by: Pieter De Gendt --- cmake/linker_script/common/common-rom.cmake | 25 --------------- include/zephyr/linker/common-rom.ld | 2 -- .../linker/common-rom/common-rom-net.ld | 31 ------------------- include/zephyr/net/coap_service.h | 2 +- include/zephyr/net/dns_sd.h | 2 +- include/zephyr/net/http/service.h | 2 +- include/zephyr/net/net_mgmt.h | 2 +- include/zephyr/net/socket.h | 2 +- include/zephyr/net/socket_service.h | 2 +- include/zephyr/toolchain/common.h | 3 ++ subsys/net/l2/ppp/ppp_internal.h | 2 +- 11 files changed, 10 insertions(+), 65 deletions(-) delete mode 100644 include/zephyr/linker/common-rom/common-rom-net.ld diff --git a/cmake/linker_script/common/common-rom.cmake b/cmake/linker_script/common/common-rom.cmake index 868e9f382d93c6d..6f32380908722b3 100644 --- a/cmake/linker_script/common/common-rom.cmake +++ b/cmake/linker_script/common/common-rom.cmake @@ -91,15 +91,6 @@ zephyr_linker_section_configure( KEEP SORT NAME ) -if(CONFIG_NET_SOCKETS) - zephyr_iterable_section(NAME net_socket_register KVMA RAM_REGION GROUP RODATA_REGION SUBALIGN ${CONFIG_LINKER_ITERABLE_SUBALIGN}) -endif() - - -if(CONFIG_NET_L2_PPP) - zephyr_iterable_section(NAME ppp_protocol_handler KVMA RAM_REGION GROUP RODATA_REGION SUBALIGN ${CONFIG_LINKER_ITERABLE_SUBALIGN}) -endif() - zephyr_iterable_section(NAME bt_l2cap_fixed_chan KVMA RAM_REGION GROUP RODATA_REGION SUBALIGN ${CONFIG_LINKER_ITERABLE_SUBALIGN}) if(CONFIG_BT_CLASSIC) @@ -161,10 +152,6 @@ if(CONFIG_EMUL) zephyr_iterable_section(NAME emul KVMA RAM_REGION GROUP RODATA_REGION SUBALIGN ${CONFIG_LINKER_ITERABLE_SUBALIGN}) endif() -if(CONFIG_DNS_SD) - zephyr_iterable_section(NAME dns_sd_rec KVMA RAM_REGION GROUP RODATA_REGION SUBALIGN ${CONFIG_LINKER_ITERABLE_SUBALIGN}) -endif() - if(CONFIG_PCIE) zephyr_iterable_section(NAME irq_alloc KVMA RAM_REGION GROUP RODATA_REGION SUBALIGN ${CONFIG_LINKER_ITERABLE_SUBALIGN}) endif() @@ -214,18 +201,6 @@ if (CONFIG_MULTI_LEVEL_INTERRUPTS) zephyr_iterable_section(NAME intc_table KVMA RAM_REGION GROUP RODATA_REGION SUBALIGN 4) endif() -if (CONFIG_HTTP_SERVER) - zephyr_iterable_section(NAME http_service_desc KVMA RAM_REGION GROUP RODATA_REGION SUBALIGN ${CONFIG_LINKER_ITERABLE_SUBALIGN}) -endif() - -if (CONFIG_COAP_SERVER) - zephyr_iterable_section(NAME coap_service KVMA RAM_REGION GROUP RODATA_REGION SUBALIGN ${CONFIG_LINKER_ITERABLE_SUBALIGN}) -endif() - -if (CONFIG_NET_MGMT) - zephyr_iterable_section(NAME net_mgmt_event_static_handler KVMA RAM_REGION GROUP RODATA_REGION SUBALIGN ${CONFIG_LINKER_ITERABLE_SUBALIGN}) -endif() - if(CONFIG_INPUT) zephyr_iterable_section(NAME input_callback KVMA RAM_REGION GROUP RODATA_REGION SUBALIGN ${CONFIG_LINKER_ITERABLE_SUBALIGN}) endif() diff --git a/include/zephyr/linker/common-rom.ld b/include/zephyr/linker/common-rom.ld index 409c3e8b8f3dffd..4b566ab856ac8d3 100644 --- a/include/zephyr/linker/common-rom.ld +++ b/include/zephyr/linker/common-rom.ld @@ -6,8 +6,6 @@ #include -#include - #include #include diff --git a/include/zephyr/linker/common-rom/common-rom-net.ld b/include/zephyr/linker/common-rom/common-rom-net.ld deleted file mode 100644 index 5305f9cf873c260..000000000000000 --- a/include/zephyr/linker/common-rom/common-rom-net.ld +++ /dev/null @@ -1,31 +0,0 @@ -/* SPDX-License-Identifier: Apache-2.0 */ - -#include - -#if defined(CONFIG_NET_SOCKETS) - ITERABLE_SECTION_ROM(net_socket_register, Z_LINK_ITERABLE_SUBALIGN) -#endif - -#if defined(CONFIG_NET_L2_PPP) - ITERABLE_SECTION_ROM(ppp_protocol_handler, Z_LINK_ITERABLE_SUBALIGN) -#endif - -#if defined(CONFIG_DNS_SD) - ITERABLE_SECTION_ROM(dns_sd_rec, Z_LINK_ITERABLE_SUBALIGN) -#endif - -#if defined(CONFIG_HTTP_SERVER) - ITERABLE_SECTION_ROM(http_service_desc, Z_LINK_ITERABLE_SUBALIGN) -#endif - -#if defined(CONFIG_COAP_SERVER) - ITERABLE_SECTION_ROM(coap_service, Z_LINK_ITERABLE_SUBALIGN) -#endif - -#if defined(CONFIG_NET_MGMT_EVENT) - ITERABLE_SECTION_ROM(net_mgmt_event_static_handler, Z_LINK_ITERABLE_SUBALIGN) -#endif - -#if defined(CONFIG_NET_SOCKETS_SERVICE) - ITERABLE_SECTION_ROM(net_socket_service_desc, Z_LINK_ITERABLE_SUBALIGN) -#endif diff --git a/include/zephyr/net/coap_service.h b/include/zephyr/net/coap_service.h index f5bf3f8405b7b67..ffd8a9461718628 100644 --- a/include/zephyr/net/coap_service.h +++ b/include/zephyr/net/coap_service.h @@ -48,7 +48,7 @@ struct coap_service_data { struct coap_pending pending[CONFIG_COAP_SERVICE_PENDING_MESSAGES]; }; -struct coap_service { +__iterable_section_rom struct coap_service { const char *name; const char *host; uint16_t *port; diff --git a/include/zephyr/net/dns_sd.h b/include/zephyr/net/dns_sd.h index 97548199dc94032..0abf1806148bc75 100644 --- a/include/zephyr/net/dns_sd.h +++ b/include/zephyr/net/dns_sd.h @@ -212,7 +212,7 @@ extern "C" { * * @see RFC 6763 */ -struct dns_sd_rec { +__iterable_section_rom struct dns_sd_rec { /** "" - e.g. "My HTTP Server" */ const char *instance; /** Top half of the "" such as "_http" */ diff --git a/include/zephyr/net/http/service.h b/include/zephyr/net/http/service.h index 6a836b7334822bd..957dacd387cf95e 100644 --- a/include/zephyr/net/http/service.h +++ b/include/zephyr/net/http/service.h @@ -64,7 +64,7 @@ struct http_resource_desc { /** @cond INTERNAL_HIDDEN */ -struct http_service_desc { +__iterable_section_rom struct http_service_desc { const char *host; uint16_t *port; void *detail; diff --git a/include/zephyr/net/net_mgmt.h b/include/zephyr/net/net_mgmt.h index fe3ee7f946d62f8..e11f4473f524209 100644 --- a/include/zephyr/net/net_mgmt.h +++ b/include/zephyr/net/net_mgmt.h @@ -204,7 +204,7 @@ typedef void (*net_mgmt_event_static_handler_t)(uint32_t mgmt_event, /** @cond INTERNAL_HIDDEN */ /* Structure for event handler registered at compile time */ -struct net_mgmt_event_static_handler { +__iterable_section_rom struct net_mgmt_event_static_handler { uint32_t event_mask; net_mgmt_event_static_handler_t handler; void *user_data; diff --git a/include/zephyr/net/socket.h b/include/zephyr/net/socket.h index 58c3fb0332db4eb..64dac62a37d84fb 100644 --- a/include/zephyr/net/socket.h +++ b/include/zephyr/net/socket.h @@ -1132,7 +1132,7 @@ struct in6_pktinfo { /** * @brief Registration information for a given BSD socket family. */ -struct net_socket_register { +__iterable_section_rom struct net_socket_register { int family; bool is_offloaded; bool (*is_supported)(int family, int type, int proto); diff --git a/include/zephyr/net/socket_service.h b/include/zephyr/net/socket_service.h index 045d98dd5461cb7..de7ca3a0c15dc56 100644 --- a/include/zephyr/net/socket_service.h +++ b/include/zephyr/net/socket_service.h @@ -67,7 +67,7 @@ struct net_socket_service_event { * User should create needed sockets and then setup the poll struct and * then register the sockets to be monitored at runtime. */ -struct net_socket_service_desc { +__iterable_section_rom struct net_socket_service_desc { #if CONFIG_NET_SOCKETS_LOG_LEVEL >= LOG_LEVEL_DBG /** * Owner name. This can be used in debugging to see who has diff --git a/include/zephyr/toolchain/common.h b/include/zephyr/toolchain/common.h index dd83e7b7c05b400..49d4086b3ef7bf2 100644 --- a/include/zephyr/toolchain/common.h +++ b/include/zephyr/toolchain/common.h @@ -180,6 +180,9 @@ /* Indicates this is a network socket object */ #define __net_socket __zpp(struct("__net_socket")) +/* Indicates a struct iterable section should be added in ROM */ +#define __iterable_section_rom __zpp(struct("__iterable_section_rom")) + #ifndef BUILD_ASSERT /* Compile-time assertion that makes the build to fail. * Common implementation swallows the message. diff --git a/subsys/net/l2/ppp/ppp_internal.h b/subsys/net/l2/ppp/ppp_internal.h index c5b5a9547f6140c..ea8e7d44fa866a1 100644 --- a/subsys/net/l2/ppp/ppp_internal.h +++ b/subsys/net/l2/ppp/ppp_internal.h @@ -36,7 +36,7 @@ struct ppp_packet { #define PPP_BUF_ALLOC_TIMEOUT K_MSEC(100) /** Protocol handler information. */ -struct ppp_protocol_handler { +__iterable_section_rom struct ppp_protocol_handler { /** Protocol init function */ void (*init)(struct ppp_context *ctx);