aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source/arch/x86_64/include/arch/video/vga/io.hpp27
-rw-r--r--source/arch/x86_64/include/arch/video/vga/text.hpp13
-rw-r--r--source/arch/x86_64/src/kernel/main.cpp1
-rw-r--r--source/arch/x86_64/src/video/vga/text.cpp11
4 files changed, 48 insertions, 4 deletions
diff --git a/source/arch/x86_64/include/arch/video/vga/io.hpp b/source/arch/x86_64/include/arch/video/vga/io.hpp
new file mode 100644
index 0000000..af77998
--- /dev/null
+++ b/source/arch/x86_64/include/arch/video/vga/io.hpp
@@ -0,0 +1,27 @@
+#ifndef TEACHOS_ARCH_X86_64_VIDEO_VGA_IO_HPP
+#define TEACHOS_ARCH_X86_64_VIDEO_VGA_IO_HPP
+
+#include "arch/io/port_io.hpp"
+
+#include <cstddef>
+
+namespace teachos::arch::video::vga
+{
+
+ namespace crtc
+ {
+
+ using address_port = arch::io::port<0x3d4, 1>;
+ using data_port = arch::io::port<0x3d5, 1>;
+
+ namespace registers
+ {
+ [[maybe_unused]] auto constexpr cursor_start = std::byte{0x0a};
+ [[maybe_unused]] auto constexpr curser_end = std::byte{0x0b};
+ } // namespace registers
+
+ }; // namespace crtc
+
+} // namespace teachos::arch::video::vga
+
+#endif \ No newline at end of file
diff --git a/source/arch/x86_64/include/arch/video/vga/text.hpp b/source/arch/x86_64/include/arch/video/vga/text.hpp
index c8ff162..e615eba 100644
--- a/source/arch/x86_64/include/arch/video/vga/text.hpp
+++ b/source/arch/x86_64/include/arch/video/vga/text.hpp
@@ -77,16 +77,23 @@ namespace teachos::arch::video::vga::text
* @brief Clear the VGA text mode buffer.
*
* @note This function also resets the text mode buffer pointer.
- *
+ *
* @param attribute The attribute to "clear" the screen with.
*/
auto clear(attribute attribute = common_attributes::gray_on_black) -> void;
/**
+ * @brief Enable or disable the VGA text mode cursor.
+ *
+ * @param enabled Whether or not to enable the cursors.
+ */
+ auto cursor(bool enabled) -> void;
+
+ /**
* @brief Write a string of code points to the VGA text buffer.
- *
+ *
* @note This function also updates the text mode buffer pointer.
- *
+ *
* @param code_points A string of (8-bit) code points to write to the VGA text mode buffer.
* @param attribute The attribute to apply to the written sequence of code points.
* @see vga::text::attribute
diff --git a/source/arch/x86_64/src/kernel/main.cpp b/source/arch/x86_64/src/kernel/main.cpp
index 26ae730..0e90264 100644
--- a/source/arch/x86_64/src/kernel/main.cpp
+++ b/source/arch/x86_64/src/kernel/main.cpp
@@ -9,6 +9,7 @@ namespace teachos::arch::kernel
using namespace video::vga;
text::clear();
+ text::cursor(false);
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 ad9e46c..8259c5a 100644
--- a/source/arch/x86_64/src/video/vga/text.cpp
+++ b/source/arch/x86_64/src/video/vga/text.cpp
@@ -1,6 +1,7 @@
#include "arch/video/vga/text.hpp"
#include "arch/boot/pointers.hpp"
+#include "arch/video/vga/io.hpp"
#include "memory/asm_pointer.hpp"
#include <algorithm>
@@ -30,9 +31,17 @@ namespace teachos::arch::video::vga::text
std::ranges::fill_n(*text_buffer, 2000, std::pair{' ', attribute});
}
+ auto cursor(bool enabled) -> void
+ {
+ auto cursor_disable_byte = std::byte{!enabled} << 5;
+
+ crtc::address_port::write(crtc::registers::cursor_start);
+ crtc::data_port::write(vga::crtc::data_port::read() | cursor_disable_byte);
+ }
+
auto write(std::string_view code_points, attribute attribute) -> void
{
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
+} // namespace teachos::arch::video::vga::text