The printk(), panic() and kernel.h update

This commit is contained in:
2026-03-26 21:07:29 +01:00
parent 2f05396651
commit 63a238d2c4
18 changed files with 366 additions and 153 deletions
+28
View File
@@ -0,0 +1,28 @@
#include <kernel.h>
#include <serial.h>
#include <stdarg.h>
#include <ctype.h>
uint8_t console_loglevel = CONSOLE_LOGLEVEL;
int printk(const char *fmt, ...) {
va_list ap;
va_start(ap, fmt);
int ret = vprintk(fmt, ap);
va_end(ap);
return ret;
}
int vprintk(const char* fmt, va_list ap) {
int loglevel = LOGLEVEL_DEFAULT;
if (*fmt == KERN_SOH_ASCII) {
fmt++;
if (isdigit(*fmt)) loglevel = *fmt++ - '0';
}
if (loglevel > console_loglevel) return 0;
// TODO: debugf("[%4d.%6d] ", seconds, milliseconds);
return vdebugf(fmt, ap);
}