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/lib.h | 2 -- src/kernel/lib/memory.c | 20 -------------------- src/kernel/lib/stdio.h | 4 +--- 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 ------ 8 files changed, 17 insertions(+), 51 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') diff --git a/src/kernel/lib/lib.h b/src/kernel/lib/lib.h index 7ebae9a..b08904f 100644 --- a/src/kernel/lib/lib.h +++ b/src/kernel/lib/lib.h @@ -36,8 +36,6 @@ void memory_info_init(struct multiboot_tag_basic_meminfo *tag); void memory_mmap_init(struct multiboot_tag_mmap *tag); -int memory_init(uint32_t multiboot_address); - void memory_print(); uint32_t memory_get_all(); diff --git a/src/kernel/lib/memory.c b/src/kernel/lib/memory.c index 6aed060..30f75f9 100644 --- a/src/kernel/lib/memory.c +++ b/src/kernel/lib/memory.c @@ -96,24 +96,4 @@ void memory_mmap_init(struct multiboot_tag_mmap *tag) } } total = sum >> 10; // I want kb -} - -int memory_init(uint32_t multiboot_address) -{ - int ret = 0; - struct multiboot_tag *tag; - - for (tag = (struct multiboot_tag *)(multiboot_address + 8); - tag->type != MULTIBOOT_TAG_TYPE_END; - tag = (struct multiboot_tag *)((multiboot_uint8_t *)tag + ((tag->size + 7) & ~7))) { - if (tag->type == MULTIBOOT_TAG_TYPE_BASIC_MEMINFO) { - info("Got memory info"); - memory_info_init((struct multiboot_tag_basic_meminfo *)tag); - } else if (tag->type == MULTIBOOT_TAG_TYPE_MMAP) { - info("Got memory map"); - memory_mmap_init((struct multiboot_tag_mmap *)tag); - ret = 1; - } - } - return ret; } \ No newline at end of file diff --git a/src/kernel/lib/stdio.h b/src/kernel/lib/stdio.h index 8668775..7dae60e 100644 --- a/src/kernel/lib/stdio.h +++ b/src/kernel/lib/stdio.h @@ -5,9 +5,7 @@ char getch(); -char *readline(); - -void writec(char c); +void putch(char c); void vprintf(const char *fmt, va_list args); 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