Compare commits

..

No commits in common. "73c58bd902bc92da361a052cb31909d9250d7f49" and "59d69f684f0962dd0fb0ce2c5954819b8fe735c9" have entirely different histories.

3 changed files with 16 additions and 20 deletions

View File

@ -143,8 +143,6 @@ namespace CPU
enable_sse();
enable_write_protect();
if (test_nx()) enable_nx();
else
kwarnln("not setting the NX bit as it is unsupported");
setup_gdt();
setup_idt();
}

View File

@ -24,11 +24,6 @@ void PageTableEntry::clear()
raw = 0;
}
static bool has_flag(int flags, MMU::Flags flag)
{
return flags & flag;
}
namespace MMU
{
@ -177,6 +172,7 @@ namespace MMU
l4.present = true;
l4.set_address(addr);
memset(l3_table(virt), 0, ARCH_PAGE_SIZE);
l4.ignore0 = l4.ignore1 = 0;
}
if (flags & Flags::ReadWrite) l4.read_write = true;
if (flags & Flags::User) l4.user = true;
@ -188,6 +184,7 @@ namespace MMU
l3.present = true;
l3.set_address(addr);
memset(l2_table(virt), 0, ARCH_PAGE_SIZE);
l3.ignore0 = l3.ignore1 = 0;
}
if (flags & Flags::ReadWrite) l3.read_write = true;
if (flags & Flags::User) l3.user = true;
@ -201,6 +198,7 @@ namespace MMU
l2.present = true;
l2.set_address(addr);
memset(l1_table(virt), 0, ARCH_PAGE_SIZE);
l2.ignore0 = l2.ignore1 = 0;
}
if (flags & Flags::ReadWrite) l2.read_write = true;
if (flags & Flags::User) l2.user = true;
@ -209,12 +207,13 @@ namespace MMU
auto& l1 = l1_entry(virt);
if (l1.present) return err(EEXIST); // Please explicitly unmap the page before mapping it again.
l1.ignore0 = l1.ignore1 = false;
l1.present = true;
l1.read_write = has_flag(flags, Flags::ReadWrite);
l1.user = has_flag(flags, Flags::User);
l1.write_through = has_flag(flags, Flags::WriteThrough);
l1.cache_disabled = has_flag(flags, Flags::CacheDisable);
l1.no_execute = has_flag(flags, Flags::NoExecute);
l1.read_write = (flags & Flags::ReadWrite);
l1.user = (flags & Flags::User);
l1.write_through = (flags & Flags::WriteThrough);
l1.cache_disabled = (flags & Flags::CacheDisable);
l1.no_execute = (flags & Flags::NoExecute);
l1.set_address(phys);
return {};
}
@ -223,12 +222,11 @@ namespace MMU
{
auto& l1 = *TRY(apply_cascading_flags(virt, flags));
if (!l1.present) return err(EFAULT);
l1.read_write = has_flag(flags, Flags::ReadWrite);
l1.user = has_flag(flags, Flags::User);
l1.write_through = has_flag(flags, Flags::WriteThrough);
l1.cache_disabled = has_flag(flags, Flags::CacheDisable);
l1.no_execute = has_flag(flags, Flags::NoExecute);
flush_page(virt);
l1.read_write = (flags & Flags::ReadWrite);
l1.user = (flags & Flags::User);
l1.write_through = (flags & Flags::WriteThrough);
l1.cache_disabled = (flags & Flags::CacheDisable);
l1.no_execute = (flags & Flags::NoExecute);
return {};
}

View File

@ -28,10 +28,10 @@ void Init::early_init()
setup_log(log_debug_enabled(), log_serial_enabled(), true);
CPU::platform_init();
MemoryManager::init();
InitRD::initialize();
CPU::platform_init();
MemoryManager::protect_kernel_sections().expect_release_value("We should succeed to protect sections");
}