acrn-hypervisor/hypervisor/include/debug/logmsg.h
Geoffroy Van Cutsem 8b16be9185 Remove "All rights reserved" string headers
Many of the license and Intel copyright headers include the "All rights
reserved" string. It is not relevant in the context of the BSD-3-Clause
license that the code is released under. This patch removes those strings
throughout the code (hypervisor, devicemodel and misc).

Tracked-On: #7254
Signed-off-by: Geoffroy Van Cutsem <geoffroy.vancutsem@intel.com>
2022-04-06 13:21:02 +08:00

126 lines
2.8 KiB
C

/*
* Copyright (C) 2018 Intel Corporation.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef LOGMSG_H
#define LOGMSG_H
#include <asm/cpu.h>
/* Logging severity levels */
#define LOG_FATAL 1U
/* For msg should be write to console and sbuf meanwhile but not fatal error */
#define LOG_ACRN 2U
#define LOG_ERROR 3U
#define LOG_WARNING 4U
#define LOG_INFO 5U
#define LOG_DEBUG 6U
#define LOG_ENTRY_SIZE 80U
/* Size of buffer used to store a message being logged,
* should align to LOG_ENTRY_SIZE.
*/
#define LOG_MESSAGE_MAX_SIZE (4U * LOG_ENTRY_SIZE)
#define DBG_LEVEL_LAPICPT 5U
#if defined(HV_DEBUG)
extern uint16_t console_loglevel;
extern uint16_t mem_loglevel;
extern uint16_t npk_loglevel;
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)
#else /* HV_DEBUG */
#define ASSERT(x, ...) do { } while (0)
#endif /* HV_DEBUG */
void init_logmsg();
/*
* @pre the severity > 0
*/
void do_logmsg(uint32_t severity, const char *fmt, ...);
/** 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.
*/
void printf(const char *fmt, ...);
/** 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.
*/
void vprintf(const char *fmt, va_list args);
#ifndef pr_prefix
#define pr_prefix
#endif
#define pr_fatal(...) \
do { \
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__); \
} while (0)
#define pr_warn(...) \
do { \
do_logmsg(LOG_WARNING, pr_prefix __VA_ARGS__); \
} while (0)
#define pr_info(...) \
do { \
do_logmsg(LOG_INFO, pr_prefix __VA_ARGS__); \
} while (0)
#define pr_dbg(...) \
do { \
do_logmsg(LOG_DEBUG, pr_prefix __VA_ARGS__); \
} while (0)
#define dev_dbg(lvl, ...) \
do { \
if ((lvl) > 0) { \
do_logmsg((lvl), pr_prefix __VA_ARGS__);\
} \
} while (0)
#define panic(...) \
do { pr_fatal("PANIC: %s line: %d\n", __func__, __LINE__); \
pr_fatal(__VA_ARGS__); \
while (1) { asm_pause(); }; } while (0)
#endif /* LOGMSG_H */