Skip to content

Commit 7297f5d

Browse files
nashifAnas Nashif
authored andcommitted
shell: move shell to its own subsystem
This moves the shell component into its own subsys and groups all related files and options into a single place. Additionally, one Kconfig option will now be required to enable the shell: CONFIG_CONSOLE_SHELL=y The header files was also moved to include/shell/shell.h and can be now referenced with #include <shell/shell.h> instead of #include <misc/shell.h> Updated documentation as well. Change-Id: Iffbba4acfa05408055e9fd28dffa213451351f94 Signed-off-by: Anas Nashif <[email protected]>
1 parent 46fa538 commit 7297f5d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+136
-122
lines changed

doc/subsystems/shell.rst

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ Shell
66
Overview
77
********
88

9-
Zephyr OS Shell enables multiple Zephyr OS modules to use and expose their
10-
shell interface simultaneously.
9+
The Shell enables multiple subsystem to use and expose their shell interface
10+
simultaneously.
1111

12-
Each module can support shell functionality dynamically by its Kconfig file,
13-
which enables or disables the shell usage for the module.
12+
Each subbsystem can support shell functionality dynamically by its Kconfig file,
13+
which enables or disables the shell usage for the subsystem.
1414

1515
Using shell commands
1616
********************
@@ -19,14 +19,19 @@ Use one of the following formats:
1919

2020
Specific module's commands
2121
==========================
22+
23+
A shell interface exposing subsystem features is a shell module, multiple
24+
modules can be available at the same time.
25+
2226
`MODULE_NAME COMMAND`
2327
One of the available modules is “KERNEL”, for the Kernel module. More
2428
information can be found in :c:macro:`SHELL_REGISTER`.
2529

2630
Help commands
2731
=============
32+
2833
`help`
29-
Prints the available modules.
34+
Prints the list of available modules.
3035

3136
`help MODULE_NAME`
3237
Prints the names of the available commands for the module.
@@ -37,6 +42,7 @@ Help commands
3742

3843
Select module commands
3944
======================
45+
4046
`set_module MODULE_NAME`
4147
Use this command when using the shell only for one module. After entering this
4248
command, you will not need to enter module name in further commands. If
@@ -54,40 +60,33 @@ There are two levels of configuration: Infrastructure level and Module level.
5460
Infrastructure level
5561
====================
5662

57-
The default value for ENABLE_SHELL flag should be considered per product.
58-
This flag enables shell services.
63+
The option :option:`CONFIG_CONSOLE_SHELL` enables the shell subsystem and enable the
64+
default features of the shell subsystem.
5965

60-
If it is enabled, kernel shell commands are also available for use.
61-
See the :option:`CONFIG_ENABLE_SHELL` Kconfig options for more information.
62-
63-
Module level
64-
============
65-
Each module using shell service should add a unique flag in its Kconfig file.
66+
Module/Subsystem level
67+
======================
68+
Each subsystem using the shell service should add a unique flag in its Kconfig file.
6669

6770
Example:
6871

69-
CONFIG_SAMPLE_MODULE_USE_SHELL=y
70-
71-
In the module’s code, the shell usage depends on this config parameter.
72-
This module-specific flag should also depend on ENABLE_SHELL flag.
72+
CONFIG_NET_SHELL=y
7373

74-
Therefore, there is one global flag, in addition to a unique flag per each
75-
module.
76-
The default value for ENABLE_SHELL flag should be considered per product.
74+
In the subsystem’s code, the shell usage depends on this config parameter.
75+
This subsystem specific flag should also depend on :option:`CONFIG_CONSOLE_SHELL` flag.
7776

7877
Configuration steps to add shell functionality to a module
7978
==========================================================
8079

81-
#. Check that ENABLE_SHELL is set to yes.
82-
#. Add the module unique flag to its Kconfig file.
80+
#. Check that :option:`CONFIG_CONSOLE_SHELL` is set to yes.
81+
#. Add the subsystem unique flag to its Kconfig file.
8382

8483
Writing a shell module
8584
**********************
8685

87-
In order to support shell in your module, the application must do the following:
86+
In order to support shell in your subsystem, the application must do the following:
8887

89-
#. Module configuration flag: Declare a new flag in your module Kconfig file.
90-
It should depend on `ENABLE_SHELL` flag.
88+
#. Module configuration flag: Declare a new flag in your subsystem Kconfig file.
89+
It should depend on `:option:`CONFIG_CONSOLE_SHELL`` flag.
9190

9291
#. Module registration to shell: Add your shell identifier and register its
9392
callback functions in the shell database using :c:macro:`SHELL_REGISTER`.

drivers/console/Kconfig

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -39,22 +39,6 @@ config CONSOLE_HANDLER
3939
This option enables console input handler allowing to write simple
4040
interaction between serial console and the OS.
4141

