From 4edbe94ce1266c9acc6a695fedf1d2edd4ce11cd Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Thu, 24 Jul 2025 15:31:31 +0000 Subject: build: factor out kernel API --- arch/x86_64/src/io.cpp | 44 ++++++++++++++++++++++++++------------------ arch/x86_64/src/memory.cpp | 12 ++++++------ arch/x86_64/src/system.cpp | 6 +++--- 3 files changed, 35 insertions(+), 27 deletions(-) (limited to 'arch/x86_64/src') diff --git a/arch/x86_64/src/io.cpp b/arch/x86_64/src/io.cpp index 8e9e411..eab6473 100644 --- a/arch/x86_64/src/io.cpp +++ b/arch/x86_64/src/io.cpp @@ -1,28 +1,36 @@ -#include "kern/print.hpp" +#include "kapi/io.hpp" + #include "x86_64/vga/text.hpp" -namespace teachos::arch::io +namespace teachos::io { auto init() -> void { + x86_64::vga::text::clear(); x86_64::vga::text::cursor(false); + } + + auto print(std::string_view text) -> void + { + x86_64::vga::text::write(text, x86_64::vga::text::common_attributes::green_on_black); + } + + auto println(std::string_view text) -> void + { + x86_64::vga::text::write(text, x86_64::vga::text::common_attributes::green_on_black); + x86_64::vga::text::newline(); + } + + auto print_error(std::string_view text) -> void + { + x86_64::vga::text::write(text, x86_64::vga::text::common_attributes::red_on_black); + } - teachos::set_print_handler( - [](auto text) { return x86_64::vga::text::write(text, x86_64::vga::text::common_attributes::green_on_black); }); - teachos::set_println_handler([](auto text) { - x86_64::vga::text::write(text, x86_64::vga::text::common_attributes::green_on_black); - x86_64::vga::text::newline(); - }); - - teachos::set_print_error_handler( - [](auto text) { return x86_64::vga::text::write(text, x86_64::vga::text::common_attributes::red_on_black); }); - teachos::set_println_error_handler([](auto text) { - x86_64::vga::text::write(text, x86_64::vga::text::common_attributes::red_on_black); - x86_64::vga::text::newline(); - }); - - teachos::println("[x86-64] Basic VGA text output initialized."); + auto println_error(std::string_view text) -> void + { + x86_64::vga::text::write(text, x86_64::vga::text::common_attributes::red_on_black); + x86_64::vga::text::newline(); } -} // namespace teachos::arch::io +} // namespace teachos::io diff --git a/arch/x86_64/src/memory.cpp b/arch/x86_64/src/memory.cpp index b6901a5..d1c1f03 100644 --- a/arch/x86_64/src/memory.cpp +++ b/arch/x86_64/src/memory.cpp @@ -1,6 +1,6 @@ -#include "arch/memory.hpp" +#include "kapi/memory.hpp" -#include "kern/error.hpp" +#include "kapi/system.hpp" #include "x86_64/boot/boot.hpp" #include "x86_64/boot/ld.hpp" @@ -11,7 +11,7 @@ #include -namespace teachos::arch::memory +namespace teachos::memory { using namespace x86_64::memory; using namespace x86_64::boot; @@ -36,13 +36,13 @@ namespace teachos::arch::memory { if (is_initialized.test_and_set()) { - teachos::panic("[x86_64] Memory management has already been initialized."); + system::panic("[x86_64] Memory management has already been initialized."); } auto memory_map = multiboot_information_pointer->maybe_memory_map(); if (!memory_map) { - teachos::panic("[x86_64] No memory map available."); + system::panic("[x86_64] No memory map available."); } auto mem_info = create_memory_information(); @@ -63,4 +63,4 @@ namespace teachos::arch::memory // video::vga::text::newline(); } -} // namespace teachos::arch::memory +} // namespace teachos::memory diff --git a/arch/x86_64/src/system.cpp b/arch/x86_64/src/system.cpp index 60ebf0e..2d4c3fe 100644 --- a/arch/x86_64/src/system.cpp +++ b/arch/x86_64/src/system.cpp @@ -1,6 +1,6 @@ -#include "arch/system.hpp" +#include "kapi/system.hpp" -namespace teachos::arch::system +namespace teachos::system { auto halt() -> void @@ -9,4 +9,4 @@ namespace teachos::arch::system __builtin_unreachable(); } -} // namespace teachos::arch::system +} // namespace teachos::system -- cgit v1.2.3