From 5f8b5ce7efb7738eaebad43f9648975788ae19ff Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Tue, 28 Apr 2020 20:59:57 +0200 Subject: Fixed userspace entering... Many other fixes too, but I won't mention them because I don't want to :) --- src/kernel/lib/stdio/getch.c | 4 ++-- src/kernel/lib/stdio/putch.c | 6 ++++++ src/kernel/lib/stdio/readline.c | 10 ---------- src/kernel/lib/stdio/vprintf.c | 16 ++++++++-------- src/kernel/lib/stdio/writec.c | 6 ------ 5 files changed, 16 insertions(+), 26 deletions(-) create mode 100644 src/kernel/lib/stdio/putch.c delete mode 100644 src/kernel/lib/stdio/readline.c delete mode 100644 src/kernel/lib/stdio/writec.c (limited to 'src/kernel/lib/stdio') diff --git a/src/kernel/lib/stdio/getch.c b/src/kernel/lib/stdio/getch.c index e806013..4f6ed39 100644 --- a/src/kernel/lib/stdio/getch.c +++ b/src/kernel/lib/stdio/getch.c @@ -1,11 +1,11 @@ #include #include +#include char getch() { keyboard_char_buffer = 0; while (keyboard_char_buffer == 0) { - timer_wait(1); // IDK why! - } + }; return keyboard_char_buffer; } \ No newline at end of file diff --git a/src/kernel/lib/stdio/putch.c b/src/kernel/lib/stdio/putch.c new file mode 100644 index 0000000..f7e0248 --- /dev/null +++ b/src/kernel/lib/stdio/putch.c @@ -0,0 +1,6 @@ +#include + +void putch(char c) +{ + vesa_draw_char(c); +} \ No newline at end of file diff --git a/src/kernel/lib/stdio/readline.c b/src/kernel/lib/stdio/readline.c deleted file mode 100644 index 1bda252..0000000 --- a/src/kernel/lib/stdio/readline.c +++ /dev/null @@ -1,10 +0,0 @@ -#include -#include - -char *readline() -{ - keyboard_clear_buffer(); - while (keyboard_buffer[strlen(keyboard_buffer) - 1] != '\n') { - } - return keyboard_buffer; -} \ No newline at end of file diff --git a/src/kernel/lib/stdio/vprintf.c b/src/kernel/lib/stdio/vprintf.c index b9188c6..2431a48 100644 --- a/src/kernel/lib/stdio/vprintf.c +++ b/src/kernel/lib/stdio/vprintf.c @@ -5,10 +5,10 @@ #include #include -void _writes(const char *data) +void _puts(const char *data) { for (size_t i = 0; i < strlen(data); i++) - writec(data[i]); + putch(data[i]); } void vprintf(const char *fmt, va_list args) @@ -20,7 +20,7 @@ void vprintf(const char *fmt, va_list args) for (; *fmt; fmt++) { if (readyToFormat) { if (*fmt == '%') { - writec('%'); + putch('%'); readyToFormat = 0; continue; } @@ -28,27 +28,27 @@ void vprintf(const char *fmt, va_list args) buff = *fmt; if (buff == 's') { const char *str = va_arg(args, const char *); - _writes(str); + _puts(str); readyToFormat = 0; } else if (buff == 'x') { char *p = htoa((uint32_t)va_arg(args, int)); - _writes(p); + _puts(p); kfree(p); readyToFormat = 0; } else if (buff == 'd') { char *p = itoa(va_arg(args, int)); - _writes(p); + _puts(p); kfree(p); readyToFormat = 0; } else if (buff == 'c') { - writec((char)va_arg(args, int)); + putch((char)va_arg(args, int)); readyToFormat = 0; } } else { if (*fmt == '%') readyToFormat = 1; else - writec(*fmt); + putch(*fmt); } } } \ No newline at end of file diff --git a/src/kernel/lib/stdio/writec.c b/src/kernel/lib/stdio/writec.c deleted file mode 100644 index 83b05de..0000000 --- a/src/kernel/lib/stdio/writec.c +++ /dev/null @@ -1,6 +0,0 @@ -#include - -void writec(char c) -{ - vesa_draw_char(c); -} \ No newline at end of file -- cgit v1.2.3