Update initialization order.
[pintos-anon] / src / threads / init.c
index 57f3cbe6646d65d66df3c3d233d5160c5e3cba63..4859d425d712df888229d10c9dda4c539210f163 100644 (file)
@@ -1,32 +1,36 @@
-#include "init.h"
-#include <stdint.h>
-#include <stddef.h>
+#include "threads/init.h"
+#include <console.h>
+#include <debug.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 <random.h>
+#include <stddef.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "devices/kbd.h"
+#include "devices/serial.h"
+#include "devices/timer.h"
+#include "devices/vga.h"
+#include "threads/interrupt.h"
+#include "threads/io.h"
+#include "threads/loader.h"
+#include "threads/malloc.h"
+#include "threads/mmu.h"
+#include "threads/paging.h"
+#include "threads/palloc.h"
+#include "threads/test.h"
+#include "threads/thread.h"
 #ifdef USERPROG
-#include "exception.h"
-#include "syscall.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. */
@@ -50,19 +54,20 @@ int main (void) NO_RETURN;
 int
 main (void)
 {
-  /* Needed by printk(), so initialize them very early. */
+  /* Initialize everything needed for printf() first. */
   ram_init ();
+  thread_init ();
   vga_init ();
-  serial_init ();
+  serial_init_poll ();
+  console_init ();
 
   /* Greet user. */
-  printk ("Booting cnachos86 with %'d kB RAM...\n", ram_pages * 4);
+  printf ("Pintos booting with %'d kB RAM...\n", ram_pages * 4);
 
   /* Parse command line. */
   argv_init ();
 
   /* Initialize memory system, segments, paging. */
-  thread_init ();
   palloc_init ();
   paging_init ();
 #ifdef USERPROG
@@ -71,7 +76,7 @@ main (void)
 #endif
   malloc_init ();
 
-  /* Set random seed if not already done. */
+  /* Set random seed if argv_init() didn't. */
   random_init (0);
 
   /* Initialize interrupt handlers. */
@@ -85,6 +90,7 @@ main (void)
 
   /* Start thread scheduler and enable interrupts. */
   thread_start ();
+  serial_init_queue ();
 
 #ifdef FILESYS
   /* Initialize filesystem. */
@@ -93,15 +99,17 @@ main (void)
   fsutil_run ();
 #endif
 
-  printk ("Boot complete.\n");
-
+  printf ("Boot complete.\n");
+  
 #ifdef USERPROG
   /* Run a user program. */
   if (initial_program != NULL)
     {
-      printk ("\nExecuting '%s':\n", initial_program);
+      printf ("\nExecuting '%s':\n", initial_program);
       thread_execute (initial_program); 
     }
+#else
+  test ();
 #endif
 
   /* Terminate this thread. */
@@ -173,7 +181,7 @@ argv_init (void)
 #endif
     else if (!strcmp (argv[i], "-u"))
       {
-        printk (
+        printf (
           "Kernel options:\n"
           " -rs SEED            Seed random seed to SEED.\n"
           " -d CLASS[,...]      Enable the given classes of debug messages.\n"