Add: serial logging function w/ errlevels
This commit is contained in:
Binary file not shown.
BIN
kernel.elf
BIN
kernel.elf
Binary file not shown.
7
kmain.c
7
kmain.c
@@ -3,11 +3,12 @@
|
|||||||
|
|
||||||
int kmain(int retvalue)
|
int kmain(int retvalue)
|
||||||
{
|
{
|
||||||
|
init_serial();
|
||||||
|
log("serial connection established", 3);
|
||||||
|
log("Kernel started", 2);
|
||||||
|
|
||||||
clear();
|
clear();
|
||||||
puts("hello\nbrave\nnew\nworld");
|
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;
|
return retvalue;
|
||||||
}
|
}
|
||||||
|
|||||||
21
serial.c
21
serial.c
@@ -42,3 +42,24 @@ void serial_puts(const char* str)
|
|||||||
write_serial(str[i]);
|
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");
|
||||||
|
}
|
||||||
|
|||||||
1
serial.h
1
serial.h
@@ -7,5 +7,6 @@ int init_serial();
|
|||||||
int is_transmit_empty();
|
int is_transmit_empty();
|
||||||
void write_serial(const char a);
|
void write_serial(const char a);
|
||||||
void serial_puts(const char* str);
|
void serial_puts(const char* str);
|
||||||
|
void log(const char* str, const int errlevel);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user