Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Pintos
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Project Purple Stallion
Pintos
Commits
92c02b48
Commit
92c02b48
authored
6 years ago
by
Shancang Li
Browse files
Options
Downloads
Patches
Plain Diff
Delete #syscall.c#
parent
84e4546c
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
userprog/#syscall.c#
+0
-106
0 additions, 106 deletions
userprog/#syscall.c#
with
0 additions
and
106 deletions
userprog/#syscall.c#
deleted
100644 → 0
+
0
−
106
View file @
84e4546c
#include "userprog/syscall.h"
#include <stdio.h>
#include <syscall-nr.h>
#include "threads/interrupt.h"
#include "threads/thread.h"
static void syscall_handler (struct intr_frame *);
void
syscall_init (void)
{
intr_register_int (0x30, 3, INTR_ON, syscall_handler, "syscall");
}
#if defined(BEN_MODS)
static uint32_t load_stack(struct intr_frame *f, int offset)
{
// need to add check for valid address
// i.e. user can do bad things
return *((uint32_t*)(f->esp + offset));
}
static void handle_halt(void)
{
printf("handle_halt\n");
}
static void handle_exit(int status)
{
struct thread * current = thread_current();
current->process_info->exit_status = status;
thread_exit();
}
static tid_t handle_exec(const char *file)
{
printf("handle_exec\n");
return 0;
}
static int handle_wait(tid_t tid)
{
printf("handle_wait\n");
return 0;
}
// file stuff
static int handle_write(int fd, const void * buffer, unsigned int length)
{
// TODO: @bgaster -- validate fd and buffer ptr
if (fd == STDOUT_FILENO) {
putbuf((const char *)buffer, (size_t)length);
}
else {
printf("handle_write does not support fd output\n");
}
return length;
}
#define ARG_CODE 0
#define ARG_1 4
#define ARG_2 8
#define ARG_3 12
#endif
static void
#if defined(BEN_MODS)
syscall_handler (struct intr_frame *f)
#else
syscall_handler (struct intr_frame *f UNUSED)
#endif
{
#if defined(BEN_MODS)
int code = (int)load_stack(f, ARG_CODE);
switch (code) {
case SYS_EXIT:
handle_exit((int)load_stack(f,ARG_1));
break; // will not return here
case SYS_WRITE:
{
int result = handle_write(
(int)load_stack(f,ARG_1),
(void *)load_stack(f, ARG_2),
(unsigned int)load_stack(f, ARG_3));
// set return value
f->eax = result;
break;
}
default:
printf("SYS_CALL (%d) not implemented\n", code);
thread_exit ();
}
#else
printf ("system call!\n");
thread_exit ();
#endif
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment