From d2e1c8ba686d7d4ab32eda91c2f532676e9b8acf Mon Sep 17 00:00:00 2001 From: TheSoeren Date: Sun, 29 Sep 2024 14:03:39 +0000 Subject: create write_number function --- arch/x86_64/src/video/vga/text.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'arch/x86_64/src/video/vga/text.cpp') diff --git a/arch/x86_64/src/video/vga/text.cpp b/arch/x86_64/src/video/vga/text.cpp index f1e7412..bf60410 100644 --- a/arch/x86_64/src/video/vga/text.cpp +++ b/arch/x86_64/src/video/vga/text.cpp @@ -17,12 +17,6 @@ namespace teachos::arch::video::vga::text 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 @@ -39,9 +33,14 @@ namespace teachos::arch::video::vga::text crtc::data_port::write(vga::crtc::data_port::read() | cursor_disable_byte); } + auto write_char(char code_point, attribute attribute) -> void + { + auto & p = *text_buffer; + (*p++) = std::pair{code_point, attribute}; + }; + auto write(std::string_view code_points, attribute attribute) -> void { - std::ranges::for_each(code_points, [&](auto code_point) { write(code_point, attribute); }); + std::ranges::for_each(code_points, [&](auto code_point) { write_char(code_point, attribute); }); } - } // namespace teachos::arch::video::vga::text -- cgit v1.2.3 From 20a5e5377c0f8e0769d67a7928891597bc463e3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matteo=20Gm=C3=BCr?= Date: Mon, 30 Sep 2024 11:32:56 +0000 Subject: Attempt to print memory map --- arch/x86_64/src/video/vga/text.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'arch/x86_64/src/video/vga/text.cpp') diff --git a/arch/x86_64/src/video/vga/text.cpp b/arch/x86_64/src/video/vga/text.cpp index bf60410..a613c3b 100644 --- a/arch/x86_64/src/video/vga/text.cpp +++ b/arch/x86_64/src/video/vga/text.cpp @@ -10,7 +10,6 @@ namespace teachos::arch::video::vga::text { - namespace { auto constexpr default_text_buffer_address = 0xb8000; -- cgit v1.2.3 From b865b36b38d951de28cc4df5fa67338b8245a1c3 Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Thu, 17 Oct 2024 13:12:29 +0200 Subject: Implement support for `std::terminate` via `::abort` --- arch/x86_64/src/video/vga/text.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'arch/x86_64/src/video/vga/text.cpp') 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 * 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(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; -- cgit v1.2.3 From bd3ae51093b504bd035cb698c637ef6f82994ba2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matteo=20Gm=C3=BCr?= Date: Mon, 28 Oct 2024 14:48:32 +0000 Subject: Remove not required includes --- arch/x86_64/src/video/vga/text.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'arch/x86_64/src/video/vga/text.cpp') diff --git a/arch/x86_64/src/video/vga/text.cpp b/arch/x86_64/src/video/vga/text.cpp index c14de16..9eef288 100644 --- a/arch/x86_64/src/video/vga/text.cpp +++ b/arch/x86_64/src/video/vga/text.cpp @@ -1,6 +1,5 @@ #include "arch/video/vga/text.hpp" -#include "arch/boot/pointers.hpp" #include "arch/video/vga/io.hpp" #include "memory/asm_pointer.hpp" -- cgit v1.2.3 From edc11135d83ef1f8fcbc1575a290b31ccbdb7e07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matteo=20Gm=C3=BCr?= Date: Sun, 10 Nov 2024 09:34:21 +0000 Subject: Identity map memory map and vga text buffer,w hen setting up kernel --- arch/x86_64/src/video/vga/text.cpp | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'arch/x86_64/src/video/vga/text.cpp') diff --git a/arch/x86_64/src/video/vga/text.cpp b/arch/x86_64/src/video/vga/text.cpp index 9eef288..0137ddb 100644 --- a/arch/x86_64/src/video/vga/text.cpp +++ b/arch/x86_64/src/video/vga/text.cpp @@ -11,9 +11,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; + auto constexpr DEFAULT_TEXT_BUFFER_WIDTH = 80U; + auto constexpr DEFAULT_TEXT_BUFFER_HEIGHT = 25U; extern "C" std::pair * vga_buffer_pointer; auto constinit text_buffer = teachos::memory::asm_pointer{vga_buffer_pointer}; @@ -21,7 +20,7 @@ namespace teachos::arch::video::vga::text auto clear(attribute attribute) -> void { - *text_buffer = reinterpret_cast(default_text_buffer_address); + *text_buffer = reinterpret_cast(DEFAULT_VGA_TEXT_BUFFER_ADDRESS); std::ranges::fill_n(*text_buffer, 2000, std::pair{' ', attribute}); } @@ -35,21 +34,21 @@ namespace teachos::arch::video::vga::text auto newline() -> void { - auto base = reinterpret_cast(default_text_buffer_address); + auto base = reinterpret_cast(DEFAULT_VGA_TEXT_BUFFER_ADDRESS); auto & raw_buffer = *text_buffer; - auto current_line = (raw_buffer - base) / default_text_buffer_width; + auto current_line = (raw_buffer - base) / DEFAULT_TEXT_BUFFER_WIDTH; auto next_line = current_line + 1; - if (next_line >= default_text_buffer_height) + 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; + 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; + raw_buffer = base + current_line * DEFAULT_TEXT_BUFFER_WIDTH; } else { - raw_buffer = base + next_line * default_text_buffer_width; + raw_buffer = base + next_line * DEFAULT_TEXT_BUFFER_WIDTH; } } -- cgit v1.2.3