aboutsummaryrefslogtreecommitdiff
path: root/arch/x86_64
diff options
context:
space:
mode:
Diffstat (limited to 'arch/x86_64')
-rw-r--r--arch/x86_64/include/arch/memory/paging/page_table.hpp2
-rw-r--r--arch/x86_64/src/memory/allocator/area_frame_allocator.cpp2
-rw-r--r--arch/x86_64/src/memory/paging/page_mapper.cpp12
-rw-r--r--arch/x86_64/src/memory/paging/page_table.cpp4
4 files changed, 10 insertions, 10 deletions
diff --git a/arch/x86_64/include/arch/memory/paging/page_table.hpp b/arch/x86_64/include/arch/memory/paging/page_table.hpp
index 291ea8d..8fcde9f 100644
--- a/arch/x86_64/include/arch/memory/paging/page_table.hpp
+++ b/arch/x86_64/include/arch/memory/paging/page_table.hpp
@@ -83,7 +83,7 @@ namespace teachos::arch::memory::paging
// been created itself. So we have to do that before we are able to allocate the wanted frame. This has to be done
// for every level, meaning we potenitally create a level 4, level 3 and level 2 page entry, each pointing to a
// page table one level below.
- if (!next_handle)
+ if (!next_handle.has_value())
{
auto allocated_frame = allocator.allocate_frame();
exception_handling::assert(allocated_frame.has_value(), "[Page mapper] Unable to allocate frame");
diff --git a/arch/x86_64/src/memory/allocator/area_frame_allocator.cpp b/arch/x86_64/src/memory/allocator/area_frame_allocator.cpp
index d91b7f4..6ed4f28 100644
--- a/arch/x86_64/src/memory/allocator/area_frame_allocator.cpp
+++ b/arch/x86_64/src/memory/allocator/area_frame_allocator.cpp
@@ -51,7 +51,7 @@ namespace teachos::arch::memory::allocator
* Only try to allocate memory if current_area is not null, because
* the current_area is null if there is no more available memory.
*/
- if (!current_area)
+ if (!current_area.has_value())
{
return std::nullopt;
}
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};
}