diff options
| author | Nathan Lee <me@nwlee.tech> | 2026-07-29 19:11:29 -0500 |
|---|---|---|
| committer | Nathan Lee <me@nwlee.tech> | 2026-07-29 19:11:29 -0500 |
| commit | 1329d1db52ede274d63b56a7aa37dd25c833ec67 (patch) | |
| tree | 50a7160175e1744464de0d7a6297d351cc1ef6a4 /console/module_main.c | |
| parent | 9d970286fc93c03acbe465faf97a9bd559ab6f1b (diff) | |
Diffstat (limited to 'console/module_main.c')
| -rw-r--r-- | console/module_main.c | 38 |
1 files changed, 36 insertions, 2 deletions
diff --git a/console/module_main.c b/console/module_main.c index 521aebc..8aeac9f 100644 --- a/console/module_main.c +++ b/console/module_main.c @@ -1,10 +1,44 @@ +#include <log.h> +#include <mmio.h> + #ifndef __KERNEL_MODULE__ #define __KERNEL_MODULE__ #endif -int test_module_init(void) { +extern console_callback_t callback; + +struct console_device_meta { + void *register_controller; + void *data_start; + void *data_end; +}; + +const char compatible[] __attribute__((section(".compatible"))) = "unix,soc-tty"; +size_t pos = 0; +struct console_device_meta dev_meta = { NULL, NULL, NULL }; + +__attribute__((visibility("hidden"))) void console_put_char(char c) { + ((char *)dev_meta.data_start)[pos++] = c; + + if (c == '\n') { + *((uint8_t *)dev_meta.register_controller) = 1; + pos = 0; + } + return; +} + + +int __attribute__((section(".module_init"))) module_init(struct mmio_device_meta *meta) { + callback = console_put_char; + + dev_meta.register_controller = meta->start; + dev_meta.data_start = (void *)((uint8_t *)meta->start + 1); + dev_meta.data_end = (void *)((uint8_t *)meta->start + meta->size); + + printk("Registered console device successfully"); return 0; } -void test_module_exit(void) { +void __attribute__((section(".module_exit"))) module_exit(void) { + printk("Unregistered console device (nothing to do)"); } |
