lib: Introduce sbi_dprintf() API

This patch introduces new sbi_dprintf() API for runtime debug
prints. The sbi_dprintf() will print to console for a given
HART only when SBI_SCRATCH_DEBUG_PRINTS option in enabled in
sbi_scratch for this HART.

We can now add debug prints using sbi_dprintf() at important
places in OpenSBI sources. These debug prints will only show
up when previous booting stage or compile time parameter sets
the SBI_SCRATCH_DEBUG_PRINTS option in scratch space.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
This commit is contained in:
Anup Patel
2019-08-08 12:10:22 +05:30
committed by Anup Patel
parent b1318e578b
commit dbff3e9f12
3 changed files with 19 additions and 0 deletions

View File

@@ -375,6 +375,19 @@ int sbi_printf(const char *format, ...)
return retval;
}
int sbi_dprintf(struct sbi_scratch *scratch, const char *format, ...)
{
va_list args;
int retval = 0;
va_start(args, format);
if (scratch->options & SBI_SCRATCH_DEBUG_PRINTS)
retval = print(NULL, NULL, format, args);
va_end(args);
return retval;
}
int sbi_console_init(struct sbi_scratch *scratch)
{
console_plat = sbi_platform_ptr(scratch);