diff --git a/src/include/sof/lib_manager.h b/src/include/sof/lib_manager.h index f918602dc..cd5f2f25c 100644 --- a/src/include/sof/lib_manager.h +++ b/src/include/sof/lib_manager.h @@ -127,13 +127,13 @@ void lib_manager_init(void); /* * \brief Register module on driver list * - * param[in] desc - library manifest descriptor - * param[in] module_id - used to get manifest offset for module + * param[in] component_id - component id coming from ipc config. This function reguires valid + * lib_id and module_id fields of component id. * * Creates new comp_driver_info and initialize it for module from library * Adds new module to sof_get()->comp_drivers list */ -int lib_manager_register_module(struct sof_man_fw_desc *desc, int module_id); +int lib_manager_register_module(const uint32_t component_id); /* * \brief Get library module manifest descriptor diff --git a/src/ipc/ipc4/helper.c b/src/ipc/ipc4/helper.c index c038af6a1..f9423fd2a 100644 --- a/src/ipc/ipc4/helper.c +++ b/src/ipc/ipc4/helper.c @@ -990,7 +990,7 @@ const struct comp_driver *ipc4_get_comp_drv(int module_id) #if CONFIG_LIBRARY_MANAGER if (!drv) { /* New module not registered yet. */ - lib_manager_register_module(desc, module_id); + lib_manager_register_module(module_id); drv = ipc4_get_drv(mod->uuid); } #endif diff --git a/src/library_manager/lib_manager.c b/src/library_manager/lib_manager.c index 45858e2df..a95633257 100644 --- a/src/library_manager/lib_manager.c +++ b/src/library_manager/lib_manager.c @@ -487,15 +487,28 @@ static void lib_manager_update_sof_ctx(void *base_addr, uint32_t lib_id) } #if CONFIG_INTEL_MODULES -int lib_manager_register_module(struct sof_man_fw_desc *desc, int module_id) +int lib_manager_register_module(const uint32_t component_id) { - uint32_t entry_index = LIB_MANAGER_GET_MODULE_INDEX(module_id); - /* allocate new comp_driver_info */ + const struct lib_manager_mod_ctx *const ctx = lib_manager_get_mod_ctx(component_id); + const uint32_t entry_index = LIB_MANAGER_GET_MODULE_INDEX(component_id); + const struct sof_man_fw_desc *desc; struct comp_driver_info *new_drv_info; struct comp_driver *drv = NULL; struct sof_man_module *mod; int ret; + /* Get library manifest based on component_id */ + if (!ctx || !ctx->base_addr) + return -ENOENT; + + desc = (const struct sof_man_fw_desc *)((const char *)ctx->base_addr + + SOF_MAN_ELF_TEXT_OFFSET); + if (entry_index >= desc->header.num_module_entries) { + tr_err(&lib_manager_tr, "Entry index %d out of bounds.", entry_index); + return -ENOENT; + } + + /* allocate new comp_driver_info */ new_drv_info = rmalloc(SOF_MEM_ZONE_RUNTIME_SHARED, 0, SOF_MEM_CAPS_RAM | SOF_MEM_FLAG_COHERENT, sizeof(struct comp_driver_info)); @@ -520,7 +533,7 @@ int lib_manager_register_module(struct sof_man_fw_desc *desc, int module_id) /* Fill the new_drv_info structure with already known parameters */ /* Check already registered components */ mod = (struct sof_man_module *)((uint8_t *)desc + SOF_MAN_MODULE_OFFSET(entry_index)); - struct sof_uuid *uid = (struct sof_uuid *)&mod->uuid[0]; + const struct sof_uuid *uid = (struct sof_uuid *)&mod->uuid[0]; declare_dynamic_module_adapter(drv, SOF_COMP_MODULE_ADAPTER, uid, &lib_manager_tr); @@ -539,7 +552,7 @@ cleanup: } #else /* CONFIG_INTEL_MODULES */ -int lib_manager_register_module(struct sof_man_fw_desc *desc, int module_id) +int lib_manager_register_module(const uint32_t component_id) { tr_err(&lib_manager_tr, "lib_manager_register_module(): Dynamic module loading is not supported");