Zephyr API Documentation  3.6.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
app_memdomain.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2019 Intel Corporation
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6#ifndef ZEPHYR_INCLUDE_APP_MEMORY_APP_MEMDOMAIN_H_
7#define ZEPHYR_INCLUDE_APP_MEMORY_APP_MEMDOMAIN_H_
8
10#include <zephyr/sys/dlist.h>
11#include <zephyr/kernel.h>
12
20#ifdef CONFIG_USERSPACE
21
30#define K_APP_DMEM_SECTION(id) data_smem_##id##_data
31
40#define K_APP_BMEM_SECTION(id) data_smem_##id##_bss
41
51#define K_APP_DMEM(id) Z_GENERIC_SECTION(K_APP_DMEM_SECTION(id))
52
61#define K_APP_BMEM(id) Z_GENERIC_SECTION(K_APP_BMEM_SECTION(id))
62
63struct z_app_region {
64 void *bss_start;
65 size_t bss_size;
66};
67
68#define Z_APP_START(id) z_data_smem_##id##_part_start
69#define Z_APP_SIZE(id) z_data_smem_##id##_part_size
70#define Z_APP_BSS_START(id) z_data_smem_##id##_bss_start
71#define Z_APP_BSS_SIZE(id) z_data_smem_##id##_bss_size
72
73/* If a partition is declared with K_APPMEM_PARTITION, but never has any
74 * data assigned to its contents, then no symbols with its prefix will end
75 * up in the symbol table. This prevents gen_app_partitions.py from detecting
76 * that the partition exists, and the linker symbols which specify partition
77 * bounds will not be generated, resulting in build errors.
78 *
79 * What this inline assembly code does is define a symbol with no data.
80 * This should work for all arches that produce ELF binaries, see
81 * https://sourceware.org/binutils/docs/as/Section.html
82 *
83 * We don't know what active flags/type of the pushed section were, so we are
84 * specific: "aw" indicates section is allocatable and writable,
85 * and "@progbits" indicates the section has data.
86 */
87#if defined(CONFIG_ARM) || defined(CONFIG_ARM64)
88/* ARM has a quirk in that '@' denotes a comment, so we have to send
89 * %progbits to the assembler instead.
90 */
91#define Z_PROGBITS_SYM "%"
92#else
93#define Z_PROGBITS_SYM "@"
94#endif
95
96#if defined(CONFIG_ARC) && defined(__CCAC__)
97/* ARC MWDT assembler has slightly different pushsection/popsection directives
98 * names.
99 */
100#define Z_PUSHSECTION_DIRECTIV ".pushsect"
101#define Z_POPSECTION_DIRECTIVE ".popsect"
102#else
103#define Z_PUSHSECTION_DIRECTIV ".pushsection"
104#define Z_POPSECTION_DIRECTIVE ".popsection"
105#endif
106
107#define Z_APPMEM_PLACEHOLDER(name) \
108 __asm__ ( \
109 Z_PUSHSECTION_DIRECTIV " " STRINGIFY(K_APP_DMEM_SECTION(name)) \
110 ",\"aw\"," Z_PROGBITS_SYM "progbits\n\t" \
111 ".global " STRINGIFY(name) "_placeholder\n\t" \
112 STRINGIFY(name) "_placeholder:\n\t" \
113 Z_POPSECTION_DIRECTIVE "\n\t")
114
127#define K_APPMEM_PARTITION_DEFINE(name) \
128 extern char Z_APP_START(name)[]; \
129 extern char Z_APP_SIZE(name)[]; \
130 struct k_mem_partition name = { \
131 .start = (uintptr_t) &Z_APP_START(name), \
132 .size = (size_t) &Z_APP_SIZE(name), \
133 .attr = K_MEM_PARTITION_P_RW_U_RW \
134 }; \
135 extern char Z_APP_BSS_START(name)[]; \
136 extern char Z_APP_BSS_SIZE(name)[]; \
137 Z_GENERIC_SECTION(.app_regions.name) \
138 const struct z_app_region name##_region = { \
139 .bss_start = &Z_APP_BSS_START(name), \
140 .bss_size = (size_t) &Z_APP_BSS_SIZE(name) \
141 }; \
142 Z_APPMEM_PLACEHOLDER(name)
143#else
144
145#define K_APP_BMEM(ptn)
146#define K_APP_DMEM(ptn)
147#define K_APP_DMEM_SECTION(ptn) .data
148#define K_APP_BMEM_SECTION(ptn) .bss
149#define K_APPMEM_PARTITION_DEFINE(name)
150
151#endif /* CONFIG_USERSPACE */
152
157#endif /* ZEPHYR_INCLUDE_APP_MEMORY_APP_MEMDOMAIN_H_ */
Public kernel APIs.