From 9cc190770660c6a2269490e4a5d9c26e31b2cfea Mon Sep 17 00:00:00 2001 From: Andy Ross Date: Tue, 14 Dec 2021 20:28:30 -0800 Subject: [PATCH] soc/intel_adsp: Add SIMCALL output to the trace_out driver When running under a simulator, it's difficult to extract output from the window (it's difficult with hardware too!). Add "SIMCALL" output to stderr (it's literally just 3 extra instructions) as an optional feature so this subsystem itself can be debugged without herculean effort. Signed-off-by: Andy Ross --- soc/xtensa/intel_adsp/Kconfig | 8 ++++++++ soc/xtensa/intel_adsp/common/trace_out.c | 10 ++++++++++ 2 files changed, 18 insertions(+) diff --git a/soc/xtensa/intel_adsp/Kconfig b/soc/xtensa/intel_adsp/Kconfig index eaf6a243290..e01c775a46a 100644 --- a/soc/xtensa/intel_adsp/Kconfig +++ b/soc/xtensa/intel_adsp/Kconfig @@ -53,6 +53,14 @@ config IMR_DATA_ADDR Location to place .data contents in IMR memory during bootloader linkage. +config ADSP_TRACE_SIMCALL + bool "Emit SIMCALL output in addition to window tracing" + help + When true, the trace_out layer will also use a SIMCALL + instruction to emit the passed data to the standard output + of an enclosing simulator process. All window contents will + remain identical. + # Select SoC Part No. and configuration options source "soc/xtensa/intel_adsp/*/Kconfig.soc" diff --git a/soc/xtensa/intel_adsp/common/trace_out.c b/soc/xtensa/intel_adsp/common/trace_out.c index 7430bb1a16d..2db7936df19 100644 --- a/soc/xtensa/intel_adsp/common/trace_out.c +++ b/soc/xtensa/intel_adsp/common/trace_out.c @@ -74,6 +74,16 @@ void intel_adsp_trace_out(int8_t *str, size_t len) return; } +#ifdef CONFIG_ADSP_TRACE_SIMCALL + register int a2 __asm__("a2") = 4; /* SYS_write */ + register int a3 __asm__("a3") = 1; /* fd 1 == stdout */ + register int a4 __asm__("a4") = (int)str; + register int a5 __asm__("a5") = len; + + __asm__ volatile("simcall" : "+r"(a2), "+r"(a3) + : "r"(a4), "r"(a5) : "memory"); +#endif + k_spinlock_key_t key = k_spin_lock((void *)&data->lock); if (!data->initialized) {