Nucleus
Barry Kernel printf routines 120a213 (3 years, 2 months ago)
diff --git a/lib/printf.c b/lib/printf.c
index 006ef40..9836835 100644
--- a/lib/printf.c
+++ b/lib/printf.c
@@ -1,15 +1,7 @@
-/*
- * This file implements the *printf routines, as well as the full kernel panic
- * routine. The kernel panic routine does not return, and halts the processor
- * after running, the other *printf routines work as they normally would.
- * kprintf() outputs to the debug port rather than to the screen.
- */
-
#include <stdint.h>
#include <stdarg.h>
#include <string.h>
#include <io.h>
-#include <nucleus/task.h>
#define IS_DIGIT(c) ((c) >= '0' && (c) <= '9')
@@ -100,7 +92,7 @@ number(char *str, int num, int base, int size, int precision, int type)
}
/* Print formatted to a buffer */
-static int
+int
vsprintf(char *buf, const char *fmt, va_list args)
{
int len, i;
@@ -259,64 +251,3 @@ sprintf(char *buf, char *fmt, ...)
va_end(args);
return ret;
}
-
-/* Print formatted text to debug port */
-void
-kprintf(char *fmt, ...)
-{
- outb(0xE9, '\033');
- outb(0xE9, '[');
- outb(0xE9, '3');
- outb(0xE9, '6');
- outb(0xE9, 'm');
-
- char buf[1024], *p = buf;
-
- /* Print message to serial port */
- va_list args;
- va_start(args, fmt);
- vsprintf(buf, fmt, args);
- va_end(args);
- while (*p)
- outb(0xE9, *p++);
- outb(0xE9, '\n');
-}
-
-/* Debug print */
-void
-dbgprintf(char *msg)
-{
- size_t len = 1024;
- if (!msg || !verify_access(msg, strnlen(msg, len), PROT_READ))
- return;
-
- /* Print to debug port */
- kprintf("\033[93;01m(%d:%d): \033[0m%s",
- current->tgid, current->tid, msg);
-}
-
-/* Kernel panic */
-_Noreturn void
-panic(char *fmt, ...)
-{
- outb(0xE9, '\033');
- outb(0xE9, '[');
- outb(0xE9, '3');
- outb(0xE9, '1');
- outb(0xE9, 'm');
-
- char buf[1024], *p = buf;
-
- /* Print error to serial port */
- va_list args;
- va_start(args, fmt);
- vsprintf(buf, fmt, args);
- va_end(args);
- while (*p)
- outb(0xE9, *p++);
- outb(0xE9, '\n');
-
- asm volatile("sti");
- while (1)
- asm volatile("hlt");
-}