2018-03-07 20:57:14 +08:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2018 Intel Corporation. All rights reserved.
|
|
|
|
*
|
2018-05-26 01:49:13 +08:00
|
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
2018-03-07 20:57:14 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <hypervisor.h>
|
|
|
|
|
hv:Clear up printf related definition
In hypervisor, all the parameter and return value printf related are
unsigned int, this patch is used to fix the function definitions.
v1->v2:
*Modify the return value of various functions, such as printf(),
vprintf(), charout(), do_printf(), charmem, print_pow2(),
print_decimal to void due to never used, no necessary to use,
or has already returned by param.
*Delete the impossible judgement of param->emit due to the type
is unsigned.
Tracked-On: #861
Signed-off-by: Junjun Shan <junjun.shan@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-09-17 17:42:03 +08:00
|
|
|
static void charout(size_t cmd, const char *s_arg, uint32_t sz_arg, void *hnd)
|
2018-03-07 20:57:14 +08:00
|
|
|
{
|
2018-07-26 12:03:12 +08:00
|
|
|
const char *s = s_arg;
|
|
|
|
uint32_t sz = sz_arg;
|
2018-03-07 20:57:14 +08:00
|
|
|
/* pointer to an integer to store the number of characters */
|
hv:Clear up printf related definition
In hypervisor, all the parameter and return value printf related are
unsigned int, this patch is used to fix the function definitions.
v1->v2:
*Modify the return value of various functions, such as printf(),
vprintf(), charout(), do_printf(), charmem, print_pow2(),
print_decimal to void due to never used, no necessary to use,
or has already returned by param.
*Delete the impossible judgement of param->emit due to the type
is unsigned.
Tracked-On: #861
Signed-off-by: Junjun Shan <junjun.shan@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-09-17 17:42:03 +08:00
|
|
|
size_t *nchars = (size_t *)hnd;
|
2018-03-07 20:57:14 +08:00
|
|
|
/* working pointer */
|
|
|
|
const char *p = s;
|
hv:Clear up printf related definition
In hypervisor, all the parameter and return value printf related are
unsigned int, this patch is used to fix the function definitions.
v1->v2:
*Modify the return value of various functions, such as printf(),
vprintf(), charout(), do_printf(), charmem, print_pow2(),
print_decimal to void due to never used, no necessary to use,
or has already returned by param.
*Delete the impossible judgement of param->emit due to the type
is unsigned.
Tracked-On: #861
Signed-off-by: Junjun Shan <junjun.shan@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-09-17 17:42:03 +08:00
|
|
|
size_t len;
|
2018-03-07 20:57:14 +08:00
|
|
|
|
|
|
|
/* copy mode ? */
|
|
|
|
if (cmd == PRINT_CMD_COPY) {
|
2018-07-24 09:25:22 +08:00
|
|
|
if (sz > 0U) { /* copy 'sz' characters */
|
2018-08-07 10:38:12 +08:00
|
|
|
len = console_write(s, sz);
|
|
|
|
s += len;
|
2018-07-13 06:02:55 +08:00
|
|
|
}
|
2018-03-07 20:57:14 +08:00
|
|
|
|
2018-06-27 08:54:33 +08:00
|
|
|
*nchars += (s - p);
|
2018-07-13 06:02:55 +08:00
|
|
|
} else {
|
2018-07-27 16:23:09 +08:00
|
|
|
/* fill mode */
|
2018-03-07 20:57:14 +08:00
|
|
|
*nchars += sz;
|
2018-07-24 09:25:22 +08:00
|
|
|
while (sz != 0U) {
|
2018-07-27 16:23:09 +08:00
|
|
|
console_putc(s);
|
2018-06-27 08:30:41 +08:00
|
|
|
sz--;
|
|
|
|
}
|
2018-03-07 20:57:14 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
hv:Clear up printf related definition
In hypervisor, all the parameter and return value printf related are
unsigned int, this patch is used to fix the function definitions.
v1->v2:
*Modify the return value of various functions, such as printf(),
vprintf(), charout(), do_printf(), charmem, print_pow2(),
print_decimal to void due to never used, no necessary to use,
or has already returned by param.
*Delete the impossible judgement of param->emit due to the type
is unsigned.
Tracked-On: #861
Signed-off-by: Junjun Shan <junjun.shan@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-09-17 17:42:03 +08:00
|
|
|
void vprintf(const char *fmt, va_list args)
|
2018-03-07 20:57:14 +08:00
|
|
|
{
|
|
|
|
/* struct to store all necessary parameters */
|
|
|
|
struct print_param param;
|
hv:Clear up printf related definition
In hypervisor, all the parameter and return value printf related are
unsigned int, this patch is used to fix the function definitions.
v1->v2:
*Modify the return value of various functions, such as printf(),
vprintf(), charout(), do_printf(), charmem, print_pow2(),
print_decimal to void due to never used, no necessary to use,
or has already returned by param.
*Delete the impossible judgement of param->emit due to the type
is unsigned.
Tracked-On: #861
Signed-off-by: Junjun Shan <junjun.shan@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-09-17 17:42:03 +08:00
|
|
|
|
2018-03-07 20:57:14 +08:00
|
|
|
/* argument fo charout() */
|
hv:Clear up printf related definition
In hypervisor, all the parameter and return value printf related are
unsigned int, this patch is used to fix the function definitions.
v1->v2:
*Modify the return value of various functions, such as printf(),
vprintf(), charout(), do_printf(), charmem, print_pow2(),
print_decimal to void due to never used, no necessary to use,
or has already returned by param.
*Delete the impossible judgement of param->emit due to the type
is unsigned.
Tracked-On: #861
Signed-off-by: Junjun Shan <junjun.shan@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-09-17 17:42:03 +08:00
|
|
|
size_t nchars = 0;
|
2018-03-07 20:57:14 +08:00
|
|
|
|
|
|
|
/* initialize parameters */
|
2018-08-01 12:08:04 +08:00
|
|
|
(void)memset(¶m, 0U, sizeof(param));
|
2018-03-07 20:57:14 +08:00
|
|
|
param.emit = charout;
|
|
|
|
param.data = &nchars;
|
|
|
|
|
|
|
|
/* execute the printf() */
|
hv:Clear up printf related definition
In hypervisor, all the parameter and return value printf related are
unsigned int, this patch is used to fix the function definitions.
v1->v2:
*Modify the return value of various functions, such as printf(),
vprintf(), charout(), do_printf(), charmem, print_pow2(),
print_decimal to void due to never used, no necessary to use,
or has already returned by param.
*Delete the impossible judgement of param->emit due to the type
is unsigned.
Tracked-On: #861
Signed-off-by: Junjun Shan <junjun.shan@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-09-17 17:42:03 +08:00
|
|
|
do_print(fmt, ¶m, args);
|
2018-03-07 20:57:14 +08:00
|
|
|
}
|
|
|
|
|
hv:Clear up printf related definition
In hypervisor, all the parameter and return value printf related are
unsigned int, this patch is used to fix the function definitions.
v1->v2:
*Modify the return value of various functions, such as printf(),
vprintf(), charout(), do_printf(), charmem, print_pow2(),
print_decimal to void due to never used, no necessary to use,
or has already returned by param.
*Delete the impossible judgement of param->emit due to the type
is unsigned.
Tracked-On: #861
Signed-off-by: Junjun Shan <junjun.shan@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-09-17 17:42:03 +08:00
|
|
|
void printf(const char *fmt, ...)
|
2018-03-07 20:57:14 +08:00
|
|
|
{
|
|
|
|
/* variable argument list needed for do_print() */
|
|
|
|
va_list args;
|
|
|
|
|
|
|
|
va_start(args, fmt);
|
|
|
|
|
|
|
|
/* execute the printf() */
|
hv:Clear up printf related definition
In hypervisor, all the parameter and return value printf related are
unsigned int, this patch is used to fix the function definitions.
v1->v2:
*Modify the return value of various functions, such as printf(),
vprintf(), charout(), do_printf(), charmem, print_pow2(),
print_decimal to void due to never used, no necessary to use,
or has already returned by param.
*Delete the impossible judgement of param->emit due to the type
is unsigned.
Tracked-On: #861
Signed-off-by: Junjun Shan <junjun.shan@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-09-17 17:42:03 +08:00
|
|
|
vprintf(fmt, args);
|
2018-03-07 20:57:14 +08:00
|
|
|
|
|
|
|
/* destroy parameter list */
|
|
|
|
va_end(args);
|
|
|
|
}
|