aboutsummaryrefslogtreecommitdiff
path: root/arch/x86_64/include
diff options
context:
space:
mode:
Diffstat (limited to 'arch/x86_64/include')
-rw-r--r--arch/x86_64/include/x86_64/boot/boot.hpp26
-rw-r--r--arch/x86_64/include/x86_64/boot/ld.hpp4
-rw-r--r--arch/x86_64/include/x86_64/cpu/registers.hpp4
-rw-r--r--arch/x86_64/include/x86_64/device_io/port_io.hpp4
-rw-r--r--arch/x86_64/include/x86_64/memory/address.hpp47
-rw-r--r--arch/x86_64/include/x86_64/memory/frame.hpp95
-rw-r--r--arch/x86_64/include/x86_64/memory/mmu.hpp6
-rw-r--r--arch/x86_64/include/x86_64/memory/region_allocator.hpp8
-rw-r--r--arch/x86_64/include/x86_64/vga/crtc.hpp8
-rw-r--r--arch/x86_64/include/x86_64/vga/text.hpp4
10 files changed, 34 insertions, 172 deletions
diff --git a/arch/x86_64/include/x86_64/boot/boot.hpp b/arch/x86_64/include/x86_64/boot/boot.hpp
index 1887e73..86f8ce3 100644
--- a/arch/x86_64/include/x86_64/boot/boot.hpp
+++ b/arch/x86_64/include/x86_64/boot/boot.hpp
@@ -48,18 +48,22 @@
#include <kstd/asm_ptr>
-extern "C"
+namespace teachos::boot::x86_64
{
- /**
- * @brief A pointer to the multiboot 2 information structure provided by the boot loader.
- */
- extern kstd::asm_ptr<multiboot2::information_view> multiboot_information_pointer;
-
- /**
- * @brief A pointer to the VGA text mode buffer.
- */
- extern kstd::asm_ptr<std::pair<char, std::byte>> vga_buffer_pointer;
-}
+
+ extern "C"
+ {
+ /**
+ * @brief A pointer to the multiboot 2 information structure provided by the boot loader.
+ */
+ extern kstd::asm_ptr<multiboot2::information_view> multiboot_information_pointer;
+
+ /**
+ * @brief A pointer to the VGA text mode buffer.
+ */
+ extern kstd::asm_ptr<std::pair<char, std::byte>> vga_buffer_pointer;
+ }
+} // namespace teachos::boot::x86_64
#endif
diff --git a/arch/x86_64/include/x86_64/boot/ld.hpp b/arch/x86_64/include/x86_64/boot/ld.hpp
index 51eb23b..cf59c66 100644
--- a/arch/x86_64/include/x86_64/boot/ld.hpp
+++ b/arch/x86_64/include/x86_64/boot/ld.hpp
@@ -17,7 +17,7 @@
#include <cstddef>
-namespace teachos::x86_64::boot
+namespace teachos::boot::x86_64
{
/**
* @var _start_physical
@@ -42,6 +42,6 @@ namespace teachos::x86_64::boot
* @see _start_physical
*/
extern "C" std::byte _end_physical;
-} // namespace teachos::x86_64::boot
+} // namespace teachos::boot::x86_64
#endif
diff --git a/arch/x86_64/include/x86_64/cpu/registers.hpp b/arch/x86_64/include/x86_64/cpu/registers.hpp
index 607d559..d19acfc 100644
--- a/arch/x86_64/include/x86_64/cpu/registers.hpp
+++ b/arch/x86_64/include/x86_64/cpu/registers.hpp
@@ -3,7 +3,7 @@
#include <cstdint>
-namespace teachos::x86_64::cpu
+namespace teachos::cpu::x86_64
{
/**
@@ -67,6 +67,6 @@ namespace teachos::x86_64::cpu
*/
auto set_cr0_bit(cr0_flags flag) -> void;
-} // namespace teachos::x86_64::cpu
+} // namespace teachos::cpu::x86_64
#endif \ No newline at end of file
diff --git a/arch/x86_64/include/x86_64/device_io/port_io.hpp b/arch/x86_64/include/x86_64/device_io/port_io.hpp
index 4cf0b65..352a4d0 100644
--- a/arch/x86_64/include/x86_64/device_io/port_io.hpp
+++ b/arch/x86_64/include/x86_64/device_io/port_io.hpp
@@ -5,7 +5,7 @@
#include <cstdint>
#include <type_traits>
-namespace teachos::x86_64::io
+namespace teachos::io::x86_64
{
/**
* @brief An I/O port of a given size at a given address.
@@ -127,6 +127,6 @@ namespace teachos::x86_64::io
}
};
-} // namespace teachos::x86_64::io
+} // namespace teachos::io::x86_64
#endif \ No newline at end of file
diff --git a/arch/x86_64/include/x86_64/memory/address.hpp b/arch/x86_64/include/x86_64/memory/address.hpp
deleted file mode 100644
index 20e9655..0000000
--- a/arch/x86_64/include/x86_64/memory/address.hpp
+++ /dev/null
@@ -1,47 +0,0 @@
-#ifndef TEACHOS_X86_64_MEMORY_ADDRESS_HPP
-#define TEACHOS_X86_64_MEMORY_ADDRESS_HPP
-
-#include <bit>
-#include <compare>
-#include <cstddef>
-#include <cstdint>
-
-namespace teachos::x86_64::memory
-{
-
- enum struct address_type : bool
- {
- linear,
- physical,
- };
-
- template<address_type Type>
- struct address
- {
- constexpr explicit address(std::uintptr_t value) noexcept
- : m_value{value}
- {
- }
-
- explicit address(std::byte * pointer) noexcept
- : m_value{std::bit_cast<std::uintptr_t>(pointer)}
- {
- }
-
- explicit operator std::byte *() const noexcept { return std::bit_cast<std::byte *>(m_value); }
-
- auto constexpr operator<=>(address const &) const noexcept -> std::strong_ordering = default;
- auto constexpr operator==(address const &) const noexcept -> bool = default;
-
- auto constexpr raw() const noexcept -> std::uintptr_t { return m_value; }
-
- private:
- std::uintptr_t m_value{};
- };
-
- using linear_address = address<address_type::linear>;
- using physical_address = address<address_type::physical>;
-
-} // namespace teachos::x86_64::memory
-
-#endif \ No newline at end of file
diff --git a/arch/x86_64/include/x86_64/memory/frame.hpp b/arch/x86_64/include/x86_64/memory/frame.hpp
deleted file mode 100644
index 21565fd..0000000
--- a/arch/x86_64/include/x86_64/memory/frame.hpp
+++ /dev/null
@@ -1,95 +0,0 @@
-#ifndef TEACHOS_X86_64_MEMORY_FRAME_HPP
-#define TEACHOS_X86_64_MEMORY_FRAME_HPP
-
-#include "x86_64/memory/address.hpp"
-
-#include <compare>
-#include <cstddef>
-
-namespace teachos::x86_64::memory
-{
- /**
- * @brief Specific physical frame containing helper functions to determine if a specific address is in that
- * physical frame or not.
- */
- struct frame
- {
- auto static inline constexpr DEFAULT_SIZE = std::size_t{4096}; ///< Default page size of x86_84 is always 4KiB.
-
- /**
- * @brief Defaulted constructor.
- */
- constexpr frame() = default;
-
- /**
- * @brief Constructor.
- *
- * @param frame_number Index number that should be assigned to this physical frame.
- */
- explicit constexpr frame(std::size_t number)
- : m_number(number)
- {
- }
-
- /**
- * @brief Returns the physical frame the given address is contained in.
- *
- * @param address Physical address we want to get the corresponding physical frame for.
- * @return Frame the given address is contained in.
- */
- auto constexpr static containing(physical_address address) noexcept -> frame
- {
- return frame{address.raw() / DEFAULT_SIZE};
- }
-
- /**
- * @brief Get the start address of this physical frame.
- *
- * @return Start address of the physical frame.
- */
- auto constexpr start_address() const noexcept -> physical_address
- {
- return physical_address{m_number * DEFAULT_SIZE};
- }
-
- auto constexpr operator+(std::size_t offset) const noexcept -> frame { return frame{m_number + offset}; }
-
- /**
- * @brief Post increment operator. Returns a copy of the value.
- *
- * @return Copy of the incremented underlying frame number.
- */
- auto constexpr operator++(int) noexcept -> frame
- {
- auto copy = *this;
- return ++copy;
- }
-
- /**
- * @brief Pre increment operator. Returns a reference to the changed value.
- *
- * @return Reference to the incremented underlying frame number.
- */
- auto constexpr operator++() noexcept -> frame &
- {
- ++m_number;
- return *this;
- }
-
- /**
- * @brief Defaulted equals operator.
- */
- auto constexpr operator==(frame const & other) const noexcept -> bool = default;
-
- /**
- * @brief Defaulted three-way comparison operator.
- */
- auto constexpr operator<=>(frame const & other) const noexcept -> std::strong_ordering = default;
-
- private:
- std::size_t m_number{}; ///< Index number of the current physical frame, used to distinguish it from other frames.
- };
-
-} // namespace teachos::x86_64::memory
-
-#endif // TEACHOS_ARCH_X86_64_MEMORY_ALLOCATOR_frame_HPP
diff --git a/arch/x86_64/include/x86_64/memory/mmu.hpp b/arch/x86_64/include/x86_64/memory/mmu.hpp
index b03ffa2..323d18a 100644
--- a/arch/x86_64/include/x86_64/memory/mmu.hpp
+++ b/arch/x86_64/include/x86_64/memory/mmu.hpp
@@ -1,9 +1,9 @@
#ifndef TEACHOS_X86_64_MEMORY_MMU_HPP
#define TEACHOS_X86_64_MEMORY_MMU_HPP
-#include "x86_64/memory/address.hpp"
+#include "kapi/memory/address.hpp"
-namespace teachos::x86_64::memory
+namespace teachos::memory::x86_64
{
/**
* @brief Invalidates any translation lookaside buffer (TLB) entry for the page table the given address is cotained
@@ -22,6 +22,6 @@ namespace teachos::x86_64::memory
*/
auto tlb_flush_all() -> void;
-} // namespace teachos::x86_64::memory
+} // namespace teachos::memory::x86_64
#endif \ No newline at end of file
diff --git a/arch/x86_64/include/x86_64/memory/region_allocator.hpp b/arch/x86_64/include/x86_64/memory/region_allocator.hpp
index 23bea10..a918195 100644
--- a/arch/x86_64/include/x86_64/memory/region_allocator.hpp
+++ b/arch/x86_64/include/x86_64/memory/region_allocator.hpp
@@ -1,15 +1,15 @@
#ifndef TEACHOS_X86_64_MEMORY_REGION_ALLOCATOR_HPP
#define TEACHOS_X86_64_MEMORY_REGION_ALLOCATOR_HPP
-#include "x86_64/memory/address.hpp"
-#include "x86_64/memory/frame.hpp"
+#include "kapi/memory/address.hpp"
+#include "kapi/memory/frame.hpp"
#include <multiboot2/information.hpp>
#include <optional>
#include <utility>
-namespace teachos::x86_64::memory
+namespace teachos::memory::x86_64
{
/**
* @brief Allocates memory linearly using memory areas read from the multiboot2 information pointer and leaks any
@@ -71,6 +71,6 @@ namespace teachos::x86_64::memory
frame const m_multiboot_end; ///< The end address of the multiboot code in memory.
};
-} // namespace teachos::x86_64::memory
+} // namespace teachos::memory::x86_64
#endif // TEACHOS_ARCH_X86_64_MEMORY_ALLOCATOR_AREA_FRAME_ALLOCATOR_HPP
diff --git a/arch/x86_64/include/x86_64/vga/crtc.hpp b/arch/x86_64/include/x86_64/vga/crtc.hpp
index 4b4eac5..e5ab9f1 100644
--- a/arch/x86_64/include/x86_64/vga/crtc.hpp
+++ b/arch/x86_64/include/x86_64/vga/crtc.hpp
@@ -5,17 +5,17 @@
#include <cstddef>
-namespace teachos::x86_64::vga::crtc
+namespace teachos::vga::x86_64::crtc
{
/**
* @brief The address port of the CRT Controller.
*/
- using address = x86_64::io::port<0x3d4, 1>;
+ using address = io::x86_64::port<0x3d4, 1>;
/**
* @brief The data port of the CRT Controller.
*/
- using data = x86_64::io::port<0x3d5, 1>;
+ using data = io::x86_64::port<0x3d5, 1>;
namespace registers
{
@@ -30,6 +30,6 @@ namespace teachos::x86_64::vga::crtc
[[maybe_unused]] auto constexpr cursor_end = std::byte{0x0b};
} // namespace registers
-} // namespace teachos::x86_64::vga::crtc
+} // namespace teachos::vga::x86_64::crtc
#endif \ No newline at end of file
diff --git a/arch/x86_64/include/x86_64/vga/text.hpp b/arch/x86_64/include/x86_64/vga/text.hpp
index f8e6f1b..c193576 100644
--- a/arch/x86_64/include/x86_64/vga/text.hpp
+++ b/arch/x86_64/include/x86_64/vga/text.hpp
@@ -6,7 +6,7 @@
#include <cstdint>
#include <string_view>
-namespace teachos::x86_64::vga::text
+namespace teachos::vga::x86_64::text
{
/**
* @brief The colors available in the standard VGA text mode.
@@ -142,6 +142,6 @@ namespace teachos::x86_64::vga::text
auto writeln(std::string_view code_points, attribute attribute) -> void;
};
-} // namespace teachos::x86_64::vga::text
+} // namespace teachos::vga::x86_64::text
#endif // TEACHOS_ARCH_X86_64_VIDEO_VGA_TEXT_HPP \ No newline at end of file