Nucleus
Barry Enable paging on all processors 4021434 (3 years, 3 months ago)
diff --git a/memory/paging.c b/memory/paging.c
index c7ebb30..bf90d0e 100644
--- a/memory/paging.c
+++ b/memory/paging.c
@@ -12,6 +12,8 @@
void copy_page_frame(uintptr_t src, uintptr_t dest);
+static page_dir_t kernelDir;
+
/* Switch page directory */
static void
switch_dir(page_dir_t dir)
@@ -93,7 +95,7 @@ void
init_paging(void)
{
uint16_t tbl, pg;
- page_dir_t kernelDir = alloc_frame();
+ kernelDir = alloc_frame();
page_table_t *kernelTables = (page_table_t *) kernelDir;
page_t *table;
for (tbl = 0; tbl < 1024; tbl++)
@@ -125,14 +127,8 @@ init_paging(void)
*/
/* Use kernel directory */
- switch_dir(kernelDir);
register_exception(14, early_page_fault_handler);
- asm volatile (
- "movl %%cr0, %%eax;"
- "orl $0x80000000, %%eax;"
- "movl %%eax, %%cr0"
- ::: "eax"
- );
+ cpu_load_paging();
/* Identity page the APIC registers */
set_page(lapicPtr, lapicPtr | PTE_PRESENT | PTE_WRITE | PTE_GLOBAL);
@@ -143,3 +139,19 @@ init_paging(void)
for (stk = 0xF0400000; stk < 0xF0800000; stk += PAGE_SIZE)
set_page(stk, alloc_frame() | PTE_PRESENT | PTE_WRITE);
}
+
+/* Enable paging on the current CPU */
+void
+cpu_load_paging(void)
+{
+ static cpu_t c = 0;
+ while (c != CPUID);
+ switch_dir(kernelDir);
+ asm volatile (
+ "movl %%cr0, %%eax;"
+ "orl $0x80000000, %%eax;"
+ "movl %%eax, %%cr0"
+ ::: "%eax"
+ );
+ c++;
+}