cp: direct all internal guest console messages to sclp
[hvf.git] / cp / nucleus / printf.c
blob37aac8bd0ef4380c232ddf40ff1b3e46b467b5f2
1 /*
2 * (C) Copyright 2007-2019 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
4 * This file is released under the GPLv2. See the COPYING file for more
5 * details.
6 */
8 #include <channel.h>
9 #include <console.h>
10 #include <directory.h>
11 #include <ebcdic.h>
12 #include <slab.h>
13 #include <clock.h>
14 #include <sched.h>
15 #include <vsprintf.h>
16 #include <stdarg.h>
17 #include <vcpu.h>
19 int con_vprintf(struct virt_cons *con, const char *fmt, va_list args)
21 struct virt_sys *sys = container_of(con, struct virt_sys, console);
22 struct datetime dt;
23 char buf[128];
24 int off = 0;
25 int ret;
27 if (sys->print_ts) {
28 memset(&dt, 0, sizeof(dt));
29 ret = get_parsed_tod(&dt);
30 off = snprintf(buf, 128, "%02d:%02d:%02d ", dt.th, dt.tm,
31 dt.ts);
34 ret = vsnprintf(buf+off, 128-off, fmt, args);
35 if (ret) {
36 if (sys->internal) {
37 /* internal guests direct all console traffic to sclp */
38 sclp_msg("%s", buf);
39 } else {
40 /* normal guests direct it to their console device */
41 ascii2ebcdic((u8 *) buf, off+ret);
42 //con_write(con, (u8 *) buf, off+ret);
46 return ret;
49 int con_printf(struct virt_cons *con, const char *fmt, ...)
51 va_list args;
52 int r;
54 va_start(args, fmt);
55 r = con_vprintf(con, fmt, args);
56 va_end(args);
58 return r;