Merge basic system calls with stack set-up infrastructure #27

Merged
td1223 merged 31 commits from user-programs into user-programs-stdout 2024-11-06 22:21:28 +00:00
2 changed files with 83 additions and 125 deletions
Showing only changes of commit 79f6a8e808 - Show all commits

View File

@@ -57,10 +57,11 @@ syscall_handler (struct intr_frame *f)
syscall_arguments syscall = syscall_lookup[syscall_number]; syscall_arguments syscall = syscall_lookup[syscall_number];
/* Next, read and copy the arguments from the stack pointer. */ /* Next, read and copy the arguments from the stack pointer. */
validate_user_pointer (f->esp, syscall.arity); validate_user_pointer (f->esp + sizeof (uintptr_t),
uintptr_t args[3]; syscall.arity * sizeof (uintptr_t));
uintptr_t args[3] = {0};
for (int i=0; i < syscall.arity; i++) for (int i=0; i < syscall.arity; i++)
args[i] = *(uintptr_t *) (f->esp + 1 + i); args[i] = *(uintptr_t *) (f->esp + sizeof (uintptr_t) * (i + 1));
/* Call the function that handles this system call with the arguments. When /* Call the function that handles this system call with the arguments. When
there is a return value it is stored in f->eax. */ there is a return value it is stored in f->eax. */