From eed77bd2970a00d1394ed027ceca5b646e4671ce Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Wed, 17 Jun 2020 18:31:46 +0200 Subject: Started rewrite --- src/kernel/syscall/actions/sys_exec.c | 7 ----- src/kernel/syscall/actions/sys_exit.c | 8 ------ src/kernel/syscall/actions/sys_free.c | 8 ------ src/kernel/syscall/actions/sys_get.c | 7 ----- src/kernel/syscall/actions/sys_get_pid.c | 7 ----- src/kernel/syscall/actions/sys_malloc.c | 7 ----- src/kernel/syscall/actions/sys_map.c | 8 ------ src/kernel/syscall/actions/sys_read.c | 7 ----- src/kernel/syscall/actions/sys_spawn.c | 7 ----- src/kernel/syscall/actions/sys_wait.c | 10 -------- src/kernel/syscall/actions/sys_write.c | 7 ----- src/kernel/syscall/syscall.c | 44 -------------------------------- src/kernel/syscall/syscall.h | 33 ------------------------ 13 files changed, 160 deletions(-) delete mode 100644 src/kernel/syscall/actions/sys_exec.c delete mode 100644 src/kernel/syscall/actions/sys_exit.c delete mode 100644 src/kernel/syscall/actions/sys_free.c delete mode 100644 src/kernel/syscall/actions/sys_get.c delete mode 100644 src/kernel/syscall/actions/sys_get_pid.c delete mode 100644 src/kernel/syscall/actions/sys_malloc.c delete mode 100644 src/kernel/syscall/actions/sys_map.c delete mode 100644 src/kernel/syscall/actions/sys_read.c delete mode 100644 src/kernel/syscall/actions/sys_spawn.c delete mode 100644 src/kernel/syscall/actions/sys_wait.c delete mode 100644 src/kernel/syscall/actions/sys_write.c delete mode 100644 src/kernel/syscall/syscall.c delete mode 100644 src/kernel/syscall/syscall.h (limited to 'src/kernel/syscall') diff --git a/src/kernel/syscall/actions/sys_exec.c b/src/kernel/syscall/actions/sys_exec.c deleted file mode 100644 index 049d085..0000000 --- a/src/kernel/syscall/actions/sys_exec.c +++ /dev/null @@ -1,7 +0,0 @@ -#include -#include - -u32 sys_exec(char *path) -{ - return uexec(path); -} \ No newline at end of file diff --git a/src/kernel/syscall/actions/sys_exit.c b/src/kernel/syscall/actions/sys_exit.c deleted file mode 100644 index eb019ab..0000000 --- a/src/kernel/syscall/actions/sys_exit.c +++ /dev/null @@ -1,8 +0,0 @@ -#include -#include - -u32 sys_exit(u32 code) -{ - process_suspend(current_proc->pid); - return code; -} \ No newline at end of file diff --git a/src/kernel/syscall/actions/sys_free.c b/src/kernel/syscall/actions/sys_free.c deleted file mode 100644 index 32e9ba8..0000000 --- a/src/kernel/syscall/actions/sys_free.c +++ /dev/null @@ -1,8 +0,0 @@ -#include -#include - -u32 sys_free(u32 ptr) -{ - free((void *)ptr); - return 0; -} \ No newline at end of file diff --git a/src/kernel/syscall/actions/sys_get.c b/src/kernel/syscall/actions/sys_get.c deleted file mode 100644 index 8a4a643..0000000 --- a/src/kernel/syscall/actions/sys_get.c +++ /dev/null @@ -1,7 +0,0 @@ -#include - -u32 sys_get(u32 id) -{ - // TODO: Implement get syscall - return -1; -} \ No newline at end of file diff --git a/src/kernel/syscall/actions/sys_get_pid.c b/src/kernel/syscall/actions/sys_get_pid.c deleted file mode 100644 index 1184ce7..0000000 --- a/src/kernel/syscall/actions/sys_get_pid.c +++ /dev/null @@ -1,7 +0,0 @@ -#include -#include - -u32 sys_get_pid() -{ - return current_proc->pid; -} \ No newline at end of file diff --git a/src/kernel/syscall/actions/sys_malloc.c b/src/kernel/syscall/actions/sys_malloc.c deleted file mode 100644 index c68606b..0000000 --- a/src/kernel/syscall/actions/sys_malloc.c +++ /dev/null @@ -1,7 +0,0 @@ -#include -#include - -u32 sys_malloc(u32 count) -{ - return (u32)malloc(count); -} \ No newline at end of file diff --git a/src/kernel/syscall/actions/sys_map.c b/src/kernel/syscall/actions/sys_map.c deleted file mode 100644 index 5af2c2a..0000000 --- a/src/kernel/syscall/actions/sys_map.c +++ /dev/null @@ -1,8 +0,0 @@ -#include -#include - -u32 sys_map(u32 id, u8 *function) -{ - event_map(id, function); - return -1; -} \ No newline at end of file diff --git a/src/kernel/syscall/actions/sys_read.c b/src/kernel/syscall/actions/sys_read.c deleted file mode 100644 index b0428a8..0000000 --- a/src/kernel/syscall/actions/sys_read.c +++ /dev/null @@ -1,7 +0,0 @@ -#include -#include - -u32 sys_read(char *path, u32 offset, u32 count, u8 *buf) -{ - return read(path, offset, count, buf); -} \ No newline at end of file diff --git a/src/kernel/syscall/actions/sys_spawn.c b/src/kernel/syscall/actions/sys_spawn.c deleted file mode 100644 index e3fa790..0000000 --- a/src/kernel/syscall/actions/sys_spawn.c +++ /dev/null @@ -1,7 +0,0 @@ -#include -#include - -u32 sys_spawn(char *path) -{ - return uspawn(path); -} \ No newline at end of file diff --git a/src/kernel/syscall/actions/sys_wait.c b/src/kernel/syscall/actions/sys_wait.c deleted file mode 100644 index 23d4639..0000000 --- a/src/kernel/syscall/actions/sys_wait.c +++ /dev/null @@ -1,10 +0,0 @@ -#include -#include -#include - -u32 sys_wait(u32 pid, u32 *status, u32 options) -{ - /* if (pid > 0) */ - /* return process_wait_pid(pid, status); */ - return -1; -} \ No newline at end of file diff --git a/src/kernel/syscall/actions/sys_write.c b/src/kernel/syscall/actions/sys_write.c deleted file mode 100644 index 585a545..0000000 --- a/src/kernel/syscall/actions/sys_write.c +++ /dev/null @@ -1,7 +0,0 @@ -#include -#include - -u32 sys_write(char *path, u32 offset, u32 count, u8 *buf) -{ - return write(path, offset, count, buf); -} \ No newline at end of file diff --git a/src/kernel/syscall/syscall.c b/src/kernel/syscall/syscall.c deleted file mode 100644 index 21738f8..0000000 --- a/src/kernel/syscall/syscall.c +++ /dev/null @@ -1,44 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include - -typedef u32 (*syscall_func)(u32, ...); - -u32 (*syscalls[])() = { [SYS_HALT] = (u32(*)())halt_loop, // DEBUG! - [SYS_EXIT] = sys_exit, - [SYS_READ] = sys_read, - [SYS_WRITE] = sys_write, - [SYS_EXEC] = sys_exec, - [SYS_SPAWN] = sys_spawn, - [SYS_WAIT] = sys_wait, - [SYS_GET_PID] = sys_get_pid, - [SYS_MALLOC] = sys_malloc, - [SYS_FREE] = sys_free, - [SYS_GET] = sys_get, - [SYS_MAP] = sys_map }; - -void syscall_handler(struct regs *r) -{ - if (r->eax >= sizeof(syscalls) / sizeof(*syscalls)) - return; - - syscall_func location = (syscall_func)syscalls[r->eax]; - if (!location) - return; - - log("[SYSCALL] %d at [0x%x] with 0x%x 0x%x 0x%x 0x%x", r->eax, location, r->ebx, r->ecx, - r->edx, r->esi, r->edi); - - r->eax = location(r->ebx, r->ecx, r->edx, r->esi, r->edi); - debug("Finished syscall"); -} - -void syscalls_install() -{ - isr_install_handler(0x80, syscall_handler); -} \ No newline at end of file diff --git a/src/kernel/syscall/syscall.h b/src/kernel/syscall/syscall.h deleted file mode 100644 index d2c50c0..0000000 --- a/src/kernel/syscall/syscall.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef MELVIX_SYSCALL_H -#define MELVIX_SYSCALL_H - -#include -#include - -extern void idt_syscall(); - -void syscalls_install(); - -u32 sys_exit(u32 code); - -u32 sys_read(char *path, u32 offset, u32 count, u8 *buf); - -u32 sys_write(char *path, u32 offset, u32 count, u8 *buf); - -u32 sys_exec(char *path); - -u32 sys_spawn(char *path); - -u32 sys_wait(u32 pid, u32 *status, u32 options); - -u32 sys_get_pid(); - -u32 sys_malloc(u32 count); - -u32 sys_free(u32 ptr); - -u32 sys_get(u32 id); - -u32 sys_map(u32 id, u8 *function); - -#endif \ No newline at end of file -- cgit v1.2.3