summaryrefslogtreecommitdiffstats
path: root/arch/x86_64/debug/printf.c
blob: 13737b9d7d87a0c681f67eea1462cb1ed167463f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include "lib/printf.h"
#include "../hal/serial_com.h"
#include "api/error.h"
#include "debug/debug.h"

int
kvprintf(const char *fmt, va_list ap)
{
    if(!_debug_has_output) return -EBADCALL;

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

#ifdef DEBUG_SERIAL
    serial_com_write(SERIAL_COM1, buffer, wlen);
#endif

    return r;
}