summaryrefslogtreecommitdiffstats
path: root/arch/x86_64/lib/printf.c
blob: 794a59299cd49eb82e81fcb1e9d63c0eba5ca630 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include "../hal/serial_com.h"
#include "lib/printf.h"
#include "lib/virtterm.h"
#include "proc/init.h"

int
kvprintf(const char *fmt, va_list ap)
{
    char buffer[256] = { 0 };
    int r = vsnprintf(buffer, 256, fmt, ap);
    int wlen = (r > 256 ? 256 : r);

    {
        jove_owned_obj_t *serial_obj = objdir_getlocal(_rootdir_obj, ROOTDIR_SERIAL_COM_I);
        serial_com_write(serial_obj, buffer, wlen);
        obj_release(serial_obj);

        jove_owned_obj_t *vt_obj = objdir_getlocal(_rootdir_obj, ROOTDIR_VIRTTERM_I);
        vt_write(vt_obj, buffer, wlen);
        obj_release(vt_obj);
    }

    return r;
}