aboutsummaryrefslogtreecommitdiff
path: root/arch
diff options
context:
space:
mode:
authorFelix Morgner <felix.morgner@ost.ch>2025-12-19 11:46:46 +0100
committerFelix Morgner <felix.morgner@ost.ch>2025-12-19 11:46:46 +0100
commitde96b0588ab680e1002c12df7ea7900d7eb71cf8 (patch)
tree41728f4f5c77a4d96dc3d89096483dfee75b3482 /arch
parent266dde7d535d997a45f6eef41e44ebcaa516b75a (diff)
downloadteachos-de96b0588ab680e1002c12df7ea7900d7eb71cf8.tar.xz
teachos-de96b0588ab680e1002c12df7ea7900d7eb71cf8.zip
kstd: move println to kstd
Diffstat (limited to 'arch')
-rw-r--r--arch/x86_64/include/x86_64/vga/text.hpp20
-rw-r--r--arch/x86_64/src/kapi/memory.cpp9
-rw-r--r--arch/x86_64/src/memory/kernel_mapper.cpp5
-rw-r--r--arch/x86_64/src/vga/text.cpp32
4 files changed, 33 insertions, 33 deletions
diff --git a/arch/x86_64/include/x86_64/vga/text.hpp b/arch/x86_64/include/x86_64/vga/text.hpp
index 9f80f94..fcda67f 100644
--- a/arch/x86_64/include/x86_64/vga/text.hpp
+++ b/arch/x86_64/include/x86_64/vga/text.hpp
@@ -121,25 +121,7 @@ namespace teachos::vga::x86_64::text
*/
auto cursor(bool enabled) -> void;
- auto write(std::string_view text) -> void override
- {
- write(text, common_attributes::green_on_black);
- }
-
- auto writeln(std::string_view text) -> void override
- {
- writeln(text, common_attributes::green_on_black);
- }
-
- auto write_error(std::string_view text) -> void override
- {
- write(text, common_attributes::red_on_black);
- }
-
- auto writeln_error(std::string_view text) -> void override
- {
- writeln(text, common_attributes::red_on_black);
- }
+ auto write(cio::output_stream stream, std::string_view text) -> void override;
private:
using glyph = std::pair<char, std::byte>;
diff --git a/arch/x86_64/src/kapi/memory.cpp b/arch/x86_64/src/kapi/memory.cpp
index 0a45a51..5234110 100644
--- a/arch/x86_64/src/kapi/memory.cpp
+++ b/arch/x86_64/src/kapi/memory.cpp
@@ -1,7 +1,6 @@
#include "kapi/memory.hpp"
#include "kapi/boot.hpp"
-#include "kapi/cio.hpp"
#include "kapi/system.hpp"
#include "x86_64/boot/boot.hpp"
@@ -17,6 +16,8 @@
#include "x86_64/memory/region_allocator.hpp"
#include "x86_64/memory/scoped_mapping.hpp"
+#include <kstd/print>
+
#include <multiboot2/information.hpp>
#include <atomic>
@@ -164,7 +165,7 @@ namespace teachos::memory
system::panic("[x86_64] Memory management has already been initialized.");
}
- cio::println("[x86_64:MEM] Enabling additional CPU protection features.");
+ kstd::println("[x86_64:MEM] Enabling additional CPU protection features.");
enable_cpu_protections();
@@ -172,7 +173,7 @@ namespace teachos::memory
buffered_allocator.emplace(&*region_based_allocator);
recursive_page_mapper.emplace(*buffered_allocator);
- cio::println("[x86_64:MEM] Preparing new paging hierarchy.");
+ kstd::println("[x86_64:MEM] Preparing new paging hierarchy.");
auto new_pml4_frame = inject_faux_pml4(*buffered_allocator, *recursive_page_mapper);
@@ -180,7 +181,7 @@ namespace teachos::memory
remap_vga_text_mode_buffer(*recursive_page_mapper);
remap_multiboot_information(*recursive_page_mapper);
- cio::println("[x86_64:MEM] Switching to new paging hierarchy.");
+ kstd::println("[x86_64:MEM] Switching to new paging hierarchy.");
auto cr3 = cpu::x86_64::cr3::read();
cr3.frame(new_pml4_frame);
diff --git a/arch/x86_64/src/memory/kernel_mapper.cpp b/arch/x86_64/src/memory/kernel_mapper.cpp
index 5295bb3..50fa325 100644
--- a/arch/x86_64/src/memory/kernel_mapper.cpp
+++ b/arch/x86_64/src/memory/kernel_mapper.cpp
@@ -1,11 +1,12 @@
#include "x86_64/memory/kernel_mapper.hpp"
-#include "kapi/cio.hpp"
#include "kapi/memory.hpp"
#include "kapi/system.hpp"
#include "x86_64/boot/ld.hpp"
+#include <kstd/print>
+
#include <elf/format.hpp>
#include <elf/section_header.hpp>
#include <multiboot2/information.hpp>
@@ -70,7 +71,7 @@ namespace teachos::memory::x86_64
auto kernel_mapper::map_section(section_header_type const & section, std::string_view name, page_mapper & mapper)
-> void
{
- cio::println("[x86_64:MEM] mapping {} ({} bytes)", name, section.size);
+ kstd::println("[x86_64:MEM] mapping {} ({} bytes)", name, section.size);
auto number_of_pages = (section.size + (PLATFORM_PAGE_SIZE - 1)) / PLATFORM_PAGE_SIZE;
diff --git a/arch/x86_64/src/vga/text.cpp b/arch/x86_64/src/vga/text.cpp
index d4548a2..8f6214e 100644
--- a/arch/x86_64/src/vga/text.cpp
+++ b/arch/x86_64/src/vga/text.cpp
@@ -1,6 +1,7 @@
#include "x86_64/vga/text.hpp"
#include "kapi/boot.hpp"
+#include "kapi/cio.hpp"
#include "x86_64/boot/boot.hpp"
#include "x86_64/boot/ld.hpp"
@@ -76,6 +77,20 @@ namespace teachos::vga::x86_64::text
m_position = (line() - scroll_count) * DEFAULT_TEXT_BUFFER_WIDTH;
}
+ auto device::write(cio::output_stream stream, std::string_view text) -> void
+ {
+ auto attributes = [&] -> attribute {
+ switch (stream)
+ {
+ case cio::output_stream::stderr:
+ return common_attributes::red_on_black;
+ default:
+ return common_attributes::green_on_black;
+ }
+ }();
+ write(text, attributes);
+ }
+
auto device::write(std::string_view code_points, attribute attribute) -> void
{
std::ranges::for_each(code_points, [&](auto code_point) -> void { write(code_point, attribute); });
@@ -87,16 +102,17 @@ namespace teachos::vga::x86_64::text
{
scroll();
}
- buffer[m_position++] = std::pair{code_point, std::bit_cast<std::byte>(attribute)};
- };
- auto device::writeln(std::string_view code_points, attribute attribute) -> void
- {
- std::ranges::for_each(code_points, [&](auto code_point) -> void { write(code_point, attribute); });
- if (column())
+ if (code_point == '\n')
{
- newline();
+ if (column())
+ {
+ newline();
+ }
+ return;
}
- }
+
+ buffer[m_position++] = std::pair{code_point, std::bit_cast<std::byte>(attribute)};
+ };
} // namespace teachos::vga::x86_64::text