X-Git-Url: https://scm.lunaixsky.com/lunaix-os.git/blobdiff_plain/eb251af8672e033f29322253f136e09c76f2b0a3..6fefc6f5af83f316e18b0cb9dbbde1cea0b98add:/lunaix-os/kernel/kprintf.c diff --git a/lunaix-os/kernel/kprintf.c b/lunaix-os/kernel/kprintf.c index 75b9fc4..d18691a 100644 --- a/lunaix-os/kernel/kprintf.c +++ b/lunaix-os/kernel/kprintf.c @@ -33,7 +33,7 @@ __kprintf(const char* component, const char* fmt, va_list args) // tty_set_theme(VGA_COLOR_BROWN, current_theme >> 12); snprintf(expanded_fmt, MAX_XFMT_SIZE, - "\x033[6;0m[%s] (%s) %s\x033[39;49m", + "\033[6;0m[%s] (%s) %s\033[39;49m", "WARN", component, fmt); @@ -42,7 +42,7 @@ __kprintf(const char* component, const char* fmt, va_list args) // tty_set_theme(VGA_COLOR_LIGHT_RED, current_theme >> 12); snprintf(expanded_fmt, MAX_XFMT_SIZE, - "\x033[12;0m[%s] (%s) %s\x033[39;49m", + "\033[12;0m[%s] (%s) %s\033[39;49m", "EROR", component, fmt); @@ -51,7 +51,7 @@ __kprintf(const char* component, const char* fmt, va_list args) // tty_set_theme(VGA_COLOR_LIGHT_BLUE, current_theme >> 12); snprintf(expanded_fmt, MAX_XFMT_SIZE, - "\x033[9;0m[%s] (%s) %s\x033[39;49m", + "\033[9;0m[%s] (%s) %s\033[39;49m", "DEBG", component, fmt); @@ -84,4 +84,30 @@ kprint_panic(const char* fmt, ...) tty_put_str_at(buf, 0, 24); va_end(args); +} + +void +kprint_hex(const void* buffer, unsigned int size) +{ + unsigned char* data = (unsigned char*)buffer; + char buf[16]; + char ch_cache[16]; + unsigned int ptr = 0; + int i; + + ch_cache[0] = '|'; + ch_cache[1] = ' '; + while (size) { + snprintf(buf, 64, " %.4p: ", ptr); + console_write_str(buf); + for (i = 0; i < 8 && size; i++, size--, ptr++) { + unsigned char c = *(data + ptr) & 0xff; + ch_cache[2 + i] = (32 <= c && c < 127) ? c : '.'; + snprintf(buf, 64, "%.2x ", c); + console_write_str(buf); + } + ch_cache[2 + i] = '\0'; + console_write_str(ch_cache); + console_write_char('\n'); + } } \ No newline at end of file