diff --git a/src/include/sof/probe/probe.h b/src/include/sof/probe/probe.h index 7b6623737895..f3f01435902b 100644 --- a/src/include/sof/probe/probe.h +++ b/src/include/sof/probe/probe.h @@ -8,8 +8,6 @@ #ifndef __SOF_PROBE_PROBE_H__ #define __SOF_PROBE_PROBE_H__ -#if CONFIG_PROBE - #include /** @@ -18,8 +16,8 @@ typedef void(*probe_logging_hook_t)(uint8_t *buffer, size_t length); #if CONFIG_LOG_BACKEND_SOF_PROBE -void probe_logging_hook(uint8_t *buffer, size_t length); const struct log_backend *log_backend_probe_get(void); +bool probe_is_backend_configured(void); #endif /** @@ -106,6 +104,4 @@ static inline struct probe_pdata *probe_get(void) return sof_get()->probe; } -#endif /* CONFIG_PROBE */ - #endif /* __SOF_PROBE_PROBE_H__ */ diff --git a/src/init/init.c b/src/init/init.c index 738ce9233e69..530e82a537de 100644 --- a/src/init/init.c +++ b/src/init/init.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -53,6 +54,7 @@ struct sof *sof_get(void) { return &sof; } +EXPORT_SYMBOL(sof_get); #if CONFIG_NO_SECONDARY_CORE_ROM /** diff --git a/src/ipc/ipc-common.c b/src/ipc/ipc-common.c index 7714a4650150..e9de1efdd2a0 100644 --- a/src/ipc/ipc-common.c +++ b/src/ipc/ipc-common.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -95,6 +96,7 @@ struct ipc_comp_dev *ipc_get_comp_dev(struct ipc *ipc, uint16_t type, uint32_t i return NULL; } +EXPORT_SYMBOL(ipc_get_comp_dev); /* Walks through the list of components looking for a sink/source endpoint component * of the given pipeline diff --git a/src/ipc/ipc4/logging.c b/src/ipc/ipc4/logging.c index 29ba657d17c7..01a981435e6e 100644 --- a/src/ipc/ipc4/logging.c +++ b/src/ipc/ipc4/logging.c @@ -185,7 +185,7 @@ int ipc4_logging_enable_logs(bool first_block, if (!probe_is_backend_configured()) return -EINVAL; - log_backend_activate(log_backend, probe_logging_hook); + log_backend_activate(log_backend, NULL); } else { log_backend_deactivate(log_backend); diff --git a/src/lib/dma.c b/src/lib/dma.c index 639bca4734a4..d95633c45234 100644 --- a/src/lib/dma.c +++ b/src/lib/dma.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -278,6 +279,8 @@ void dma_put(struct dma *dma) k_spin_unlock(&dma->lock, key); } #endif +EXPORT_SYMBOL(dma_get); +EXPORT_SYMBOL(dma_put); int dma_sg_alloc(struct dma_sg_elem_array *elem_array, enum mem_zone zone, @@ -318,6 +321,7 @@ void dma_sg_free(struct dma_sg_elem_array *elem_array) rfree(elem_array->elems); dma_sg_init(elem_array); } +EXPORT_SYMBOL(dma_sg_free); int dma_buffer_copy_from(struct comp_buffer *source, struct comp_buffer *sink, diff --git a/src/lib/notifier.c b/src/lib/notifier.c index 98fbad4346fc..4b096111019c 100644 --- a/src/lib/notifier.c +++ b/src/lib/notifier.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include @@ -78,6 +79,7 @@ int notifier_register(void *receiver, void *caller, enum notify_id type, k_spin_unlock(¬ify->lock, key); return ret; } +EXPORT_SYMBOL(notifier_register); void notifier_unregister(void *receiver, void *caller, enum notify_id type) { @@ -114,6 +116,7 @@ void notifier_unregister(void *receiver, void *caller, enum notify_id type) k_spin_unlock(¬ify->lock, key); } +EXPORT_SYMBOL(notifier_unregister); void notifier_unregister_all(void *receiver, void *caller) { 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 b6e689bd75d3..4ac38e49b8cc 100644 --- a/src/probe/probe.c +++ b/src/probe/probe.c @@ -759,7 +759,6 @@ static uint32_t probe_gen_format(uint32_t frame_fmt, uint32_t rate, default: tr_err(&pr_tr, "probe_gen_format(): Invalid frame format specified = 0x%08x", frame_fmt); - assert(false); return 0; } @@ -836,7 +835,7 @@ static void kick_probe_task(struct probe_pdata *_probe) } #if CONFIG_LOG_BACKEND_SOF_PROBE -void probe_logging_hook(uint8_t *buffer, size_t length) +static void probe_logging_hook(uint8_t *buffer, size_t length) { struct probe_pdata *_probe = probe_get(); uint64_t checksum; @@ -1088,7 +1087,7 @@ static struct comp_buffer *ipc4_get_buffer(struct ipc_comp_dev *dev, probe_point static bool enable_logs(const struct probe_point *probe) { #if CONFIG_IPC_MAJOR_4 - return probe->buffer_id.fields.module_id == 0; + return probe->buffer_id.full_id == 0; #else return probe->purpose == PROBE_PURPOSE_LOGGING; #endif @@ -1511,6 +1510,25 @@ static const struct module_interface probe_interface = { }; DECLARE_MODULE_ADAPTER(probe_interface, PROBE_UUID, pr_tr); -SOF_MODULE_INIT(asrc, sys_comp_module_probe_interface_init); +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/src/schedule/zephyr_ll.c b/src/schedule/zephyr_ll.c index 49b1cc0d63a2..899fb5b37268 100644 --- a/src/schedule/zephyr_ll.c +++ b/src/schedule/zephyr_ll.c @@ -6,6 +6,7 @@ #include #include +#include #include #include #include @@ -522,6 +523,7 @@ int zephyr_ll_task_init(struct task *task, return 0; } +EXPORT_SYMBOL(zephyr_ll_task_init); /* TODO: low-power mode clock support */ /* Runs on each core during initialisation with the same domain argument */ diff --git a/zephyr/CMakeLists.txt b/zephyr/CMakeLists.txt index c27f407ec891..c583a837203d 100644 --- a/zephyr/CMakeLists.txt +++ b/zephyr/CMakeLists.txt @@ -1129,9 +1129,13 @@ 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(${SOF_SRC_PATH}/probe/probe.c) +endif() zephyr_library_sources_ifdef(CONFIG_MULTICORE ${SOF_SRC_PATH}/idc/idc.c diff --git a/zephyr/schedule.c b/zephyr/schedule.c index e675beece766..75155b5d4913 100644 --- a/zephyr/schedule.c +++ b/zephyr/schedule.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include @@ -22,3 +23,4 @@ struct schedulers **arch_schedulers_get(void) { return _schedulers + cpu_get_id(); } +EXPORT_SYMBOL(arch_schedulers_get);