Skip to content

Commit c58cf14

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 5c2063a commit c58cf14

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
@@ -645,6 +645,40 @@ __cold int ipc_user_init(void)
645645

646646
ret = k_mem_domain_add_partition(zephyr_ll_mem_domain(), &ipc_context_part);
647647

648+
/*
649+
* Grant user-space access to .cold (execute) and .coldrodata (read)
650+
* sections in IMR. The prepare path walks component code that may
651+
* reference __cold functions and __cold_rodata data.
652+
*/
653+
#ifdef CONFIG_COLD_STORE_EXECUTE_DRAM
654+
{
655+
extern char __cold_start[], __cold_end[];
656+
extern char __coldrodata_start[];
657+
extern char _imr_end[];
658+
struct k_mem_partition cold_part;
659+
660+
cold_part.start = (uintptr_t)__cold_start;
661+
cold_part.size = ALIGN_UP((uintptr_t)__cold_end -
662+
(uintptr_t)__cold_start,
663+
CONFIG_MMU_PAGE_SIZE);
664+
cold_part.attr = K_MEM_PARTITION_P_RX_U_RX;
665+
ret = k_mem_domain_add_partition(zephyr_ll_mem_domain(),
666+
&cold_part);
667+
if (ret < 0)
668+
LOG_WRN("cold text partition add failed: %d", ret);
669+
670+
cold_part.start = (uintptr_t)__coldrodata_start;
671+
cold_part.size = ALIGN_UP((uintptr_t)_imr_end -
672+
(uintptr_t)__coldrodata_start,
673+
CONFIG_MMU_PAGE_SIZE);
674+
cold_part.attr = K_MEM_PARTITION_P_RO_U_RO;
675+
ret = k_mem_domain_add_partition(zephyr_ll_mem_domain(),
676+
&cold_part);
677+
if (ret < 0)
678+
LOG_WRN("cold rodata partition add failed: %d", ret);
679+
}
680+
#endif
681+
648682
k_sem_init(ipc_user->sem, 0, 1);
649683

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

0 commit comments

Comments
 (0)