feat: capability list to enable greater flexibility of devices
[lunaix-os.git] / lunaix-os / kernel / boot_helper.c
index fa87bff5fae8777df9e121dbc998c85eacd74065..d50e471afedf868eebf78f78eb026038f6d985d8 100644 (file)
@@ -4,6 +4,7 @@
 #include <lunaix/mm/pmm.h>
 #include <lunaix/mm/vmm.h>
 #include <lunaix/spike.h>
+#include <lunaix/kcmd.h>
 #include <sys/mm/mempart.h>
 
 /**
@@ -32,6 +33,15 @@ boot_begin(struct boot_handoff* bhctx)
             vmm_set_mapping(VMS_SELF, pa, pa, PG_PREM_RW, VMAP_IGNORE);
         }
     }
+
+    /* Reserve region for all loaded modules */
+    for (size_t i = 0; i < bhctx->mods.mods_num; i++) {
+        struct boot_modent* mod = &bhctx->mods.entries[i];
+        pmm_mark_chunk_occupied(KERNEL_PID,
+                                PN(mod->start),
+                                CEIL(mod->end - mod->start, PG_SIZE_BITS),
+                                PP_FGLOCKED);
+    }
 }
 
 extern u8_t __kexec_boot_end; /* link/linker.ld */
@@ -79,4 +89,13 @@ boot_cleanup()
         vmm_del_mapping(VMS_SELF, (ptr_t)i);
         pmm_free_page(KERNEL_PID, (ptr_t)i);
     }
+}
+
+void
+boot_parse_cmdline(struct boot_handoff* bhctx) {
+    if (!bhctx->kexec.len) {
+        return;
+    }
+
+    kcmd_parse_cmdline(bhctx->kexec.cmdline);
 }
\ No newline at end of file