acrn-hypervisor/hypervisor/debug/printf.c
Mingqiang Chi 501b3f7e82 hv:cleanup header files for debug folder
cleanup debug folder, only include some necessary
header files,doesn't include hypervisor.h

Tracked-On: #1842
Signed-off-by: Mingqiang Chi <mingqiang.chi@intel.com>
Reviewed-by: Eddie Dong <eddie.dong@intel.com>

	modified:   debug/console.c
	modified:   debug/dbg_cmd.c
	modified:   debug/dump.c
	modified:   debug/hypercall.c
	modified:   debug/logmsg.c
	modified:   debug/npk_log.c
	modified:   debug/printf.c
	modified:   debug/profiling.c
	modified:   debug/sbuf.c
	modified:   debug/shell.c
	modified:   debug/string.c
	modified:   debug/trace.c
	modified:   debug/uart16550.c
	modified:   debug/vuart.c
	modified:   include/debug/console.h
	modified:   include/debug/vuart.h
2019-02-27 11:12:48 +08:00

72 lines
1.4 KiB
C

/*
* Copyright (C) 2018 Intel Corporation. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <types.h>
#include <rtl.h>
#include <util.h>
#include <sprintf.h>
#include <console.h>
static void
charout(size_t cmd, const char *s_arg, uint32_t sz_arg, struct snprint_param *param)
{
const char *s = s_arg;
uint32_t sz = sz_arg;
/* pointer to an integer to store the number of characters */
size_t nchars = param->wrtn;
/* working pointer */
const char *p = s;
size_t len;
/* copy mode ? */
if (cmd == PRINT_CMD_COPY) {
if (sz > 0U) { /* copy 'sz' characters */
len = console_write(s, sz);
s += len;
}
nchars += (s - p);
} else {
/* fill mode */
nchars += sz;
while (sz != 0U) {
console_putc(s);
sz--;
}
}
param->wrtn = nchars;
}
void vprintf(const char *fmt, va_list args)
{
/* struct to store all necessary parameters */
struct print_param param;
struct snprint_param snparam;
/* initialize parameters */
(void)memset(&snparam, 0U, sizeof(snparam));
(void)memset(&param, 0U, sizeof(param));
param.emit = charout;
param.data = &snparam;
/* execute the printf() */
do_print(fmt, &param, args);
}
void printf(const char *fmt, ...)
{
/* variable argument list needed for do_print() */
va_list args;
va_start(args, fmt);
/* execute the printf() */
vprintf(fmt, args);
/* destroy parameter list */
va_end(args);
}