_M procs start up at _start/hart_entry for vcore0
[akaros.git] / kern / src / init.c
index 3981ea2..889974a 100644 (file)
@@ -4,8 +4,8 @@
 #pragma nosharc
 #endif
 
-#ifdef __BSD_ON_CORE_0__
-#include Everything For Free -- It just works!!
+#ifdef __CONFIG_BSD_ON_CORE0__
+#error "Yeah, it's not possible to build ROS with BSD on Core 0, sorry......"
 #else
 
 #include <arch/arch.h>
 #include <kclock.h>
 #include <manager.h>
 #include <testing.h>
+#include <kmalloc.h>
+#include <hashtable.h>
+#include <mm.h>
+#include <frontend.h>
 
-#ifdef __i386__
-#include <arch/rl8168.h>
-#include <arch/ne2k.h>
-#include <arch/mptables.h>
-#include <arch/pci.h>
-#include <arch/ioapic.h>
-#endif
+#include <arch/init.h>
+#include <arch/bitmask.h>
+#include <slab.h>
+#include <kfs.h>
+
+// zra: flag for Ivy
+int booting = 1;
 
 void kernel_init(multiboot_info_t *mboot_info)
 {
-       extern char (BND(__this, end) edata)[], (SNT end)[];
+       extern char (RO BND(__this, end) edata)[], (RO SNT end)[];
 
        // Before doing anything else, complete the ELF loading process.
        // Clear the uninitialized global data (BSS) section of our program.
@@ -57,48 +61,36 @@ void kernel_init(multiboot_info_t *mboot_info)
        // Paul: Can't use KADDR as arg to multiboot_detect_memory
        //  since multiboot_detect_memory is what sets npages. 
        //  Must simulate KADDR macro (ugly).
-       multiboot_detect_memory((multiboot_info_t*SAFE)(void*TRUSTED)((physaddr_t)mboot_info + KERNBASE));
-       
-       multiboot_print_memory_map((multiboot_info_t*COUNT(1))KADDR((physaddr_t)mboot_info));
-
-       vm_init();
-
-       cache_init();
-       page_init();
+       multiboot_detect_memory((multiboot_info_t*CT(1))TC((physaddr_t)mboot_info + KERNBASE));
+
+       multiboot_print_memory_map((multiboot_info_t*CT(1))KADDR((physaddr_t)mboot_info));
+
+       vm_init();                      // Sets up pages tables, turns on paging
+       cache_init();                                   // Determine systems's cache properties
+       page_init();                                    // Initializes free page list, etc
+       kmem_cache_init();              // Sets up slab allocator
+       kmalloc_init();
+       hashtable_init();
+       cache_color_alloc_init();       // Inits data structs
+       colored_page_alloc_init();      // Allocates colors for agnostic processes
+       mmap_init();
+       file_init();
        page_check();
-       //test_page_coloring();
 
        idt_init();
+       kernel_msg_init();
        sysenter_init();
        timer_init();
        
-       // @todo: Add an arch specific init? This is ugly
-       #ifdef __i386__
-       mptables_parse();
-       pci_init();
-       ioapic_init(); // MUST BE AFTER PCI/ISA INIT!
-       #endif // __i386__
+       // At this point our boot paths diverge based on arch. 
+       arch_init();
                
-       // this returns when all other cores are done and ready to receive IPIs
-       smp_boot();
-       env_init();
-       
+//     printk("Starting tests....\n");
+//     test_color_alloc();
+//     printk("Testing complete....\n");
 
-       /* EXPERIMENTAL NETWORK FUNCTIONALITY
-        * To enable, define __NETWORK__ in your Makelocal
-        * If enabled, will load the rl8168 driver (if device exists)
-        * and will a boot into userland matrix, so remote syscalls can be performed.
-        * If in simulation, will do some debugging information with the ne2k device
-        *
-        * Note: If you use this, you should also define the mac address of the 
-        * teathered machine via USER_MAC_ADDRESS in Makelocal.
-        *
-        * Additionally, you should have a look at the syscall server in the tools directory
-        */
-       #ifdef __NETWORK__
-       rl8168_init();          
-       ne2k_init();
-       #endif // __NETWORK__
+       // zra: let's Ivy know we're done booting
+       booting = 0;
 
        manager();
 }