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/allocator/physical_frame.hpp42
-rw-r--r--arch/x86_64/include/arch/memory/multiboot/elf_symbols_section.hpp4
-rw-r--r--arch/x86_64/include/arch/memory/multiboot/memory_map.hpp4
-rw-r--r--arch/x86_64/include/arch/memory/paging/kernel_mapper.hpp10
-rw-r--r--arch/x86_64/include/arch/shared/container.hpp10
-rw-r--r--arch/x86_64/include/arch/shared/contiguous_pointer_iterator.hpp189
-rw-r--r--arch/x86_64/include/arch/shared/forward_value_iterator.hpp109
-rw-r--r--arch/x86_64/include/arch/shared/random_access_iterator.hpp204
-rw-r--r--arch/x86_64/src/memory/allocator/area_frame_allocator.cpp6
-rw-r--r--arch/x86_64/src/memory/allocator/physical_frame.cpp27
-rw-r--r--arch/x86_64/src/memory/multiboot/reader.cpp17
11 files changed, 327 insertions, 295 deletions
diff --git a/arch/x86_64/include/arch/memory/allocator/physical_frame.hpp b/arch/x86_64/include/arch/memory/allocator/physical_frame.hpp
index 43a22a2..a39517a 100644
--- a/arch/x86_64/include/arch/memory/allocator/physical_frame.hpp
+++ b/arch/x86_64/include/arch/memory/allocator/physical_frame.hpp
@@ -2,7 +2,7 @@
#define TEACHOS_ARCH_X86_64_MEMORY_ALLOCATOR_PHYSICAL_FRAME_HPP
#include "arch/shared/container.hpp"
-#include "arch/shared/random_access_iterator.hpp"
+#include "arch/shared/forward_value_iterator.hpp"
#include <compare>
#include <cstdint>
@@ -66,44 +66,6 @@ namespace teachos::arch::memory::allocator
auto operator++() -> physical_frame &;
/**
- * @brief Addition assignment operator. Returns a reference to the changed value.
- *
- * @param operand Value we want to add to the underlying address.
- * @return Reference to the changed underlying address.
- */
- auto operator+=(std::size_t operand) -> physical_frame &;
-
- /**
- * @brief Subtraction assignment operator. Returns a reference to the changed value.
- *
- * @param operand Value we want to subtract from the underlying address.
- * @return Reference to the changed underlying address.
- */
- auto operator-=(std::size_t operand) -> physical_frame &;
-
- /**
- * @brief Post increment operator. Returns a copy of the value.
- *
- * @return Copy of the incremented underlying address.
- */
- auto operator+(std::size_t operand) const -> physical_frame;
-
- /**
- * @brief Pre increment operator. Returns a reference to the changed value.
- *
- * @return Reference to the incremented underlying address.
- */
- auto operator-(std::size_t operand) const -> physical_frame;
-
- /**
- * @brief Subtraction operator. Returns the size difference between two iterators.
- *
- * @param other Other iterator we want to substract the underlying address with ours.
- * @return Size difference between the underlying address of this instance and the given iterator.
- */
- auto operator-(physical_frame const & other) const -> std::size_t;
-
- /**
* @brief Defaulted equals operator.
*/
auto operator==(physical_frame const & other) const -> bool = default;
@@ -117,7 +79,7 @@ namespace teachos::arch::memory::allocator
{}; ///< Index number of the current physical frame, used to distinguish it from other frames.
};
- typedef shared::container<shared::random_access_iterator<physical_frame>> frame_container;
+ typedef shared::container<shared::forward_value_iterator<physical_frame>> frame_container;
} // namespace teachos::arch::memory::allocator
#endif // TEACHOS_ARCH_X86_64_MEMORY_ALLOCATOR_PHYSICAL_FRAME_HPP
diff --git a/arch/x86_64/include/arch/memory/multiboot/elf_symbols_section.hpp b/arch/x86_64/include/arch/memory/multiboot/elf_symbols_section.hpp
index 6227fc9..549839a 100644
--- a/arch/x86_64/include/arch/memory/multiboot/elf_symbols_section.hpp
+++ b/arch/x86_64/include/arch/memory/multiboot/elf_symbols_section.hpp
@@ -3,7 +3,7 @@
#include "arch/memory/multiboot/info.hpp"
#include "arch/shared/container.hpp"
-#include "arch/shared/random_access_iterator.hpp"
+#include "arch/shared/contiguous_pointer_iterator.hpp"
#include <bitset>
#include <cstdint>
@@ -162,7 +162,7 @@ namespace teachos::arch::memory::multiboot
///< contained in the section, to ensure byte alignment is actually 4 byte.
};
- typedef shared::container<shared::random_access_iterator<elf_section_header *>> elf_section_header_container;
+ typedef shared::container<shared::contiguous_pointer_iterator<elf_section_header>> elf_section_header_container;
} // namespace teachos::arch::memory::multiboot
#endif // TEACHOS_ARCH_X86_64_MEMORY_MULTIBOOT_ELF_SYBOLS_SECTION_HPP
diff --git a/arch/x86_64/include/arch/memory/multiboot/memory_map.hpp b/arch/x86_64/include/arch/memory/multiboot/memory_map.hpp
index ccd5cf0..413f5a1 100644
--- a/arch/x86_64/include/arch/memory/multiboot/memory_map.hpp
+++ b/arch/x86_64/include/arch/memory/multiboot/memory_map.hpp
@@ -3,7 +3,7 @@
#include "arch/memory/multiboot/info.hpp"
#include "arch/shared/container.hpp"
-#include "arch/shared/random_access_iterator.hpp"
+#include "arch/shared/contiguous_pointer_iterator.hpp"
#include <cstdint>
@@ -46,7 +46,7 @@ namespace teachos::arch::memory::multiboot
struct memory_area entries; ///< Specific memory regions.
};
- typedef shared::container<shared::random_access_iterator<memory_area *>> memory_area_container;
+ typedef shared::container<shared::contiguous_pointer_iterator<memory_area>> memory_area_container;
} // namespace teachos::arch::memory::multiboot
#endif // TEACHOS_ARCH_X86_64_MEMORY_MULTIBOOT_MEMORY_MAP_HPP
diff --git a/arch/x86_64/include/arch/memory/paging/kernel_mapper.hpp b/arch/x86_64/include/arch/memory/paging/kernel_mapper.hpp
index d301c91..2eb3c4a 100644
--- a/arch/x86_64/include/arch/memory/paging/kernel_mapper.hpp
+++ b/arch/x86_64/include/arch/memory/paging/kernel_mapper.hpp
@@ -101,23 +101,23 @@ namespace teachos::arch::memory::paging
exception_handling::assert(!mem_info.sections.empty(), "[Kernel Mapper] Kernel elf sections empty");
for (auto const & section : mem_info.sections)
{
- if (!section->flags.contains_flags(multiboot::elf_section_flags::OCCUPIES_MEMORY))
+ if (!section.flags.contains_flags(multiboot::elf_section_flags::OCCUPIES_MEMORY))
{
continue;
}
- exception_handling::assert(section->physical_address % allocator::PAGE_FRAME_SIZE == 0U,
+ exception_handling::assert(section.physical_address % allocator::PAGE_FRAME_SIZE == 0U,
"[Kernel Mapper] Section must be page aligned");
- auto const start_frame = allocator::physical_frame::containing_address(section->physical_address);
+ auto const start_frame = allocator::physical_frame::containing_address(section.physical_address);
// End address is exclusive, so that it is not part of the section anymore (one past the last frame of this
// section). But end frame would now point to the actual last frame and not one past the last frame, therefore
// we increment by one to get one past the last frame of this section.
auto end_frame =
- ++(allocator::physical_frame::containing_address(section->physical_address + section->section_size - 1));
+ ++(allocator::physical_frame::containing_address(section.physical_address + section.section_size - 1));
allocator::frame_container::iterator const begin{start_frame};
allocator::frame_container::iterator const end{end_frame};
allocator::frame_container frames{begin, end};
- entry entry{section->flags};
+ entry entry{section.flags};
for (auto const & frame : frames)
{
diff --git a/arch/x86_64/include/arch/shared/container.hpp b/arch/x86_64/include/arch/shared/container.hpp
index 9b4192e..b335e72 100644
--- a/arch/x86_64/include/arch/shared/container.hpp
+++ b/arch/x86_64/include/arch/shared/container.hpp
@@ -5,16 +5,20 @@
namespace teachos::arch::shared
{
+ /**
+ * @brief Minimal iterator concept required for usage in container
+ */
template<typename T>
- concept Iterator = std::contiguous_iterator<T>;
+ concept Iterator = std::forward_iterator<T>;
/**
* @brief Read-only container for given template type, that allow to easily use this container instance in C++20
* ranges calls.
*
- * @tparam T Iterator the container uses to signal the start and end of it's data.
+ * @tparam T Iterator the container uses to signal the start and end of it's data, has to atleast be a simple forward
+ * iterator.
*/
- template<typename T>
+ template<Iterator T>
struct container
{
using iterator = T; ///< Iterators used by this container.
diff --git a/arch/x86_64/include/arch/shared/contiguous_pointer_iterator.hpp b/arch/x86_64/include/arch/shared/contiguous_pointer_iterator.hpp
new file mode 100644
index 0000000..7d5019a
--- /dev/null
+++ b/arch/x86_64/include/arch/shared/contiguous_pointer_iterator.hpp
@@ -0,0 +1,189 @@
+#ifndef TEACHOS_ARCH_X86_64_SHARED_CONTIGUOUS_POINTER_ITERATOR_HPP
+#define TEACHOS_ARCH_X86_64_SHARED_CONTIGUOUS_POINTER_ITERATOR_HPP
+
+#include <iterator>
+
+namespace teachos::arch::shared
+{
+ /**
+ * @brief Generic contiguous iterator for given template type. Allows to easily use this iterator instance in
+ * algorithm calls.
+ *
+ * @note Allows any value that is contained in an array in memory, which is a block of contiguous memory. This is the
+ * case because we assume we can simply increment or decrement the pointer address to get the next valid instance of
+ * the given value type.
+ *
+ * @tparam T Value the iterator points too.
+ */
+ template<typename T>
+ struct contiguous_pointer_iterator
+ {
+ using iterator_category = std::contiguous_iterator_tag; ///< Iterator category of this type.
+ using difference_type = std::ptrdiff_t; ///< Type when diving one instance of this iterator by another.
+ using value_type = T; ///< Underlying value pointed to by this iterator.
+ using reference_type = value_type &; ///< Reference to value returned by dereference * operation.
+ using pointer_type = value_type *; ///< Pointer to value returned by arrow -> operation.
+
+ /**
+ * @brief Defaulted constructor.
+ */
+ contiguous_pointer_iterator() = default;
+
+ /**
+ * @brief Constructor.
+ *
+ * @param p Underlying address the iterator should point too.
+ */
+ explicit contiguous_pointer_iterator(value_type * p)
+ : ptr(p)
+ {
+ // Nothing to do
+ }
+
+ /**
+ * @brief Dereferences the initally given pointer to its value.
+ *
+ * @return Reference to the value.
+ */
+ auto operator*() const -> reference_type { return *ptr; }
+
+ /**
+ * @brief Get underlying value, which is the intially passed pointer.
+ *
+ * @return Pointer to the underlying value passed intially.
+ */
+ auto operator->() const -> pointer_type { return ptr; }
+
+ /**
+ * @brief Pre decrement operator. Returns a reference to the changed address.
+ *
+ * @return Reference to the decremented underlying address.
+ */
+ auto operator--() -> contiguous_pointer_iterator &
+ {
+ contiguous_pointer_iterator const old_value = *this;
+ ++ptr;
+ return old_value;
+ }
+
+ /**
+ * @brief Pre increment operator. Returns a reference to the changed address.
+ *
+ * @return Reference to the incremented underlying address.
+ */
+ auto operator++() -> contiguous_pointer_iterator &
+ {
+ ++ptr;
+ return *this;
+ }
+
+ /**
+ * @brief Post decrement operator. Returns a copy of the address.
+ *
+ * @return Copy of the decremented underlying address.
+ */
+ auto operator--(int) -> contiguous_pointer_iterator
+ {
+ auto const old_value = *this;
+ --ptr;
+ return old_value;
+ }
+
+ /**
+ * @brief Post increment operator. Returns a copy of the address.
+ *
+ * @return Copy of the incremented underlying address.
+ */
+ auto operator++(int) -> contiguous_pointer_iterator
+ {
+ auto const old_value = *this;
+ ++ptr;
+ return old_value;
+ }
+
+ /**
+ * @brief Addition assignment operator. Returns a reference to the changed address.
+ *
+ * @param value Value we want to add to the underlying address.
+ * @return Reference to the changed underlying address.
+ */
+ auto operator+=(difference_type value) -> contiguous_pointer_iterator &
+ {
+ ptr += value;
+ return *this;
+ }
+
+ /**
+ * @brief Subtraction assignment operator. Returns a reference to the changed address.
+ *
+ * @param value Value we want to subtract from the underlying address.
+ * @return Reference to the changed underlying address.
+ */
+ auto operator-=(difference_type value) -> contiguous_pointer_iterator &
+ {
+ ptr -= value;
+ return *this;
+ }
+
+ /**
+ * @brief Addition operator. Returns the changed address.
+ *
+ * @param value Value we want to add to a copy of the underlying address.
+ * @return Copy of underlying address incremented by the given value.
+ */
+ auto operator+(difference_type value) const -> contiguous_pointer_iterator
+ {
+ return contiguous_pointer_iterator{ptr + value};
+ }
+
+ /**
+ * @brief Subtraction operator. Returns the changed address.
+ *
+ * @param value Value we want to subtrcat from a copy of the underlying address.
+ * @return Copy of underlying address decremented by the given value.
+ */
+ auto operator-(difference_type value) const -> contiguous_pointer_iterator
+ {
+ return contiguous_pointer_iterator{ptr - value};
+ }
+
+ /**
+ * @brief Subtraction operator. Returns the size difference between two iterators.
+ *
+ * @param other Other iterator we want to substract the underlying address with ours.
+ * @return Size difference between the underlying address of this instance and the given iterator.
+ */
+ auto operator-(const contiguous_pointer_iterator & other) const -> difference_type { return ptr - other.ptr; }
+
+ /**
+ * @brief Index operator overload. Returns a reference to the value at the given index. Simply returns the
+ * dereferenced underlying pointer incremented by the given index.
+ *
+ * @param index Index we want to access and get the value from.
+ * @return Reference to the value at the given index.
+ */
+ auto operator[](difference_type index) const -> value_type & { return *(ptr + index); }
+
+ /**
+ * @brief Defaulted comparsion operator. Simply compares the memory address of both iterators.
+ *
+ * @param other Other iterator to compare to.
+ * @return Whether both iterators point to the same underlying address in memory.
+ */
+ auto operator==(contiguous_pointer_iterator const & other) const -> bool = default;
+
+ /**
+ * @brief Defaulted threeway comparsion operator. Simply compares the memory address of both iterators.
+ *
+ * @param other Other iterator to compare to.
+ * @return Whether the given iterator is smaller or larger than this iterator.
+ */
+ auto operator<=>(contiguous_pointer_iterator const & other) const -> std::strong_ordering = default;
+
+ private:
+ pointer_type ptr =
+ {}; ///< Underlying value the iterator is currently pointing too and should increment or decrement.
+ };
+} // namespace teachos::arch::shared
+
+#endif // TEACHOS_ARCH_X86_64_SHARED_CONTIGUOUS_POINTER_ITERATOR_HPP
diff --git a/arch/x86_64/include/arch/shared/forward_value_iterator.hpp b/arch/x86_64/include/arch/shared/forward_value_iterator.hpp
new file mode 100644
index 0000000..a84d291
--- /dev/null
+++ b/arch/x86_64/include/arch/shared/forward_value_iterator.hpp
@@ -0,0 +1,109 @@
+#ifndef TEACHOS_ARCH_X86_64_SHARED_FORWARD_VALUE_ITERATOR_HPP
+#define TEACHOS_ARCH_X86_64_SHARED_FORWARD_VALUE_ITERATOR_HPP
+
+#include <iterator>
+
+namespace teachos::arch::shared
+{
+ /**
+ * @brief Concept for a type to have a post and prefix increment operator, that returns the correct type.
+ */
+ template<typename T>
+ concept Incrementable = requires(T t) {
+ { ++t } -> std::same_as<T &>;
+ { t++ } -> std::same_as<T>;
+ };
+
+ /**
+ * @brief Iterable concept for the forward value iterator, meaning the type itself is incrementable and comparable.
+ */
+ template<typename T>
+ concept Iterable = std::regular<T> && Incrementable<T>;
+
+ /**
+ * @brief Generic forward iterator for given template type. Allows to easily use this iterator
+ * instance in algorithm calls.
+ *
+ * @note Allows any value that itself can be incremented until we have reached the end, does not interact with the
+ * address of the value in any way.
+ *
+ * @tparam T Value the iterator contains.
+ */
+ template<Iterable T>
+ struct forward_value_iterator
+ {
+ using iterator_category = std::forward_iterator_tag; ///< Iterator category of this type.
+ using difference_type = std::ptrdiff_t; ///< Type when diving one instance of this iterator by another.
+ using value_type = T; ///< Underlying value contained by this iterator.
+ using const_reference_type =
+ value_type const &; ///< Constant reference to value returned by dereference * operation.
+ using const_pointer_type = value_type const *; ///< Constant pointer to value returned by arrow -> operation.
+
+ /**
+ * @brief Defaulted constructor.
+ */
+ forward_value_iterator() = default;
+
+ /**
+ * @brief Constructor.
+ *
+ * @param value Underlying value the iterator contains.
+ */
+ explicit forward_value_iterator(value_type value)
+ : value(value)
+ {
+ // Nothing to do
+ }
+
+ /**
+ * @brief Returns the initally given value.
+ *
+ * @return Reference to the value.
+ */
+ auto operator*() const -> const_reference_type { return value; }
+
+ /**
+ * @brief Gets pointer to the underlying value passed intially.
+ *
+ * @return Pointer to the underlying value passed intially.
+ */
+ auto operator->() const -> const_pointer_type { return &value; }
+
+ /**
+ * @brief Pre increment operator. Returns a reference to the changed value.
+ *
+ * @return Reference to the incremented underlying value.
+ */
+ auto operator++() -> forward_value_iterator &
+ {
+ ++value;
+ return *this;
+ }
+
+ /**
+ * @brief Post increment operator. Returns a copy of the value.
+ *
+ * @return Copy of the incremented underlying value.
+ */
+ auto operator++(int) -> forward_value_iterator
+ {
+ auto const old_value = *this;
+ ++value;
+ return old_value;
+ }
+
+ /**
+ * @brief Defaulted comparsion operator. Simply compares the memory address of both iterators.
+ *
+ * @param other Other iterator to compare to.
+ * @return Whether both iterators point to the same underlying address in memory.
+ */
+ auto operator==(forward_value_iterator const & other) const -> bool = default;
+
+ private:
+ value_type value =
+ {}; ///< Underlying value the iterator is currently pointing too and should increment or decrement.
+ };
+} // namespace teachos::arch::shared
+
+#endif // TEACHOS_ARCH_X86_64_SHARED_FORWARD_VALUE_ITERATOR_HPP
diff --git a/arch/x86_64/include/arch/shared/random_access_iterator.hpp b/arch/x86_64/include/arch/shared/random_access_iterator.hpp
deleted file mode 100644
index 69617f3..0000000
--- a/arch/x86_64/include/arch/shared/random_access_iterator.hpp
+++ /dev/null
@@ -1,204 +0,0 @@
-#ifndef TEACHOS_ARCH_X86_64_SHARED_RANDOM_ACCESS_ITERATOR_HPP
-#define TEACHOS_ARCH_X86_64_SHARED_RANDOM_ACCESS_ITERATOR_HPP
-
-#include <iterator>
-
-namespace teachos::arch::shared
-{
- template<typename T>
- concept Iterable = std::incrementable<T> && std::three_way_comparable<T> && std::indirectly_readable<T>;
-
- /**
- * @brief Generic random access iterator for given template type. Allows any value that Allows to easily use this
- * iterator instance in algorithm calls.
- *
- * @tparam T Value the iterator points too.
- */
- template<Iterable T>
- struct random_access_iterator
- {
- using iterator_category = std::contiguous_iterator_tag; ///< Iterator category of this type.
- using difference_type = std::ptrdiff_t; ///< Type when diving one instance of this iterator by another.
- using value_type = T; ///< Underlying value pointed to by this iterator.
- using reference_type = value_type &; ///< Reference to value returned by dereference * operation.
- using pointer_type = value_type *; ///< Pointer to value returned by arrow -> operation.
- using const_reference_type = value_type const &; ///< Reference to value returned by const dereference * operation.
- using const_pointer_type = value_type const *; ///< Pointer to value returned by const arrow -> operation.
-
- /**
- * @brief Defaulted constructor.
- */
- random_access_iterator() = default;
-
- /**
- * @brief Constructor.
- *
- * @param value Underlying value the iterator should point too and increment or decrement.
- */
- explicit random_access_iterator(value_type value)
- : value(value)
- {
- // Nothing to do
- }
-
- /**
- * @brief Gets a reference to the underlying value.
- *
- * @return Reference to the value.
- */
- auto operator*() -> reference_type { return value; }
-
- /**
- * @brief Gets a pointer to the underlying value.
- *
- * @return Underlying value passed intially.
- */
- auto operator->() -> pointer_type { return &value; }
-
- /**
- * @brief Gets a const reference to the underlying value.
- *
- * @return Reference to the value.
- */
- auto operator*() const -> const_reference_type { return value; }
-
- /**
- * @brief Gets a const pointer to the underlying value.
- *
- * @return Underlying value passed intially.
- */
- auto operator->() const -> const_pointer_type { return &value; }
-
- /**
- * @brief Pre decrement operator. Returns a reference to the changed value.
- *
- * @return Reference to the decrement underlying value.
- */
- auto operator--() -> random_access_iterator &
- {
- --value;
- return *this;
- }
-
- /**
- * @brief Pre increment operator. Returns a reference to the changed value.
- *
- * @return Reference to the incremented underlying value.
- */
- auto operator++() -> random_access_iterator &
- {
- ++value;
- return *this;
- }
-
- /**
- * @brief Post decrement operator. Returns a copy of the value.
- *
- * @return Copy of the decremented underlying value.
- */
- auto operator--(int) -> random_access_iterator
- {
- auto const old_value = *this;
- --value;
- return old_value;
- }
-
- /**
- * @brief Post increment operator. Returns a copy of the value.
- *
- * @return Copy of the incremented underlying value.
- */
- auto operator++(int) -> random_access_iterator
- {
- auto const old_value = *this;
- ++value;
- return old_value;
- }
-
- /**
- * @brief Addition assignment operator. Returns a reference to the changed value.
- *
- * @param operand Value we want to add to the underlying value the iterator is pointing too.
- * @return Reference to the changed underlying value.
- */
- auto operator+=(difference_type operand) -> random_access_iterator &
- {
- value += operand;
- return *this;
- }
-
- /**
- * @brief Subtraction assignment operator. Returns a reference to the changed value.
- *
- * @param operand Value we want to subtract from the underlying value the iterator is pointing too.
- * @return Reference to the changed underlying value.
- */
- auto operator-=(difference_type operand) -> random_access_iterator &
- {
- value -= operand;
- return *this;
- }
-
- /**
- * @brief Addition operator. Returns the changed value.
- *
- * @param operand Value we want to add to a copy of the underlying value the iterator is pointing too.
- * @return Copy of underlying value incremented by the given value.
- */
- auto operator+(difference_type operand) const -> random_access_iterator
- {
- return random_access_iterator{value + operand};
- }
-
- /**
- * @brief Subtraction operator. Returns the changed value.
- *
- * @param operand Value we want to subtract from a copy of the underlying value the iterator is pointing too.
- * @return Copy of underlying value decremented by the given value.
- */
- auto operator-(difference_type operand) const -> random_access_iterator
- {
- return random_access_iterator{value - operand};
- }
-
- /**
- * @brief Subtraction operator. Returns the size difference between two iterators.
- *
- * @param other Other iterator we want to substract the underlying value with ours.
- * @return Size difference between the underlying value of this instance and the given iterator.
- */
- auto operator-(random_access_iterator const & other) const -> difference_type { return value - other.value; }
-
- /**
- * @brief Index operator overload. Returns a reference to the value at the given index. Simply returns the
- * underlying value the iterator is pointing too incremented by the given index.
- *
- * @param index Index we want to access and get the value from.
- * @return Reference to the value at the given index.
- */
- auto operator[](difference_type index) const -> value_type const & { return value + index; }
-
- /**
- * @brief Defaulted comparsion operator. Forwards to the comparsion operator of the given template type.
- *
- * @param other Other iterator to compare to.
- * @return Whether both iterators point to the same underlying value in memory.
- */
- auto operator==(random_access_iterator const & other) const -> bool = default;
-
- /**
- * @brief Defaulted threeway comparsion operator. Forwards to the threeway comparsion operator of the given
- * template type.
- *
- * @param other Other iterator to compare to.
- * @return Whether the given iterator is smaller or larger than this iterator.
- */
- auto operator<=>(random_access_iterator const & other) const -> std::strong_ordering = default;
-
- private:
- value_type value =
- {}; ///< Underlying value the iterator is currently pointing too and should increment or decrement.
- };
-} // namespace teachos::arch::shared
-
-#endif // TEACHOS_ARCH_X86_64_SHARED_RANDOM_ACCESS_ITERATOR_HPP
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 42aff68..3bc9676 100644
--- a/arch/x86_64/src/memory/allocator/area_frame_allocator.cpp
+++ b/arch/x86_64/src/memory/allocator/area_frame_allocator.cpp
@@ -24,16 +24,16 @@ namespace teachos::arch::memory::allocator
{
current_area = std::nullopt;
auto next_area_with_free_frames = memory_areas | std::views::filter([this](auto const & area) {
- auto address = area->base_address + area->area_length - 1;
+ auto address = area.base_address + area.area_length - 1;
return physical_frame::containing_address(address) >= next_free_frame;
});
auto const lowest_area_with_free_frames = std::ranges::min_element(
- next_area_with_free_frames, [](auto const & a, auto const & b) { return a->base_address < b->base_address; });
+ next_area_with_free_frames, [](auto const & a, auto const & b) { return a.base_address < b.base_address; });
if (lowest_area_with_free_frames != next_area_with_free_frames.end())
{
- current_area = **lowest_area_with_free_frames;
+ current_area = *lowest_area_with_free_frames;
// Update the `next_free_frame` according to the new memory area
auto const start_frame = physical_frame::containing_address(current_area.value().base_address);
if (next_free_frame < start_frame)
diff --git a/arch/x86_64/src/memory/allocator/physical_frame.cpp b/arch/x86_64/src/memory/allocator/physical_frame.cpp
index 63d84ec..ec387a1 100644
--- a/arch/x86_64/src/memory/allocator/physical_frame.cpp
+++ b/arch/x86_64/src/memory/allocator/physical_frame.cpp
@@ -21,31 +21,4 @@ namespace teachos::arch::memory::allocator
++frame_number;
return *this;
}
-
- auto physical_frame::operator+=(std::size_t operand) -> physical_frame &
- {
- frame_number += operand;
- return *this;
- }
-
- auto physical_frame::operator-=(std::size_t operand) -> physical_frame &
- {
- frame_number -= operand;
- return *this;
- }
-
- auto physical_frame::operator+(std::size_t operand) const -> physical_frame
- {
- return physical_frame{frame_number + operand};
- }
-
- auto physical_frame::operator-(std::size_t operand) const -> physical_frame
- {
- return physical_frame{frame_number - operand};
- }
-
- auto physical_frame::operator-(const physical_frame & other) const -> std::size_t
- {
- return frame_number - other.frame_number;
- }
} // namespace teachos::arch::memory::allocator
diff --git a/arch/x86_64/src/memory/multiboot/reader.cpp b/arch/x86_64/src/memory/multiboot/reader.cpp
index 178cc45..1dd18ff 100644
--- a/arch/x86_64/src/memory/multiboot/reader.cpp
+++ b/arch/x86_64/src/memory/multiboot/reader.cpp
@@ -51,27 +51,26 @@ namespace teachos::arch::memory::multiboot
auto const begin = elf_section_header_container::iterator{reinterpret_cast<elf_section_header *>(&symbol->end)};
auto const end = begin + symbol->number_of_sections;
- exception_handling::assert((*begin)->is_null(),
+ exception_handling::assert(begin->is_null(),
"[Multiboot Reader] Elf symbols section not starting with SHT_NULL section");
elf_section_header_container sections{begin, end};
auto const elf_section_with_lowest_physical_address = std::ranges::min_element(
- sections, [](auto const & a, auto const & b) { return a->physical_address < b->physical_address; });
+ sections, [](auto const & a, auto const & b) { return a.physical_address < b.physical_address; });
auto const elf_section_with_highest_physical_address =
std::ranges::max_element(sections, [](auto const & a, auto const & b) {
- auto a_physical_address_end = a->physical_address + a->section_size;
- auto b_physical_address_end = b->physical_address + b->section_size;
+ auto a_physical_address_end = a.physical_address + a.section_size;
+ auto b_physical_address_end = b.physical_address + b.section_size;
return a_physical_address_end < b_physical_address_end;
});
auto const symbol_table_section_count = std::ranges::count_if(sections, [](auto const & section) {
- return section->type == elf_section_type::DYNAMIC_SYMBOL_TABLE ||
- section->type == elf_section_type::SYMBOL_TABLE;
+ return section.type == elf_section_type::DYNAMIC_SYMBOL_TABLE || section.type == elf_section_type::SYMBOL_TABLE;
});
auto const dynamic_section_count = std::ranges::count_if(
- sections, [](auto const & section) { return section->type == elf_section_type::DYNAMIC; });
+ sections, [](auto const & section) { return section.type == elf_section_type::DYNAMIC; });
exception_handling::assert(
symbol_table_section_count == 1U,
@@ -81,10 +80,10 @@ namespace teachos::arch::memory::multiboot
"[Multiboot Reader] ELF Specifications allows only (1) or less dynamic sections, but got more");
auto const lowest_elf_section = *elf_section_with_lowest_physical_address;
- kernel_start = lowest_elf_section->physical_address;
+ kernel_start = lowest_elf_section.physical_address;
auto const highest_elf_section = *elf_section_with_highest_physical_address;
- kernel_end = highest_elf_section->physical_address + highest_elf_section->section_size;
+ kernel_end = highest_elf_section.physical_address + highest_elf_section.section_size;
return sections;
}