summaryrefslogtreecommitdiff
path: root/kern/shell.c
diff options
context:
space:
mode:
authorRichard Braun <rbraun@sceen.net>2019-05-19 18:00:06 +0200
committerRichard Braun <rbraun@sceen.net>2019-05-19 18:00:06 +0200
commitc45d94a590d778c26dc78386c41231fed9df1b14 (patch)
tree5449081427d9f22aa45cde141a28a7b5f30f2cbd /kern/shell.c
parent294946552c4330ecb846d6b57cf81034844b8abf (diff)
kern/{log,shell}: use a bulletin for initial log dump notification
Diffstat (limited to 'kern/shell.c')
-rw-r--r--kern/shell.c49
1 files changed, 29 insertions, 20 deletions
diff --git a/kern/shell.c b/kern/shell.c
index 1fff5d26..65c995d6 100644
--- a/kern/shell.c
+++ b/kern/shell.c
@@ -26,6 +26,7 @@
#include <stdint.h>
#include <string.h>
+#include <kern/bulletin.h>
#include <kern/hash.h>
#include <kern/init.h>
#include <kern/log.h>
@@ -67,6 +68,8 @@ struct shell_esc_seq {
#define SHELL_ERASE_BS '\b'
#define SHELL_ERASE_DEL '\x7f'
+static struct bulletin_sub shell_log_bulletin_sub;
+
static const char *
shell_find_word(const char *str)
{
@@ -1114,7 +1117,7 @@ shell_process_ctrl_char(struct shell *shell, char c)
return 0;
}
-void
+static void
shell_run(struct shell *shell)
{
int c, error, escape;
@@ -1204,12 +1207,37 @@ shell_main_vfprintf(void *io_object, const char *format, va_list ap)
vprintf(format, ap);
}
+static void
+shell_main_run(void *arg)
+{
+ shell_run(arg);
+}
+
+static void
+shell_start(uintptr_t value, void *arg)
+{
+ struct thread_attr attr;
+ struct thread *thread;
+ int error;
+
+ (void)value;
+ (void)arg;
+
+ thread_attr_init(&attr, THREAD_KERNEL_PREFIX "shell");
+ thread_attr_set_detached(&attr);
+ error = thread_create(&thread, &attr, shell_main_run, &shell_main);
+ error_check(error, "thread_create");
+}
+
static int __init
shell_setup(void)
{
shell_cmd_set_init(&shell_main_cmd_set);
shell_init(&shell_main, &shell_main_cmd_set,
shell_main_getc, shell_main_vfprintf, NULL);
+ bulletin_subscribe(log_get_bulletin(), &shell_log_bulletin_sub,
+ shell_start, NULL);
+
return 0;
}
@@ -1223,22 +1251,3 @@ shell_get_main_cmd_set(void)
{
return &shell_main_cmd_set;
}
-
-static void
-shell_main_run(void *arg)
-{
- shell_run(arg);
-}
-
-void __init
-shell_start(void)
-{
- struct thread_attr attr;
- struct thread *thread;
- int error;
-
- thread_attr_init(&attr, THREAD_KERNEL_PREFIX "shell");
- thread_attr_set_detached(&attr);
- error = thread_create(&thread, &attr, shell_main_run, &shell_main);
- error_check(error, "thread_create");
-}