aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.vscode/tasks.json4
-rw-r--r--arch/x86_64/CMakeLists.txt3
-rw-r--r--arch/x86_64/include/x86_64/debug/qemu_output.hpp26
-rw-r--r--arch/x86_64/src/debug/qemu_output.cpp24
-rw-r--r--arch/x86_64/src/kapi/cio.cpp7
5 files changed, 61 insertions, 3 deletions
diff --git a/.vscode/tasks.json b/.vscode/tasks.json
index f94098e..e07afd2 100644
--- a/.vscode/tasks.json
+++ b/.vscode/tasks.json
@@ -13,6 +13,8 @@
"q35",
"-display",
"curses",
+ "-debugcon",
+ "file:${workspaceFolder}/qemu-debugcon-${command:cmake.buildType}.log",
"-no-reboot",
"-d",
"int,cpu_reset",
@@ -52,6 +54,8 @@
"q35",
"-display",
"curses",
+ "-debugcon",
+ "file:${workspaceFolder}/qemu-debugcon-${command:cmake.buildType}.log",
"-cdrom",
"${command:cmake.buildDirectory}/bin/${command:cmake.buildType}/kernel.iso",
"2>${workspaceFolder}/qemu-stderr-${command:cmake.buildType}.log"
diff --git a/arch/x86_64/CMakeLists.txt b/arch/x86_64/CMakeLists.txt
index 2505bb6..519fb93 100644
--- a/arch/x86_64/CMakeLists.txt
+++ b/arch/x86_64/CMakeLists.txt
@@ -17,6 +17,9 @@ target_sources("x86_64" PRIVATE
"src/boot/initialize_runtime.cpp"
"src/boot/multiboot.s"
+ # Debug interfaces
+ "src/debug/qemu_output.cpp"
+
# api::kapi implementation
"src/kapi/cio.cpp"
"src/kapi/cpu.cpp"
diff --git a/arch/x86_64/include/x86_64/debug/qemu_output.hpp b/arch/x86_64/include/x86_64/debug/qemu_output.hpp
new file mode 100644
index 0000000..759a66b
--- /dev/null
+++ b/arch/x86_64/include/x86_64/debug/qemu_output.hpp
@@ -0,0 +1,26 @@
+#ifndef TEACHOS_X86_64_DEBUG_QEMU_OUTPUT_HPP
+#define TEACHOS_X86_64_DEBUG_QEMU_OUTPUT_HPP
+
+#include "kapi/cio.hpp"
+
+#include "x86_64/device_io/port_io.hpp"
+
+#include <string_view>
+
+namespace teachos::debug::x86_64
+{
+ struct qemu_output : cio::output_device
+ {
+ using dbg = io::x86_64::port<0xE9, char, io::x86_64::port_write>;
+
+ qemu_output(output_device & lower);
+
+ auto write(cio::output_stream stream, std::string_view text) -> void override;
+
+ private:
+ output_device & m_lower;
+ };
+
+} // namespace teachos::debug::x86_64
+
+#endif \ No newline at end of file
diff --git a/arch/x86_64/src/debug/qemu_output.cpp b/arch/x86_64/src/debug/qemu_output.cpp
new file mode 100644
index 0000000..773306f
--- /dev/null
+++ b/arch/x86_64/src/debug/qemu_output.cpp
@@ -0,0 +1,24 @@
+#include "x86_64/debug/qemu_output.hpp"
+
+#include "kapi/cio.hpp"
+
+#include <string_view>
+
+namespace teachos::debug::x86_64
+{
+
+ qemu_output::qemu_output(output_device & lower)
+ : m_lower{lower}
+ {}
+
+ auto qemu_output::write(cio::output_stream stream, std::string_view text) -> void
+ {
+ for (auto c : text)
+ {
+ dbg::write(c);
+ }
+
+ m_lower.write(stream, text);
+ }
+
+} // namespace teachos::debug::x86_64
diff --git a/arch/x86_64/src/kapi/cio.cpp b/arch/x86_64/src/kapi/cio.cpp
index 617146e..5594fcc 100644
--- a/arch/x86_64/src/kapi/cio.cpp
+++ b/arch/x86_64/src/kapi/cio.cpp
@@ -1,5 +1,6 @@
#include "kapi/cio.hpp"
+#include "x86_64/debug/qemu_output.hpp"
#include "x86_64/vga/text.hpp"
#include <optional>
@@ -8,12 +9,12 @@ namespace teachos::cio
{
auto static constinit vga_device = std::optional<vga::x86_64::text::device>{};
+ auto static constinit dbg_device = std::optional<debug::x86_64::qemu_output>{};
auto init() -> void
{
- vga_device.emplace();
- vga_device->cursor(false);
- set_output_device(*vga_device);
+ vga_device.emplace().cursor(false);
+ set_output_device(dbg_device.emplace(*vga_device));
}
} // namespace teachos::cio