diff options
author | Marvin Borner | 2019-12-07 13:40:28 +0100 |
---|---|---|
committer | Marvin Borner | 2019-12-07 13:40:28 +0100 |
commit | d94b024b73aeca06de417e0fd3c502495312a8b2 (patch) | |
tree | bff5cc1b757eeed7f58878cc13551c63464c5a31 /src/kernel/syscall | |
parent | 322167ceab19588473f9074e761390fdeb701790 (diff) |
Added userspace libc and began userspace based shell
Diffstat (limited to 'src/kernel/syscall')
-rw-r--r-- | src/kernel/syscall/actions/sys_read.c | 21 | ||||
-rw-r--r-- | src/kernel/syscall/actions/sys_write.c | 12 | ||||
-rw-r--r-- | src/kernel/syscall/syscall.c | 6 | ||||
-rw-r--r-- | src/kernel/syscall/syscall.h | 4 |
4 files changed, 35 insertions, 8 deletions
diff --git a/src/kernel/syscall/actions/sys_read.c b/src/kernel/syscall/actions/sys_read.c new file mode 100644 index 0000000..761eec7 --- /dev/null +++ b/src/kernel/syscall/actions/sys_read.c @@ -0,0 +1,21 @@ +#include <stdint-gcc.h> +#include <kernel/lib/stdio.h> +#include <kernel/lib/string.h> +#include <kernel/io/io.h> +#include <kernel/input/input.h> +#include <kernel/timer/timer.h> + +uint32_t sys_read() +{ + serial_write("CALL\n"); + + keyboard_clear_buffer(); + while (keyboard_buffer[strlen(keyboard_buffer) - 1] != '\n') { + { + timer_wait(1); // IDK why? + } + } + serial_write(keyboard_buffer); + serial_write("\n"); + return (uint32_t) keyboard_buffer; +}
\ No newline at end of file diff --git a/src/kernel/syscall/actions/sys_write.c b/src/kernel/syscall/actions/sys_write.c index 882ff19..aef2b2b 100644 --- a/src/kernel/syscall/actions/sys_write.c +++ b/src/kernel/syscall/actions/sys_write.c @@ -1,9 +1,11 @@ #include <stdint-gcc.h> -#include <mlibc/stdio.h> +#include <kernel/lib/stdio.h> +#include <kernel/lib/string.h> +#include <kernel/io/io.h> -uint32_t sys_write(unsigned int fd, unsigned int buf, unsigned int count) +uint32_t sys_write(unsigned int buf) { - for (uint32_t i = 0; i < count; i++) - writec(*((char *) buf++)); - return count; + serial_put(((char *) buf)[0]); + printf((const char *) buf); + return strlen((const char *) buf); }
\ No newline at end of file diff --git a/src/kernel/syscall/syscall.c b/src/kernel/syscall/syscall.c index 0eac619..eb44c87 100644 --- a/src/kernel/syscall/syscall.c +++ b/src/kernel/syscall/syscall.c @@ -6,11 +6,14 @@ typedef uint32_t (*syscall_func)(unsigned int, ...); uint32_t (*syscalls[])() = { - [1] = sys_write + [1] = sys_write, + [2] = sys_read }; void syscall_handler(struct regs *r) { + serial_write("Received syscall!\n"); + if (r->eax >= sizeof(syscalls) / sizeof(*syscalls)) return; @@ -18,7 +21,6 @@ void syscall_handler(struct regs *r) if (!location) return; - serial_write("Received syscall!\n"); location(r->ebx, r->ecx, r->edx, r->esi, r->edi); } diff --git a/src/kernel/syscall/syscall.h b/src/kernel/syscall/syscall.h index 8730dbf..8ed532d 100644 --- a/src/kernel/syscall/syscall.h +++ b/src/kernel/syscall/syscall.h @@ -5,6 +5,8 @@ extern void idt_syscall(); void syscalls_install(); -uint32_t sys_write(unsigned int buf, unsigned int count); +uint32_t sys_write(unsigned int buf); + +uint32_t sys_read(); #endif
\ No newline at end of file |