aboutsummaryrefslogtreecommitdiff
path: root/arch/x86_64/pre/src/memory
diff options
context:
space:
mode:
Diffstat (limited to 'arch/x86_64/pre/src/memory')
-rw-r--r--arch/x86_64/pre/src/memory/allocator/area_frame_allocator.cpp5
-rw-r--r--arch/x86_64/pre/src/memory/heap/global_heap_allocator.cpp33
-rw-r--r--arch/x86_64/pre/src/memory/heap/memory_block.cpp5
-rw-r--r--arch/x86_64/pre/src/memory/heap/user_heap_allocator.cpp4
-rw-r--r--arch/x86_64/pre/src/memory/main.cpp4
-rw-r--r--arch/x86_64/pre/src/memory/multiboot/elf_symbols_section.cpp5
-rw-r--r--arch/x86_64/pre/src/memory/paging/active_page_table.cpp11
-rw-r--r--arch/x86_64/pre/src/memory/paging/page_entry.cpp27
-rw-r--r--arch/x86_64/pre/src/memory/paging/page_table.cpp20
-rw-r--r--arch/x86_64/pre/src/memory/paging/virtual_page.cpp7
10 files changed, 88 insertions, 33 deletions
diff --git a/arch/x86_64/pre/src/memory/allocator/area_frame_allocator.cpp b/arch/x86_64/pre/src/memory/allocator/area_frame_allocator.cpp
index a5a1b49..3105023 100644
--- a/arch/x86_64/pre/src/memory/allocator/area_frame_allocator.cpp
+++ b/arch/x86_64/pre/src/memory/allocator/area_frame_allocator.cpp
@@ -81,5 +81,8 @@ namespace teachos::arch::memory::allocator
return allocate_frame();
}
- auto area_frame_allocator::deallocate_frame(physical_frame const & physical_frame) -> void { (void)physical_frame; }
+ auto area_frame_allocator::deallocate_frame(physical_frame const & physical_frame) -> void
+ {
+ (void)physical_frame;
+ }
} // namespace teachos::arch::memory::allocator
diff --git a/arch/x86_64/pre/src/memory/heap/global_heap_allocator.cpp b/arch/x86_64/pre/src/memory/heap/global_heap_allocator.cpp
index 35cd623..709cda1 100644
--- a/arch/x86_64/pre/src/memory/heap/global_heap_allocator.cpp
+++ b/arch/x86_64/pre/src/memory/heap/global_heap_allocator.cpp
@@ -27,13 +27,25 @@ namespace teachos::arch::memory::heap
heap_allocator * global_heap_allocator::kernel_allocator_instance = nullptr;
user_heap_allocator * global_heap_allocator::user_allocator_instance = nullptr;
- auto global_heap_allocator::kmalloc(std::size_t size) -> void * { return kernel().allocate(size); }
+ auto global_heap_allocator::kmalloc(std::size_t size) -> void *
+ {
+ return kernel().allocate(size);
+ }
- auto global_heap_allocator::kfree(void * pointer) noexcept -> void { kernel().deallocate(pointer); }
+ auto global_heap_allocator::kfree(void * pointer) noexcept -> void
+ {
+ kernel().deallocate(pointer);
+ }
- auto global_heap_allocator::malloc(std::size_t size) -> void * { return user().allocate(size); }
+ auto global_heap_allocator::malloc(std::size_t size) -> void *
+ {
+ return user().allocate(size);
+ }
- auto global_heap_allocator::free(void * pointer) noexcept -> void { user().deallocate(pointer); }
+ auto global_heap_allocator::free(void * pointer) noexcept -> void
+ {
+ user().deallocate(pointer);
+ }
auto global_heap_allocator::register_heap_allocator(heap_allocator_type new_type) -> void
{
@@ -45,20 +57,21 @@ namespace teachos::arch::memory::heap
case heap_allocator_type::NONE:
// Nothing to do
break;
- case heap_allocator_type::BUMP: {
- static bump_allocator kernel_allocator{KERNEL_HEAP_START, KERNEL_HEAP_START + KERNEL_HEAP_SIZE};
+ case heap_allocator_type::BUMP:
+ {
+ bump_allocator static kernel_allocator{KERNEL_HEAP_START, KERNEL_HEAP_START + KERNEL_HEAP_SIZE};
kernel_allocator_instance = &kernel_allocator;
break;
}
- case heap_allocator_type::LINKED_LIST: {
- static linked_list_allocator kernel_allocator{KERNEL_HEAP_START, KERNEL_HEAP_START + KERNEL_HEAP_SIZE};
+ case heap_allocator_type::LINKED_LIST:
+ {
+ linked_list_allocator static kernel_allocator{KERNEL_HEAP_START, KERNEL_HEAP_START + KERNEL_HEAP_SIZE};
kernel_allocator_instance = &kernel_allocator;
break;
}
}
- [[gnu::section(".user_data")]]
- static user_heap_allocator user_allocator{};
+ [[gnu::section(".user_data")]] user_heap_allocator static user_allocator{};
user_allocator_instance = &user_allocator;
}
diff --git a/arch/x86_64/pre/src/memory/heap/memory_block.cpp b/arch/x86_64/pre/src/memory/heap/memory_block.cpp
index bc97bd6..4c07454 100644
--- a/arch/x86_64/pre/src/memory/heap/memory_block.cpp
+++ b/arch/x86_64/pre/src/memory/heap/memory_block.cpp
@@ -11,5 +11,8 @@ namespace teachos::arch::memory::heap
this->next = next;
}
- memory_block::~memory_block() { memset(static_cast<void *>(this), 0U, sizeof(memory_block)); }
+ memory_block::~memory_block()
+ {
+ memset(static_cast<void *>(this), 0U, sizeof(memory_block));
+ }
} // namespace teachos::arch::memory::heap
diff --git a/arch/x86_64/pre/src/memory/heap/user_heap_allocator.cpp b/arch/x86_64/pre/src/memory/heap/user_heap_allocator.cpp
index 427a68a..96de005 100644
--- a/arch/x86_64/pre/src/memory/heap/user_heap_allocator.cpp
+++ b/arch/x86_64/pre/src/memory/heap/user_heap_allocator.cpp
@@ -39,7 +39,7 @@ namespace teachos::arch::memory::heap
}
}
- char constexpr OUT_OF_MEMORY_ERROR_MESSAGE[] = "[Linked List Allocator] Out of memory";
+ constexpr char OUT_OF_MEMORY_ERROR_MESSAGE[] = "[Linked List Allocator] Out of memory";
context_switching::syscall::syscall(context_switching::syscall::type::ASSERT,
{false, reinterpret_cast<uint64_t>(&OUT_OF_MEMORY_ERROR_MESSAGE)});
return nullptr;
@@ -178,7 +178,7 @@ namespace teachos::arch::memory::heap
// Check if the block we want to deallocate is contained in the previous block, because if it is it can only mean
// that the block has already been deallocated and we therefore attempted a double free.
- char constexpr DOUBLE_FREE_ERROR_MESSAGE[] = "[Linked List Allocator] Attempted double free detected";
+ constexpr char DOUBLE_FREE_ERROR_MESSAGE[] = "[Linked List Allocator] Attempted double free detected";
context_switching::syscall::syscall(
context_switching::syscall::type::ASSERT,
{previous_block == nullptr ||
diff --git a/arch/x86_64/pre/src/memory/main.cpp b/arch/x86_64/pre/src/memory/main.cpp
index 2746a71..b5980db 100644
--- a/arch/x86_64/pre/src/memory/main.cpp
+++ b/arch/x86_64/pre/src/memory/main.cpp
@@ -15,7 +15,7 @@ namespace teachos::arch::memory
{
namespace
{
- static std::optional<allocator::area_frame_allocator> frame_allocator;
+ std::optional<allocator::area_frame_allocator> static frame_allocator;
auto create_frame_allocator(multiboot::memory_information const & memory_information)
-> allocator::area_frame_allocator &
@@ -54,7 +54,7 @@ namespace teachos::arch::memory
auto initialize_memory_management() -> void
{
- static bool has_been_called = false;
+ bool static has_been_called = false;
arch::exception_handling::assert(!has_been_called,
"[Initialization] Memory management has already been initialized");
has_been_called = true;
diff --git a/arch/x86_64/pre/src/memory/multiboot/elf_symbols_section.cpp b/arch/x86_64/pre/src/memory/multiboot/elf_symbols_section.cpp
index f5d126b..3105120 100644
--- a/arch/x86_64/pre/src/memory/multiboot/elf_symbols_section.cpp
+++ b/arch/x86_64/pre/src/memory/multiboot/elf_symbols_section.cpp
@@ -2,7 +2,10 @@
namespace teachos::arch::memory::multiboot
{
- auto elf_section_flags::contains_flags(std::bitset<64U> other) const -> bool { return (flags & other) == other; }
+ auto elf_section_flags::contains_flags(std::bitset<64U> other) const -> bool
+ {
+ return (flags & other) == other;
+ }
auto elf_section_header::is_null() const -> bool
{
diff --git a/arch/x86_64/pre/src/memory/paging/active_page_table.cpp b/arch/x86_64/pre/src/memory/paging/active_page_table.cpp
index 0113869..930588d 100644
--- a/arch/x86_64/pre/src/memory/paging/active_page_table.cpp
+++ b/arch/x86_64/pre/src/memory/paging/active_page_table.cpp
@@ -4,18 +4,21 @@ namespace teachos::arch::memory::paging
{
namespace
{
- paging::virtual_address constexpr PAGE_TABLE_LEVEL_4_ADDRESS = 0xffffffff'fffff000;
+ constexpr paging::virtual_address PAGE_TABLE_LEVEL_4_ADDRESS = 0xffff'ffff'ffff'f000;
}
auto active_page_table::create_or_get() -> active_page_table &
{
- static page_table_handle active_handle{reinterpret_cast<page_table *>(PAGE_TABLE_LEVEL_4_ADDRESS),
+ page_table_handle static active_handle{reinterpret_cast<page_table *>(PAGE_TABLE_LEVEL_4_ADDRESS),
page_table_handle::LEVEL4};
- static active_page_table active_page{active_handle};
+ active_page_table static active_page{active_handle};
return active_page;
}
- auto active_page_table::operator[](std::size_t index) -> entry & { return active_handle[index]; }
+ auto active_page_table::operator[](std::size_t index) -> entry &
+ {
+ return active_handle[index];
+ }
auto active_page_table::translate_address(virtual_address address) -> std::optional<allocator::physical_address>
{
diff --git a/arch/x86_64/pre/src/memory/paging/page_entry.cpp b/arch/x86_64/pre/src/memory/paging/page_entry.cpp
index 57045ca..ec45068 100644
--- a/arch/x86_64/pre/src/memory/paging/page_entry.cpp
+++ b/arch/x86_64/pre/src/memory/paging/page_entry.cpp
@@ -6,7 +6,7 @@ namespace teachos::arch::memory::paging
{
namespace
{
- std::size_t constexpr PHYSICAL_ADDRESS_MASK = 0x000fffff'fffff000;
+ constexpr std::size_t PHYSICAL_ADDRESS_MASK = 0x000f'ffff'ffff'f000;
} // namespace
entry::entry(uint64_t flags)
@@ -33,11 +33,20 @@ namespace teachos::arch::memory::paging
}
}
- auto entry::is_unused() const -> bool { return flags == 0U; }
+ auto entry::is_unused() const -> bool
+ {
+ return flags == 0U;
+ }
- auto entry::set_unused() -> void { flags = 0U; }
+ auto entry::set_unused() -> void
+ {
+ flags = 0U;
+ }
- auto entry::set_user_accessible() -> void { flags |= entry::USER_ACCESSIBLE; }
+ auto entry::set_user_accessible() -> void
+ {
+ flags |= entry::USER_ACCESSIBLE;
+ }
auto entry::calculate_pointed_to_frame() const -> std::optional<allocator::physical_frame>
{
@@ -49,7 +58,10 @@ namespace teachos::arch::memory::paging
return std::nullopt;
}
- auto entry::contains_flags(std::bitset<64U> other) const -> bool { return (flags & other) == other; }
+ 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
{
@@ -59,5 +71,8 @@ namespace teachos::arch::memory::paging
flags = frame.start_address() | additional_flags.to_ulong();
}
- auto entry::get_flags() const -> std::bitset<64U> { return flags.to_ulong() & ~PHYSICAL_ADDRESS_MASK; }
+ auto entry::get_flags() const -> std::bitset<64U>
+ {
+ return flags.to_ulong() & ~PHYSICAL_ADDRESS_MASK;
+ }
} // namespace teachos::arch::memory::paging
diff --git a/arch/x86_64/pre/src/memory/paging/page_table.cpp b/arch/x86_64/pre/src/memory/paging/page_table.cpp
index eb11810..e79c3e5 100644
--- a/arch/x86_64/pre/src/memory/paging/page_table.cpp
+++ b/arch/x86_64/pre/src/memory/paging/page_table.cpp
@@ -96,9 +96,15 @@ namespace teachos::arch::memory::paging
"[Page Table] Attempted to pass nullptr as table to page table table method");
}
- auto page_table_handle::zero_entries() -> void { table->zero_entries(); }
+ auto page_table_handle::zero_entries() -> void
+ {
+ table->zero_entries();
+ }
- auto page_table_handle::is_empty() const -> bool { return table->is_empty(); }
+ auto page_table_handle::is_empty() const -> bool
+ {
+ return table->is_empty();
+ }
auto page_table_handle::next_table(std::size_t table_index) const -> std::optional<page_table_handle>
{
@@ -113,9 +119,15 @@ namespace teachos::arch::memory::paging
return std::nullopt;
}
- auto page_table_handle::get_level() const -> page_table_handle::level { return table_level; }
+ auto page_table_handle::get_level() const -> page_table_handle::level
+ {
+ return table_level;
+ }
- auto page_table_handle::operator[](std::size_t index) -> entry & { return table->operator[](index); }
+ auto page_table_handle::operator[](std::size_t index) -> entry &
+ {
+ return table->operator[](index);
+ }
auto operator--(page_table_handle::level & value) -> page_table_handle::level &
{
diff --git a/arch/x86_64/pre/src/memory/paging/virtual_page.cpp b/arch/x86_64/pre/src/memory/paging/virtual_page.cpp
index d374156..8d34918 100644
--- a/arch/x86_64/pre/src/memory/paging/virtual_page.cpp
+++ b/arch/x86_64/pre/src/memory/paging/virtual_page.cpp
@@ -6,12 +6,15 @@ namespace teachos::arch::memory::paging
{
auto virtual_page::containing_address(virtual_address address) -> virtual_page
{
- exception_handling::assert(address < 0x00008000'00000000 || address >= 0xffff8000'00000000,
+ exception_handling::assert(address < 0x0000'8000'0000'0000 || address >= 0xffff'8000'0000'0000,
"[Virtual Page] Attempted to create virtual page from invalid address");
return virtual_page{address / allocator::PAGE_FRAME_SIZE};
}
- auto virtual_page::start_address() const -> virtual_address { return page_number * allocator::PAGE_FRAME_SIZE; }
+ auto virtual_page::start_address() const -> virtual_address
+ {
+ return page_number * allocator::PAGE_FRAME_SIZE;
+ }
auto virtual_page::get_level_index(page_table_handle::level level) const -> size_t
{