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#include <rtos/userspace_data.h>
18
19#ifdef CONFIG_USERSPACE
20#include <zephyr/cache.h>
21#include <zephyr/app_memory/app_memdomain.h>
22
23#define USER_MOD_HEAP_SIZE ALIGN_UP(CONFIG_SOF_ZEPHYR_USERSPACE_MODULE_HEAP_SIZE, \
24 CONFIG_MM_DRV_PAGE_SIZE)
25
27struct userspace_context;
28
40struct k_heap *module_driver_heap_init(void);
41
52int user_memory_attach_common_partition(struct k_mem_domain *dom);
53
54#endif
55
68void *user_stack_allocate(size_t stack_size, uint32_t options);
69
81int user_stack_free(void *p_stack);
82
91void module_driver_heap_remove(struct k_heap *mod_drv_heap);
92
93#ifdef CONFIG_USERSPACE
94
101int user_access_to_mailbox(struct k_mem_domain *domain, k_tid_t thread_id);
102
109static inline uint32_t user_get_partition_cache_attr(uintptr_t ptr)
110{
111 return sys_cache_is_ptr_cached(UINT_TO_POINTER(ptr)) ? XTENSA_MMU_CACHED_WB : 0;
112}
113
119void user_grant_dai_access_all(struct k_thread *thread);
120
126void user_grant_dma_access_all(struct k_thread *thread);
127
128#else
129
136static inline int user_access_to_mailbox(struct k_mem_domain *domain, k_tid_t thread_id)
137{
138 return 0;
139}
140
141#endif /* CONFIG_USERSPACE */
142
143#ifdef CONFIG_SOF_USERSPACE_LL
144
145int user_memory_attach_system_user_partition(struct k_mem_domain *dom);
146
147#else
148
159static inline int user_memory_attach_system_user_partition(struct k_mem_domain *dom)
160{
161 return 0;
162}
163
164#endif /* CONFIG_SOF_USERSPACE_LL */
165
166#endif /* __ZEPHYR_LIB_USERSPACE_HELPER_H__ */
Definition base.h:103
Placement of data that user-space threads must be able to access.
static int user_access_to_mailbox(struct k_mem_domain *domain, k_tid_t thread_id)
Add access to mailbox.h interface to a user-space thread (no-op stub when CONFIG_USERSPACE is disable...
Definition userspace_helper.h:136
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:159
void * user_stack_allocate(size_t stack_size, uint32_t options)
Userspace support functions.
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.