@@ -72,6 +72,41 @@ namespace system
7272#ifdef __cplusplus
7373extern " 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+ */
75110void *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