Skip to content

Commit

Permalink
iadk: system_agent: Check error code returned by the module entry point
Browse files Browse the repository at this point in the history
Change the definition of the system_agent_start function so that it returns
the error code returned by the module's entry point functions. Return the
created IadkModuleAdapter object via a parameter.

Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
  • Loading branch information
softwarecki committed Sep 10, 2024
1 parent 5545125 commit f74c888
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 17 deletions.
16 changes: 6 additions & 10 deletions src/audio/module_adapter/iadk/system_agent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,17 +118,15 @@ int SystemAgent::CheckIn(ProcessingModuleFactoryInterface& module_factory,
} /* namespace system */
} /* namespace intel_adsp */

#ifdef __cplusplus
extern "C" {
#endif
/* The create_instance_f is a function call type known in IADK module. The module entry_point
* points to this type of function which starts module creation.
*/
typedef int (*create_instance_f)(uint32_t module_id, uint32_t instance_id, uint32_t core_id,
void *mod_cfg, void *parent_ppl, void **mod_ptr);

void* system_agent_start(uint32_t entry_point, uint32_t module_id, uint32_t instance_id,
uint32_t core_id, uint32_t log_handle, void* mod_cfg)
int system_agent_start(uint32_t entry_point, uint32_t module_id, uint32_t instance_id,
uint32_t core_id, uint32_t log_handle, void* mod_cfg,
void **adapter)
{
uint32_t ret;
SystemAgent system_agent(module_id, instance_id, core_id, log_handle);
Expand All @@ -137,13 +135,11 @@ void* system_agent_start(uint32_t entry_point, uint32_t module_id, uint32_t inst
create_instance_f ci = (create_instance_f)(entry_point);
ret = ci(module_id, instance_id, core_id, mod_cfg, NULL, &system_agent_p);

return system_agent_p;
IadkModuleAdapter* module_adapter = reinterpret_cast<IadkModuleAdapter*>(system_agent_p);
*adapter = module_adapter;
return ret;
}

#ifdef __cplusplus
}
#endif

extern "C" void __cxa_pure_virtual() __attribute__((weak));

void __cxa_pure_virtual()
Expand Down
15 changes: 10 additions & 5 deletions src/audio/module_adapter/module/modules.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ static int modules_init(struct processing_module *mod)
const struct comp_driver *const drv = dev->drv;
const struct ipc4_base_module_cfg *src_cfg = &md->cfg.base_cfg;
const struct comp_ipc_config *config = &dev->ipc_config;
void *system_agent;
void *adapter;
int ret;

uintptr_t module_entry_point = lib_manager_allocate_module(mod, config, src_cfg);

Expand All @@ -81,16 +82,20 @@ static int modules_init(struct processing_module *mod)
.size = md->cfg.size >> 2,
};

system_agent = system_agent_start(module_entry_point, module_id, instance_id, 0, log_handle,
&mod_cfg);
ret = system_agent_start(module_entry_point, module_id, instance_id, 0, log_handle,
&mod_cfg, &adapter);
if (ret) {
comp_info(dev, "System agent failed");
return ret;
}

module_set_private_data(mod, system_agent);
module_set_private_data(mod, adapter);

md->mpd.in_buff_size = src_cfg->ibs;
md->mpd.out_buff_size = src_cfg->obs;

mod->proc_type = MODULE_PROCESS_TYPE_SOURCE_SINK;
return iadk_wrapper_init(system_agent);
return iadk_wrapper_init(adapter);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/include/sof/audio/module_adapter/iadk/system_agent.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ extern "C" {
* method (the variant with 7 parameters) via a parameter that initially contained the address to
* the agent system. The system_agent_start function returns it in the variable adapter.
*/
void *system_agent_start(uint32_t entry_point, uint32_t module_id, uint32_t instance_id,
uint32_t core_id, uint32_t log_handle, void *mod_cfg);
int system_agent_start(uint32_t entry_point, uint32_t module_id, uint32_t instance_id,
uint32_t core_id, uint32_t log_handle, void *mod_cfg, void **adapter);
#ifdef __cplusplus
}
#endif
Expand Down

0 comments on commit f74c888

Please sign in to comment.