diff --git a/src/kernel.c b/src/kernel.c index b998b88..0570b92 100644 --- a/src/kernel.c +++ b/src/kernel.c @@ -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."); } diff --git a/src/serial.h b/src/serial.h index 4caf342..fc81df3 100644 --- a/src/serial.h +++ b/src/serial.h @@ -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);