summaryrefslogtreecommitdiff
path: root/kernel/common/log.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/common/log.c')
-rw-r--r--kernel/common/log.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/kernel/common/log.c b/kernel/common/log.c
index d75daeb..f65c165 100644
--- a/kernel/common/log.c
+++ b/kernel/common/log.c
@@ -1,3 +1,4 @@
+#include <sys/stddef.h>
#include <sys/log.h>
__attribute__((section(".ringbuf"), aligned(64)))
@@ -35,6 +36,29 @@ void put_uint(unsigned int value, unsigned int radix) {
put_char(tmp[i]);
}
+
+void put_ptr(uintptr_t value) {
+ char tmp[16];
+ const char digits[] = "0123456789abcdef";
+ int i = 0;
+
+ if (value == 0) {
+ put_char('0');
+ return;
+ }
+
+ while (value) {
+ tmp[i++] = digits[value % 16];
+ value /= 16;
+ }
+
+ put_char('0');
+ put_char('x');
+
+ while (i--)
+ put_char(tmp[i]);
+}
+
void put_int(int value) {
if (value < 0) {
put_char('-');
@@ -79,6 +103,10 @@ void vprintk(const char *fmt, __builtin_va_list args) {
put_uint(__builtin_va_arg(args, unsigned int), 16);
break;
+ case 'p':
+ put_ptr(__builtin_va_arg(args, uintptr_t));
+ break;
+
default:
put_char('%');
put_char(*fmt);