aboutsummaryrefslogtreecommitdiff
path: root/arch/x86_64/src/memory/paging
diff options
context:
space:
mode:
authorFabian Imhof <fabian.imhof@ost.ch>2024-10-27 13:27:33 +0000
committerFabian Imhof <fabian.imhof@ost.ch>2024-10-27 13:27:33 +0000
commit1518177efac38961a36db0bc40152d00c38e6281 (patch)
tree8c4ce4f8c5b967533a0a4b14aa1460cee9508405 /arch/x86_64/src/memory/paging
parentca17ed52ea768f1e1c837207f7d27afa6ed99cc2 (diff)
downloadteachos-1518177efac38961a36db0bc40152d00c38e6281.tar.xz
teachos-1518177efac38961a36db0bc40152d00c38e6281.zip
add correct optional handling
Diffstat (limited to 'arch/x86_64/src/memory/paging')
-rw-r--r--arch/x86_64/src/memory/paging/page_mapper.cpp12
-rw-r--r--arch/x86_64/src/memory/paging/page_table.cpp4
2 files changed, 8 insertions, 8 deletions
diff --git a/arch/x86_64/src/memory/paging/page_mapper.cpp b/arch/x86_64/src/memory/paging/page_mapper.cpp
index 75d6759..bc0c0d9 100644
--- a/arch/x86_64/src/memory/paging/page_mapper.cpp
+++ b/arch/x86_64/src/memory/paging/page_mapper.cpp
@@ -28,7 +28,7 @@ namespace teachos::arch::memory::paging
auto next_handle = current_handle.next_table(page.get_level_index(level));
// If the next table method failed then it is highly likely that it was a huge page and we therefore have to
// parse the table differently. Therefore, we attempt to parse it using the method required by huge pages.
- if (!next_handle)
+ if (!next_handle.has_value())
{
return translate_huge_page(page);
}
@@ -45,14 +45,14 @@ namespace teachos::arch::memory::paging
auto current_handle = create_or_get();
auto level3_handle = current_handle.next_table(page.get_level_index(page_table_handle::LEVEL4));
- if (!level3_handle)
+ if (!level3_handle.has_value())
{
return std::nullopt;
}
auto level3_entry = level3_handle.value()[page.get_level_index(page_table_handle::LEVEL3)];
auto level3_frame = level3_entry.calculate_pointed_to_frame();
- if (level3_frame && level3_entry.contains_flags(entry::HUGE_PAGE))
+ if (level3_frame.has_value() && level3_entry.contains_flags(entry::HUGE_PAGE))
{
exception_handling::assert(
level3_frame.value().frame_number % (PAGE_TABLE_ENTRY_COUNT * PAGE_TABLE_ENTRY_COUNT) == 0U,
@@ -63,11 +63,11 @@ namespace teachos::arch::memory::paging
}
auto level2_handle = level3_handle.value().next_table(page.get_level_index(page_table_handle::LEVEL3));
- if (level2_handle)
+ if (level2_handle.has_value())
{
auto level2_entry = level2_handle.value()[page.get_level_index(page_table_handle::LEVEL2)];
auto level2_frame = level2_entry.calculate_pointed_to_frame();
- if (level2_frame && level2_entry.contains_flags(entry::HUGE_PAGE))
+ if (level2_frame.has_value() && level2_entry.contains_flags(entry::HUGE_PAGE))
{
exception_handling::assert(level2_frame.value().frame_number % PAGE_TABLE_ENTRY_COUNT == 0U,
"[Page Mapper] Physical address must be 2 MiB aligned");
@@ -84,7 +84,7 @@ namespace teachos::arch::memory::paging
virtual_page page = virtual_page::containing_address(virtual_address);
std::optional<allocator::physical_frame> frame = translate_page(page);
- if (frame)
+ if (frame.has_value())
{
return frame.value().frame_number * allocator::PAGE_FRAME_SIZE + offset;
}
diff --git a/arch/x86_64/src/memory/paging/page_table.cpp b/arch/x86_64/src/memory/paging/page_table.cpp
index 868cf86..f1df31d 100644
--- a/arch/x86_64/src/memory/paging/page_table.cpp
+++ b/arch/x86_64/src/memory/paging/page_table.cpp
@@ -72,7 +72,7 @@ namespace teachos::arch::memory::paging
auto page_table::next_table(std::size_t table_index) -> std::optional<page_table *>
{
auto address = next_table_address(table_index);
- if (address)
+ if (address.has_value())
{
return reinterpret_cast<page_table *>(address.value());
}
@@ -136,7 +136,7 @@ namespace teachos::arch::memory::paging
exception_handling::assert(handle_level != page_table_handle::LEVEL1,
"[Page Table] Attempted to call next_table on level 1 page table");
auto next_table = handle->next_table(table_index);
- if (next_table)
+ if (next_table.has_value())
{
return page_table_handle{next_table.value(), --handle_level};
}