Sound Open Firmware
Loading...
Searching...
No Matches
userspace_helper.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-3-Clause
2 *
3 * Copyright(c) 2025 Intel Corporation. All rights reserved.
4 *
5 * Author: Jaroslaw Stelter <jaroslaw.stelter@intel.com>
6 * Adrian Warecki <adrian.warecki@intel.com>
7 */
8
12#ifndef __ZEPHYR_LIB_USERSPACE_HELPER_H__
13#define __ZEPHYR_LIB_USERSPACE_HELPER_H__
14
15#include <zephyr/kernel.h>
16
17#ifndef CONFIG_USERSPACE
18#define APP_TASK_BSS
19#define APP_TASK_DATA
20#define APP_SYSUSER_BSS
21#define APP_SYSUSER_DATA
22#else
23#include <zephyr/cache.h>
24#include <zephyr/app_memory/app_memdomain.h>
25
26#define USER_MOD_HEAP_SIZE ALIGN_UP(CONFIG_SOF_ZEPHYR_USERSPACE_MODULE_HEAP_SIZE, \
27 CONFIG_MM_DRV_PAGE_SIZE)
28#define APP_TASK_BSS K_APP_BMEM(common_partition)
29#define APP_TASK_DATA K_APP_DMEM(common_partition)
30
31#ifdef CONFIG_SOF_USERSPACE_LL
32#define APP_SYSUSER_BSS K_APP_BMEM(sysuser_partition)
33#define APP_SYSUSER_DATA K_APP_DMEM(sysuser_partition)
34#else
35#define APP_SYSUSER_BSS
36#define APP_SYSUSER_DATA
37#endif
38
39struct processing_module;
40struct userspace_context;
41
53struct k_heap *module_driver_heap_init(void);
54
65int user_memory_attach_common_partition(struct k_mem_domain *dom);
66
67#endif
68
81void *user_stack_allocate(size_t stack_size, uint32_t options);
82
94int user_stack_free(void *p_stack);
95
104void module_driver_heap_remove(struct k_heap *mod_drv_heap);
105
106#ifdef CONFIG_USERSPACE
107
114int user_access_to_mailbox(struct k_mem_domain *domain, k_tid_t thread_id);
115
122static inline uint32_t user_get_partition_cache_attr(uintptr_t ptr)
123{
124 return sys_cache_is_ptr_cached(UINT_TO_POINTER(ptr)) ? XTENSA_MMU_CACHED_WB : 0;
125}
126
132void user_grant_dai_access_all(struct k_thread *thread);
133
139void user_grant_dma_access_all(struct k_thread *thread);
140
141#else
142
143static inline int user_access_to_mailbox(struct k_mem_domain *domain, k_tid_t thread_id)
144{
145 return 0;
146}
147
148#endif /* CONFIG_USERSPACE */
149
150#ifdef CONFIG_SOF_USERSPACE_LL
151
152int user_memory_attach_system_user_partition(struct k_mem_domain *dom);
153
154#else
155
166static inline int user_memory_attach_system_user_partition(struct k_mem_domain *dom)
167{
168 return 0;
169}
170
171#endif /* CONFIG_SOF_USERSPACE_LL */
172
173#endif /* __ZEPHYR_LIB_USERSPACE_HELPER_H__ */
static int user_access_to_mailbox(struct k_mem_domain *domain, k_tid_t thread_id)
Definition userspace_helper.h:143
static int user_memory_attach_system_user_partition(struct k_mem_domain *dom)
Attach SOF system user memory partition to a memory domain.
Definition userspace_helper.h:166
void * user_stack_allocate(size_t stack_size, uint32_t options)
Allocates thread stack memory.
int user_stack_free(void *p_stack)
Free thread stack memory.
void module_driver_heap_remove(struct k_heap *mod_drv_heap)
Free private processing module heap.