rewrite the device subsystem interfaces (#48)
[lunaix-os.git] / lunaix-os / kernel / kinit.c
index a08418303f030c558e36a425d1172990eb9d5722..38804f2f58d0d63dfe665fc04d3989a93bdfbbe8 100644 (file)
@@ -2,13 +2,14 @@
 #include <lunaix/block.h>
 #include <lunaix/boot_generic.h>
 #include <lunaix/device.h>
 #include <lunaix/block.h>
 #include <lunaix/boot_generic.h>
 #include <lunaix/device.h>
-#include <lunaix/foptions.h>
 #include <lunaix/input.h>
 #include <lunaix/input.h>
+
 #include <lunaix/mm/cake.h>
 #include <lunaix/mm/pmm.h>
 #include <lunaix/mm/page.h>
 #include <lunaix/mm/valloc.h>
 #include <lunaix/mm/vmm.h>
 #include <lunaix/mm/cake.h>
 #include <lunaix/mm/pmm.h>
 #include <lunaix/mm/page.h>
 #include <lunaix/mm/valloc.h>
 #include <lunaix/mm/vmm.h>
+
 #include <lunaix/process.h>
 #include <lunaix/sched.h>
 #include <lunaix/spike.h>
 #include <lunaix/process.h>
 #include <lunaix/sched.h>
 #include <lunaix/spike.h>
 #include <lunaix/syslog.h>
 #include <lunaix/sections.h>
 
 #include <lunaix/syslog.h>
 #include <lunaix/sections.h>
 
-#include <hal/acpi/acpi.h>
 #include <hal/devtree.h>
 
 #include <hal/devtree.h>
 
-#include <sys/abi.h>
-#include <sys/mm/mm_defs.h>
-
-#include <klibc/strfmt.h>
-#include <klibc/string.h>
+#include <asm/mm_defs.h>
 
 LOG_MODULE("kinit")
 
 
 LOG_MODULE("kinit")
 
@@ -59,7 +55,7 @@ kmem_init(struct boot_handoff* bhctx)
 
     unsigned int i = ptep_vfn(ptep);
     do {
 
     unsigned int i = ptep_vfn(ptep);
     do {
-        if (l0tep_implie_vmnts(ptep)) {
+        if (lntep_implie_vmnts(ptep, L0T_SIZE)) {
             ptep++;
             continue;
         }
             ptep++;
             continue;
         }
@@ -118,8 +114,6 @@ __remap_and_load_dtb(struct boot_handoff* bhctx)
 void
 kernel_bootstrap(struct boot_handoff* bhctx)
 {
 void
 kernel_bootstrap(struct boot_handoff* bhctx)
 {
-    vmm_init();
-
     pmm_init(bhctx);
     // now we can start reserving physical space
 
     pmm_init(bhctx);
     // now we can start reserving physical space
 
@@ -129,7 +123,6 @@ kernel_bootstrap(struct boot_handoff* bhctx)
     /* Setup kernel memory layout and services */
     kmem_init(bhctx);
 
     /* Setup kernel memory layout and services */
     kmem_init(bhctx);
 
-    __remap_and_load_dtb(bhctx);
 
     boot_parse_cmdline(bhctx);
 
 
     boot_parse_cmdline(bhctx);
 
@@ -138,19 +131,19 @@ kernel_bootstrap(struct boot_handoff* bhctx)
 
     device_scan_drivers();
 
 
     device_scan_drivers();
 
+    initfn_invoke_sysconf();
+    
+    __remap_and_load_dtb(bhctx);
     device_sysconf_load();
 
     device_sysconf_load();
 
-    invoke_init_function(on_earlyboot);
+    // TODO register devtree hooks
+    // TODO re-scan devtree to bind devices.
 
     clock_init();
     timer_init();
 
 
     clock_init();
     timer_init();
 
-    /*
-        TODO autoload these init function that do not have dependency between
-       them
-    */
+    initfn_invoke_earlyboot();
 
 
-    /* Let's get fs online as soon as possible, as things rely on them */
     vfs_init();
     fsm_init();
     input_init();
     vfs_init();
     fsm_init();
     input_init();
@@ -164,7 +157,7 @@ kernel_bootstrap(struct boot_handoff* bhctx)
     must_success(vfs_mount_root("ramfs", NULL));
     must_success(vfs_mount("/dev", "devfs", NULL, 0));
     
     must_success(vfs_mount_root("ramfs", NULL));
     must_success(vfs_mount("/dev", "devfs", NULL, 0));
     
-    invoke_init_function(on_boot);
+    initfn_invoke_boot();
 
     /* Finish up bootstrapping sequence, we are ready to spawn the root process
      * and start geting into uspace
 
     /* Finish up bootstrapping sequence, we are ready to spawn the root process
      * and start geting into uspace