42-
config CONSOLE_HANDLER_SHELL
43-
bool
44-
prompt "Enable console input handler [ Experimental ]"
45-
default n
46-
depends on CONSOLE_HANDLER
47-
help
48-
Shell implementation based on CONSOLE_HANDLER.
49-
50-
config CONSOLE_HANDLER_SHELL_STACKSIZE
51-
int
52-
prompt "Console handler shell stack size"
53-
default 2000
54-
depends on CONSOLE_HANDLER_SHELL
55-
help
56-
Stack size for the console handler shell.
57-
5842
config UART_CONSOLE
5943
bool
6044
prompt "Use UART for console"

drivers/console/Makefile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
obj-$(CONFIG_ENABLE_SHELL) += shells/
2-
obj-$(CONFIG_CONSOLE_HANDLER_SHELL) += console_handler_shell.o
31
obj-$(CONFIG_UART_CONSOLE) += uart_console.o
42
obj-$(CONFIG_RAM_CONSOLE) += ram_console.o
53
obj-$(CONFIG_RTT_CONSOLE) += rtt_console.o

drivers/console/shells/Kconfig

Lines changed: 0 additions & 20 deletions
This file was deleted.

include/misc/shell.h renamed to include/shell/shell.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ struct shell_module {
6464
* @param shell_commands Array of commands to register.
6565
* Shell array entries must be packed to calculate array size correctly.
6666
*/
67-
#ifdef CONFIG_ENABLE_SHELL
67+
#ifdef CONFIG_CONSOLE_SHELL
6868
#define SHELL_REGISTER(shell_name, shell_commands) \
6969
\
7070
static struct shell_module (__shell_shell_name) __used \
@@ -115,7 +115,7 @@ void shell_register_default_module(const char *name);
115115
*/
116116

117117

118-
#ifdef CONFIG_ENABLE_SHELL
118+
#ifdef CONFIG_CONSOLE_SHELL
119119
int shell_run(struct device *dev);
120120
#else
121121
static inline int shell_run(struct device *dev)

samples/legacy/task_profiler/README.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,6 @@ For that purpose, following flags must be enabled in project configuration file
230230
<-- snippet
231231
CONFIG_KERNEL_EVENT_LOGGER_DYNAMIC=y
232232
CONFIG_CONSOLE_HANDLER=y
233-
CONFIG_CONSOLE_HANDLER_SHELL=y
234233
-->
235234

236235
command implementation.

samples/legacy/task_profiler/microkernel/prj.conf

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
CONFIG_STDOUT_CONSOLE=y
22
CONFIG_CONSOLE_HANDLER=y
3-
CONFIG_CONSOLE_HANDLER_SHELL=y
4-
CONFIG_ENABLE_SHELL=y
3+
CONFIG_CONSOLE_SHELL=y
54
CONFIG_TASK_MONITOR=y
65
CONFIG_TASK_MONITOR_MASK=6
76
CONFIG_RING_BUFFER=y

samples/legacy/task_profiler/microkernel/prj_quark_se_c1000_devboard.conf

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
CONFIG_STDOUT_CONSOLE=y
22
CONFIG_CONSOLE_HANDLER=y
3-
CONFIG_CONSOLE_HANDLER_SHELL=y
4-
CONFIG_ENABLE_SHELL=y
3+
CONFIG_CONSOLE_SHELL=y
54
CONFIG_TASK_MONITOR=y
65
CONFIG_TASK_MONITOR_MASK=6
76
CONFIG_RING_BUFFER=y

samples/legacy/task_profiler/nanokernel/prj.conf

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
CONFIG_STDOUT_CONSOLE=y
22
CONFIG_CONSOLE_HANDLER=y
3-
CONFIG_CONSOLE_HANDLER_SHELL=y
4-
CONFIG_ENABLE_SHELL=y
3+
CONFIG_CONSOLE_SHELL=y
54
CONFIG_RING_BUFFER=y
65
CONFIG_KERNEL_EVENT_LOGGER=y
76
CONFIG_KERNEL_EVENT_LOGGER_DYNAMIC=y

samples/legacy/task_profiler/nanokernel/prj_quark_se_c1000_devboard.conf

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
CONFIG_STDOUT_CONSOLE=y
22
CONFIG_CONSOLE_HANDLER=y
3-
CONFIG_CONSOLE_HANDLER_SHELL=y
4-
CONFIG_ENABLE_SHELL=y
3+
CONFIG_CONSOLE_SHELL=y
54
CONFIG_RING_BUFFER=y
65
CONFIG_KERNEL_EVENT_LOGGER=y
76
CONFIG_KERNEL_EVENT_LOGGER_DYNAMIC=y

0 commit comments

Comments
 (0)