diff options
| author | Fabian Imhof <fabian.imhof@ost.ch> | 2024-10-27 14:16:35 +0000 |
|---|---|---|
| committer | Fabian Imhof <fabian.imhof@ost.ch> | 2024-10-27 14:16:35 +0000 |
| commit | 38e87d52891429d56d20a54ce205d1e421068f36 (patch) | |
| tree | 59d0fd1b06fe78800ae1cb712e8de9550ab86b58 /arch/x86_64/src | |
| parent | d0f47ef0cd8cb2f5079808a261dd724b3eb1a3a1 (diff) | |
| download | teachos-38e87d52891429d56d20a54ce205d1e421068f36.tar.xz teachos-38e87d52891429d56d20a54ce205d1e421068f36.zip | |
update gas
Diffstat (limited to 'arch/x86_64/src')
| -rw-r--r-- | arch/x86_64/src/boot/boot.s | 10 | ||||
| -rw-r--r-- | arch/x86_64/src/memory/paging/page_entry.cpp | 17 |
2 files changed, 7 insertions, 20 deletions
diff --git a/arch/x86_64/src/boot/boot.s b/arch/x86_64/src/boot/boot.s index f04ae44..c1b3203 100644 --- a/arch/x86_64/src/boot/boot.s +++ b/arch/x86_64/src/boot/boot.s @@ -271,11 +271,6 @@ enable_paging: mov $page_map_level_4, %eax mov %eax, %cr3 - /* Map the P4 table recursively */ - mov $page_map_level_4, %eax - or 0b11, %eax /* Write present + writable flags into eax register */ - mov %eax, (page_map_level_4 + 511 * 8) - /* Enable Physical Address Extension */ mov %cr4, %eax or $(1 << 5), %eax @@ -317,6 +312,11 @@ enable_sse: * page map entries. */ prepare_page_maps: + /* Map the P4 table recursively */ + mov $page_map_level_4, %eax + or $0b11, %eax /* Write present + writable flags into eax register */ + mov %eax, (page_map_level_4 + 511 * 8) + /* Add an entry to the PML4, pointing to the PML3 */ mov $page_map_level_3, %eax or $0x3, %eax diff --git a/arch/x86_64/src/memory/paging/page_entry.cpp b/arch/x86_64/src/memory/paging/page_entry.cpp index 8b4aa36..f3b5be1 100644 --- a/arch/x86_64/src/memory/paging/page_entry.cpp +++ b/arch/x86_64/src/memory/paging/page_entry.cpp @@ -18,25 +18,12 @@ namespace teachos::arch::memory::paging { if (contains_flags(PRESENT)) { - auto physical_address = calculate_physical_address(); - return allocator::physical_frame::containing_address(physical_address & 0x000ffffffffff000); + constexpr std::size_t mask = 0x000fffff'fffff000; + return allocator::physical_frame::containing_address(flags.to_ullong() & mask); } return std::nullopt; } - auto entry::calculate_physical_address() const -> std::size_t - { - constexpr std::size_t start_bit = 12U; - constexpr std::size_t end_bit = 52U; - size_t value = 0U; - - for (auto i = start_bit; i < end_bit; i++) - { - value |= (flags[i] ? (1 << (i - start_bit)) : 0); - } - return value; - } - auto entry::contains_flags(std::bitset<64U> other) const -> bool { return (flags & other) == other; } auto entry::set_entry(allocator::physical_frame frame, std::bitset<64U> additional_flags) -> void |
