Refactor syscall to follow PintOS style in adding space after after function name in calls
This commit is contained in:
@@ -17,17 +17,19 @@ typedef uintptr_t (*syscall_function) (uintptr_t, uintptr_t, uintptr_t);
|
|||||||
static void halt (void);
|
static void halt (void);
|
||||||
static void exit (int status);
|
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. */
|
{
|
||||||
int arity; /* Number of arguments of the function. */
|
syscall_function function; /* Function pointer. */
|
||||||
} syscall_arguments;
|
int arity; /* Number of arguments of the function. */
|
||||||
|
} 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},
|
||||||
};
|
};
|
||||||
@@ -47,7 +49,7 @@ static void
|
|||||||
syscall_handler (struct intr_frame *f)
|
syscall_handler (struct intr_frame *f)
|
||||||
{
|
{
|
||||||
/* First, read the system call number from the stack. */
|
/* First, read the system call number from the stack. */
|
||||||
validate_user_pointer(f->esp, 1);
|
validate_user_pointer (f->esp, 1);
|
||||||
int syscall_number = *(int *) f->esp;
|
int syscall_number = *(int *) f->esp;
|
||||||
|
|
||||||
/* Ensures the number corresponds to a system call that can be handled. */
|
/* Ensures the number corresponds to a system call that can be handled. */
|
||||||
@@ -65,7 +67,7 @@ syscall_handler (struct intr_frame *f)
|
|||||||
|
|
||||||
/* 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. */
|
||||||
f->eax = syscall.function(args[0], args[1], args[2]);
|
f->eax = syscall.function (args[0], args[1], args[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|||||||
Reference in New Issue
Block a user