9ns: Add fs_files and tree_files
[akaros.git] / kern / src / init.c
index a6a0553..1304f28 100644 (file)
 #include <process.h>
 #include <trap.h>
 #include <syscall.h>
-#include <kclock.h>
 #include <manager.h>
 #include <testing.h>
 #include <kmalloc.h>
 #include <hashtable.h>
 #include <radix.h>
 #include <mm.h>
-#include <frontend.h>
 #include <ex_table.h>
 #include <percpu.h>
 
@@ -41,9 +39,8 @@
 #include <blockdev.h>
 #include <ext2fs.h>
 #include <kthread.h>
-#include <console.h>
 #include <linker_func.h>
-#include <ip.h>
+#include <net/ip.h>
 #include <acpi.h>
 #include <coreboot_tables.h>
 
@@ -57,7 +54,8 @@
                }                                                                               \
        } while (0)
 
-int booting = 1;
+bool booting = TRUE;
+struct proc_global_info __proc_global_info;
 struct sysinfo_t sysinfo;
 static char boot_cmdline[MAX_BOOT_CMDLINE_SIZE];
 
@@ -118,6 +116,8 @@ static void extract_multiboot_cmdline(struct multiboot_info *mbi)
        }
 }
 
+static void __kernel_init_part_deux(void *arg);
+
 void kernel_init(multiboot_info_t *mboot_info)
 {
        extern char __start_bss[], __stop_bss[];
@@ -137,28 +137,30 @@ void kernel_init(multiboot_info_t *mboot_info)
        printk("Boot Command Line: '%s'\n", boot_cmdline);
 
        exception_table_init();
-       cache_init();                                   // Determine systems's cache properties
+       num_cores = get_early_num_cores();
        pmem_init(multiboot_kaddr);
-       kmem_cache_init();              // Sets up slab allocator
        kmalloc_init();
+       vmap_init();
        hashtable_init();
        radix_init();
-       cache_color_alloc_init();       // Inits data structs
-       colored_page_alloc_init();      // Allocates colors for agnostic processes
        acpiinit();
        topology_init();
        percpu_init();
        kthread_init();                                 /* might need to tweak when this happens */
        vmr_init();
-       file_init();
        page_check();
        idt_init();
+       /* After kthread_init and idt_init, we can use a real kstack. */
+       __use_real_kstack(__kernel_init_part_deux);
+}
+
+static void __kernel_init_part_deux(void *arg)
+{
        kernel_msg_init();
        timer_init();
        vfs_init();
        devfs_init();
-       train_timing();
-       kb_buf_init(&cons_buf);
+       time_init();
        arch_init();
        block_init();
        enable_irq();
@@ -169,13 +171,13 @@ void kernel_init(multiboot_info_t *mboot_info)
        devtabinit();
 
 #ifdef CONFIG_EXT2FS
-       mount_fs(&ext2_fs_type, "/dev/ramdisk", "/mnt", 0);
+       mount_fs(&ext2_fs_type, "/dev_vfs/ramdisk", "/mnt", 0);
 #endif /* CONFIG_EXT2FS */
 #ifdef CONFIG_ETH_AUDIO
        eth_audio_init();
 #endif /* CONFIG_ETH_AUDIO */
        get_coreboot_info(&sysinfo);
-       booting = 0;
+       booting = FALSE;
 
 #ifdef CONFIG_RUN_INIT_SCRIPT
        if (run_init_script()) {
@@ -207,12 +209,11 @@ static int run_init_script(void)
 
                /* Initialize l_argv with its first three arguments, but allocate space
                 * for all arguments as calculated above */
-               int static_args = 3;
+               int static_args = 2;
                int total_args = vargs + static_args;
                char *l_argv[total_args];
-               l_argv[0] = "";
-               l_argv[1] = "busybox";
-               l_argv[2] = "ash";
+               l_argv[0] = "/bin/bash";
+               l_argv[1] = "bash";
 
                /* Initialize l_argv with the rest of the arguments */
                int i = static_args;
@@ -254,12 +255,19 @@ void _panic(const char *file, int line, const char *fmt,...)
        cprintf("\n");
        va_end(ap);
 
-dead:
        monitor(NULL);
-       /* We could consider turning the lock checker back on here, but things are
-        * probably a mess anyways, and with it on we would probably lock up right
-        * away when we idle. */
-       //pcpui->__lock_checking_enabled++;
+       if (pcpui->cur_proc) {
+               printk("panic killing proc %d\n", pcpui->cur_proc->pid);
+               proc_destroy(pcpui->cur_proc);
+       }
+       /* Yikes!  We're claiming to be not in IRQ/trap ctx and not holding any
+        * locks.  Obviously we could be wrong, and could easily deadlock.  We could
+        * be in an IRQ handler, an unhandled kernel fault, or just a 'normal' panic
+        * in a syscall - any of which can involve unrestore invariants. */
+       pcpui->__ctx_depth = 0;
+       pcpui->lock_depth = 0;
+       if (pcpui->cur_kthread)
+               kth_panic_sysc(pcpui->cur_kthread);
        smp_idle();
 }