soaplin/kernel/src/sys/log.c
RaphProductions a8e919b033 kernel - v0.7 beta
+ acpi: add acpi support
+ lapic: add lapic support
+ ioapic: add ioapic support
+ arch/x86_64: add support for "syscall"/"sysret"
2025-05-15 18:49:09 +02:00

46 lines
No EOL
889 B
C

#include "arch//x86_64/io.h"
#include "sys/gfx/flanterm/flanterm.h"
#include <lib/spinlock.h>
#include <lib/string.h>
#include <stdarg.h>
#include <sys/printf.h>
extern struct flanterm_context *ft_ctx;
static spinlock_t log_lock = {0};
void log(char *format, ...) {
// TODO: replace this call with a call to printf() when the RTC is
// implemented.
//spinlock_acquire(&log_lock);
char *date = "1970-01-01 00:00:00 | ";
if (ft_ctx)
flanterm_write(ft_ctx, date, strlen(date));
char buf[2048];
va_list l;
va_start(l, format);
npf_vsnprintf(buf, 2048, format, l);
va_end(l);
if (ft_ctx)
flanterm_write(ft_ctx, buf, strlen(buf));
for (int i = 0;; i++) {
if (date[i] == '\0')
break;
outb(0xE9, date[i]);
}
for (int i = 0;; i++) {
if (buf[i] == '\0')
break;
outb(0xE9, buf[i]);
}
//spinlock_release(&log_lock);
}