From 54e6f829e4019e10734588b9ba63c2c186c94f8e Mon Sep 17 00:00:00 2001 From: Frans Kaashoek Date: Tue, 9 Oct 2018 14:28:54 -0400 Subject: Separate system call path from trap path. Passes usertests on 1 and 2 cpus. --- syscall.c | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) (limited to 'syscall.c') diff --git a/syscall.c b/syscall.c index 481bde8..b815f28 100644 --- a/syscall.c +++ b/syscall.c @@ -62,17 +62,17 @@ fetcharg(int n) struct proc *curproc = myproc(); switch (n) { case 0: - return curproc->tf->rdi; + return curproc->sf->rdi; case 1: - return curproc->tf->rsi; + return curproc->sf->rsi; case 2: - return curproc->tf->rdx; + return curproc->sf->rdx; case 3: - return curproc->tf->r10; + return curproc->sf->r10; case 4: - return curproc->tf->r8; + return curproc->sf->r8; case 5: - return curproc->tf->r9; + return curproc->sf->r9; } panic("fetcharg"); return -1; @@ -169,18 +169,31 @@ static int (*syscalls[])(void) = { [SYS_close] sys_close, }; -void -syscall(void) +static void +dosyscall(void) { int num; struct proc *curproc = myproc(); - num = curproc->tf->rax; + num = curproc->sf->rax; if(num > 0 && num < NELEM(syscalls) && syscalls[num]) { - curproc->tf->rax = syscalls[num](); + curproc->sf->rax = syscalls[num](); } else { cprintf("%d %s: unknown sys call %d\n", curproc->pid, curproc->name, num); - curproc->tf->rax = -1; + curproc->sf->rax = -1; } } + +void +syscall(struct sysframe *sf) +{ + if(myproc()->killed) + exit(); + myproc()->sf = sf; + dosyscall(); + if(myproc()->killed) + exit(); + return; +} + -- cgit v1.2.3