working on exposing vga to userspace
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#include "print.h"
|
||||
#include "drivers/serial/serial.h"
|
||||
#include "stream.h"
|
||||
#include "tasks.h"
|
||||
|
||||
@@ -13,16 +14,21 @@ extern psf_font_t* kfont;
|
||||
|
||||
static char* hex_chars = "0123456789abcdef";
|
||||
|
||||
static void kwrite(char c) {
|
||||
write_serial(c);
|
||||
console_putchar(c);
|
||||
}
|
||||
|
||||
static void kprint(const char *str) {
|
||||
while (*str) {
|
||||
console_putchar(*str);
|
||||
kwrite(*str);
|
||||
str++;
|
||||
}
|
||||
}
|
||||
|
||||
static void kputd(int d) {
|
||||
if (d == 0) {
|
||||
console_putchar('0');
|
||||
kwrite('0');
|
||||
return;
|
||||
}
|
||||
char buffer[12];
|
||||
@@ -32,13 +38,13 @@ static void kputd(int d) {
|
||||
d /= 10;
|
||||
}
|
||||
for (int j = i - 1; j >= 0; j--) {
|
||||
console_putchar(buffer[j]);
|
||||
kwrite(buffer[j]);
|
||||
}
|
||||
}
|
||||
|
||||
static void kputx(unsigned int x) {
|
||||
if (x == 0) {
|
||||
console_putchar('0');
|
||||
kwrite('0');
|
||||
return;
|
||||
}
|
||||
char buffer[8];
|
||||
@@ -49,13 +55,13 @@ static void kputx(unsigned int x) {
|
||||
x >>= 4;
|
||||
}
|
||||
for (int j = i - 1; j >= 0; j--) {
|
||||
console_putchar(buffer[j]);
|
||||
kwrite(buffer[j]);
|
||||
}
|
||||
}
|
||||
|
||||
void kputc(const char c) {
|
||||
spin_lock(&kwrite_lock);
|
||||
console_putchar(c);
|
||||
kwrite(c);
|
||||
spin_unlock(&kwrite_lock);
|
||||
}
|
||||
|
||||
@@ -85,20 +91,20 @@ void kprintf(const char* fmt, ...) {
|
||||
}
|
||||
case 'c': {
|
||||
int c = va_arg(args, int);
|
||||
console_putchar((char)c);
|
||||
kwrite((char)c);
|
||||
break;
|
||||
}
|
||||
case '%':
|
||||
console_putchar('%');
|
||||
kwrite('%');
|
||||
break;
|
||||
default:
|
||||
console_putchar('%');
|
||||
console_putchar(*fmt);
|
||||
kwrite('%');
|
||||
kwrite(*fmt);
|
||||
break;
|
||||
}
|
||||
fmt++;
|
||||
} else {
|
||||
console_putchar(*fmt);
|
||||
kwrite(*fmt);
|
||||
fmt++;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user