diff options
Diffstat (limited to 'userprog/syscall.c')
| -rw-r--r-- | userprog/syscall.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/userprog/syscall.c b/userprog/syscall.c index f8e0197..541668d 100644 --- a/userprog/syscall.c +++ b/userprog/syscall.c | |||
| @@ -17,6 +17,9 @@ | |||
| 17 | 17 | ||
| 18 | #define STACK_SLOT_SIZE sizeof(int) | 18 | #define STACK_SLOT_SIZE sizeof(int) |
| 19 | 19 | ||
| 20 | /* stored stack pointer for the "page fault inside syscall/kernel"-case */ | ||
| 21 | void *syscall_sp; | ||
| 22 | |||
| 20 | /* Prototypes for Utilities */ | 23 | /* Prototypes for Utilities */ |
| 21 | static int get_user (const uint8_t *uaddr); | 24 | static int get_user (const uint8_t *uaddr); |
| 22 | static bool put_user (uint8_t *udst, uint8_t byte); | 25 | static bool put_user (uint8_t *udst, uint8_t byte); |
| @@ -195,10 +198,10 @@ syscall_handler (struct intr_frame *f) | |||
| 195 | handler* fp; | 198 | handler* fp; |
| 196 | bool segfault = false; | 199 | bool segfault = false; |
| 197 | int result; | 200 | int result; |
| 198 | void *sp = f->esp; | 201 | syscall_sp = f->esp; |
| 199 | 202 | ||
| 200 | /* The system call number and the arguments are on the stack */ | 203 | /* The system call number and the arguments are on the stack */ |
| 201 | if (! copy_from_user (&syscall_nr,sp)) | 204 | if (! copy_from_user (&syscall_nr,syscall_sp)) |
| 202 | goto fail; | 205 | goto fail; |
| 203 | switch (syscall_nr) { | 206 | switch (syscall_nr) { |
| 204 | case SYS_HALT: fp = syscall_halt; break; | 207 | case SYS_HALT: fp = syscall_halt; break; |
| @@ -217,7 +220,7 @@ syscall_handler (struct intr_frame *f) | |||
| 217 | default: | 220 | default: |
| 218 | goto fail; | 221 | goto fail; |
| 219 | } | 222 | } |
| 220 | result = fp (sp, &segfault); | 223 | result = fp (syscall_sp, &segfault); |
| 221 | if (segfault) | 224 | if (segfault) |
| 222 | goto fail; | 225 | goto fail; |
| 223 | f->eax = result; | 226 | f->eax = result; |
