diff options
Diffstat (limited to 'source/arch/x86_64/src')
| -rw-r--r-- | source/arch/x86_64/src/boot/boot.s | 6 | ||||
| -rw-r--r-- | source/arch/x86_64/src/kernel/main.cpp | 9 | ||||
| -rw-r--r-- | source/arch/x86_64/src/video/vga/text.cpp | 21 |
3 files changed, 20 insertions, 16 deletions
diff --git a/source/arch/x86_64/src/boot/boot.s b/source/arch/x86_64/src/boot/boot.s index 45f261e..7b4e193 100644 --- a/source/arch/x86_64/src/boot/boot.s +++ b/source/arch/x86_64/src/boot/boot.s @@ -362,11 +362,7 @@ _transition_to_long_mode: mov %rax, %fs mov %rax, %gs - /* Clear the screen */ - mov $0x0f200f200f200f20, %rax - mov $0x0b8000, %rdi - mov $500, %rcx - rep stosq + movl $0xb8000, (vga_buffer_pointer) call _init diff --git a/source/arch/x86_64/src/kernel/main.cpp b/source/arch/x86_64/src/kernel/main.cpp index 9ea756a..26ae730 100644 --- a/source/arch/x86_64/src/kernel/main.cpp +++ b/source/arch/x86_64/src/kernel/main.cpp @@ -6,10 +6,9 @@ namespace teachos::arch::kernel { auto main() -> void { - video::vga::text::write("TeachOS is starting up...", static_cast<std::byte>(0x4f)); - while (true) - { - asm volatile("hlt"); - } + using namespace video::vga; + + text::clear(); + text::write("TeachOS is starting up...", text::common_attributes::green_on_black); } } // namespace teachos::arch::kernel diff --git a/source/arch/x86_64/src/video/vga/text.cpp b/source/arch/x86_64/src/video/vga/text.cpp index 11e3b1a..df61ce6 100644 --- a/source/arch/x86_64/src/video/vga/text.cpp +++ b/source/arch/x86_64/src/video/vga/text.cpp @@ -5,25 +5,34 @@ #include <algorithm> #include <string_view> +#include <utility> namespace teachos::arch::video::vga::text { namespace { - auto constinit text_buffer = teachos::boot::asm_pointer{boot::vga_buffer_pointer}; + auto constexpr default_text_buffer_address = 0xb8000; - auto write(char character, std::byte color) -> void + extern "C" std::pair<char, attribute> * vga_buffer_pointer; + auto constinit text_buffer = teachos::boot::asm_pointer{vga_buffer_pointer}; + + auto write(char code_point, attribute attribute) -> void { auto & p = *text_buffer; - (*p++) = static_cast<std::byte>(character); - (*p++) = color; + (*p++) = std::pair{code_point, attribute}; }; } // namespace - auto write(std::string_view text, std::byte color) -> void + auto clear(attribute attribute) -> void + { + *text_buffer = reinterpret_cast<decltype(text_buffer)::pointer>(default_text_buffer_address); + std::ranges::generate_n(*text_buffer, 2000, [&]{ return std::pair{' ', attribute}; }); + } + + auto write(std::string_view code_points, attribute attribute) -> void { - std::ranges::for_each(text, [&](auto character) { write(character, color); }); + std::ranges::for_each(code_points, [&](auto code_point) { write(code_point, attribute); }); } } // namespace teachos::arch::video::vga::text
\ No newline at end of file |
