2018-03-07 20:57:14 +08:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2018 Intel Corporation. All rights reserved.
|
|
|
|
*
|
2018-05-26 01:49:13 +08:00
|
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
2018-03-07 20:57:14 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef LOGMSG_H
|
|
|
|
#define LOGMSG_H
|
2018-12-26 14:05:05 +08:00
|
|
|
#include <cpu.h>
|
2018-03-07 20:57:14 +08:00
|
|
|
|
|
|
|
/* Logging severity levels */
|
2018-07-03 22:55:34 +08:00
|
|
|
#define LOG_FATAL 1U
|
2018-05-23 11:34:08 +08:00
|
|
|
/* For msg should be write to console and sbuf meanwhile but not fatal error */
|
2018-07-03 22:55:34 +08:00
|
|
|
#define LOG_ACRN 2U
|
|
|
|
#define LOG_ERROR 3U
|
|
|
|
#define LOG_WARNING 4U
|
|
|
|
#define LOG_INFO 5U
|
|
|
|
#define LOG_DEBUG 6U
|
2018-03-07 20:57:14 +08:00
|
|
|
|
|
|
|
/* Logging flags */
|
2018-06-19 18:33:58 +08:00
|
|
|
#define LOG_FLAG_STDOUT 0x00000001U
|
|
|
|
#define LOG_FLAG_MEMORY 0x00000002U
|
2018-08-01 13:23:35 +08:00
|
|
|
#define LOG_FLAG_NPK 0x00000004U
|
2018-09-11 10:56:05 +08:00
|
|
|
#define LOG_ENTRY_SIZE 80U
|
2018-06-05 15:25:07 +08:00
|
|
|
/* Size of buffer used to store a message being logged,
|
|
|
|
* should align to LOG_ENTRY_SIZE.
|
|
|
|
*/
|
2018-09-17 13:39:40 +08:00
|
|
|
#define LOG_MESSAGE_MAX_SIZE (4U * LOG_ENTRY_SIZE)
|
2018-03-07 20:57:14 +08:00
|
|
|
|
2018-12-22 20:12:53 +08:00
|
|
|
#define ACRN_DBG_LAPICPT 5U
|
2018-03-07 20:57:14 +08:00
|
|
|
#if defined(HV_DEBUG)
|
|
|
|
|
2018-11-09 11:39:18 +08:00
|
|
|
extern uint16_t console_loglevel;
|
|
|
|
extern uint16_t mem_loglevel;
|
|
|
|
extern uint16_t npk_loglevel;
|
2018-03-07 20:57:14 +08:00
|
|
|
|
2018-08-13 21:23:50 +08:00
|
|
|
void asm_assert(int32_t line, const char *file, const char *txt);
|
|
|
|
|
|
|
|
#define ASSERT(x, ...) \
|
|
|
|
do { \
|
|
|
|
if (!(x)) {\
|
|
|
|
asm_assert(__LINE__, __FILE__, "fatal error");\
|
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
|
2018-11-27 14:16:46 +08:00
|
|
|
#else /* HV_DEBUG */
|
|
|
|
|
|
|
|
#define ASSERT(x, ...) do { } while (0)
|
|
|
|
|
|
|
|
#endif /* HV_DEBUG */
|
|
|
|
|
|
|
|
void init_logmsg(uint32_t flags);
|
|
|
|
void do_logmsg(uint32_t severity, const char *fmt, ...);
|
|
|
|
|
2018-08-13 21:23:50 +08:00
|
|
|
/** The well known printf() function.
|
|
|
|
*
|
|
|
|
* Formats a string and writes it to the console output.
|
|
|
|
*
|
|
|
|
* @param fmt A pointer to the NUL terminated format string.
|
|
|
|
*
|
|
|
|
* @return The number of characters actually written or a negative
|
|
|
|
* number if an error occurred.
|
|
|
|
*/
|
|
|
|
|
hv:Clear up printf related definition
In hypervisor, all the parameter and return value printf related are
unsigned int, this patch is used to fix the function definitions.
v1->v2:
*Modify the return value of various functions, such as printf(),
vprintf(), charout(), do_printf(), charmem, print_pow2(),
print_decimal to void due to never used, no necessary to use,
or has already returned by param.
*Delete the impossible judgement of param->emit due to the type
is unsigned.
Tracked-On: #861
Signed-off-by: Junjun Shan <junjun.shan@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-09-17 17:42:03 +08:00
|
|
|
void printf(const char *fmt, ...);
|
2018-08-13 21:23:50 +08:00
|
|
|
|
|
|
|
/** The well known vprintf() function.
|
|
|
|
*
|
|
|
|
* Formats a string and writes it to the console output.
|
|
|
|
*
|
|
|
|
* @param fmt A pointer to the NUL terminated format string.
|
|
|
|
* @param args The variable long argument list as va_list.
|
|
|
|
* @return The number of characters actually written or a negative
|
|
|
|
* number if an error occurred.
|
|
|
|
*/
|
|
|
|
|
hv:Clear up printf related definition
In hypervisor, all the parameter and return value printf related are
unsigned int, this patch is used to fix the function definitions.
v1->v2:
*Modify the return value of various functions, such as printf(),
vprintf(), charout(), do_printf(), charmem, print_pow2(),
print_decimal to void due to never used, no necessary to use,
or has already returned by param.
*Delete the impossible judgement of param->emit due to the type
is unsigned.
Tracked-On: #861
Signed-off-by: Junjun Shan <junjun.shan@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-09-17 17:42:03 +08:00
|
|
|
void vprintf(const char *fmt, va_list args);
|
2018-08-13 21:23:50 +08:00
|
|
|
|
2018-05-28 21:47:38 +08:00
|
|
|
#ifndef pr_prefix
|
|
|
|
#define pr_prefix
|
2018-03-07 20:57:14 +08:00
|
|
|
#endif
|
|
|
|
|
2018-05-28 21:47:38 +08:00
|
|
|
#define pr_fatal(...) \
|
|
|
|
do { \
|
|
|
|
do_logmsg(LOG_FATAL, pr_prefix __VA_ARGS__); \
|
2018-03-07 20:57:14 +08:00
|
|
|
} while (0)
|
|
|
|
|
2018-05-23 11:34:08 +08:00
|
|
|
#define pr_acrnlog(...) \
|
|
|
|
do { \
|
|
|
|
do_logmsg(LOG_ACRN, pr_prefix __VA_ARGS__); \
|
|
|
|
} while (0)
|
|
|
|
|
2018-05-28 21:47:38 +08:00
|
|
|
#define pr_err(...) \
|
|
|
|
do { \
|
|
|
|
do_logmsg(LOG_ERROR, pr_prefix __VA_ARGS__); \
|
2018-03-07 20:57:14 +08:00
|
|
|
} while (0)
|
|
|
|
|
2018-05-28 21:47:38 +08:00
|
|
|
#define pr_warn(...) \
|
|
|
|
do { \
|
|
|
|
do_logmsg(LOG_WARNING, pr_prefix __VA_ARGS__); \
|
2018-03-07 20:57:14 +08:00
|
|
|
} while (0)
|
|
|
|
|
2018-05-28 21:47:38 +08:00
|
|
|
#define pr_info(...) \
|
|
|
|
do { \
|
|
|
|
do_logmsg(LOG_INFO, pr_prefix __VA_ARGS__); \
|
2018-03-07 20:57:14 +08:00
|
|
|
} while (0)
|
|
|
|
|
2018-05-28 21:47:38 +08:00
|
|
|
#define pr_dbg(...) \
|
|
|
|
do { \
|
|
|
|
do_logmsg(LOG_DEBUG, pr_prefix __VA_ARGS__); \
|
2018-03-07 20:57:14 +08:00
|
|
|
} while (0)
|
|
|
|
|
2018-05-28 21:47:38 +08:00
|
|
|
#define dev_dbg(lvl, ...) \
|
2018-03-07 20:57:14 +08:00
|
|
|
do { \
|
2018-09-05 10:55:29 +08:00
|
|
|
do_logmsg((lvl), pr_prefix __VA_ARGS__); \
|
2018-03-07 20:57:14 +08:00
|
|
|
} while (0)
|
|
|
|
|
2018-05-24 16:27:06 +08:00
|
|
|
#define panic(...) \
|
|
|
|
do { pr_fatal("PANIC: %s line: %d\n", __func__, __LINE__); \
|
|
|
|
pr_fatal(__VA_ARGS__); \
|
2018-12-26 14:05:05 +08:00
|
|
|
while (1) { asm_pause(); }; } while (0)
|
2018-03-07 20:57:14 +08:00
|
|
|
|
|
|
|
#endif /* LOGMSG_H */
|