aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/arch/x86_64/serial.cpp
diff options
context:
space:
mode:
authorEmulatedSeasons <89668582+EmulatedSeasons@users.noreply.github.com>2024-05-07 11:07:03 -0400
committerEmulatedSeasons <89668582+EmulatedSeasons@users.noreply.github.com>2024-05-07 11:07:03 -0400
commitabaab98bd757cd0818cfcddc983eee25ab7672ed (patch)
tree4e5d407cf55877b38699ac12b904be2dc3d99864 /kernel/arch/x86_64/serial.cpp
parent47d94ed4fd724d0e8b7819e7e3d0783c798ea190 (diff)
Made framebuffer class, serial write functions, and finally got makefile to build without having to make clean
Diffstat (limited to 'kernel/arch/x86_64/serial.cpp')
-rw-r--r--kernel/arch/x86_64/serial.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/kernel/arch/x86_64/serial.cpp b/kernel/arch/x86_64/serial.cpp
new file mode 100644
index 0000000..e90bcde
--- /dev/null
+++ b/kernel/arch/x86_64/serial.cpp
@@ -0,0 +1,23 @@
+#include <io.h>
+#include <string.h>
+
+#define PORT 0x3f8
+
+int is_transmit_empty() {
+ return inb(PORT + 5) & 0x20;
+}
+
+extern "C" void serial_putchar(char c) {
+ while (is_transmit_empty() == 0);
+ outb(PORT, c);
+}
+
+void serial_write(const char* data, size_t size) {
+ for (size_t i = 0; i < size; i++) {
+ serial_putchar(data[i]);
+ }
+}
+
+void serial_writestring(const char* data) {
+ serial_write(data, strlen(data));
+} \ No newline at end of file