summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Braun <rbraun@sceen.net>2017-12-03 15:08:01 +0100
committerRichard Braun <rbraun@sceen.net>2017-12-03 15:08:01 +0100
commit303ed5305f8dae17ab46aa1e0dc6086d4277808c (patch)
tree5275ceb2c2321970a3a92cbcb9d17b5bf8b7d048
parent10790d4b1f1f3546fa110fea313a08cce999243f (diff)
kern/shell: don't make the public interface conditional
-rw-r--r--kern/log.c31
-rw-r--r--kern/shell.h8
2 files changed, 22 insertions, 17 deletions
diff --git a/kern/log.c b/kern/log.c
index 3b1336e3..755be7f9 100644
--- a/kern/log.c
+++ b/kern/log.c
@@ -267,19 +267,38 @@ log_record_print(const struct log_record *record, unsigned int level)
}
}
+#ifdef CONFIG_SHELL
+
+static void
+log_start_shell(unsigned long *flags)
+{
+ static bool shell_started = false;
+
+ if (shell_started) {
+ return;
+ }
+
+ spinlock_unlock_intr_restore(&log_lock, *flags);
+ shell_start();
+ spinlock_lock_intr_save(&log_lock, flags);
+ shell_started = true;
+}
+
+#else /* CONFIG_SHELL */
+#define log_start_shell(flags)
+#endif /* CONFIG_SHELL*/
+
static void
log_run(void *arg)
{
unsigned long flags, nr_overruns;
struct log_consume_ctx ctx;
struct log_record record;
- bool start_shell;
int error;
(void)arg;
nr_overruns = 0;
- start_shell = true;
spinlock_lock_intr_save(&log_lock, &flags);
@@ -292,13 +311,7 @@ log_run(void *arg)
* time cleanly serializes log messages and shell prompt, making
* a clean ordered output.
*/
- if (start_shell) {
- spinlock_unlock_intr_restore(&log_lock, flags);
- shell_start();
- start_shell = false;
- spinlock_lock_intr_save(&log_lock, &flags);
- }
-
+ log_start_shell(&flags);
log_index = log_consume_ctx_index(&ctx);
thread_sleep(&log_lock, &log_cbuf, "log_cbuf");
diff --git a/kern/shell.h b/kern/shell.h
index ee56856e..bdd02d98 100644
--- a/kern/shell.h
+++ b/kern/shell.h
@@ -25,8 +25,6 @@
#include <kern/error.h>
#include <kern/macros.h>
-#ifdef CONFIG_SHELL
-
#define SHELL_REGISTER_CMDS(cmds) \
MACRO_BEGIN \
size_t ___i; \
@@ -81,12 +79,6 @@ void shell_start(void);
*/
int shell_cmd_register(struct shell_cmd *cmd);
-#else /* CONFIG_SHELL */
-#define SHELL_REGISTER_CMDS(cmds)
-#define shell_setup()
-#define shell_start()
-#endif /* CONFIG_SHELL */
-
/*
* This init operation provides :
* - commands can be registered