From 77011ce60efb802517e833d5011f0de0d0c87995 Mon Sep 17 00:00:00 2001 From: Yonghua Huang Date: Mon, 13 Aug 2018 21:23:50 +0800 Subject: [PATCH] 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 Acked-by: Eddie Dong --- hypervisor/include/debug/assert.h | 21 ------------- hypervisor/include/debug/console.h | 9 ++++++ hypervisor/include/debug/logmsg.h | 45 +++++++++++++++++++++++++++ hypervisor/include/debug/printf.h | 49 ------------------------------ hypervisor/include/debug/shell.h | 21 ------------- hypervisor/include/hv_debug.h | 3 -- 6 files changed, 54 insertions(+), 94 deletions(-) delete mode 100644 hypervisor/include/debug/assert.h delete mode 100644 hypervisor/include/debug/printf.h delete mode 100644 hypervisor/include/debug/shell.h diff --git a/hypervisor/include/debug/assert.h b/hypervisor/include/debug/assert.h deleted file mode 100644 index b5f170db9..000000000 --- a/hypervisor/include/debug/assert.h +++ /dev/null @@ -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 */ diff --git a/hypervisor/include/debug/console.h b/hypervisor/include/debug/console.h index 6c491bc32..706f5b100 100644 --- a/hypervisor/include/debug/console.h +++ b/hypervisor/include/debug/console.h @@ -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 */ diff --git a/hypervisor/include/debug/logmsg.h b/hypervisor/include/debug/logmsg.h index 7e1ed7040..c8de4c567 100644 --- a/hypervisor/include/debug/logmsg.h +++ b/hypervisor/include/debug/logmsg.h @@ -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 diff --git a/hypervisor/include/debug/printf.h b/hypervisor/include/debug/printf.h deleted file mode 100644 index 6e6c9111f..000000000 --- a/hypervisor/include/debug/printf.h +++ /dev/null @@ -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 */ diff --git a/hypervisor/include/debug/shell.h b/hypervisor/include/debug/shell.h deleted file mode 100644 index 829e0ac59..000000000 --- a/hypervisor/include/debug/shell.h +++ /dev/null @@ -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 */ diff --git a/hypervisor/include/hv_debug.h b/hypervisor/include/hv_debug.h index ff41e32e2..7198132f0 100644 --- a/hypervisor/include/hv_debug.h +++ b/hypervisor/include/hv_debug.h @@ -12,9 +12,6 @@ #include #include #include -#include #include -#include -#include #endif /* HV_DEBUG_H */