summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Braun <rbraun@sceen.net>2017-05-31 21:11:29 +0200
committerRichard Braun <rbraun@sceen.net>2017-05-31 21:11:29 +0200
commitccefd921e76ba4ca7f3d6b54691315c0718b039c (patch)
tree537221be8c7add94eb226401020126f6904e65ad
parenta9ce9f79a324e1b8d6d299bc4e43f02f71d0eb7f (diff)
kern/shell: separate initialization into two steps
The shell must be able to register commands early. As a result, it's now initialized in two steps, one of which starts the shell thread.
-rw-r--r--arch/x86/machine/boot.c2
-rw-r--r--kern/kernel.c2
-rw-r--r--kern/shell.c10
-rw-r--r--kern/shell.h5
4 files changed, 16 insertions, 3 deletions
diff --git a/arch/x86/machine/boot.c b/arch/x86/machine/boot.c
index b7a9b0ee..84960eb6 100644
--- a/arch/x86/machine/boot.c
+++ b/arch/x86/machine/boot.c
@@ -58,6 +58,7 @@
#include <kern/panic.h>
#include <kern/param.h>
#include <kern/percpu.h>
+#include <kern/shell.h>
#include <kern/sleepq.h>
#include <kern/sref.h>
#include <kern/syscnt.h>
@@ -473,6 +474,7 @@ boot_main(void)
uart_bootstrap();
printf_setup();
boot_show_version();
+ shell_setup();
arg_info();
uart_info();
pmap_bootstrap();
diff --git a/kern/kernel.c b/kern/kernel.c
index 05cf8392..1d61b0ca 100644
--- a/kern/kernel.c
+++ b/kern/kernel.c
@@ -50,8 +50,8 @@ kernel_main(void)
work_setup();
llsync_setup();
sref_setup();
- shell_setup();
vm_page_info();
+ shell_start();
#ifdef X15_RUN_TEST_MODULE
test_setup();
diff --git a/kern/shell.c b/kern/shell.c
index c4675bf4..ba756a5f 100644
--- a/kern/shell.c
+++ b/kern/shell.c
@@ -1158,8 +1158,6 @@ shell_run(void *arg)
void __init
shell_setup(void)
{
- struct thread_attr attr;
- struct thread *thread;
unsigned long i;
int error;
@@ -1169,6 +1167,14 @@ shell_setup(void)
error = shell_cmd_register(&shell_default_cmds[i]);
error_check(error, "shell_cmd_register");
}
+}
+
+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);
diff --git a/kern/shell.h b/kern/shell.h
index 5ff4920d..a33abbef 100644
--- a/kern/shell.h
+++ b/kern/shell.h
@@ -56,6 +56,11 @@ void shell_cmd_init(struct shell_cmd *cmd, const char *name,
void shell_setup(void);
/*
+ * Start the shell thread.
+ */
+void shell_start(void);
+
+/*
* Register a shell command.
*
* The command name must be unique. It must not include characters outside