summaryrefslogtreecommitdiff
path: root/i386/i386/mp_desc.c
diff options
context:
space:
mode:
authorAlmuHS <almuhs@github.com>2019-07-08 21:14:52 +0200
committerAlmuHS <almuhs@github.com>2019-07-08 21:14:52 +0200
commit1b05999a3d13b1c7ad9a57bfb85b8e69ec9a6c96 (patch)
treed56da0a123ea6efc8021b8206693f5eb7e5d22ce /i386/i386/mp_desc.c
parente4df7e2dc4d1d97900d3189a76a8116934b5467a (diff)
experiment: move paging enabling to C
Diffstat (limited to 'i386/i386/mp_desc.c')
-rw-r--r--i386/i386/mp_desc.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/i386/i386/mp_desc.c b/i386/i386/mp_desc.c
index 3bb207b1..e9834111 100644
--- a/i386/i386/mp_desc.c
+++ b/i386/i386/mp_desc.c
@@ -367,6 +367,34 @@ cpu_setup()
return 0;
}
+void paging_setup(){
+
+#if PAE
+ set_cr3(pdpbase_addr);
+#ifndef MACH_HYP
+ if (!CPU_HAS_FEATURE(CPU_FEATURE_PAE))
+ set_cr4(get_cr4() | CR4_PAE);
+#endif /* MACH_HYP */
+#else
+ set_cr3(kernel_page_dir_addr);
+#endif /* PAE */
+#ifndef MACH_HYP
+ /* Turn paging on.
+ * Also set the WP bit so that on 486 or better processors
+ * page-level write protection works in kernel mode.
+ */
+ set_cr0(get_cr0() | CR0_PG | CR0_WP);
+ set_cr0(get_cr0() & ~(CR0_CD | CR0_NW));
+
+ if (CPU_HAS_FEATURE(CPU_FEATURE_PGE))
+ set_cr4(get_cr4() | CR4_PGE);
+
+#endif /* MACH_HYP */
+
+ flush_instr_queue();
+ flush_tlb();
+
+}
int
cpu_ap_main()