#include "arch/video/vga/text.hpp" #include "arch/boot/pointers.hpp" #include "arch/video/vga/io.hpp" #include "memory/asm_pointer.hpp" #include #include #include namespace teachos::arch::video::vga::text { namespace { auto constexpr default_text_buffer_address = 0xb8000; extern "C" std::pair * 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(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