updated readme, fix configuration shell invoked twice.
[lunaix-os.git] / lunaix-os / kernel / boot_helper.c
index 365295933282e151a5d79a4e5aab10b5154bfb10..37e6bb4775ce991c1522c7e59d54a6ecae1f8e1c 100644 (file)
@@ -4,9 +4,8 @@
 #include <lunaix/mm/vmm.h>
 #include <lunaix/spike.h>
 #include <lunaix/kcmd.h>
 #include <lunaix/mm/vmm.h>
 #include <lunaix/spike.h>
 #include <lunaix/kcmd.h>
-#include <sys/mm/mm_defs.h>
-
-extern unsigned char __kexec_end[], __kexec_start[];
+#include <lunaix/sections.h>
+#include <asm/mm_defs.h>
 
 /**
  * @brief Reserve memory for kernel bootstrapping initialization
 
 /**
  * @brief Reserve memory for kernel bootstrapping initialization
@@ -21,7 +20,7 @@ boot_begin(struct boot_handoff* bhctx)
     boot_begin_arch_reserve(bhctx);
     
     // 将内核占据的页,包括前1MB,hhk_init 设为已占用
     boot_begin_arch_reserve(bhctx);
     
     // 将内核占据的页,包括前1MB,hhk_init 设为已占用
-    size_t pg_count = leaf_count(to_kphysical(__kexec_end));
+    size_t pg_count = leaf_count(to_kphysical(kernel_load_end));
     pmm_onhold_range(0, pg_count);
 
     size_t i;
     pmm_onhold_range(0, pg_count);
 
     size_t i;
@@ -44,7 +43,20 @@ boot_begin(struct boot_handoff* bhctx)
     }
 }
 
     }
 }
 
-extern u8_t __kboot_end; /* link/linker.ld */
+static void
+__free_reclaimable()
+{
+    ptr_t start;
+    pfn_t pgs;
+    pte_t* ptep;
+
+    start = reclaimable_start;
+    pgs   = leaf_count(reclaimable_end - start);
+    ptep  = mkptep_va(VMS_SELF, start);
+
+    pmm_unhold_range(pfn(to_kphysical(start)), pgs);
+    vmm_unset_ptes(ptep, pgs);
+}
 
 /**
  * @brief Release memory for kernel bootstrapping initialization
 
 /**
  * @brief Release memory for kernel bootstrapping initialization
@@ -67,6 +79,8 @@ boot_end(struct boot_handoff* bhctx)
     bhctx->release(bhctx);
 
     boot_clean_arch_reserve(bhctx);
     bhctx->release(bhctx);
 
     boot_clean_arch_reserve(bhctx);
+
+    __free_reclaimable();
 }
 
 void
 }
 
 void