aboutsummaryrefslogtreecommitdiff
path: root/kernel/features
diff options
context:
space:
mode:
authorMarvin Borner2020-08-15 14:21:52 +0200
committerMarvin Borner2020-08-15 14:21:52 +0200
commit32b8722128dfb4ca9e814940a23c2b22a283bb12 (patch)
tree80c881a7717dc129fd11baaf98cd8b226fd30c67 /kernel/features
parent162c84cfe6b4652bae213776944b910390553d41 (diff)
Added some syscall wrappers
Diffstat (limited to 'kernel/features')
-rw-r--r--kernel/features/load.c6
-rw-r--r--kernel/features/proc.c5
-rw-r--r--kernel/features/syscall.c7
3 files changed, 15 insertions, 3 deletions
diff --git a/kernel/features/load.c b/kernel/features/load.c
index 5ef7def..2f3f65f 100644
--- a/kernel/features/load.c
+++ b/kernel/features/load.c
@@ -9,9 +9,12 @@
#include <proc.h>
#include <str.h>
-void bin_load(char *path, struct proc *proc)
+int bin_load(char *path, struct proc *proc)
{
char *data = read_file(path);
+ if (!data)
+ return 0;
+
u32 stack = (u32)malloc(0x1000) + 0x1000;
proc->regs.ebp = (u32)stack;
@@ -19,6 +22,7 @@ void bin_load(char *path, struct proc *proc)
proc->regs.useresp = (u32)stack;
proc->regs.eip = (u32)data;
strcpy(proc->name, path + 1);
+ return 1;
}
int elf_verify(struct elf_header *h)
diff --git a/kernel/features/proc.c b/kernel/features/proc.c
index 64a4ac1..40a52f8 100644
--- a/kernel/features/proc.c
+++ b/kernel/features/proc.c
@@ -72,6 +72,11 @@ void proc_attach(struct proc *proc)
}
}
+void proc_exit()
+{
+ current->state = PROC_ASLEEP;
+}
+
struct proc *proc_make()
{
struct proc *proc = malloc(sizeof(*proc));
diff --git a/kernel/features/syscall.c b/kernel/features/syscall.c
index 519532c..fd57f3b 100644
--- a/kernel/features/syscall.c
+++ b/kernel/features/syscall.c
@@ -30,8 +30,11 @@ void syscall_handler(struct regs *r)
case SYS_EXEC: {
char *path = (char *)r->ebx;
struct proc *proc = proc_make();
- bin_load(path, proc);
- proc_print();
+ r->eax = bin_load(path, proc);
+ break;
+ }
+ case SYS_EXIT: {
+ proc_exit();
break;
}
default: {