From 90208286a8405b2d98cae20207fed6a1846e5870 Mon Sep 17 00:00:00 2001 From: Jyri Sarha Date: Mon, 4 Nov 2024 12:17:41 +0200 Subject: [PATCH] probe: llext: Enable building probe as loadable llext module To build PROBE as module just set CONFIG_PROBE=m in Kconfig. Signed-off-by: Jyri Sarha --- src/include/sof/probe/probe.h | 4 ++-- src/logging/log_backend_probe.c | 1 + src/probe/Kconfig | 8 +++++++- src/probe/llext/CMakeLists.txt | 6 ++++++ src/probe/llext/llext.toml.h | 10 ++++++++++ src/probe/probe.c | 21 ++++++++++++++++++++- src/probe/probe.toml | 6 +++++- zephyr/CMakeLists.txt | 12 +++++++++--- 8 files changed, 60 insertions(+), 8 deletions(-) create mode 100644 src/probe/llext/CMakeLists.txt create mode 100644 src/probe/llext/llext.toml.h diff --git a/src/include/sof/probe/probe.h b/src/include/sof/probe/probe.h index 158d60b573e1..0ba075012c55 100644 --- a/src/include/sof/probe/probe.h +++ b/src/include/sof/probe/probe.h @@ -8,7 +8,7 @@ #ifndef __SOF_PROBE_PROBE_H__ #define __SOF_PROBE_PROBE_H__ -#if CONFIG_PROBE +#if CONFIG_PROBE || CONFIG_PROBE_MODULE #include @@ -106,6 +106,6 @@ static inline struct probe_pdata *probe_get(void) return sof_get()->probe; } -#endif /* CONFIG_PROBE */ +#endif /* CONFIG_PROBE || CONFIG_PROBE_MODULE */ #endif /* __SOF_PROBE_PROBE_H__ */ diff --git a/src/logging/log_backend_probe.c b/src/logging/log_backend_probe.c index 6baf22df2e14..b701fb88756b 100644 --- a/src/logging/log_backend_probe.c +++ b/src/logging/log_backend_probe.c @@ -109,6 +109,7 @@ void probe_logging_init(probe_logging_hook_t fn) { probe_hook = fn; } +EXPORT_SYMBOL(probe_logging_init); const struct log_backend *log_backend_probe_get(void) { diff --git a/src/probe/Kconfig b/src/probe/Kconfig index 20fcbbe9cd3d..a45947ab5181 100644 --- a/src/probe/Kconfig +++ b/src/probe/Kconfig @@ -5,11 +5,14 @@ menu "Probe" config PROBE - bool "Probes enabled" + tristate "Probes enabled" + default m if LIBRARY_DEFAULT_MODULAR default y if CAVS help Select for enabling debug probes to extract/inject buffers +if PROBE != n + config PROBE_POINTS_MAX int "Maximum probe points" depends on PROBE @@ -23,4 +26,7 @@ config PROBE_DMA_MAX default 0 help Define maximum number of injection DMAs. + +endif + endmenu diff --git a/src/probe/llext/CMakeLists.txt b/src/probe/llext/CMakeLists.txt new file mode 100644 index 000000000000..c77ad93ee88d --- /dev/null +++ b/src/probe/llext/CMakeLists.txt @@ -0,0 +1,6 @@ +# Copyright (c) 2024 Intel Corporation. +# SPDX-License-Identifier: Apache-2.0 + +sof_llext_build("probe" + SOURCES ../probe.c +) diff --git a/src/probe/llext/llext.toml.h b/src/probe/llext/llext.toml.h new file mode 100644 index 000000000000..4567111f4c52 --- /dev/null +++ b/src/probe/llext/llext.toml.h @@ -0,0 +1,10 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * + * Copyright(c) 2024 Intel Corporation. All rights reserved. + */ +#include +#define LOAD_TYPE "2" +#include "../probe.toml" + +[module] +count = __COUNTER__ diff --git a/src/probe/probe.c b/src/probe/probe.c index e09520eee30b..b7f7bf45f8c6 100644 --- a/src/probe/probe.c +++ b/src/probe/probe.c @@ -1513,4 +1513,23 @@ static const struct module_interface probe_interface = { DECLARE_MODULE_ADAPTER(probe_interface, PROBE_UUID, pr_tr); SOF_MODULE_INIT(probe, sys_comp_module_probe_interface_init); -#endif +#if CONFIG_PROBE_MODULE +/* modular: llext dynamic link */ + +#include +#include +#include + +#define UUID_PROBE 0x08, 0x08, 0xAD, 0x7C, 0x10, 0xAB, 0x23, 0xCD, 0xEF, 0x45, \ + 0x12, 0xAB, 0x34, 0xCD, 0x56, 0xEF, + +SOF_LLEXT_MOD_ENTRY(probe, &probe_interface); + +static const struct sof_man_module_manifest mod_manifest __section(".module") __used = + SOF_LLEXT_MODULE_MANIFEST("PROBE", probe_llext_entry, 1, UUID_PROBE, 40); + +SOF_LLEXT_BUILDINFO; + +#endif /* CONFIG_COMP_PROBE_MODULE */ + +#endif /* CONFIG_IPC_MAJOR_4 */ diff --git a/src/probe/probe.toml b/src/probe/probe.toml index b3ae8f8d4c9e..848234b0085c 100644 --- a/src/probe/probe.toml +++ b/src/probe/probe.toml @@ -1,10 +1,14 @@ +#ifndef LOAD_TYPE +#define LOAD_TYPE "0" +#endif + [[module.entry]] name = "PROBE" uuid = "7CAD0808-AB10-CD23-EF45-12AB34CD56EF" affinity_mask = "0x1" instance_count = "1" domain_types = "0" - load_type = "0" + load_type = LOAD_TYPE module_type = "9" auto_start = "0" sched_caps = [1, 0x00008000] diff --git a/zephyr/CMakeLists.txt b/zephyr/CMakeLists.txt index c27f407ec891..fcaaba4808e7 100644 --- a/zephyr/CMakeLists.txt +++ b/zephyr/CMakeLists.txt @@ -1129,9 +1129,15 @@ zephyr_library_sources_ifdef(CONFIG_WAVES_CODEC_STUB ${SOF_AUDIO_PATH}/module_adapter/module/waves/maxx_stub.c ) -zephyr_library_sources_ifdef(CONFIG_PROBE - ${SOF_SRC_PATH}/probe/probe.c -) +if(CONFIG_PROBE STREQUAL "m") + add_subdirectory(${SOF_SRC_PATH}/probe/llext + ${PROJECT_BINARY_DIR}/probe_llext) + add_dependencies(app probe) +elseif(CONFIG_PROBE) + zephyr_library_sources_ifdef(CONFIG_PROBE + ${SOF_SRC_PATH}/probe/probe.c + ) +endif() zephyr_library_sources_ifdef(CONFIG_MULTICORE ${SOF_SRC_PATH}/idc/idc.c