blob: 19959e7542aa28aacecb7146938144e73bd3dea3 [file] [log] [blame]
#include "log.h"
#include "kint.h"
#include "vga.h"
#include "stdarg.h"
void kprintf(const char *format, ...)
{
va_list args;
va_start(args, format);
while (*format)
{
if (*format == '%')
{
format++;
switch (*format)
{
case 'd':
{
uint x = (uint) va_arg(args, uint);
vga_putd(x);
break;
}
case 'x':
{
// consider hex always unsigned
uint x = (uint) va_arg(args, uint);
vga_putx(x);
break;
}
case 's':
{
char *s = va_arg(args, char *);
vga_write(s);
break;
}
}
format++;
}
else
{
vga_put(*format);
format++;
}
}
va_end(args);
}
void kassert_int(bool condition, const char *message, const char *file, const int line)
{
if (!condition)
{
vga_set_color(LIGHT_RED, BLACK);
kprintf("ASSERTION FAILED: %s:%d\n%s\n", file, line, message);
while (1)
{}
}
}