From 7390488b8d5c14de94333fd2193893cd9cbc5608 Mon Sep 17 00:00:00 2001 From: Chenli Wei Date: Tue, 30 Nov 2021 10:35:47 +0800 Subject: [PATCH] hv: remove CONFIG_LOG_DESTINATION MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The CONFIG_LOG_DESTINATION parameter selects where the logging messages send toļ¼Œserial console or memory or npk device MMIO region. Now we want to remove it and check the loglevel of each channel,close the output when the loglevel is ZERO. Tracked-On: #6934 Signed-off-by: Chenli Wei Acked-by: Anthony Xu --- hypervisor/arch/x86/init.c | 2 +- hypervisor/debug/logmsg.c | 16 +++++++--------- hypervisor/include/debug/logmsg.h | 14 ++++++++------ hypervisor/release/logmsg.c | 2 +- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/hypervisor/arch/x86/init.c b/hypervisor/arch/x86/init.c index 36c1fcede..0b30da41b 100644 --- a/hypervisor/arch/x86/init.c +++ b/hypervisor/arch/x86/init.c @@ -38,7 +38,7 @@ static void init_debug_pre(void) console_init(); /* Enable logging */ - init_logmsg(CONFIG_LOG_DESTINATION); + init_logmsg(); } /*TODO: move into debug module */ diff --git a/hypervisor/debug/logmsg.c b/hypervisor/debug/logmsg.c index 9b652659c..560ade7e8 100644 --- a/hypervisor/debug/logmsg.c +++ b/hypervisor/debug/logmsg.c @@ -19,16 +19,14 @@ */ struct acrn_logmsg_ctl { - uint32_t flags; int32_t seq; spinlock_t lock; }; static struct acrn_logmsg_ctl logmsg_ctl; -void init_logmsg(uint32_t flags) +void init_logmsg() { - logmsg_ctl.flags = flags; logmsg_ctl.seq = 0; spinlock_init(&(logmsg_ctl.lock)); @@ -45,9 +43,9 @@ void do_logmsg(uint32_t severity, const char *fmt, ...) char *buffer; struct thread_object *current; - do_console_log = (((logmsg_ctl.flags & LOG_FLAG_STDOUT) != 0U) && (severity <= console_loglevel)); - do_mem_log = (((logmsg_ctl.flags & LOG_FLAG_MEMORY) != 0U) && (severity <= mem_loglevel)); - do_npk_log = ((logmsg_ctl.flags & LOG_FLAG_NPK) != 0U && (severity <= npk_loglevel)); + do_console_log = (severity <= console_loglevel); + do_mem_log = (severity <= mem_loglevel); + do_npk_log = (severity <= npk_loglevel); if (!do_console_log && !do_mem_log && !do_npk_log) { return; @@ -76,12 +74,12 @@ void do_logmsg(uint32_t severity, const char *fmt, ...) - strnlen_s(buffer, LOG_MESSAGE_MAX_SIZE), fmt, args); va_end(args); - /* Check if flags specify to output to NPK */ + /* Check whether output to NPK */ if (do_npk_log) { npk_log_write(buffer, strnlen_s(buffer, LOG_MESSAGE_MAX_SIZE)); } - /* Check if flags specify to output to stdout */ + /* Check whether output to stdout */ if (do_console_log) { spinlock_irqsave_obtain(&(logmsg_ctl.lock), &rflags); @@ -91,7 +89,7 @@ void do_logmsg(uint32_t severity, const char *fmt, ...) spinlock_irqrestore_release(&(logmsg_ctl.lock), rflags); } - /* Check if flags specify to output to memory */ + /* Check whether output to memory */ if (do_mem_log) { uint32_t i, msg_len; struct shared_buf *sbuf = per_cpu(sbuf, pcpu_id)[ACRN_HVLOG]; diff --git a/hypervisor/include/debug/logmsg.h b/hypervisor/include/debug/logmsg.h index 1e70ab2d9..6b1349a53 100644 --- a/hypervisor/include/debug/logmsg.h +++ b/hypervisor/include/debug/logmsg.h @@ -17,10 +17,6 @@ #define LOG_INFO 5U #define LOG_DEBUG 6U -/* Logging flags */ -#define LOG_FLAG_STDOUT 0x00000001U -#define LOG_FLAG_MEMORY 0x00000002U -#define LOG_FLAG_NPK 0x00000004U #define LOG_ENTRY_SIZE 80U /* Size of buffer used to store a message being logged, * should align to LOG_ENTRY_SIZE. @@ -49,7 +45,11 @@ void asm_assert(int32_t line, const char *file, const char *txt); #endif /* HV_DEBUG */ -void init_logmsg(uint32_t flags); +void init_logmsg(); + +/* + * @pre the severity > 0 + */ void do_logmsg(uint32_t severity, const char *fmt, ...); /** The well known printf() function. @@ -112,7 +112,9 @@ void vprintf(const char *fmt, va_list args); #define dev_dbg(lvl, ...) \ do { \ - do_logmsg((lvl), pr_prefix __VA_ARGS__); \ + if ((lvl) > 0) { \ + do_logmsg((lvl), pr_prefix __VA_ARGS__);\ + } \ } while (0) #define panic(...) \ diff --git a/hypervisor/release/logmsg.c b/hypervisor/release/logmsg.c index 5966d032f..d656f1afa 100644 --- a/hypervisor/release/logmsg.c +++ b/hypervisor/release/logmsg.c @@ -6,7 +6,7 @@ #include -void init_logmsg(__unused uint32_t flags) {} +void init_logmsg() {} void do_logmsg(__unused uint32_t severity, __unused const char *fmt, ...) {} void printf(__unused const char *fmt, ...) {} void vprintf(__unused const char *fmt, __unused va_list args) {}