diff options
author | Marvin Borner | 2020-05-09 17:39:31 +0200 |
---|---|---|
committer | Marvin Borner | 2020-05-09 17:39:31 +0200 |
commit | 09a66e91ec9e8a677aa48f27798753084f213713 (patch) | |
tree | 9685a13b459e60d830179c565417ed72ae855ebe /src/kernel/syscall | |
parent | 3a97fef4bb4780e4bc2423699063d40cbf5da923 (diff) |
Replaced fork() with spawn()!
Who needs forks anyway
Diffstat (limited to 'src/kernel/syscall')
-rw-r--r-- | src/kernel/syscall/actions/sys_exec.c | 1 | ||||
-rw-r--r-- | src/kernel/syscall/actions/sys_fork.c | 23 | ||||
-rw-r--r-- | src/kernel/syscall/actions/sys_spawn.c | 7 | ||||
-rw-r--r-- | src/kernel/syscall/syscall.c | 7 | ||||
-rw-r--r-- | src/kernel/syscall/syscall.h | 4 |
5 files changed, 11 insertions, 31 deletions
diff --git a/src/kernel/syscall/actions/sys_exec.c b/src/kernel/syscall/actions/sys_exec.c index a74bd29..049d085 100644 --- a/src/kernel/syscall/actions/sys_exec.c +++ b/src/kernel/syscall/actions/sys_exec.c @@ -1,4 +1,3 @@ -#include <io/io.h> #include <stdint.h> #include <tasks/process.h> diff --git a/src/kernel/syscall/actions/sys_fork.c b/src/kernel/syscall/actions/sys_fork.c deleted file mode 100644 index ae1b17f..0000000 --- a/src/kernel/syscall/actions/sys_fork.c +++ /dev/null @@ -1,23 +0,0 @@ -#include <interrupts/interrupts.h> -#include <io/io.h> -#include <lib/lib.h> -#include <memory/paging.h> -#include <stdint.h> -#include <system.h> -#include <tasks/process.h> - -u32 sys_fork(struct regs *r) -{ - cli(); - struct page_directory *dir = paging_copy_user_directory(current_proc->cr3); - struct process *proc = process_make_new(); - proc->cr3 = dir; - memcpy(&proc->registers, r, sizeof(struct regs)); - proc->registers.eax = proc->pid; - proc->pid = current_proc->pid + 1; - - sti(); - process_spawn(proc); - - return 0; -}
\ No newline at end of file diff --git a/src/kernel/syscall/actions/sys_spawn.c b/src/kernel/syscall/actions/sys_spawn.c new file mode 100644 index 0000000..e3fa790 --- /dev/null +++ b/src/kernel/syscall/actions/sys_spawn.c @@ -0,0 +1,7 @@ +#include <stdint.h> +#include <tasks/process.h> + +u32 sys_spawn(char *path) +{ + return uspawn(path); +}
\ No newline at end of file diff --git a/src/kernel/syscall/syscall.c b/src/kernel/syscall/syscall.c index 2ae60b2..d46d3fa 100644 --- a/src/kernel/syscall/syscall.c +++ b/src/kernel/syscall/syscall.c @@ -11,10 +11,10 @@ typedef u32 (*syscall_func)(u32, ...); u32 (*syscalls[])() = { [SYS_HALT] = (u32(*)())halt_loop, // DEBUG! [SYS_EXIT] = sys_exit, - [SYS_FORK] = sys_fork, [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, @@ -36,10 +36,7 @@ void syscall_handler(struct regs *r) 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); - if (r->eax == SYS_FORK) // TODO: Fix hardcoded fork parameters - r->eax = location(r); - else - 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); sti(); } diff --git a/src/kernel/syscall/syscall.h b/src/kernel/syscall/syscall.h index 7e37c81..d2c50c0 100644 --- a/src/kernel/syscall/syscall.h +++ b/src/kernel/syscall/syscall.h @@ -10,14 +10,14 @@ void syscalls_install(); u32 sys_exit(u32 code); -u32 sys_fork(struct regs *r); - 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(); |