Add: serial logging function w/ errlevels

This commit is contained in:
xamidev
2024-05-22 11:54:59 +02:00
parent 87c1a97d47
commit 61dec7fe14
7 changed files with 26 additions and 3 deletions

BIN
com1.out

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -3,11 +3,12 @@
int kmain(int retvalue)
{
init_serial();
log("serial connection established", 3);
log("Kernel started", 2);
clear();
puts("hello\nbrave\nnew\nworld");
init_serial();
serial_puts("Hello, brave new world. This is a message to let you know that the kernel has started.\n");
serial_puts("This is a second message.\n");
return retvalue;
}

BIN
os.iso

Binary file not shown.

View File

@@ -42,3 +42,24 @@ void serial_puts(const char* str)
write_serial(str[i]);
}
}
void log(const char* str, const int errlevel)
{
switch (errlevel)
{
case 0:
serial_puts("[ERROR] ");
break;
case 1:
serial_puts("[WARNING] ");
break;
case 2:
serial_puts("[INFO] ");
break;
case 3:
serial_puts("[DEBUG] ");
break;
}
serial_puts(str);
serial_puts("\n");
}

View File

@@ -7,5 +7,6 @@ int init_serial();
int is_transmit_empty();
void write_serial(const char a);
void serial_puts(const char* str);
void log(const char* str, const int errlevel);
#endif