aboutsummaryrefslogtreecommitdiff
path: root/source/kernel/arch/x86_64
diff options
context:
space:
mode:
Diffstat (limited to 'source/kernel/arch/x86_64')
-rw-r--r--source/kernel/arch/x86_64/CMakeLists.txt1
-rw-r--r--source/kernel/arch/x86_64/include/kernel/vga.hpp11
-rw-r--r--source/kernel/arch/x86_64/src/entry.cpp9
-rw-r--r--source/kernel/arch/x86_64/src/vga.cpp30
4 files changed, 46 insertions, 5 deletions
diff --git a/source/kernel/arch/x86_64/CMakeLists.txt b/source/kernel/arch/x86_64/CMakeLists.txt
index 99fafe7..ffce50c 100644
--- a/source/kernel/arch/x86_64/CMakeLists.txt
+++ b/source/kernel/arch/x86_64/CMakeLists.txt
@@ -7,6 +7,7 @@ mark_as_advanced(TEACHOS_KERNEL_LINKER_SCRIPT)
target_sources("kernel" PRIVATE
"src/entry.cpp"
+ "src/vga.cpp"
)
target_include_directories("kernel" PRIVATE
diff --git a/source/kernel/arch/x86_64/include/kernel/vga.hpp b/source/kernel/arch/x86_64/include/kernel/vga.hpp
new file mode 100644
index 0000000..ee5a808
--- /dev/null
+++ b/source/kernel/arch/x86_64/include/kernel/vga.hpp
@@ -0,0 +1,11 @@
+#ifndef TEACHOS_KERNEL_VGA_HPP
+#define TEACHOS_KERNEL_VGA_HPP
+
+#include <string_view>
+
+namespace teachos::kernel::vga
+{
+ auto write(std::string_view text, std::byte color) -> void;
+}
+
+#endif \ No newline at end of file
diff --git a/source/kernel/arch/x86_64/src/entry.cpp b/source/kernel/arch/x86_64/src/entry.cpp
index 2d4e7fb..fd9d9d0 100644
--- a/source/kernel/arch/x86_64/src/entry.cpp
+++ b/source/kernel/arch/x86_64/src/entry.cpp
@@ -1,10 +1,9 @@
-namespace teachos
+#include "kernel/vga.hpp"
+
+namespace teachos::kernel
{
extern "C" auto kernel_main() -> void
{
- while (true)
- {
- asm volatile("nop");
- }
+ vga::write("TeachOS is starting up...", static_cast<std::byte>(0x4f));
}
} // namespace teachos
diff --git a/source/kernel/arch/x86_64/src/vga.cpp b/source/kernel/arch/x86_64/src/vga.cpp
new file mode 100644
index 0000000..d25eaa5
--- /dev/null
+++ b/source/kernel/arch/x86_64/src/vga.cpp
@@ -0,0 +1,30 @@
+#include "kernel/vga.hpp"
+
+#include "boot/asm_pointer.hpp"
+#include "boot/pointers.hpp"
+
+#include <string_view>
+#include <algorithm>
+
+namespace teachos::kernel::vga
+{
+
+ namespace
+ {
+ auto constinit text_buffer_pointer = boot::asm_pointer{boot::vga_buffer_pointer};
+
+ auto write(char character, std::byte color) -> void
+ {
+ auto & p = *text_buffer_pointer;
+ (*p++) = static_cast<std::byte>(character);
+ (*p++) = color;
+ };
+ } // namespace
+
+ auto write(std::string_view text, std::byte color) -> void {
+ std::ranges::for_each(text, [&](auto character) {
+ write(character, color);
+ });
+ }
+
+} // namespace teachos::kernel \ No newline at end of file