acrn-hypervisor/hypervisor/include/debug/console.h
Yin Fengwei d34700a1ae hv: prepare for Sx(S3/S5) support in ACRN.
Couple of small changes merged in this change:
 - export main_entry, trampoline_spinlock and stop_cpus.
 - change vm_resume() name to resume_vm()
 - change resume_console_enable() name to resume_console()
 - extend reset_vcpu to reset more fields of vcpu

Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-06-29 00:50:01 +08:00

108 lines
2.3 KiB
C

/*
* Copyright (C) 2018 Intel Corporation. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef CONSOLE_H
#define CONSOLE_H
#ifdef HV_DEBUG
extern struct timer console_timer;
/** Initializes the console module.
*
* @param cdev A pointer to the character device to use for the console.
*
* @return '0' on success. Any other value indicates an error.
*/
int console_init(void);
/** Writes a NUL terminated string to the console.
*
* @param str A pointer to the NUL terminated string to write.
*
* @return The number of characters written or -1 if an error occurred
* and no character was written.
*/
int console_puts(const char *str);
/** Writes a given number of characters to the console.
*
* @param str A pointer to character array to write.
* @param len The number of characters to write.
*
* @return The number of characters written or -1 if an error occurred
* and no character was written.
*/
int console_write(const char *str, size_t len);
/** Writes a single character to the console.
*
* @param ch The character to write.
*
* @preturn The number of characters written or -1 if an error
* occurred before any character was written.
*/
int console_putc(int ch);
/** Dumps an array to the console.
*
* This function dumps an array of bytes to the console
* in a hexadecimal format.
*
* @param p A pointer to the byte array to dump.
* @param len The number of bytes to dump.
*/
void console_dump_bytes(const void *p, unsigned int len);
void console_setup_timer(void);
uint32_t get_serial_handle(void);
static inline void suspend_console(void)
{
del_timer(&console_timer);
}
static inline void resume_console(void)
{
console_setup_timer();
}
#else
static inline int console_init(void)
{
return 0;
}
static inline int console_puts(__unused const char *str)
{
return 0;
}
static inline int console_write(__unused const char *str,
__unused size_t len)
{
return 0;
}
static inline int console_putc(__unused int ch)
{
return 0;
}
static inline void console_dump_bytes(__unused const void *p,
__unused unsigned int len)
{
}
static inline void console_setup_timer(void) {}
static inline uint32_t get_serial_handle(void) { return 0; }
static inline void suspend_console(void) {}
static inline void resume_console(void) {}
#endif
#endif /* CONSOLE_H */