Architectural Support: x86_64 (#37)
[lunaix-os.git] / lunaix-os / arch / x86 / boot / boot_helper.c
diff --git a/lunaix-os/arch/x86/boot/boot_helper.c b/lunaix-os/arch/x86/boot/boot_helper.c
new file mode 100644 (file)
index 0000000..c5f0c46
--- /dev/null
@@ -0,0 +1,46 @@
+#include <lunaix/boot_generic.h>
+#include <lunaix/mm/pagetable.h>
+
+#include "sys/mm/mm_defs.h"
+
+#ifdef CONFIG_ARCH_X86_64
+
+void
+boot_begin_arch_reserve(struct boot_handoff* bhctx)
+{
+    return;
+}
+
+
+void
+boot_clean_arch_reserve(struct boot_handoff* bhctx)
+{
+    return;
+}
+
+#else
+
+#include <lunaix/mm/vmm.h>
+
+void
+boot_begin_arch_reserve(struct boot_handoff* bhctx)
+{
+    // Identity-map the first 3GiB address spaces
+    pte_t* ptep  = mkl0tep(mkptep_va(VMS_SELF, 0));
+    pte_t pte    = mkpte_prot(KERNEL_DATA);
+    size_t count = page_count(KERNEL_RESIDENT, L0T_SIZE);
+
+    vmm_set_ptes_contig(ptep, pte_mkhuge(pte), L0T_SIZE, count);
+}
+
+
+void
+boot_clean_arch_reserve(struct boot_handoff* bhctx)
+{
+    pte_t* ptep  = mkl0tep(mkptep_va(VMS_SELF, 0));
+    size_t count = page_count(KERNEL_RESIDENT, L0T_SIZE);
+    vmm_unset_ptes(ptep, count);
+}
+
+
+#endif
\ No newline at end of file