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 38 additions and 122 deletions
Showing only changes of commit 62453ef432 - Show all commits

View File

@@ -10,12 +10,24 @@ static void syscall_handler (struct intr_frame *);
/* A syscall_function is a function that receives up to 3 arguments, the /* A syscall_function is a function that receives up to 3 arguments, the
arguments to the functions are either ints or pointers taking up to 32 bits arguments to the functions are either ints or pointers taking up to 32 bits
in size. */ in size. */
typedef uintptr_t syscall_function (uintptr_t, uintptr_t, uintptr_t); typedef uintptr_t (*syscall_function) (uintptr_t, uintptr_t, uintptr_t);
/* System Call Functions */ /* System Call Functions */
static void halt (void); static void halt (void);
static void exit (int status); static void exit (int status);
/* A struct defining a pair of a syscall_function along with its arity. */
typedef struct {
syscall_function function;
int arity;
} syscall_arguments;
/* A look-up table for system call functions mapped using their numbers. */
static const syscall_arguments syscall_lookup[] = {
[SYS_HALT] = {(syscall_function) halt, 0},
[SYS_EXIT] = {(syscall_function) exit, 1},
};
void void
syscall_init (void) syscall_init (void)
{ {