Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 367
library manager: initial implementation#5796
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
4b603434f02dd5e5962809a32de03a68e90File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,194 @@ | ||
| /* SPDX-License-Identifier: BSD-3-Clause | ||
| * | ||
| * Copyright(c) 2022 Intel Corporation. All rights reserved. | ||
| * | ||
| * Author: Jaroslaw Stelter <jaroslaw.stelter@intel.com> | ||
| * Pawel Dobrowolski <pawelx.dobrowolski@intel.com> | ||
| */ | ||
| /* | ||
| * Library manager implementation for SOF is using module adapter API for | ||
| * loadable native and external libraries. Depends of information received from | ||
pjdobrowolski marked this conversation as resolved.
Outdated
Uh oh!There was an error while loading. Please reload this page. | ||
| * it manages memory and locate accordingly to available space. | ||
| * | ||
| * Driver IPC4 Library MEMORY ENTITY | ||
| * Handler Manager VERIF. | ||
| * | | | | | | ||
| * | IPC4_GLB_LOAD_LIBRARY | | | | | ||
| * | --------------------> | lib_manager_load_library() | | | | ||
| * | | -------------------------> | Prepare DMA transfer | | | ||
| * | | | ------- | | | ||
pjdobrowolski marked this conversation as resolved.
Outdated
Uh oh!There was an error while loading. Please reload this page. | ||
| * | | | | | | | ||
| * | | | <------ | | | ||
| * | | | -----------------------> | | | ||
| * | | | | | | ||
| * | | | (IF AUTH_API_ENABLED) | | | ||
| * | | | Verify Manifest | | | ||
| * | | | -------------------------|-------> | | ||
| * | | | results | | | ||
| * | | | <------------------------|-------- | | ||
| * | | | (IF AUTH_API_ENABLED) | | | ||
| * | | | | | | ||
| * | | | Parse Manifest | | | ||
| * | | | Prepare Storage Memory | | | ||
| * | | | ------- | | | ||
| * | | | | | | | ||
| * | | | <------ | | | ||
| * | | | | | | ||
| * | | | Copy Library Data | | | ||
| * | | | -----------------------> | | | ||
| * | | | | | | ||
| * | | | (IF AUTH_API_ENABLED) | | | ||
| * | | | Verify Manifest | | | ||
| * | | | -------------------------|-------> | | ||
| * | | | results | | | ||
| * | | | <------------------------|-------- | | ||
| * | | | (IF AUTH_API_ENABLED) | | | ||
| * | | | | | | ||
| * | | | Update Library | | | ||
| * | | | descriptors table | | | ||
| * | | | ------- | | | ||
| * | | | | | | | ||
| * | | | <------ | | | ||
| * | | return status | | | | ||
| * | | <------------------------- | | | | ||
| * | Complete IPC request | | | | | ||
| * | <------------------- | | | | | ||
| * | ||
| * Driver IPC4 Library MEMORY ENTITY | ||
| * Handler Manager VERIF. | ||
| */ | ||
| #ifndef __SOF_LIB_MANAGER_H__ | ||
| #define __SOF_LIB_MANAGER_H__ | ||
| #include <stdint.h> | ||
| #include <rimage/cavs/cavs_ext_manifest.h> | ||
| #include <rimage/sof/user/manifest.h> | ||
| #define LIB_MANAGER_MAX_LIBS 16 | ||
| #define LIB_MANAGER_LIB_ID_SHIFT 12 | ||
| #define LIB_MANAGER_LIB_NOTIX_MAX_COUNT 4 | ||
| #define LIB_MANAGER_GET_LIB_ID(module_id) ((module_id) >> LIB_MANAGER_LIB_ID_SHIFT) | ||
| #define LIB_MANAGER_GET_MODULE_INDEX(module_id) ((module_id) & 0xFFF) | ||
pjdobrowolski marked this conversation as resolved.
Outdated
Uh oh!There was an error while loading. Please reload this page. | ||
| #ifdef CONFIG_LIBRARY_MANAGER | ||
| struct ipc_lib_msg { | ||
| struct ipc_msg *msg; | ||
| struct list_item list; | ||
| }; | ||
| struct ext_library { | ||
| struct k_spinlock lock; /* last locking CPU record */ | ||
| struct sof_man_fw_desc *desc[LIB_MANAGER_MAX_LIBS]; | ||
pjdobrowolski marked this conversation as resolved.
Outdated
Uh oh!There was an error while loading. Please reload this page. | ||
| uint32_t mods_exec_load_cnt; | ||
pjdobrowolski marked this conversation as resolved.
Outdated
Uh oh!There was an error while loading. Please reload this page. | ||
| struct ipc_lib_msg *lib_notif_pool; | ||
| uint32_t lib_notif_count; | ||
| }; | ||
| /* lib manager context, used by lib_notification */ | ||
| extern struct tr_ctx lib_manager_tr; | ||
| static inline struct ext_library *ext_lib_get(void) | ||
| { | ||
| return sof_get()->ext_library; | ||
pjdobrowolski marked this conversation as resolved.
Outdated
Uh oh!There was an error while loading. Please reload this page. | ||
| } | ||
| #endif | ||
| /* | ||
| * \brief Initialize library manager | ||
| */ | ||
| 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 | ||
| * | ||
| * 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); | ||
| /* | ||
| * \brief Get library module manifest descriptor | ||
| * | ||
| * param[in] module_id - used to get text manifest offset | ||
| * | ||
| * Gets firmware manifest descriptor using module_id to locate it | ||
| */ | ||
| struct sof_man_fw_desc *lib_manager_get_library_module_desc(int module_id); | ||
| /* | ||
| * \brief Allocate module | ||
| * | ||
| * param[in] drv - component driver | ||
| * param[in] ipc_config - audio component base configuration from IPC at creation | ||
| * param[in] ipc_specific_config - ipc4 base configuration | ||
| * | ||
| * Function is responsible to allocate module in available free memory and assigning proper address. | ||
| * (WIP) These feature will contain module validation and proper memory management. | ||
| */ | ||
| uint32_t lib_manager_allocate_module(const struct comp_driver *drv, | ||
| struct comp_ipc_config *ipc_config, | ||
| void *ipc_specific_config); | ||
| /* | ||
| * \brief Free module | ||
| * | ||
| * param[in] drv - component driver | ||
| * param[in] ipc_config - audio component base configuration from IPC at creation | ||
| * param[in] ipc_specific_config - ipc4 base configuration | ||
| * | ||
| * Function is responsible to free module resources in HP memory. | ||
| */ | ||
| int lib_manager_free_module(const struct comp_driver *drv, | ||
| struct comp_ipc_config *ipc_config); | ||
| /* | ||
| * \brief Load library | ||
| * | ||
| * param[in] dma_id - channel used to transfer binary from host | ||
| * param[in] lib_id | ||
| * | ||
| * Function will load library manifest into temporary buffer. | ||
| * Then it will read library parameters, allocate memory for library and load it into | ||
| * destination memory region. | ||
| */ | ||
| int lib_manager_load_library(uint32_t dma_id, uint32_t lib_id); | ||
| /* | ||
| * \brief Initialize message | ||
| * | ||
| * param[in] header - IPC header provided by caller | ||
| * param[in] size - size of data buffer for messege to be send | ||
| * | ||
| * Function search lib_notif_pool for free message handler. | ||
| * If not found allocates new message handle and returns it to | ||
| * caller. | ||
| */ | ||
| struct ipc_msg *lib_notif_msg_init(uint32_t header, uint32_t size); | ||
| /* | ||
| * \brief Send message | ||
| * | ||
| * param[in] msg - IPC message handler | ||
| * | ||
| * Function sends IPC message and calls lib_notif_msg_clean() to | ||
| * free unused message handlers. Only single message handle will | ||
| * be kept in list while at least one loadable module is loaded. | ||
| */ | ||
| void lib_notif_msg_send(struct ipc_msg *msg); | ||
| /* | ||
| * \brief Clean unused message handles | ||
| * | ||
| * param[in] leave_one_handle - remove all unused or keep one | ||
| * | ||
| * Function search lib_notif_pool list for unused message handles. | ||
| * Remove them keeping one if leave_one_handle == true. | ||
| */ | ||
| void lib_notif_msg_clean(bool leave_one_handle); | ||
| #endif /* __SOF_LIB_MANAGER_H__ */ | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -190,8 +190,9 @@ void ipc_msg_send(struct ipc_msg *msg, void *data, bool high_priority) | ||
| key = k_spin_lock(&ipc->lock); | ||
| /* copy mailbox data to message */ | ||
| if (msg->tx_size > 0 && msg->tx_size < SOF_IPC_MSG_MAX_SIZE) { | ||
| /* copy mailbox data to message if not already copied */ | ||
| if ((msg->tx_size > 0 && msg->tx_size < SOF_IPC_MSG_MAX_SIZE) && | ||
| msg->tx_data != data) { | ||
| ret = memcpy_s(msg->tx_data, msg->tx_size, data, msg->tx_size); | ||
| assert(!ret); | ||
| } | ||
pjdobrowolski marked this conversation as resolved.
Outdated
Uh oh!There was an error while loading. Please reload this page. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -32,6 +32,8 @@ | ||
| #include <user/trace.h> | ||
pjdobrowolski marked this conversation as resolved.
Outdated
Uh oh!There was an error while loading. Please reload this page. | ||
| #include <rtos/kernel.h> | ||
| #include <sof/trace/dma-trace.h> | ||
| #include <sof/lib_manager.h> | ||
| #include <errno.h> | ||
| #include <stdbool.h> | ||
| @@ -498,6 +500,22 @@ static int ipc4_set_pipeline_state(struct ipc4_message_request *ipc4) | ||
| return ret; | ||
| } | ||
| #if CONFIG_LIBRARY_MANAGER | ||
| static int ipc4_load_library(struct ipc4_message_request *ipc4) | ||
| { | ||
| struct ipc4_module_load_library library; | ||
| int ret = IPC4_UNAVAILABLE; | ||
| library.header.dat = ipc4->primary.dat; | ||
| library.data.dat = ipc4->extension.dat; | ||
| ret = lib_manager_load_library(library.header.r.dma_id, library.header.r.lib_id); | ||
pjdobrowolski marked this conversation as resolved.
Outdated
Uh oh!There was an error while loading. Please reload this page. | ||
| tr_info(&ipc_tr, "ipc: ipc4_load_library %d", ret); | ||
| return ret; | ||
| } | ||
| #endif | ||
| static int ipc4_process_chain_dma(struct ipc4_message_request *ipc4) | ||
| { | ||
| struct ipc4_chain_dma cdma; | ||
| @@ -569,7 +587,11 @@ static int ipc4_process_glb_message(struct ipc4_message_request *ipc4) | ||
| break; | ||
| /* Loads library (using Code Load or HD/A Host Output DMA) */ | ||
| #ifdef CONFIG_LIBRARY_MANAGER | ||
| case SOF_IPC4_GLB_LOAD_LIBRARY: | ||
| ret = ipc4_load_library(ipc4); | ||
| break; | ||
| #endif | ||
| case SOF_IPC4_GLB_INTERNAL_MESSAGE: | ||
| tr_err(&ipc_tr, "not implemented ipc message type %d", type); | ||
| ret = IPC4_UNAVAILABLE; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| # SPDX-License-Identifier: BSD-3-Clause | ||
| if(CONFIG_LIBRARY_MANAGER) | ||
| add_local_sources(sof lib_manager.c, lib_notifications.c) | ||
| endif() |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.