File tree Expand file tree Collapse file tree
sof/audio/module_adapter/library Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1111#include <sof/audio/sink_api.h>
1212#include <sof/audio/source_api.h>
1313#include <sof/audio/sink_source_utils.h>
14+ #include <rtos/userspace_helper.h>
1415#include <sof/common.h>
1516#include <rtos/interrupt.h>
1617#include <rtos/alloc.h>
@@ -161,7 +162,7 @@ static void comp_buffer_free(struct sof_audio_buffer *audio_buffer)
161162 rfree (buffer );
162163}
163164
164- static const struct source_ops comp_buffer_source_ops = {
165+ APP_TASK_DATA static const struct source_ops comp_buffer_source_ops = {
165166 .get_data_available = comp_buffer_get_data_available ,
166167 .get_data = comp_buffer_get_data ,
167168 .release_data = comp_buffer_release_data ,
@@ -170,7 +171,7 @@ static const struct source_ops comp_buffer_source_ops = {
170171 .set_alignment_constants = audio_buffer_source_set_alignment_constants ,
171172};
172173
173- static const struct sink_ops comp_buffer_sink_ops = {
174+ APP_TASK_DATA static const struct sink_ops comp_buffer_sink_ops = {
174175 .get_free_size = comp_buffer_get_free_size ,
175176 .get_buffer = comp_buffer_get_buffer ,
176177 .commit_buffer = comp_buffer_commit_buffer ,
Original file line number Diff line number Diff line change 1515
1616#include "interface.h"
1717#include "../ipc4/base-config.h"
18+ #include <rtos/userspace_helper.h>
1819
1920#define module_get_private_data (mod ) ((mod)->priv.private)
2021#define module_set_private_data (mod , data ) ((mod)->priv.private = data)
@@ -180,6 +181,7 @@ struct processing_module {
180181 uint32_t max_sinks ;
181182
182183 enum module_processing_type proc_type ;
184+ struct userspace_context * user_ctx ;
183185#endif /* SOF_MODULE_PRIVATE */
184186};
185187
Original file line number Diff line number Diff line change 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+ * Author: Adrian Warecki <adrian.warecki@intel.com>
7+ */
8+
9+ #ifndef __SOF_AUDIO_USERSPACE_PROXY_H__
10+ #define __SOF_AUDIO_USERSPACE_PROXY_H__
11+
12+ #if CONFIG_USERSPACE
13+ #include <stdint.h>
14+ #include <stdbool.h>
15+
16+ #include <zephyr/kernel.h>
17+
18+ /* Processing module structure fields needed for user mode */
19+ struct userspace_context {
20+ struct k_mem_domain * comp_dom ; /* Module specific memory domain */
21+ };
22+
23+ #endif /* CONFIG_USERSPACE */
24+
25+ #endif /* __SOF_AUDIO_USERSPACE_PROXY_H__ */
Original file line number Diff line number Diff line change 1212#ifndef __ZEPHYR_LIB_USERSPACE_HELPER_H__
1313#define __ZEPHYR_LIB_USERSPACE_HELPER_H__
1414
15- #ifdef CONFIG_USERSPACE
15+ #ifndef CONFIG_USERSPACE
16+ #define APP_TASK_BSS
17+ #define APP_TASK_DATA
18+ #else
19+
20+ #include <zephyr/app_memory/app_memdomain.h>
21+
1622#define DRV_HEAP_SIZE ALIGN_UP(CONFIG_SOF_ZEPHYR_USERSPACE_MODULE_HEAP_SIZE, \
1723 CONFIG_MM_DRV_PAGE_SIZE)
24+ #define APP_TASK_BSS K_APP_BMEM(common_partition)
25+ #define APP_TASK_DATA K_APP_DMEM(common_partition)
26+
27+ struct processing_module ;
28+ struct userspace_context ;
1829
1930/**
2031 * Initialize private processing module heap.
2940 */
3041struct sys_heap * module_driver_heap_init (void );
3142
43+ /**
44+ * Add DP scheduler created thread to module memory domain.
45+ * @param thread_id - id of thread to be added to memory domain.
46+ * @param module - processing module structure
47+ *
48+ * @return 0 for success, error otherwise.
49+ *
50+ * @note
51+ * Function used only when CONFIG_USERSPACE is set.
52+ */
53+ int user_memory_init_shared (k_tid_t thread_id , struct processing_module * mod );
54+
3255#endif
3356
3457/**
Original file line number Diff line number Diff line change 1616
1717#include <rtos/alloc.h>
1818#include <rtos/userspace_helper.h>
19+ #include <sof/audio/module_adapter/module/generic.h>
20+ #include <sof/audio/module_adapter/library/userspace_proxy.h>
1921
2022#define MODULE_DRIVER_HEAP_CACHED CONFIG_SOF_ZEPHYR_HEAP_CACHED
2123
24+ /* Zephyr includes */
25+ #include <zephyr/kernel.h>
26+ #include <zephyr/app_memory/app_memdomain.h>
27+
2228#if CONFIG_USERSPACE
29+
30+ K_APPMEM_PARTITION_DEFINE (common_partition );
31+
2332struct sys_heap * module_driver_heap_init (void )
2433{
2534 struct sys_heap * mod_drv_heap = rballoc (SOF_MEM_FLAG_USER , sizeof (struct sys_heap ));
@@ -122,6 +131,18 @@ void module_driver_heap_remove(struct sys_heap *mod_drv_heap)
122131 }
123132}
124133
134+ int user_memory_init_shared (k_tid_t thread_id , struct processing_module * mod )
135+ {
136+ struct k_mem_domain * comp_dom = mod -> user_ctx -> comp_dom ;
137+ int ret ;
138+
139+ ret = k_mem_domain_add_partition (comp_dom , & common_partition );
140+ if (ret < 0 )
141+ return ret ;
142+
143+ return k_mem_domain_add_thread (comp_dom , thread_id );
144+ }
145+
125146#else /* CONFIG_USERSPACE */
126147
127148void * module_driver_heap_rmalloc (struct sys_heap * mod_drv_heap , uint32_t flags , size_t bytes )
You can’t perform that action at this time.
0 commit comments