Add better serial logging

This commit is contained in:
2026-08-27 12:53:59 +03:00
parent 6cead0b223
commit a6c5053b1d
2 changed files with 22 additions and 1 deletions
+2 -1
View File
@@ -13,7 +13,8 @@
void kernel_main(void) {
init_serial();
if (!test_serial()) {
serial_log(S_ERR, "Failed to init serial!");
return;
}
send_serials("Init serial succesfully.");
serial_log(S_LOG, "Init serial succesfully.");
}
+20
View File
@@ -28,6 +28,26 @@ static inline void send_serials(const char *str) {
}
}
typedef enum {
S_LOG,
S_ERR,
} serial_print_type;
static inline void serial_log(serial_print_type type, const char *str) {
switch (type) {
case S_LOG: {
send_serials("\033[32m"); // green
break;
}
case S_ERR: {
send_serials("\033[31m"); // red
break;
}
}
send_serials(str);
send_serials("\033[0m\n");
}
static inline bool test_serial() {
bool to_return = true;
outb(COM1 + 4, 0x10);