Skip to content

Commit a759851

Browse files
softwareckikv2019i
authored andcommitted
iadk: Add module pass buffer definition
Add a definition specifying the size of space reserved in module memory for module handle and a iadk adapter. Add a brief description of the iadk module loading sequence. Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
1 parent 1b08d6c commit a759851

3 files changed

Lines changed: 45 additions & 0 deletions

File tree

src/include/sof/audio/module_adapter/iadk/api_version.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,10 @@
1919
#define IADK_MODULE_API_CURRENT_VERSION MODULE_API_VERSION_ENCODE(IADK_MODULE_API_MAJOR_VERSION, \
2020
IADK_MODULE_API_MIDDLE_VERSION, IADK_MODULE_API_MINOR_VERSION)
2121

22+
/* Defines the size of the space reserved within ModuleHandle for SOF to store its private data.
23+
* This size comes from the IADK header files and must match the IADK API version.
24+
* Please do not modify this value!
25+
*/
26+
#define IADK_MODULE_PASS_BUFFER_SIZE 320
27+
2228
#endif /* __MODULE_ADAPTER_IADK_API_VERSION_H__ */

src/include/sof/audio/module_adapter/iadk/iadk_module_adapter.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
#include <module_initial_settings.h>
1616
#include <adsp_stddef.h>
1717
#include <system_error.h>
18+
#include <sof/common.h>
19+
#include <api_version.h>
1820

1921
#ifdef __cplusplus
2022
extern "C" {
@@ -112,6 +114,8 @@ namespace dsp_fw
112114
intel_adsp::ProcessingModuleInterface &processing_module_;
113115
};
114116

117+
STATIC_ASSERT(sizeof(IadkModuleAdapter) <= IADK_MODULE_PASS_BUFFER_SIZE, IadkModuleAdapter_too_big);
118+
115119
} /* namespace dsp_fw */
116120

117121
} /* extern "C" */

src/include/sof/audio/module_adapter/iadk/system_agent.h

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,41 @@ namespace system
7272
#ifdef __cplusplus
7373
extern "C" {
7474
#endif
75+
/*
76+
* The process of loading a IADK module is quite complicated. The function call stack is as follows:
77+
*
78+
* 1. IADK module adapter initialization function (modules_init) pass module entry point to the
79+
* system_agent_start function.
80+
*
81+
* 2. system_agent_start: This function creates an instance of the SystemAgent class on the stack
82+
* and then calls the module entry point function (ModuleEntryPoint) passing a pointer to the
83+
* SystemAgent object as a parameter.
84+
*
85+
* 3. ModuleEntryPoint(system_agent): Creates a ModuleFactory object of the module on the stack
86+
* (inheriting from ProcessingModuleFactoryInterface) and then calls the
87+
* LoadableModuleMain(system_agent, module_factory, placeholder) function, which is the default
88+
* entry point for all IADK modules. Placeholder is part of the .bss section intended for
89+
* a given module instance, with its address is determined based on the instance ID.
90+
*
91+
* 4. LoadableModuleMain(system_agent, module_factory, placeholder): Calls the CheckIn method
92+
* (variant with 7 parameters) of the SystemAgent class.
93+
*
94+
* 5. SystemAgent.CheckIn(7): Calls the Create method from the ModuleFactory object.
95+
*
96+
* 6. ModuleFactory.Create(system_agent, placeholder): Creates an instance of the module class
97+
* (inheriting from ProcessingModule) at the address pointed to by placeholder.
98+
* The ProcessingModule class contains a module_handle field, which reserves an area in memory
99+
* of size IADK_MODULE_PASS_BUFFER_SIZE bytes. The constructor of this class calls the CheckIn
100+
* method (the variant with 3 parameters) from the SystemAgent class, passing a pointer to self
101+
* and a pointer to module_handle.
102+
*
103+
* 7. SystemAgent.CheckIn(3): Stores the address of module_handle in a private variable and
104+
* creates an instance of the IadkModuleAdapter class in this location.
105+
*
106+
* The saved address of the module_handle (the adapter's IADK instance) is returned in the CheckIn
107+
* method (the variant with 7 parameters) via a parameter that initially contained the address to
108+
* the agent system. The system_agent_start function returns it in the variable adapter.
109+
*/
75110
void *system_agent_start(uint32_t entry_point, uint32_t module_id, uint32_t instance_id,
76111
uint32_t core_id, uint32_t log_handle, void *mod_cfg);
77112
#ifdef __cplusplus

0 commit comments

Comments
 (0)