System call interface.
authorBen Pfaff <blp@cs.stanford.edu>
Sun, 5 Sep 2004 08:30:04 +0000 (08:30 +0000)
committerBen Pfaff <blp@cs.stanford.edu>
Sun, 5 Sep 2004 08:30:04 +0000 (08:30 +0000)
src/Makefile.inc
src/threads/init.c
src/userprog/syscall.c [new file with mode: 0644]
src/userprog/syscall.h [new file with mode: 0644]

index 9d929095583ee700d38edd600e87270ce2e44ce9..885c6bba53ccefb1fa7d464ca75e459f9cd5bfb2 100644 (file)
@@ -51,6 +51,7 @@ FILESYS_SRC += fsutil.c               # Utilities.
 # User process code.
 USERPROG_SRC  = addrspace.c    # Address spaces.
 USERPROG_SRC += exception.c    # User exception handler.
+USERPROG_SRC += syscall.c      # System call handler.
 USERPROG_SRC += gdt.c          # GDT initialization.
 USERPROG_SRC += tss.c          # TSS management.
 
index b099d02dd33ccbb8fb88889b821cde91ab772ad5..57f3cbe6646d65d66df3c3d233d5160c5e3cba63 100644 (file)
@@ -19,6 +19,7 @@
 #include "vga.h"
 #ifdef USERPROG
 #include "exception.h"
+#include "syscall.h"
 #include "gdt.h"
 #include "tss.h"
 #endif
@@ -79,6 +80,7 @@ main (void)
   kbd_init ();
 #ifdef USERPROG
   exception_init ();
+  syscall_init ();
 #endif
 
   /* Start thread scheduler and enable interrupts. */
diff --git a/src/userprog/syscall.c b/src/userprog/syscall.c
new file mode 100644 (file)
index 0000000..6084726
--- /dev/null
@@ -0,0 +1,19 @@
+#include "syscall.h"
+#include "lib.h"
+#include "interrupt.h"
+#include "thread.h"
+
+static void syscall_handler (struct intr_frame *);
+
+void
+syscall_init (void) 
+{
+  intr_register (0x30, 3, INTR_ON, syscall_handler, "syscall");
+}
+
+static void
+syscall_handler (struct intr_frame *f) 
+{
+  printk ("system call!\n");
+  thread_exit ();
+}
diff --git a/src/userprog/syscall.h b/src/userprog/syscall.h
new file mode 100644 (file)
index 0000000..f57676c
--- /dev/null
@@ -0,0 +1,6 @@
+#ifndef HEADER_SYSCALL_H
+#define HEADER_SYSCALL_H 1
+
+void syscall_init (void);
+
+#endif /* syscall.h */