Skip to content

Commit

Permalink
lib-manager: add a function to identify component type
Browse files Browse the repository at this point in the history
Extract the module_is_llext() macro into a header and add a function
to identify a loadable module type of a component.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
  • Loading branch information
lyakh committed Aug 13, 2024
1 parent 646c9b0 commit 892ecc7
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
15 changes: 14 additions & 1 deletion src/include/sof/llext_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,34 @@
#ifndef __SOF_LLEXT_MANAGER_H__
#define __SOF_LLEXT_MANAGER_H__

#include <stdbool.h>
#include <stdint.h>

#if CONFIG_LLEXT
#include <rimage/sof/user/manifest.h>

struct comp_dev;
struct comp_driver;
struct comp_ipc_config;

#if CONFIG_LLEXT
static inline bool module_is_llext(const struct sof_man_module *mod)
{
return mod->type.load_type == SOF_MAN_MOD_TYPE_LLEXT;
}

uintptr_t llext_manager_allocate_module(struct processing_module *proc,
const struct comp_ipc_config *ipc_config,
const void *ipc_specific_config);

int llext_manager_free_module(const uint32_t component_id);

bool comp_is_llext(struct comp_dev *comp);
#else
#define module_is_llext(mod) false
#define llext_manager_allocate_module(proc, ipc_config, ipc_specific_config) 0
#define llext_manager_free_module(component_id) 0
#define llext_unload(ext) 0
#define comp_is_llext(comp) false
#endif

#endif
5 changes: 0 additions & 5 deletions src/library_manager/lib_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -339,11 +339,6 @@ static int lib_manager_free_module_instance(uint32_t module_id, uint32_t instanc
return sys_mm_drv_unmap_region((__sparse_force void *)va_base, bss_size);
}

static inline bool module_is_llext(const struct sof_man_module *mod)
{
return mod->type.load_type == SOF_MAN_MOD_TYPE_LLEXT;
}

uintptr_t lib_manager_allocate_module(struct processing_module *proc,
const struct comp_ipc_config *ipc_config,
const void *ipc_specific_config)
Expand Down
10 changes: 10 additions & 0 deletions src/library_manager/llext_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -363,3 +363,13 @@ int llext_manager_free_module(const uint32_t component_id)

return llext_manager_unload_module(base_module_id, mod);
}

bool comp_is_llext(struct comp_dev *comp)
{
const uint32_t module_id = IPC4_MOD_ID(comp->ipc_config.id);
const unsigned int base_module_id = LIB_MANAGER_GET_LIB_ID(module_id) <<
LIB_MANAGER_LIB_ID_SHIFT;
const struct sof_man_module *mod = lib_manager_get_module_manifest(base_module_id);

return mod && module_is_llext(mod);
}

0 comments on commit 892ecc7

Please sign in to comment.