1/* SPDX-License-Identifier: Apache-2.0 */
2
3#include <zephyr/linker/iterable_sections.h>
4
5#if defined(CONFIG_NETWORKING)
6#ifndef NETWORK_RAM_SECTIONS
7#define NETWORK_RAM_SECTIONS \
8	ITERABLE_SECTION_RAM(net_if, Z_LINK_ITERABLE_SUBALIGN) \
9	ITERABLE_SECTION_RAM(net_if_dev, Z_LINK_ITERABLE_SUBALIGN) \
10	ITERABLE_SECTION_RAM(net_l2, Z_LINK_ITERABLE_SUBALIGN) \
11	ITERABLE_SECTION_RAM(eth_bridge, Z_LINK_ITERABLE_SUBALIGN)
12#endif
13#endif /* NETWORKING */
14
15#ifdef CONFIG_ARM_SCMI
16ITERABLE_SECTION_RAM(scmi_protocol, Z_LINK_ITERABLE_SUBALIGN)
17#endif /* CONFIG_ARM_SCMI */
18
19#if defined(CONFIG_GEN_SW_ISR_TABLE) && defined(CONFIG_DYNAMIC_INTERRUPTS)
20	SECTION_DATA_PROLOGUE(sw_isr_table,,)
21	{
22		/*
23		 * Some arch requires an entry to be aligned to arch
24		 * specific boundary for using double word load
25		 * instruction.  See include/sw_isr_table.h.
26		 */
27		. = ALIGN(CONFIG_ARCH_SW_ISR_TABLE_ALIGN);
28		*(_SW_ISR_TABLE_SECTION_SYMS)
29	} GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
30
31#if defined(CONFIG_SHARED_INTERRUPTS)
32	SECTION_DATA_PROLOGUE(shared_sw_isr_table,,)
33	{
34		/* TODO: does this section require alignment? */
35		KEEP(*(_SHARED_SW_ISR_TABLE_SECTION_SYMS))
36	} GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
37#endif
38
39#endif
40
41        SECTION_DATA_PROLOGUE(device_states,,)
42        {
43		/* Device states used by the device objects. */
44                __device_states_start = .;
45		KEEP(*(".z_devstate"));
46		KEEP(*(".z_devstate.*"));
47                __device_states_end = .;
48        } GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
49
50#ifdef CONFIG_PM_DEVICE
51	ITERABLE_SECTION_RAM(pm_device_slots, Z_LINK_ITERABLE_SUBALIGN)
52#endif
53
54#if defined(CONFIG_DEVICE_DEPS_DYNAMIC)
55	SECTION_DATA_PROLOGUE(device_deps,,)
56	{
57#include "device-deps.ld"
58	} GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
59#endif 	/* CONFIG_DEVICE_DEPS_DYNAMIC */
60
61	ITERABLE_SECTION_RAM_GC_ALLOWED(log_mpsc_pbuf, Z_LINK_ITERABLE_SUBALIGN)
62	ITERABLE_SECTION_RAM(log_msg_ptr, Z_LINK_ITERABLE_SUBALIGN)
63	ITERABLE_SECTION_RAM(log_dynamic, Z_LINK_ITERABLE_SUBALIGN)
64
65#ifdef CONFIG_USERSPACE
66	/* All kernel objects within are assumed to be either completely
67	 * initialized at build time, or initialized automatically at runtime
68	 * via iteration before the POST_KERNEL phase.
69	 *
70	 * These two symbols only used by gen_kobject_list.py
71	 */
72
73	_static_kernel_objects_begin = .;
74#endif /* CONFIG_USERSPACE */
75
76	ITERABLE_SECTION_RAM_GC_ALLOWED(k_timer, Z_LINK_ITERABLE_SUBALIGN)
77	ITERABLE_SECTION_RAM_GC_ALLOWED(k_mem_slab, Z_LINK_ITERABLE_SUBALIGN)
78	ITERABLE_SECTION_RAM_GC_ALLOWED(k_heap, Z_LINK_ITERABLE_SUBALIGN)
79	ITERABLE_SECTION_RAM_GC_ALLOWED(k_mutex, Z_LINK_ITERABLE_SUBALIGN)
80	ITERABLE_SECTION_RAM_GC_ALLOWED(k_stack, Z_LINK_ITERABLE_SUBALIGN)
81	ITERABLE_SECTION_RAM_GC_ALLOWED(k_msgq, Z_LINK_ITERABLE_SUBALIGN)
82	ITERABLE_SECTION_RAM_GC_ALLOWED(k_mbox, Z_LINK_ITERABLE_SUBALIGN)
83	ITERABLE_SECTION_RAM_GC_ALLOWED(k_pipe, Z_LINK_ITERABLE_SUBALIGN)
84	ITERABLE_SECTION_RAM_GC_ALLOWED(k_sem, Z_LINK_ITERABLE_SUBALIGN)
85	ITERABLE_SECTION_RAM_GC_ALLOWED(k_event, Z_LINK_ITERABLE_SUBALIGN)
86	ITERABLE_SECTION_RAM_GC_ALLOWED(k_queue, Z_LINK_ITERABLE_SUBALIGN)
87	ITERABLE_SECTION_RAM_GC_ALLOWED(k_fifo, Z_LINK_ITERABLE_SUBALIGN)
88	ITERABLE_SECTION_RAM_GC_ALLOWED(k_lifo, Z_LINK_ITERABLE_SUBALIGN)
89	ITERABLE_SECTION_RAM_GC_ALLOWED(k_condvar, Z_LINK_ITERABLE_SUBALIGN)
90	ITERABLE_SECTION_RAM_GC_ALLOWED(sys_mem_blocks_ptr, Z_LINK_ITERABLE_SUBALIGN)
91
92	ITERABLE_SECTION_RAM(net_buf_pool, Z_LINK_ITERABLE_SUBALIGN)
93
94#if defined(CONFIG_NETWORKING)
95	NETWORK_RAM_SECTIONS
96#endif /* NETWORKING */
97
98#if defined(CONFIG_PCIE)
99	ITERABLE_SECTION_RAM(pcie_dev, Z_LINK_ITERABLE_SUBALIGN)
100#endif /* PCIE */
101
102#if defined(CONFIG_USB_DEVICE_STACK)
103	SECTION_DATA_PROLOGUE(usb_descriptor,,SUBALIGN(1))
104	{
105		__usb_descriptor_start = .;
106		*(".usb.descriptor")
107		KEEP(*(SORT_BY_NAME(".usb.descriptor*")))
108		__usb_descriptor_end = .;
109	} GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
110
111	ITERABLE_SECTION_RAM(usb_cfg_data, Z_LINK_ITERABLE_SUBALIGN)
112#endif /* CONFIG_USB_DEVICE_STACK */
113
114#if defined(CONFIG_USB_DEVICE_BOS)
115	SECTION_DATA_PROLOGUE(usb_bos_desc,,SUBALIGN(1))
116	{
117		__usb_bos_desc_start = .;
118		*(".usb.bos_desc")
119		KEEP(*(SORT_BY_NAME(".usb.bos_desc*")))
120		__usb_bos_desc_end = .;
121	} GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
122#endif /* CONFIG_USB_DEVICE_BOS */
123
124#if defined(CONFIG_RTIO)
125	ITERABLE_SECTION_RAM(rtio, Z_LINK_ITERABLE_SUBALIGN)
126	ITERABLE_SECTION_RAM(rtio_iodev, Z_LINK_ITERABLE_SUBALIGN)
127	ITERABLE_SECTION_RAM(rtio_sqe_pool, Z_LINK_ITERABLE_SUBALIGN)
128	ITERABLE_SECTION_RAM(rtio_cqe_pool, Z_LINK_ITERABLE_SUBALIGN)
129#endif /* CONFIG_RTIO */
130
131#if defined(CONFIG_SENSING)
132	ITERABLE_SECTION_RAM(sensing_sensor, Z_LINK_ITERABLE_SUBALIGN)
133#endif /* CONFIG_SENSING */
134
135#if defined(CONFIG_ZBUS)
136	ITERABLE_SECTION_RAM(zbus_channel_observation_mask, 1)
137#endif /* CONFIG_ZBUS */
138
139#if defined(CONFIG_DEVICE_MUTABLE)
140	ITERABLE_SECTION_RAM(device_mutable, Z_LINK_ITERABLE_SUBALIGN)
141#endif
142
143#if defined(CONFIG_BT_ZEPHYR_NUS)
144	ITERABLE_SECTION_RAM(bt_nus_inst, Z_LINK_ITERABLE_SUBALIGN)
145#endif
146
147#ifdef CONFIG_USERSPACE
148	_static_kernel_objects_end = .;
149#endif
150