summaryrefslogtreecommitdiff
path: root/i386/i386/mp_desc.c
diff options
context:
space:
mode:
authorAlmuHS <almuhs@github.com>2019-05-18 15:43:31 +0200
committerAlmuHS <almuhs@github.com>2019-05-18 15:43:31 +0200
commit52718c4771f60393ac64ce52ea0e565208d76c3d (patch)
tree909e694336077347724ac4d854ee1abba1dfc88f /i386/i386/mp_desc.c
parentb3b57ac8bfe7e1c956aa148e8ea14007002a8d7e (diff)
experiment: configure pmap from C function
Diffstat (limited to 'i386/i386/mp_desc.c')
-rw-r--r--i386/i386/mp_desc.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/i386/i386/mp_desc.c b/i386/i386/mp_desc.c
index 7117a96f..5e3899b7 100644
--- a/i386/i386/mp_desc.c
+++ b/i386/i386/mp_desc.c
@@ -51,6 +51,7 @@
#include <string.h>
#include <include/stdint.h> //uint16_t, uint32_t_t...
#include <imps/apic.h>
+#include <i386/locore.h>
/*
* The i386 needs an interrupt stack to keep the PCB stack from being
@@ -153,6 +154,8 @@ void* stack_ptr = 0;
#define SEND_PENDING 1
extern int lapic_addr;
+extern pt_entry_t *kernel_page_dir;
+
/*
* Allocate and initialize the per-processor descriptor tables.
@@ -290,6 +293,42 @@ void startup_cpu(uint32_t apic_id)
}
+void pmap_conf()
+{
+#ifdef MACH_PV_PAGETABLES
+ for (i = 0; i < PDPNUM; i++)
+ pmap_set_page_readonly_init((void*) kernel_page_dir + i * INTEL_PGBYTES);
+#if PAE
+ pmap_set_page_readonly_init(kernel_pmap->pdpbase);
+#endif /* PAE */
+#endif /* MACH_PV_PAGETABLES */
+#if PAE
+ set_cr3((unsigned)_kvtophys(kernel_pmap->pdpbase));
+#ifndef MACH_HYP
+ if (!CPU_HAS_FEATURE(CPU_FEATURE_PAE))
+ panic("CPU doesn't have support for PAE.");
+ set_cr4(get_cr4() | CR4_PAE);
+#endif /* MACH_HYP */
+#else
+ set_cr3((unsigned)_kvtophys(kernel_page_dir));
+#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();
+#ifdef MACH_PV_PAGETABLES
+ pmap_clear_bootstrap_pagetable((void *)boot_info.pt_base);
+#endif /* MACH_PV_PAGETABLES */
+
+}
+
int
cpu_setup()
{