Zephyr Project API 4.4.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
19
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#define Z_APPMEM_PLACEHOLDER(name) \
97 __asm__ ( \
98 PUSHSECTION_DIRECTIVE " " STRINGIFY(K_APP_DMEM_SECTION(name)) \
99 ",\"aw\"," Z_PROGBITS_SYM "progbits\n\t" \
100 ".global " STRINGIFY(name) "_placeholder\n\t" \
101 STRINGIFY(name) "_placeholder:\n\t" \
102 POPSECTION_DIRECTIVE "\n\t")
103
116#define K_APPMEM_PARTITION_DEFINE(name) \
117 extern char Z_APP_START(name)[]; \
118 extern char Z_APP_SIZE(name)[]; \
119 struct k_mem_partition name = { \
120 .start = (uintptr_t) &Z_APP_START(name)[0], \
121 .size = (size_t) &Z_APP_SIZE(name)[0], \
122 .attr = K_MEM_PARTITION_P_RW_U_RW \
123 }; \
124 extern char Z_APP_BSS_START(name)[]; \
125 extern char Z_APP_BSS_SIZE(name)[]; \
126 Z_GENERIC_SECTION(.app_regions.name) \
127 const struct z_app_region name##_region = { \
128 .bss_start = &Z_APP_BSS_START(name)[0], \
129 .bss_size = (size_t) &Z_APP_BSS_SIZE(name)[0] \
130 }; \
131 Z_APPMEM_PLACEHOLDER(name)
132#else
133
134#define K_APP_BMEM(ptn)
135#define K_APP_DMEM(ptn)
136#define K_APP_DMEM_SECTION(ptn) .data
137#define K_APP_BMEM_SECTION(ptn) .bss
138#define K_APPMEM_PARTITION_DEFINE(name)
139
140#endif /* CONFIG_USERSPACE */
141
145
146#endif /* ZEPHYR_INCLUDE_APP_MEMORY_APP_MEMDOMAIN_H_ */
Header file for the doubly-linked list API.
Public kernel APIs.