summaryrefslogtreecommitdiffstats
path: root/arch/x86_64/lib/printf.c
blob: db47f6b5bb5a0fa12cdc907e2058000e1853ca4e (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
25
#include "../hal/serial_com.h"
#include "lib/printf.h"
#include "lib/virtterm.h"
#include "proc/init.h"
#include "sys/objdir.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, INIT_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, INIT_ROOTDIR_VIRTTERM_I);
        vt_write(vt_obj, buffer, wlen);
        obj_release(vt_obj);
    }

    return r;
}