Skip to content

Commit 6de0ca4

Browse files
committed
WIP: ipc: expose coldrodata to IPC user thread
If SOF is built with CONFIG_SOF_USERSPACE_LL, the IPC user handled will require access to coldrodata sections to initialize audio modules. This logic is not required for LLEXT modules, which have existing code to add access to coldrodata (and other sections). This commit is needed for builds where LLEXT is not used. Signed-off-by: Kai Vehmanen <[email protected]>
1 parent 7ef89f8 commit 6de0ca4

1 file changed

Lines changed: 34 additions & 0 deletions

File tree

src/ipc/ipc-common.c

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -575,6 +575,40 @@ __cold int ipc_user_init(void)
575575

576576
ret = k_mem_domain_add_partition(zephyr_ll_mem_domain(), &ipc_context_part);
577577

578+
/*
579+
* Grant user-space access to .cold (execute) and .coldrodata (read)
580+
* sections in IMR. The prepare path walks component code that may
581+
* reference __cold functions and __cold_rodata data.
582+
*/
583+
#ifdef CONFIG_COLD_STORE_EXECUTE_DRAM
584+
{
585+
extern char __cold_start[], __cold_end[];
586+
extern char __coldrodata_start[];
587+
extern char _imr_end[];
588+
struct k_mem_partition cold_part;
589+
590+
cold_part.start = (uintptr_t)__cold_start;
591+
cold_part.size = ALIGN_UP((uintptr_t)__cold_end -
592+
(uintptr_t)__cold_start,
593+
CONFIG_MMU_PAGE_SIZE);
594+
cold_part.attr = K_MEM_PARTITION_P_RX_U_RX;
595+
ret = k_mem_domain_add_partition(zephyr_ll_mem_domain(),
596+
&cold_part);
597+
if (ret < 0)
598+
LOG_WRN("cold text partition add failed: %d", ret);
599+
600+
cold_part.start = (uintptr_t)__coldrodata_start;
601+
cold_part.size = ALIGN_UP((uintptr_t)_imr_end -
602+
(uintptr_t)__coldrodata_start,
603+
CONFIG_MMU_PAGE_SIZE);
604+
cold_part.attr = K_MEM_PARTITION_P_RO_U_RO;
605+
ret = k_mem_domain_add_partition(zephyr_ll_mem_domain(),
606+
&cold_part);
607+
if (ret < 0)
608+
LOG_WRN("cold rodata partition add failed: %d", ret);
609+
}
610+
#endif
611+
578612
k_sem_init(ipc_user->sem, 0, 1);
579613

580614
/* Allocate kernel objects for the user-space thread */

0 commit comments

Comments
 (0)