Arthur Heymans | 0832e67 | 2023-07-13 17:16:37 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | |
| 3 | #include <stdint.h> |
| 4 | #include <stdio.h> |
| 5 | #include <string.h> |
| 6 | #include <console/console.h> |
| 7 | #include "opensil_console.h" |
| 8 | #include <SilCommon.h> |
| 9 | |
| 10 | static int translate_opensil_debug_level(size_t MsgLevel) |
| 11 | { |
| 12 | switch (MsgLevel) { |
| 13 | case SIL_TRACE_ERROR: |
| 14 | return BIOS_ERR; |
| 15 | case SIL_TRACE_WARNING: |
| 16 | return BIOS_WARNING; |
| 17 | case SIL_TRACE_ENTRY: |
| 18 | case SIL_TRACE_EXIT: |
| 19 | return BIOS_SPEW; |
| 20 | case SIL_TRACE_INFO: |
| 21 | return BIOS_DEBUG; |
| 22 | default: |
| 23 | return BIOS_NEVER; |
| 24 | } |
| 25 | } |
| 26 | |
| 27 | void HostDebugService(size_t MsgLevel, const char *SilPrefix, const char *Message, |
| 28 | const char *Function, size_t Line, ...) |
| 29 | { |
| 30 | if (!CONFIG(OPENSIL_DEBUG_OUTPUT)) |
| 31 | return; |
| 32 | |
| 33 | const int loglevel = translate_opensil_debug_level(MsgLevel); |
| 34 | |
| 35 | /* print fomatted prefix */ |
| 36 | if (CONFIG(OPENSIL_DEBUG_PREFIX)) |
| 37 | printk(loglevel, "%s%s:%zu:", SilPrefix, Function, Line); |
| 38 | |
| 39 | /* print formatted message */ |
| 40 | va_list args; |
| 41 | va_start(args, Line); |
Felix Held | 6325687 | 2024-01-24 21:11:39 +0100 | [diff] [blame^] | 42 | vprintk(loglevel, Message, args); |
Arthur Heymans | 0832e67 | 2023-07-13 17:16:37 +0200 | [diff] [blame] | 43 | va_end(args); |
| 44 | } |