aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMarvin Borner2019-10-10 18:56:48 +0200
committerMarvin Borner2019-10-10 18:56:48 +0200
commit007c5b5c429d9d524b3f88884cbebab73d15a7ea (patch)
treeed4e9eef98fb11b0976ccd8beab46ee48269ae19 /src
parent15af103dae360bcfb59b9275458db7c918b4c5ca (diff)
Implemented serial console debugging
Still trying to fix the EDID table
Diffstat (limited to 'src')
-rw-r--r--src/kernel/io/io.c22
-rw-r--r--src/kernel/io/io.h11
2 files changed, 33 insertions, 0 deletions
diff --git a/src/kernel/io/io.c b/src/kernel/io/io.c
index 74776ee..7cb364c 100644
--- a/src/kernel/io/io.c
+++ b/src/kernel/io/io.c
@@ -1,4 +1,5 @@
#include <stdint.h>
+#include "../lib/lib.h"
uint8_t receive_b(uint16_t port) {
unsigned char value;
@@ -29,3 +30,24 @@ void send_w(uint16_t port, uint16_t data) {
void send_l(uint16_t port, uint32_t data) {
asm volatile ("outl %0, %1"::"a" (data), "Nd"(port));
}
+
+void init_serial() {
+ send_b(0x3f8 + 1, 0x00);
+ send_b(0x3f8 + 3, 0x80);
+ send_b(0x3f8 + 0, 0x03);
+ send_b(0x3f8 + 1, 0x00);
+ send_b(0x3f8 + 3, 0x03);
+ send_b(0x3f8 + 2, 0xC7);
+ send_b(0x3f8 + 4, 0x0B);
+}
+
+int is_transmit_empty() {
+ return receive_b(0x3f8 + 5) & 0x20;
+}
+
+void write_serial(char *data) {
+ for (size_t i = 0; i < strlen(data); i++) {
+ while (is_transmit_empty() == 0);
+ send_b(0x3f8, data[i]);
+ }
+}
diff --git a/src/kernel/io/io.h b/src/kernel/io/io.h
index 8e39f84..e72d794 100644
--- a/src/kernel/io/io.h
+++ b/src/kernel/io/io.h
@@ -45,4 +45,15 @@ void send_w(uint16_t port, uint16_t data);
*/
void send_l(uint16_t port, uint32_t data);
+/**
+ * Initialize the serial conenction
+ */
+void init_serial();
+
+/**
+ * Write a string to the serial port (QEMU logging)
+ * @param data
+ */
+void write_serial(char *data);
+
#endif