summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--console/module_main.c4
-rw-r--r--include/log.h2
-rw-r--r--kernel/log.c4
3 files changed, 7 insertions, 3 deletions
diff --git a/console/module_main.c b/console/module_main.c
index 8aeac9f..643afc1 100644
--- a/console/module_main.c
+++ b/console/module_main.c
@@ -5,8 +5,6 @@
#define __KERNEL_MODULE__
#endif
-extern console_callback_t callback;
-
struct console_device_meta {
void *register_controller;
void *data_start;
@@ -29,7 +27,7 @@ __attribute__((visibility("hidden"))) void console_put_char(char c) {
int __attribute__((section(".module_init"))) module_init(struct mmio_device_meta *meta) {
- callback = console_put_char;
+ register_console_callback(console_put_char);
dev_meta.register_controller = meta->start;
dev_meta.data_start = (void *)((uint8_t *)meta->start + 1);
diff --git a/include/log.h b/include/log.h
index f1e4110..da9274b 100644
--- a/include/log.h
+++ b/include/log.h
@@ -6,3 +6,5 @@ typedef void (*console_callback_t)(char);
void vprintk(const char *message, __builtin_va_list args);
void printk(const char *message, ...);
+
+void register_console_callback(console_callback_t callback);
diff --git a/kernel/log.c b/kernel/log.c
index 98267e3..84b52d3 100644
--- a/kernel/log.c
+++ b/kernel/log.c
@@ -103,3 +103,7 @@ void printk(const char *fmt, ...) {
vprintk(fmt, args);
__builtin_va_end(args);
}
+
+void register_console_callback(console_callback_t cb) {
+ callback = cb;
+}