Skip to content

Commit 737b4d8

Browse files
committed
zephyr: rtos: userspace_helper.h: add sysuser memory partition
Add APP_SYSUSER_BSS() and APP_SYSUSER_DATA() macros to put global objects to a memory partition that is available to the user context used to run main SOF application. If SOF is run in kernel space, these are no-ops, but if CONFIG_SOF_USERSPACE_LL is set, a dedicated memory partition is used. Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
1 parent 563aa88 commit 737b4d8

2 files changed

Lines changed: 34 additions & 0 deletions

File tree

zephyr/include/rtos/userspace_helper.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@
2626
#define APP_TASK_BSS K_APP_BMEM(common_partition)
2727
#define APP_TASK_DATA K_APP_DMEM(common_partition)
2828

29+
#define APP_SYSUSER_BSS K_APP_BMEM(sysuser_partition)
30+
#define APP_SYSUSER_DATA K_APP_DMEM(sysuser_partition)
31+
2932
struct processing_module;
3033
struct userspace_context;
3134

@@ -137,4 +140,27 @@ static inline int user_access_to_mailbox(struct k_mem_domain *domain, k_tid_t th
137140

138141
#endif /* CONFIG_USERSPACE */
139142

143+
#ifdef CONFIG_SOF_USERSPACE_LL
144+
145+
int user_memory_attach_system_user_partition(struct k_mem_domain *dom);
146+
147+
#else
148+
149+
/**
150+
* Attach SOF system user memory partition to a memory domain.
151+
* @param dom - memory domain to attach the sysuser partition to.
152+
*
153+
* @return 0 for success, error otherwise.
154+
*
155+
* @note
156+
* Function used only when CONFIG_USERSPACE is set.
157+
* The sysuser partition contains shared objects required by user-space modules.
158+
*/
159+
static 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+
140166
#endif /* __ZEPHYR_LIB_USERSPACE_HELPER_H__ */

zephyr/lib/userspace_helper.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ LOG_MODULE_REGISTER(userspace_helper, CONFIG_SOF_LOG_LEVEL);
3636

3737
K_APPMEM_PARTITION_DEFINE(common_partition);
3838

39+
#ifdef CONFIG_SOF_USERSPACE_LL
40+
K_APPMEM_PARTITION_DEFINE(sysuser_partition);
41+
#endif
42+
3943
struct k_heap *module_driver_heap_init(void)
4044
{
4145
struct k_heap *mod_drv_heap = rballoc(SOF_MEM_FLAG_USER, sizeof(*mod_drv_heap));
@@ -83,6 +87,10 @@ int user_memory_attach_common_partition(struct k_mem_domain *dom)
8387
}
8488

8589
#ifdef CONFIG_SOF_USERSPACE_LL
90+
int user_memory_attach_system_user_partition(struct k_mem_domain *dom)
91+
{
92+
return k_mem_domain_add_partition(dom, &sysuser_partition);
93+
}
8694

8795
int user_access_to_mailbox(struct k_mem_domain *domain, k_tid_t thread_id)
8896
{

0 commit comments

Comments
 (0)