Complete syscall lookup table, and syscall stubs and skeletons w/ S.
This commit is contained in:
@@ -16,6 +16,17 @@ 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);
|
||||||
|
static pid_t exec (const char *cmd_line);
|
||||||
|
static int wait (pid_t pid);
|
||||||
|
static bool file_create (const char *file, unsigned initial_size);
|
||||||
|
static bool file_remove (const char *file);
|
||||||
|
static int open (const char *file);
|
||||||
|
static int filesize (int fd);
|
||||||
|
static int read (int fd, void *buffer, unsigned size);
|
||||||
|
static int write (int fd, const void *buffer, unsigned size);
|
||||||
|
static void seek (int fd, unsigned position);
|
||||||
|
static unsigned tell (int fd);
|
||||||
|
static void close (int fd);
|
||||||
|
|
||||||
static void *validate_user_pointer(void *ptr, size_t size);
|
static void *validate_user_pointer(void *ptr, size_t size);
|
||||||
|
|
||||||
@@ -29,6 +40,17 @@ typedef struct {
|
|||||||
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},
|
||||||
|
[SYS_EXEC] = {(syscall_function) exec, 1},
|
||||||
|
[SYS_WAIT] = {(syscall_function) wait, 1},
|
||||||
|
[SYS_CREATE] = {(syscall_function) file_create, 2},
|
||||||
|
[SYS_REMOVE] = {(syscall_function) file_remove, 1},
|
||||||
|
[SYS_OPEN] = {(syscall_function) open, 1},
|
||||||
|
[SYS_FILESIZE] = {(syscall_function) filesize, 1},
|
||||||
|
[SYS_READ] = {(syscall_function) read, 3},
|
||||||
|
[SYS_WRITE] = {(syscall_function) write, 3},
|
||||||
|
[SYS_SEEK] = {(syscall_function) seek, 2},
|
||||||
|
[SYS_TELL] = {(syscall_function) tell, 1},
|
||||||
|
[SYS_CLOSE] = {(syscall_function) close, 1},
|
||||||
};
|
};
|
||||||
|
|
||||||
static const int lookup_size
|
static const int lookup_size
|
||||||
@@ -72,6 +94,81 @@ exit (int status)
|
|||||||
//TODO
|
//TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static pid_t
|
||||||
|
exec (const char *cmd_line)
|
||||||
|
{
|
||||||
|
//TODO
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
wait (pid_t pid)
|
||||||
|
{
|
||||||
|
//TODO
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool
|
||||||
|
file_create (const char *file, unsigned initial_size)
|
||||||
|
{
|
||||||
|
//TODO
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool
|
||||||
|
file_remove (const char *file)
|
||||||
|
{
|
||||||
|
//TODO
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
open (const char *file)
|
||||||
|
{
|
||||||
|
//TODO
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
filesize (int fd)
|
||||||
|
{
|
||||||
|
//TODO
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
read (int fd, void *buffer, unsigned size)
|
||||||
|
{
|
||||||
|
//TODO
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
write (int fd, const void *buffer, unsigned size)
|
||||||
|
{
|
||||||
|
//TODO
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
seek (int fd, unsigned position)
|
||||||
|
{
|
||||||
|
//TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
static unsigned
|
||||||
|
tell (int fd)
|
||||||
|
{
|
||||||
|
//TODO
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
close (int fd)
|
||||||
|
{
|
||||||
|
//TODO
|
||||||
|
}
|
||||||
|
|
||||||
/* A function to validate if a block of memory starting at PTR and of
|
/* A function to validate if a block of memory starting at PTR and of
|
||||||
size SIZE bytes is fully contained within user virtual memory. */
|
size SIZE bytes is fully contained within user virtual memory. */
|
||||||
static void *
|
static void *
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
#ifndef USERPROG_SYSCALL_H
|
#ifndef USERPROG_SYSCALL_H
|
||||||
#define USERPROG_SYSCALL_H
|
#define USERPROG_SYSCALL_H
|
||||||
|
|
||||||
|
typedef int pid_t;
|
||||||
|
|
||||||
void syscall_init (void);
|
void syscall_init (void);
|
||||||
|
|
||||||
#endif /* userprog/syscall.h */
|
#endif /* userprog/syscall.h */
|
||||||
|
|||||||
Reference in New Issue
Block a user