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 <andrew.j.ross@intel.com>
This commit is contained in:
Andy Ross 2021-12-14 20:28:30 -08:00 committed by Anas Nashif
commit 9cc1907706
2 changed files with 18 additions and 0 deletions

View file

@ -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"

View file

@ -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) {