HV: Merge hypervisor debug header files

-- merge 'assert.h' & 'printf.h' into 'logmsg.h'
  -- merge 'shell.h' into 'console.h'

Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
Yonghua Huang 2018-08-13 21:23:50 +08:00 committed by wenlingz
parent a6bc36f8ed
commit 77011ce60e
6 changed files with 54 additions and 94 deletions

View File

@ -1,21 +0,0 @@
/*
* Copyright (C) 2018 Intel Corporation. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef ASSERT_H
#define ASSERT_H
#ifdef HV_DEBUG
void asm_assert(int32_t line, const char *file, const char *txt);
#define ASSERT(x, ...) \
if (!(x)) {\
asm_assert(__LINE__, __FILE__, "fatal error");\
}
#else
#define ASSERT(x, ...) do { } while(0)
#endif
#endif /* ASSERT_H */

View File

@ -7,6 +7,9 @@
#ifndef CONSOLE_H
#define CONSOLE_H
/* Switching key combinations for shell and uart console */
#define GUEST_CONSOLE_TO_HV_SWITCH_KEY 0 /* CTRL + SPACE */
#ifdef HV_DEBUG
extern struct hv_timer console_timer;
@ -52,6 +55,9 @@ static inline void resume_console(void)
}
void uart16550_set_property(bool enabled, bool port_mapped, uint64_t base_addr);
void shell_init(void);
void shell_kick(void);
#else
static inline void console_init(void)
{
@ -70,6 +76,9 @@ static inline void suspend_console(void) {}
static inline void resume_console(void) {}
static inline void uart16550_set_property(__unused bool enabled,
__unused bool port_mapped, __unused uint64_t base_addr) {}
static inline void shell_init(void) {}
static inline void shell_kick(void) {}
#endif
#endif /* CONSOLE_H */

View File

@ -33,6 +33,39 @@ void init_logmsg(__unused uint32_t mem_size, uint32_t flags);
void print_logmsg_buffer(uint16_t pcpu_id);
void do_logmsg(uint32_t severity, const char *fmt, ...);
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)
/** 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.
*/
int 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.
*/
int vprintf(const char *fmt, va_list args);
#else /* HV_DEBUG */
static inline void init_logmsg(__unused uint32_t mem_size,
@ -49,6 +82,18 @@ static inline void print_logmsg_buffer(__unused uint16_t pcpu_id)
{
}
#define ASSERT(x, ...) do { } while (0)
static inline int printf(__unused const char *fmt, ...)
{
return 0;
}
static inline int vprintf(__unused const char *fmt, __unused va_list args)
{
return 0;
}
#endif /* HV_DEBUG */
#ifndef pr_prefix

View File

@ -1,49 +0,0 @@
/*
* Copyright (C) 2018 Intel Corporation. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef PRINTF_H
#define PRINTF_H
#ifdef HV_DEBUG
/** 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.
*/
int 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.
*/
int vprintf(const char *fmt, va_list args);
#else /* HV_DEBUG */
static inline int printf(__unused const char *fmt, ...)
{
return 0;
}
static inline int vprintf(__unused const char *fmt, __unused va_list args)
{
return 0;
}
#endif /* HV_DEBUG */
#endif /* PRINTF_H */

View File

@ -1,21 +0,0 @@
/*
* Copyright (C) 2018 Intel Corporation. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef SHELL_H
#define SHELL_H
/* Switching key combinations for shell and uart console */
#define GUEST_CONSOLE_TO_HV_SWITCH_KEY 0 /* CTRL + SPACE */
#ifdef HV_DEBUG
void shell_init(void);
void shell_kick(void);
#else
static inline void shell_init(void) {}
static inline void shell_kick(void) {}
#endif
#endif /* SHELL_H */

View File

@ -12,9 +12,6 @@
#include <console.h>
#include <dump.h>
#include <trace.h>
#include <shell.h>
#include <sbuf.h>
#include <assert.h>
#include <printf.h>
#endif /* HV_DEBUG_H */