diff options
author | Robert Morris <[email protected]> | 2022-08-24 13:24:37 -0400 |
---|---|---|
committer | Robert Morris <[email protected]> | 2022-08-24 13:24:37 -0400 |
commit | 29ce3161f8c3604541045fd6d6202b9fdfccc6c6 (patch) | |
tree | 740d61b5f832e6b77fea0c3288c6ae76718a4508 | |
parent | 9c1b8a4eb085d7c639c2039fc14beba83d95653e (diff) | |
parent | cc486ddee0c617ab2a0bd000b4674e1094661386 (diff) | |
download | xv6-labs-29ce3161f8c3604541045fd6d6202b9fdfccc6c6.tar.gz xv6-labs-29ce3161f8c3604541045fd6d6202b9fdfccc6c6.tar.bz2 xv6-labs-29ce3161f8c3604541045fd6d6202b9fdfccc6c6.zip |
Merge branch 'riscv' of g.csail.mit.edu:xv6-dev into riscv
-rw-r--r-- | kernel/syscall.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/kernel/syscall.c b/kernel/syscall.c index ee94696..ed65409 100644 --- a/kernel/syscall.c +++ b/kernel/syscall.c @@ -79,6 +79,7 @@ argstr(int n, char *buf, int max) return fetchstr(addr, buf, max); } +// Prototypes for the functions that handle system calls. extern uint64 sys_fork(void); extern uint64 sys_exit(void); extern uint64 sys_wait(void); @@ -101,6 +102,8 @@ extern uint64 sys_link(void); extern uint64 sys_mkdir(void); extern uint64 sys_close(void); +// An array mapping syscall numbers from syscall.h +// to the function that handles the system call. static uint64 (*syscalls[])(void) = { [SYS_fork] sys_fork, [SYS_exit] sys_exit, @@ -133,6 +136,8 @@ syscall(void) num = p->trapframe->a7; if(num > 0 && num < NELEM(syscalls) && syscalls[num]) { + // Use num to lookup the system call function for num, call it, + // and store its return value in p->trapframe->a0 p->trapframe->a0 = syscalls[num](); } else { printf("%d %s: unknown sys call %d\n", |