Add better serial logging
This commit is contained in:
+2
-1
@@ -13,7 +13,8 @@
|
|||||||
void kernel_main(void) {
|
void kernel_main(void) {
|
||||||
init_serial();
|
init_serial();
|
||||||
if (!test_serial()) {
|
if (!test_serial()) {
|
||||||
|
serial_log(S_ERR, "Failed to init serial!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
send_serials("Init serial succesfully.");
|
serial_log(S_LOG, "Init serial succesfully.");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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() {
|
static inline bool test_serial() {
|
||||||
bool to_return = true;
|
bool to_return = true;
|
||||||
outb(COM1 + 4, 0x10);
|
outb(COM1 + 4, 0x10);
|
||||||
|
|||||||
Reference in New Issue
Block a user