console vga stuff
This commit is contained in:
@@ -5,21 +5,24 @@
|
||||
#include <stdarg.h>
|
||||
|
||||
#include <drivers/vga/vga.h>
|
||||
#include <drivers/console/console.h>
|
||||
|
||||
spinlock_t kwrite_lock = {0};
|
||||
|
||||
extern psf_font_t* kfont;
|
||||
|
||||
static char* hex_chars = "0123456789abcdef";
|
||||
|
||||
static void kprint(const char *str) {
|
||||
while (*str) {
|
||||
vga_putchar(*str);
|
||||
console_putchar(*str);
|
||||
str++;
|
||||
}
|
||||
}
|
||||
|
||||
static void kputd(int d) {
|
||||
if (d == 0) {
|
||||
vga_putchar('0');
|
||||
console_putchar('0');
|
||||
return;
|
||||
}
|
||||
char buffer[12];
|
||||
@@ -29,13 +32,13 @@ static void kputd(int d) {
|
||||
d /= 10;
|
||||
}
|
||||
for (int j = i - 1; j >= 0; j--) {
|
||||
vga_putchar(buffer[j]);
|
||||
console_putchar(buffer[j]);
|
||||
}
|
||||
}
|
||||
|
||||
static void kputx(unsigned int x) {
|
||||
if (x == 0) {
|
||||
vga_putchar('0');
|
||||
console_putchar('0');
|
||||
return;
|
||||
}
|
||||
char buffer[8];
|
||||
@@ -46,13 +49,13 @@ static void kputx(unsigned int x) {
|
||||
x >>= 4;
|
||||
}
|
||||
for (int j = i - 1; j >= 0; j--) {
|
||||
vga_putchar(buffer[j]);
|
||||
console_putchar(buffer[j]);
|
||||
}
|
||||
}
|
||||
|
||||
void kputc(const char c) {
|
||||
spin_lock(&kwrite_lock);
|
||||
vga_putchar(c);
|
||||
console_putchar(c);
|
||||
spin_unlock(&kwrite_lock);
|
||||
}
|
||||
|
||||
@@ -82,20 +85,20 @@ void kprintf(const char* fmt, ...) {
|
||||
}
|
||||
case 'c': {
|
||||
int c = va_arg(args, int);
|
||||
vga_putchar((char)c);
|
||||
console_putchar((char)c);
|
||||
break;
|
||||
}
|
||||
case '%':
|
||||
vga_putchar('%');
|
||||
console_putchar('%');
|
||||
break;
|
||||
default:
|
||||
vga_putchar('%');
|
||||
vga_putchar(*fmt);
|
||||
console_putchar('%');
|
||||
console_putchar(*fmt);
|
||||
break;
|
||||
}
|
||||
fmt++;
|
||||
} else {
|
||||
vga_putchar(*fmt);
|
||||
console_putchar(*fmt);
|
||||
fmt++;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user