diff --git a/getting_started/loadable_modules/lmdk_user_guide.rst b/getting_started/loadable_modules/lmdk_user_guide.rst index b6085e01..551c1ade 100644 --- a/getting_started/loadable_modules/lmdk_user_guide.rst +++ b/getting_started/loadable_modules/lmdk_user_guide.rst @@ -7,10 +7,65 @@ What is LMDK ************ LMDK(Loadable Module Development Kit) is a standalone package required to build loadable module. It is independent from SOF FW but contains necessary data structures to interact with it. +Package consists building CMake scripts and headers pack which is generated by python building script by executing it with -p: +.. code-block:: bash + + $ python scripts/lmdk/build_modules.py -l dummy -k "/path/to/signing/key.pem" -p + +These headers should be extracted in include directory of lmdk: +.. code-block:: cmake + + set(LMDK_DIR_INCLUDE ../../../lmdk/include) + target_include_directories(up_down_mixer PRIVATE "${LMDK_DIR_INCLUDE}" + "${LMDK_DIR_INCLUDE}/sof" + "${LMDK_DIR_INCLUDE}/sof/audio" + "${LMDK_DIR_INCLUDE}/module/audio") + +How to prepare MODULE to be loadable +************************************ + +Loadable modules are using functions provided by native_system_services which are narrowed to only neccesary and safe functions. For example all dynamic allocations are done on strict size local heap_mem +declared in a body of the module. + +.. code-block:: c + + static struct native_system_service_api* system_service; + uint32_t heap_mem[2048] __attribute__((section(".heap_mem"))) __attribute__((aligned(4096))); + +Each module also has to declare as a loadable and has prepared manifest which is specific for each. + +.. code-block:: c + + DECLARE_LOADABLE_MODULE_API_VERSION(dummy); + + static void* entry_point(void* mod_cfg, void* parent_ppl, void** mod_ptr) + { + system_service = *(const struct native_system_agent**)mod_ptr; + + return &up_down_mixer_interface; + } + + __attribute__((section(".module"))) + const struct sof_man_module_manifest dummy_module_manifest = { + .module = { + .name = "DUMMY", + .uuid = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, + .entry_point = (uint32_t)dummyPackageEntryPoint, + .type = { + .load_type = SOF_MAN_MOD_TYPE_MODULE, + .domain_ll = 1 + }, + .affinity_mask = 3, + } + }; + + How to build ************ +Using CMake scripts +=================== To build example loadable library execute: .. code-block:: bash @@ -23,3 +78,6 @@ To build example loadable library execute: Here RIMAGE_COMMAND is path to rimage executable binary, SIGNING_KEY is path to signing key for rimage. `LMDK ` + +Using Python scripts +====================