aboutsummaryrefslogtreecommitdiff
path: root/arch/x86_64/src/video
diff options
context:
space:
mode:
authorFelix Morgner <felix.morgner@ost.ch>2024-09-16 14:07:41 +0000
committerFelix Morgner <felix.morgner@ost.ch>2024-09-17 08:58:55 +0200
commit8f9b9cd8aac30572b7e275bbeb1b32d2cbb8950a (patch)
tree5e215dd93c34b3d58c287b036ad2d190e0a9a772 /arch/x86_64/src/video
parentc16a3739649fa15178df667d610553e93db83e4c (diff)
downloadteachos-8f9b9cd8aac30572b7e275bbeb1b32d2cbb8950a.tar.xz
teachos-8f9b9cd8aac30572b7e275bbeb1b32d2cbb8950a.zip
build: migrate away from conan
Diffstat (limited to 'arch/x86_64/src/video')
-rw-r--r--arch/x86_64/src/video/vga/text.cpp47
1 files changed, 47 insertions, 0 deletions
diff --git a/arch/x86_64/src/video/vga/text.cpp b/arch/x86_64/src/video/vga/text.cpp
new file mode 100644
index 0000000..f1e7412
--- /dev/null
+++ b/arch/x86_64/src/video/vga/text.cpp
@@ -0,0 +1,47 @@
+#include "arch/video/vga/text.hpp"
+
+#include "arch/boot/pointers.hpp"
+#include "arch/video/vga/io.hpp"
+#include "memory/asm_pointer.hpp"
+
+#include <algorithm>
+#include <string_view>
+#include <utility>
+
+namespace teachos::arch::video::vga::text
+{
+
+ namespace
+ {
+ auto constexpr default_text_buffer_address = 0xb8000;
+
+ extern "C" std::pair<char, attribute> * vga_buffer_pointer;
+ auto constinit text_buffer = teachos::memory::asm_pointer{vga_buffer_pointer};
+
+ auto write(char code_point, attribute attribute) -> void
+ {
+ auto & p = *text_buffer;
+ (*p++) = std::pair{code_point, attribute};
+ };
+ } // namespace
+
+ auto clear(attribute attribute) -> void
+ {
+ *text_buffer = reinterpret_cast<decltype(text_buffer)::pointer>(default_text_buffer_address);
+ std::ranges::fill_n(*text_buffer, 2000, std::pair{' ', attribute});
+ }
+
+ auto cursor(bool enabled) -> void
+ {
+ auto cursor_disable_byte = std::byte{!enabled} << 5;
+
+ crtc::address_port::write(crtc::registers::cursor_start);
+ crtc::data_port::write(vga::crtc::data_port::read() | cursor_disable_byte);
+ }
+
+ auto write(std::string_view code_points, attribute attribute) -> void
+ {
+ std::ranges::for_each(code_points, [&](auto code_point) { write(code_point, attribute); });
+ }
+
+} // namespace teachos::arch::video::vga::text