aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelix Morgner <felix.morgner@ost.ch>2025-07-23 13:21:32 +0000
committerFelix Morgner <felix.morgner@ost.ch>2025-07-23 13:21:32 +0000
commite97e86d169849527190cef1913efdd247e6f68df (patch)
treec46f0fe0eeaf50354f7a1c65304faae0b670a1b5
parent3a407e83b2dbd15936569ff90e4433078ea1cbaf (diff)
downloadteachos-e97e86d169849527190cef1913efdd247e6f68df.tar.xz
teachos-e97e86d169849527190cef1913efdd247e6f68df.zip
libs: move asm_ptr to kstd
-rw-r--r--arch/x86_64/include/x86_64/boot/boot.hpp8
-rw-r--r--arch/x86_64/src/vga/text.cpp9
-rw-r--r--libs/kstd/CMakeLists.txt1
-rw-r--r--libs/kstd/include/kstd/asm_ptr (renamed from arch/include/arch/asm_pointer.hpp)23
4 files changed, 20 insertions, 21 deletions
diff --git a/arch/x86_64/include/x86_64/boot/boot.hpp b/arch/x86_64/include/x86_64/boot/boot.hpp
index 066e49e..1887e73 100644
--- a/arch/x86_64/include/x86_64/boot/boot.hpp
+++ b/arch/x86_64/include/x86_64/boot/boot.hpp
@@ -44,21 +44,21 @@
#else
-#include "arch/asm_pointer.hpp"
-
#include <multiboot2/information.hpp>
+#include <kstd/asm_ptr>
+
extern "C"
{
/**
* @brief A pointer to the multiboot 2 information structure provided by the boot loader.
*/
- extern teachos::arch::asm_pointer<multiboot2::information_view> multiboot_information_pointer;
+ extern kstd::asm_ptr<multiboot2::information_view> multiboot_information_pointer;
/**
* @brief A pointer to the VGA text mode buffer.
*/
- extern teachos::arch::asm_pointer<std::pair<char, std::byte>> vga_buffer_pointer;
+ extern kstd::asm_ptr<std::pair<char, std::byte>> vga_buffer_pointer;
}
#endif
diff --git a/arch/x86_64/src/vga/text.cpp b/arch/x86_64/src/vga/text.cpp
index 16abf08..dcfdb6b 100644
--- a/arch/x86_64/src/vga/text.cpp
+++ b/arch/x86_64/src/vga/text.cpp
@@ -1,15 +1,14 @@
#include "x86_64/vga/text.hpp"
-#include "arch/asm_pointer.hpp"
+#include "x86_64/boot/boot.hpp"
#include "x86_64/vga/io.hpp"
#include <algorithm>
+#include <bit>
#include <cstddef>
#include <string_view>
#include <utility>
-extern "C" teachos::arch::asm_pointer<std::pair<char, teachos::x86_64::vga::text::attribute>> vga_buffer_pointer;
-
namespace teachos::x86_64::vga::text
{
namespace
@@ -23,7 +22,7 @@ namespace teachos::x86_64::vga::text
auto clear(attribute attribute) -> void
{
buffer_offset = 0;
- std::ranges::fill_n(vga_buffer_pointer.get(), 2000, std::pair{' ', attribute});
+ std::ranges::fill_n(vga_buffer_pointer.get(), 2000, std::pair{' ', std::bit_cast<std::byte>(attribute)});
}
auto cursor(bool enabled) -> void
@@ -54,7 +53,7 @@ namespace teachos::x86_64::vga::text
auto write_char(char code_point, attribute attribute) -> void
{
- vga_buffer_pointer[buffer_offset++] = std::pair{code_point, attribute};
+ vga_buffer_pointer[buffer_offset++] = std::pair{code_point, std::bit_cast<std::byte>(attribute)};
};
auto write(std::string_view code_points, attribute attribute) -> void
diff --git a/libs/kstd/CMakeLists.txt b/libs/kstd/CMakeLists.txt
index b0abaaf..ac9e78f 100644
--- a/libs/kstd/CMakeLists.txt
+++ b/libs/kstd/CMakeLists.txt
@@ -13,6 +13,7 @@ target_sources("kstd" PUBLIC
"include/kstd/bits/shared_ptr.hpp"
"include/kstd/bits/unique_ptr.hpp"
+ "include/kstd/asm_ptr"
"include/kstd/memory"
"include/kstd/mutex"
"include/kstd/stack"
diff --git a/arch/include/arch/asm_pointer.hpp b/libs/kstd/include/kstd/asm_ptr
index c867d8f..e9072e2 100644
--- a/arch/include/arch/asm_pointer.hpp
+++ b/libs/kstd/include/kstd/asm_ptr
@@ -1,19 +1,18 @@
-#ifndef TEACHOS_MEMORY_ASM_POINTER_HPP
-#define TEACHOS_MEMORY_ASM_POINTER_HPP
+#ifndef KSTD_ASM_POINTER_HPP
+#define KSTD_ASM_POINTER_HPP
#include <bit>
-namespace teachos::arch
+namespace kstd
{
/**
* @brief A pointer that is defined in some assembly source file.
*
* @tparam Type The type of the pointer
- * @since 0.0.1
*/
template<typename Type>
- struct asm_pointer
+ struct asm_ptr
{
using value_type = Type;
using pointer = value_type *;
@@ -21,12 +20,12 @@ namespace teachos::arch
using reference = value_type &;
using const_reference = value_type const &;
- asm_pointer() = delete;
- asm_pointer(asm_pointer const &) = delete;
- asm_pointer(asm_pointer &&) = delete;
+ asm_ptr() = delete;
+ asm_ptr(asm_ptr const &) = delete;
+ asm_ptr(asm_ptr &&) = delete;
- auto constexpr operator=(asm_pointer const &) = delete;
- auto constexpr operator=(asm_pointer &&) = delete;
+ auto constexpr operator=(asm_ptr const &) = delete;
+ auto constexpr operator=(asm_ptr &&) = delete;
auto get() const noexcept -> pointer { return m_ptr; }
@@ -51,6 +50,6 @@ namespace teachos::arch
pointer m_ptr;
};
-} // namespace teachos::arch
+} // namespace kstd
-#endif // TEACHOS_MEMORY_ASM_POINTER_HPP
+#endif \ No newline at end of file