blob: 0766a60f77829de1c9ad8155bfac09f23b5f8c7c [file] [log] [blame]
#include "log.h"
#include "kint.h"
#include "stdarg.h"
#include "vga.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)
{
}
}
}