aboutsummaryrefslogtreecommitdiff
path: root/kernel/features/syscall.c
diff options
context:
space:
mode:
authorMarvin Borner2020-08-21 23:08:16 +0200
committerMarvin Borner2020-08-21 23:08:16 +0200
commit94de27efb7f9f97d162c1cd6b0a2bb89e3fe555f (patch)
treeb2ae93419138cd0af46559b0b1f1a03862d62242 /kernel/features/syscall.c
parentf700ba6668dbdb91a03b2c5aa387eb4cabae8fcd (diff)
Finished proper return of processes
Diffstat (limited to 'kernel/features/syscall.c')
-rw-r--r--kernel/features/syscall.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/kernel/features/syscall.c b/kernel/features/syscall.c
index 02b17e5..ac79fc1 100644
--- a/kernel/features/syscall.c
+++ b/kernel/features/syscall.c
@@ -47,13 +47,18 @@ void syscall_handler(struct regs *r)
printf("exec\n");
char *path = (char *)r->ebx;
struct proc *proc = proc_make();
-
r->eax = bin_load(path, proc);
- ((u32 *)proc->regs.useresp)[0] = 42;
- ((char *)proc->regs.useresp)[1] = r->ecx;
- ((char *)proc->regs.useresp)[2] = r->edx;
- ((char *)proc->regs.useresp)[3] = r->esi;
- ((char *)proc->regs.useresp)[4] = r->edi;
+ int argc = 3; // TODO: Add argc evaluator
+ char **argv = malloc(sizeof(*argv) * (argc + 1));
+ argv[0] = (char *)r->ecx;
+ argv[1] = (char *)r->edx;
+ argv[2] = (char *)r->esi;
+ argv[3] = (char *)r->edi;
+ argv[4] = NULL;
+ ((u32 *)proc->regs.useresp)[0] = argc;
+ ((u32 *)proc->regs.useresp)[1] = (u32)argv;
+ if (r->eax)
+ proc->state = PROC_ERROR;
break;
}
case SYS_EXIT: {