Move filesys_init into main_thread.
[pintos-anon] / src / threads / init.c
index 6da714e124a125bf1fee5e7ec63f28cc96d04364..6e06f2faab178c8ee83a01051355ef42dded2956 100644 (file)
@@ -18,6 +18,7 @@
 #include "vga.h"
 #ifdef FILESYS
 #include "filesys.h"
+#include "disk.h"
 #endif
 
 /* Size of kernel static code and data, in 4 kB pages. */
@@ -32,7 +33,12 @@ void power_off (void);
 static void
 main_thread (void *aux UNUSED) 
 {
-  thread_execute ("a.out");
+  disk_init ();
+
+#ifdef FILESYS
+  filesys_init (true);
+#endif
+  filesys_self_test ();
 }
 
 int
@@ -44,16 +50,16 @@ main (void)
   /* Clear out the BSS segment. */
   memset (&__bss_start, 0, &_end - &__bss_start);
 
+  /* Initialize components needed by printk() very early. */
   vga_init ();
   serial_init ();
+  printk ("Booting cnachos86...\n");
 
   /* Calculate how much RAM the kernel uses, and find out from
      the bootloader how much RAM this machine has. */
   kernel_pages = (&_end - &_text + 4095) / 4096;
   ram_pages = *(uint32_t *) (0x7e00 - 6);
-
-  printk ("Initializing nachos-x86, %d kB RAM detected.\n",
-          ram_pages * 4);
+  printk ("ram: detected %'d kB main memory.\n", ram_pages * 4);
 
   /* Memory from the end of the kernel through the end of memory
      is free.  Give it to the page allocator. */
@@ -69,10 +75,6 @@ main (void)
   timer_init ();
   kbd_init ();
 
-#ifdef FILESYS
-  filesys_init (false);
-#endif
-
   thread_init ();
 
   t = thread_create ("main", main_thread, NULL);