aboutsummaryrefslogtreecommitdiff
path: root/arch/x86_64/pre/include
diff options
context:
space:
mode:
authorFelix Morgner <felix.morgner@ost.ch>2025-10-29 15:01:43 +0100
committerFelix Morgner <felix.morgner@ost.ch>2025-10-29 15:01:43 +0100
commitb157e2c472d8bd67ac1656404a6a6ee821260f4b (patch)
tree9c4ebaee21c9ad3521f86c543dc1f29906305baa /arch/x86_64/pre/include
parentc2b0bdfe3b725166f16c742cdaca7969052df382 (diff)
downloadteachos-b157e2c472d8bd67ac1656404a6a6ee821260f4b.tar.xz
teachos-b157e2c472d8bd67ac1656404a6a6ee821260f4b.zip
chore: reformat source code
Diffstat (limited to 'arch/x86_64/pre/include')
-rw-r--r--arch/x86_64/pre/include/arch/context_switching/interrupt_descriptor_table/segment_selector.hpp6
-rw-r--r--arch/x86_64/pre/include/arch/context_switching/syscall/main.hpp5
-rw-r--r--arch/x86_64/pre/include/arch/memory/allocator/tiny_frame_allocator.hpp2
-rw-r--r--arch/x86_64/pre/include/arch/memory/heap/global_heap_allocator.hpp19
-rw-r--r--arch/x86_64/pre/include/arch/memory/heap/heap_allocator.hpp8
-rw-r--r--arch/x86_64/pre/include/arch/memory/heap/linked_list_allocator.hpp6
-rw-r--r--arch/x86_64/pre/include/arch/memory/heap/user_heap_allocator.hpp6
-rw-r--r--arch/x86_64/pre/include/arch/memory/multiboot/reader.hpp2
-rw-r--r--arch/x86_64/pre/include/arch/memory/paging/active_page_table.hpp4
-rw-r--r--arch/x86_64/pre/include/arch/memory/paging/kernel_mapper.hpp18
-rw-r--r--arch/x86_64/pre/include/arch/memory/paging/page_table.hpp2
-rw-r--r--arch/x86_64/pre/include/arch/memory/paging/virtual_page.hpp4
12 files changed, 45 insertions, 37 deletions
diff --git a/arch/x86_64/pre/include/arch/context_switching/interrupt_descriptor_table/segment_selector.hpp b/arch/x86_64/pre/include/arch/context_switching/interrupt_descriptor_table/segment_selector.hpp
index 2a7704e..ea8c145 100644
--- a/arch/x86_64/pre/include/arch/context_switching/interrupt_descriptor_table/segment_selector.hpp
+++ b/arch/x86_64/pre/include/arch/context_switching/interrupt_descriptor_table/segment_selector.hpp
@@ -96,9 +96,9 @@ namespace teachos::arch::context_switching::interrupt_descriptor_table
private:
uint8_t _flags : 3 = {}; ///< Underlying bits used to read the flags from.
- uint16_t _index : 13 =
- {}; ///< Index into the local or global descriptor table. Processor multiplies the index value by 16 (number of
- ///< bytes in segment descriptor) and adds the result to the base address.
+ uint16_t _index
+ : 13 = {}; ///< Index into the local or global descriptor table. Processor multiplies the index value by 16
+ ///< (number of bytes in segment descriptor) and adds the result to the base address.
};
} // namespace teachos::arch::context_switching::interrupt_descriptor_table
diff --git a/arch/x86_64/pre/include/arch/context_switching/syscall/main.hpp b/arch/x86_64/pre/include/arch/context_switching/syscall/main.hpp
index 59adc13..f507c61 100644
--- a/arch/x86_64/pre/include/arch/context_switching/syscall/main.hpp
+++ b/arch/x86_64/pre/include/arch/context_switching/syscall/main.hpp
@@ -41,7 +41,10 @@ namespace teachos::arch::context_switching::syscall
* @param e Error code that was returned by the syscall.
* @return Return true if there was no error and false otherwise.
*/
- constexpr bool operator!(error e) { return e == error::OK; }
+ constexpr bool operator!(error e)
+ {
+ return e == error::OK;
+ }
/**
* @brief Maximum amount of arguments that can be passed to a syscall. Default value is 0 and arguments are only ever
diff --git a/arch/x86_64/pre/include/arch/memory/allocator/tiny_frame_allocator.hpp b/arch/x86_64/pre/include/arch/memory/allocator/tiny_frame_allocator.hpp
index 1ceb74d..1e4746d 100644
--- a/arch/x86_64/pre/include/arch/memory/allocator/tiny_frame_allocator.hpp
+++ b/arch/x86_64/pre/include/arch/memory/allocator/tiny_frame_allocator.hpp
@@ -10,7 +10,7 @@ namespace teachos::arch::memory::allocator
{
namespace
{
- uint8_t constexpr TINY_ALLOCATOR_FRAMES_COUNT = 3U;
+ constexpr uint8_t TINY_ALLOCATOR_FRAMES_COUNT = 3U;
}
/**
diff --git a/arch/x86_64/pre/include/arch/memory/heap/global_heap_allocator.hpp b/arch/x86_64/pre/include/arch/memory/heap/global_heap_allocator.hpp
index c98c130..480b1d0 100644
--- a/arch/x86_64/pre/include/arch/memory/heap/global_heap_allocator.hpp
+++ b/arch/x86_64/pre/include/arch/memory/heap/global_heap_allocator.hpp
@@ -37,7 +37,7 @@ namespace teachos::arch::memory::heap
*
* @param new_type Type of the heap allocation implementation we want to instantiate
*/
- static auto register_heap_allocator(heap_allocator_type new_type) -> void;
+ auto static register_heap_allocator(heap_allocator_type new_type) -> void;
/**
* @brief Allocates the given amount of memory and returns the pointer to the start of the allocatable memory area.
@@ -46,7 +46,7 @@ namespace teachos::arch::memory::heap
* @param size Amount of bytes that should be allocated
* @return void* Pointer to the start of the allocatable memory area
*/
- static auto kmalloc(std::size_t size) -> void *;
+ auto static kmalloc(std::size_t size) -> void *;
/**
* @brief Deallocated all memory associated with the memory area starting from the given pointer address.
@@ -54,7 +54,7 @@ namespace teachos::arch::memory::heap
*
* @param pointer Previously allocated memory area, that should now be freed
*/
- static auto kfree(void * pointer) noexcept -> void;
+ auto static kfree(void * pointer) noexcept -> void;
/**
* @brief Allocates the given amount of memory and returns the pointer to the start of the allocatable memory area.
@@ -64,7 +64,7 @@ namespace teachos::arch::memory::heap
* @return void* Pointer to the start of the allocatable memory area
*/
[[gnu::section(".user_text")]]
- static auto malloc(std::size_t size) -> void *;
+ auto static malloc(std::size_t size) -> void *;
/**
* @brief Deallocated all memory associated with the memory area starting from the given pointer address.
@@ -73,11 +73,11 @@ namespace teachos::arch::memory::heap
* @param pointer Previously allocated memory area, that should now be freed
*/
[[gnu::section(".user_text")]]
- static auto free(void * pointer) noexcept -> void;
+ auto static free(void * pointer) noexcept -> void;
private:
- static heap_allocator * kernel_allocator_instance; ///< Instance used to allocate and deallocate kernel heap memory
- [[gnu::section(".user_data")]] static user_heap_allocator *
+ heap_allocator static * kernel_allocator_instance; ///< Instance used to allocate and deallocate kernel heap memory
+ [[gnu::section(".user_data")]] user_heap_allocator static *
user_allocator_instance; ///< Instance used to allocate and deallocate user heap memory
/**
@@ -85,15 +85,14 @@ namespace teachos::arch::memory::heap
*
* @return Reference to the registered kernel heap allocation
*/
- static auto kernel() -> heap_allocator &;
+ auto static kernel() -> heap_allocator &;
/**
* @brief Either returns the previously registered heap allocated or halts further execution
*
* @return Reference to the registered user heap allocation
*/
- [[gnu::section(".user_text")]]
- static auto user() -> user_heap_allocator &;
+ [[gnu::section(".user_text")]] auto static user() -> user_heap_allocator &;
};
} // namespace teachos::arch::memory::heap
diff --git a/arch/x86_64/pre/include/arch/memory/heap/heap_allocator.hpp b/arch/x86_64/pre/include/arch/memory/heap/heap_allocator.hpp
index 420a1d3..6c25532 100644
--- a/arch/x86_64/pre/include/arch/memory/heap/heap_allocator.hpp
+++ b/arch/x86_64/pre/include/arch/memory/heap/heap_allocator.hpp
@@ -5,10 +5,10 @@
namespace teachos::arch::memory::heap
{
- std::size_t constexpr KERNEL_HEAP_START = 0x100000000;
- std::size_t constexpr KERNEL_HEAP_SIZE = 100 * 1024;
- std::size_t constexpr USER_HEAP_START = 0x100019000; // Starts directly after kernel heap
- std::size_t constexpr USER_HEAP_SIZE = 100 * 1024;
+ constexpr std::size_t KERNEL_HEAP_START = 0x1'0000'0000;
+ constexpr std::size_t KERNEL_HEAP_SIZE = 100 * 1024;
+ constexpr std::size_t USER_HEAP_START = 0x1'0001'9000; // Starts directly after kernel heap
+ constexpr std::size_t USER_HEAP_SIZE = 100 * 1024;
/**
* @brief Heap allocator interface containing methods required to allocate and deallocate heap memory areas
diff --git a/arch/x86_64/pre/include/arch/memory/heap/linked_list_allocator.hpp b/arch/x86_64/pre/include/arch/memory/heap/linked_list_allocator.hpp
index bbbad19..540ff5c 100644
--- a/arch/x86_64/pre/include/arch/memory/heap/linked_list_allocator.hpp
+++ b/arch/x86_64/pre/include/arch/memory/heap/linked_list_allocator.hpp
@@ -3,7 +3,6 @@
#include "arch/memory/heap/heap_allocator.hpp"
#include "arch/memory/heap/memory_block.hpp"
-
#include <kstd/mutex.hpp>
namespace teachos::arch::memory::heap
@@ -44,7 +43,10 @@ namespace teachos::arch::memory::heap
*
* @return Smallest allocatable block of heap memory.
*/
- auto constexpr min_allocatable_size() -> std::size_t { return sizeof(memory_block); }
+ constexpr auto min_allocatable_size() -> std::size_t
+ {
+ return sizeof(memory_block);
+ }
/**
* @brief Removes a free memory block from the free list and returns its address so the caller can allocate into it.
diff --git a/arch/x86_64/pre/include/arch/memory/heap/user_heap_allocator.hpp b/arch/x86_64/pre/include/arch/memory/heap/user_heap_allocator.hpp
index 3b47f15..15d8574 100644
--- a/arch/x86_64/pre/include/arch/memory/heap/user_heap_allocator.hpp
+++ b/arch/x86_64/pre/include/arch/memory/heap/user_heap_allocator.hpp
@@ -5,6 +5,7 @@
// #include <kstd/mutex.hpp>
#include <kstd/mutex.hpp>
+
#include <optional>
namespace teachos::arch::memory::heap
@@ -47,7 +48,10 @@ namespace teachos::arch::memory::heap
*
* @return Smallest allocatable block of heap memory.
*/
- [[gnu::section(".user_text")]] auto constexpr min_allocatable_size() -> std::size_t { return sizeof(memory_block); }
+ [[gnu::section(".user_text")]] constexpr auto min_allocatable_size() -> std::size_t
+ {
+ return sizeof(memory_block);
+ }
/**
* @brief Checks if the given memory block is big enough and if it is allocates into the current block.
diff --git a/arch/x86_64/pre/include/arch/memory/multiboot/reader.hpp b/arch/x86_64/pre/include/arch/memory/multiboot/reader.hpp
index c5464cb..ba80918 100644
--- a/arch/x86_64/pre/include/arch/memory/multiboot/reader.hpp
+++ b/arch/x86_64/pre/include/arch/memory/multiboot/reader.hpp
@@ -5,9 +5,9 @@
// #include "arch/memory/multiboot/memory_map.hpp"
#include "arch/memory/multiboot/elf_symbols_section.hpp"
+#include <multiboot2/information.hpp>
#include <cstdint>
-#include <multiboot2/information.hpp>
#include <span>
namespace teachos::arch::memory::multiboot
diff --git a/arch/x86_64/pre/include/arch/memory/paging/active_page_table.hpp b/arch/x86_64/pre/include/arch/memory/paging/active_page_table.hpp
index f68d8b6..abefd61 100644
--- a/arch/x86_64/pre/include/arch/memory/paging/active_page_table.hpp
+++ b/arch/x86_64/pre/include/arch/memory/paging/active_page_table.hpp
@@ -25,7 +25,7 @@ namespace teachos::arch::memory::paging
*
* @return Active single unique instance of the level 4 page table.
*/
- static auto create_or_get() -> active_page_table &;
+ auto static create_or_get() -> active_page_table &;
/**
* @brief Index operator overload to access specific mutable entry directy of the level 4 page table.
@@ -186,7 +186,7 @@ namespace teachos::arch::memory::paging
* @param handle Page Table handle we want to access the entry that should be cleared on.
*/
template<allocator::FrameAllocator T>
- static auto unmap_page_table_entry(T & allocator, virtual_page page, page_table_handle & handle) -> void
+ auto static unmap_page_table_entry(T & allocator, virtual_page page, page_table_handle & handle) -> void
{
auto level_index = page.get_level_index(handle.get_level());
auto & entry = handle[level_index];
diff --git a/arch/x86_64/pre/include/arch/memory/paging/kernel_mapper.hpp b/arch/x86_64/pre/include/arch/memory/paging/kernel_mapper.hpp
index 3afb54b..581f142 100644
--- a/arch/x86_64/pre/include/arch/memory/paging/kernel_mapper.hpp
+++ b/arch/x86_64/pre/include/arch/memory/paging/kernel_mapper.hpp
@@ -47,7 +47,7 @@ namespace teachos::arch::memory::paging
auto cr4 = kernel::cpu::read_control_register(kernel::cpu::control_register::CR4);
kernel::cpu::write_control_register(kernel::cpu::control_register::CR4, cr4 | 0x80);
- temporary_page temporary_page{virtual_page{0xCAFEBABE}, allocator};
+ temporary_page temporary_page{virtual_page{0xCAFE'BABE}, allocator};
decltype(auto) active_table = active_page_table::create_or_get();
auto const frame = allocator.allocate_frame();
exception_handling::assert(frame.has_value(),
@@ -124,14 +124,14 @@ namespace teachos::arch::memory::paging
auto map_elf_kernel_sections(active_page_table & active_table) -> void
{
exception_handling::assert(!mem_info.sections.empty(), "[Kernel Mapper] Kernel elf sections empty");
- std::array<uint64_t, 6U> constexpr USER_SECTION_BASES = {
- 0x102000, // .boot_bss (Contains statically allocated variables)
- 0x209000, // .stl_text (Contains code for custom std implementations and standard library code)
- 0x217000, // .user_text (Contains the actual user code executed)
- 0x21E000, // .user_data (Contains static user variables)
-
- 0x20A000 // .text (Necessary, because symbols for all template standard library features are placed here if
- // they were first used in the Kernel Code Section)
+ constexpr std::array<uint64_t, 6U> USER_SECTION_BASES = {
+ 0x102000, // .boot_bss (Contains statically allocated variables)
+ 0x209000, // .stl_text (Contains code for custom std implementations and standard library code)
+ 0x217000, // .user_text (Contains the actual user code executed)
+ 0x21E000, // .user_data (Contains static user variables)
+
+ 0x20A000 // .text (Necessary, because symbols for all template standard library features are placed here if
+ // they were first used in the Kernel Code Section)
};
for (auto const & section : mem_info.sections)
diff --git a/arch/x86_64/pre/include/arch/memory/paging/page_table.hpp b/arch/x86_64/pre/include/arch/memory/paging/page_table.hpp
index b972337..247086c 100644
--- a/arch/x86_64/pre/include/arch/memory/paging/page_table.hpp
+++ b/arch/x86_64/pre/include/arch/memory/paging/page_table.hpp
@@ -7,7 +7,7 @@
namespace teachos::arch::memory::paging
{
- std::size_t constexpr PAGE_TABLE_ENTRY_COUNT = 512U; ///< Default entry count of a page table in x86_84 is 512.
+ constexpr std::size_t PAGE_TABLE_ENTRY_COUNT = 512U; ///< Default entry count of a page table in x86_84 is 512.
/**
* @brief Forward delcaration of the page_table, because it should only be accessible over the handle.
diff --git a/arch/x86_64/pre/include/arch/memory/paging/virtual_page.hpp b/arch/x86_64/pre/include/arch/memory/paging/virtual_page.hpp
index a6c8c39..1a20eae 100644
--- a/arch/x86_64/pre/include/arch/memory/paging/virtual_page.hpp
+++ b/arch/x86_64/pre/include/arch/memory/paging/virtual_page.hpp
@@ -73,12 +73,12 @@ namespace teachos::arch::memory::paging
/**
* @brief Defaulted equals operator.
*/
- auto operator==(const virtual_page & other) const -> bool = default;
+ auto operator==(virtual_page const & other) const -> bool = default;
/**
* @brief Defaulted three-way comparsion operator.
*/
- auto operator<=>(const virtual_page & other) const -> std::partial_ordering = default;
+ auto operator<=>(virtual_page const & other) const -> std::partial_ordering = default;
std::size_t page_number =
{}; ///< Index number of the current virtual page, used to distinguish it from other pages.