#include <stdint.h>
#include <stddef.h>
#include <limits.h>
-#include "debug.h"
#include "interrupt.h"
#include "io.h"
-#include "kbd.h"
-#include "lib.h"
#include "loader.h"
#include "malloc.h"
#include "mmu.h"
#include "paging.h"
#include "palloc.h"
-#include "random.h"
-#include "serial.h"
#include "thread.h"
-#include "timer.h"
-#include "vga.h"
+#include "devices/kbd.h"
+#include "devices/serial.h"
+#include "devices/timer.h"
+#include "devices/vga.h"
+#include "lib/debug.h"
+#include "lib/lib.h"
+#include "lib/random.h"
#ifdef USERPROG
-#include "exception.h"
-#include "gdt.h"
-#include "tss.h"
+#include "userprog/exception.h"
+#include "userprog/gdt.h"
+#include "userprog/syscall.h"
+#include "userprog/tss.h"
#endif
#ifdef FILESYS
-#include "filesys.h"
-#include "disk.h"
-#include "fsutil.h"
+#include "devices/disk.h"
+#include "filesys/filesys.h"
+#include "filesys/fsutil.h"
#endif
/* Amount of physical memory, in 4 kB pages. */
static char *initial_program;
#endif
-static thread_func main_thread;
static void ram_init (void);
static void argv_init (void);
+int main (void) NO_RETURN;
+
int
main (void)
{
argv_init ();
/* Initialize memory system, segments, paging. */
+ thread_init ();
palloc_init ();
paging_init ();
#ifdef USERPROG
kbd_init ();
#ifdef USERPROG
exception_init ();
+ syscall_init ();
#endif
- /* Do everything else in a system thread. */
- thread_init ();
- thread_create ("main", main_thread, NULL);
+ /* Start thread scheduler and enable interrupts. */
thread_start ();
-}
-/* Initial thread. */
-static void
-main_thread (void *aux UNUSED)
-{
#ifdef FILESYS
+ /* Initialize filesystem. */
disk_init ();
filesys_init (format_filesys);
fsutil_run ();
#endif
+ printk ("Boot complete.\n");
+
#ifdef USERPROG
+ /* Run a user program. */
if (initial_program != NULL)
- thread_execute (initial_program);
- else
- PANIC ("no initial program specified");
-#else
- PANIC ("boot successful");
+ {
+ printk ("\nExecuting '%s':\n", initial_program);
+ thread_execute (initial_program);
+ }
#endif
+
+ /* Terminate this thread. */
+ thread_exit ();
}
\f
/* Clear BSS and obtain RAM size from loader. */