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 85 additions and 125 deletions
Showing only changes of commit 0d057da3dc - Show all commits

View File

@@ -20,14 +20,16 @@ static void exit (int status);
static void *validate_user_pointer (void *ptr, size_t size); static void *validate_user_pointer (void *ptr, size_t size);
/* A struct defining a syscall_function pointer along with its arity. */ /* A struct defining a syscall_function pointer along with its arity. */
typedef struct { typedef struct
{
syscall_function function; /* Function pointer. */ syscall_function function; /* Function pointer. */
int arity; /* Number of arguments of the function. */ int arity; /* Number of arguments of the function. */
} syscall_arguments; } syscall_arguments;
/* A look-up table mapping numbers to system call functions with their number of /* A look-up table mapping numbers to system call functions with their number of
arguments. */ arguments. */
static const syscall_arguments syscall_lookup[] = { static const syscall_arguments syscall_lookup[] =
{
[SYS_HALT] = {(syscall_function) halt, 0}, [SYS_HALT] = {(syscall_function) halt, 0},
[SYS_EXIT] = {(syscall_function) exit, 1}, [SYS_EXIT] = {(syscall_function) exit, 1},
}; };