From 80a79fed39c66c60b15522fffe41a46f5def9e98 Mon Sep 17 00:00:00 2001 From: Kaige Fu Date: Wed, 23 May 2018 11:34:08 +0800 Subject: [PATCH] HV: Replace printf with pr_acrnlog after logmsg init There are some massages which is not fatal error but should to print to serial and sbuf(hvlog) at the same time. pr_fatal is for fatal error massages and it is not good choice for the situation above. Introduce a new API pr_acrnlog to deal with the situation. And replace the following printf with pr_acrnlog for massages should be print to sbuf and serial. Then developers can get those massages on serial and BTM(Boot Time Measurement) can use acrnlog to get those massages from sbuf. BTM refers to Boot Time Measurement which will read acrnlog file to get timestamps of steps we want. Signed-off-by: Kaige Fu Reviewed-by: Kevin Tian --- hypervisor/arch/x86/cpu.c | 10 +++++----- hypervisor/bsp/sbl/include/bsp/bsp_cfg.h | 4 ++-- hypervisor/bsp/uefi/include/bsp/bsp_cfg.h | 4 ++-- hypervisor/include/debug/logmsg.h | 15 +++++++++++---- 4 files changed, 20 insertions(+), 13 deletions(-) diff --git a/hypervisor/arch/x86/cpu.c b/hypervisor/arch/x86/cpu.c index 126957c4a..a41f4146a 100644 --- a/hypervisor/arch/x86/cpu.c +++ b/hypervisor/arch/x86/cpu.c @@ -239,7 +239,7 @@ static int hardware_detect_support(void) if (ret) return ret; - printf("hardware support HV\n"); + pr_acrnlog("hardware support HV"); return 0; } @@ -484,20 +484,20 @@ void bsp_boot_init(void) LOG_DESTINATION); if (HV_RC_VERSION) - printf("HV version %d.%d-rc%d-%s-%s %s build by %s, start time %lluus\r\n", + pr_acrnlog("HV version %d.%d-rc%d-%s-%s %s build by %s, start time %lluus", HV_MAJOR_VERSION, HV_MINOR_VERSION, HV_RC_VERSION, HV_BUILD_TIME, HV_BUILD_VERSION, HV_BUILD_TYPE, HV_BUILD_USER, TICKS_TO_US(start_tsc)); else - printf("HV version %d.%d-%s-%s %s build by %s, start time %lluus\r\n", + pr_acrnlog("HV version %d.%d-%s-%s %s build by %s, start time %lluus", HV_MAJOR_VERSION, HV_MINOR_VERSION, HV_BUILD_TIME, HV_BUILD_VERSION, HV_BUILD_TYPE, HV_BUILD_USER, TICKS_TO_US(start_tsc)); - printf("API version %d.%d\r\n", + pr_acrnlog("API version %d.%d", HV_API_MAJOR_VERSION, HV_API_MINOR_VERSION); - printf("Detect processor: %s\n", boot_cpu_data.model_name); + pr_acrnlog("Detect processor: %s", boot_cpu_data.model_name); pr_dbg("Core %d is up", CPU_BOOT_ID); diff --git a/hypervisor/bsp/sbl/include/bsp/bsp_cfg.h b/hypervisor/bsp/sbl/include/bsp/bsp_cfg.h index a10709e88..4ad3f57be 100644 --- a/hypervisor/bsp/sbl/include/bsp/bsp_cfg.h +++ b/hypervisor/bsp/sbl/include/bsp/bsp_cfg.h @@ -39,8 +39,8 @@ #define MALLOC_ALIGN 16 #define NUM_ALLOC_PAGES 4096 #define HEAP_SIZE 0x100000 -#define CONSOLE_LOGLEVEL_DEFAULT 2 -#define MEM_LOGLEVEL_DEFAULT 4 +#define CONSOLE_LOGLEVEL_DEFAULT 3 +#define MEM_LOGLEVEL_DEFAULT 5 #define CONFIG_LOW_RAM_START 0x00001000 #define CONFIG_LOW_RAM_SIZE 0x000CF000 #define CONFIG_RAM_START 0x6E000000 diff --git a/hypervisor/bsp/uefi/include/bsp/bsp_cfg.h b/hypervisor/bsp/uefi/include/bsp/bsp_cfg.h index 53b145c7d..30e56dc13 100644 --- a/hypervisor/bsp/uefi/include/bsp/bsp_cfg.h +++ b/hypervisor/bsp/uefi/include/bsp/bsp_cfg.h @@ -39,8 +39,8 @@ #define MALLOC_ALIGN 16 #define NUM_ALLOC_PAGES 4096 #define HEAP_SIZE 0x100000 -#define CONSOLE_LOGLEVEL_DEFAULT 2 -#define MEM_LOGLEVEL_DEFAULT 4 +#define CONSOLE_LOGLEVEL_DEFAULT 3 +#define MEM_LOGLEVEL_DEFAULT 5 #define CONFIG_LOW_RAM_START 0x00008000 #define CONFIG_LOW_RAM_SIZE 0x00010000 #define CONFIG_RAM_START 0x20000000 diff --git a/hypervisor/include/debug/logmsg.h b/hypervisor/include/debug/logmsg.h index b51ba2290..b0485c9b8 100644 --- a/hypervisor/include/debug/logmsg.h +++ b/hypervisor/include/debug/logmsg.h @@ -33,10 +33,12 @@ /* Logging severity levels */ #define LOG_FATAL 1 -#define LOG_ERROR 2 -#define LOG_WARNING 3 -#define LOG_INFO 4 -#define LOG_DEBUG 5 +/* For msg should be write to console and sbuf meanwhile but not fatal error */ +#define LOG_ACRN 2 +#define LOG_ERROR 3 +#define LOG_WARNING 4 +#define LOG_INFO 5 +#define LOG_DEBUG 6 /* Logging flags */ #define LOG_FLAG_STDOUT 0x00000001 @@ -77,6 +79,11 @@ static inline void print_logmsg_buffer(__unused uint32_t cpu_id) do_logmsg(LOG_FATAL, pr_prefix __VA_ARGS__); \ } while (0) +#define pr_acrnlog(...) \ + do { \ + do_logmsg(LOG_ACRN, pr_prefix __VA_ARGS__); \ + } while (0) + #define pr_err(...) \ do { \ do_logmsg(LOG_ERROR, pr_prefix __VA_ARGS__); \