diff options
| author | Felix Morgner <felix.morgner@ost.ch> | 2024-10-17 13:12:29 +0200 |
|---|---|---|
| committer | Matteo Gmür <matteo.gmuer1@ost.ch> | 2024-10-17 13:12:29 +0200 |
| commit | b865b36b38d951de28cc4df5fa67338b8245a1c3 (patch) | |
| tree | 694825047086e18855bdb34fc24698292f6258ff /arch/x86_64/src/video/vga | |
| parent | d539ed1f4f26a42959bcae6ea3050b7f99f5f872 (diff) | |
| download | teachos-b865b36b38d951de28cc4df5fa67338b8245a1c3.tar.xz teachos-b865b36b38d951de28cc4df5fa67338b8245a1c3.zip | |
Implement support for `std::terminate` via `::abort`
Diffstat (limited to 'arch/x86_64/src/video/vga')
| -rw-r--r-- | arch/x86_64/src/video/vga/text.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/arch/x86_64/src/video/vga/text.cpp b/arch/x86_64/src/video/vga/text.cpp index a613c3b..c14de16 100644 --- a/arch/x86_64/src/video/vga/text.cpp +++ b/arch/x86_64/src/video/vga/text.cpp @@ -13,6 +13,8 @@ namespace teachos::arch::video::vga::text namespace { auto constexpr default_text_buffer_address = 0xb8000; + auto constexpr default_text_buffer_width = 80; + auto constexpr default_text_buffer_height = 25; extern "C" std::pair<char, attribute> * vga_buffer_pointer; auto constinit text_buffer = teachos::memory::asm_pointer{vga_buffer_pointer}; @@ -32,6 +34,26 @@ namespace teachos::arch::video::vga::text crtc::data_port::write(vga::crtc::data_port::read() | cursor_disable_byte); } + auto newline() -> void + { + auto base = reinterpret_cast<decltype(text_buffer)::pointer>(default_text_buffer_address); + auto & raw_buffer = *text_buffer; + auto current_line = (raw_buffer - base) / default_text_buffer_width; + auto next_line = current_line + 1; + + if (next_line >= default_text_buffer_height) + { + auto begin = base + default_text_buffer_width; + auto end = base + default_text_buffer_width * default_text_buffer_height; + std::ranges::move(begin, end, base); + raw_buffer = base + current_line * default_text_buffer_width; + } + else + { + raw_buffer = base + next_line * default_text_buffer_width; + } + } + auto write_char(char code_point, attribute attribute) -> void { auto & p = *text_buffer; |
