extern int sys_cxnet(long, long, long, long, long, long, long);
extern int sys_cxipc(long, long, long);
#if FEATURE(POSIX)
-extern int sys_posixcall(long, long, long, long, long, long, long);
+extern int sys_posixcall(stack_frame_t*);
#endif /* FEATURE(POSIX) */
static const char *_exc_name[] = {
#if FEATURE(POSIX)
case SYS_VECTOR_POSIX:
- ret_val = sys_posixcall(ctx.eax, ctx.ebx, ctx.ecx, ctx.edx, ctx.esi, ctx.edi, ctx.ebp);
+ ret_val = sys_posixcall(&ctx);
break;
#endif /* FEATURE(POSIX) */
#include <corax/errno.h>
#include <corax/syscall.h>
#include <corax/types.h>
+#include <arch.h>
#include <process.h>
+#include <debug.h>
int sys_exit(int status)
{
return(ret_val);
}
-int sys_fork(void)
+int sys_fork(stack_frame_t *stk)
{
+ int ret_val;
+ task_t *ct;
+
/*
* process_fork() always forks the calling process, so
* it doesn't get told which process to fork
*/
- return(process_fork(0));
+
+ ret_val = process_fork(0);
+
+ /*
+ * Update the stack frame, since the page directory
+ * will have changed for one of the processes
+ */
+ ct = task_get_current();
+
+ stk->cr3 = ct->t_pgdir;
+
+ return(ret_val);
}
int sys_vfork(void)
return(-ENOSYS);
}
-int sys_posixcall(long vec, long arg1, long arg2, long arg3, long arg4, long arg5, long arg6)
+int sys_posixcall(stack_frame_t *stk)
{
int ret_val;
ret_val = -EFAULT;
- switch(vec) {
+ switch(stk->eax) {
case SYS_EXIT:
- ret_val = sys_exit((int)arg1);
+ ret_val = sys_exit((int)stk->ebx);
break;
case SYS_FORK:
- ret_val = sys_fork();
+ /* sys_fork() will need to modify the stack frame */
+ ret_val = sys_fork(stk);
break;
case SYS_VFORK:
+ /*
+ * sys_vfork() spawns a new process within the same address space,
+ * so it's not necessary for it to modify the stack frame
+ */
ret_val = sys_vfork();
break;
case SYS_WAIT:
- ret_val = sys_wait((int*)arg1);
+ ret_val = sys_wait((int*)stk->ebx);
break;
case SYS_WAITPID:
- ret_val = sys_waitpid((pid_t)arg1, (int*)arg2, (int)arg3);
+ ret_val = sys_waitpid((pid_t)stk->ebx, (int*)stk->ecx, (int)stk->edx);
break;
case SYS_WAITID: