1 /*
2 * Copyright (c) 2018 Nordic Semiconductor ASA
3 * Copyright (c) 2016 Intel Corporation
4 *
5 * SPDX-License-Identifier: Apache-2.0
6 */
7
8 #include "kernel_shell.h"
9
10 #include <zephyr/sys/reboot.h>
11
cmd_kernel_reboot_warm(const struct shell * sh,size_t argc,char ** argv)12 static int cmd_kernel_reboot_warm(const struct shell *sh,
13 size_t argc, char **argv)
14 {
15 ARG_UNUSED(argc);
16 ARG_UNUSED(argv);
17 #if (CONFIG_KERNEL_SHELL_REBOOT_DELAY > 0)
18 k_sleep(K_MSEC(CONFIG_KERNEL_SHELL_REBOOT_DELAY));
19 #endif
20 sys_reboot(SYS_REBOOT_WARM);
21 return 0;
22 }
23
cmd_kernel_reboot_cold(const struct shell * sh,size_t argc,char ** argv)24 static int cmd_kernel_reboot_cold(const struct shell *sh,
25 size_t argc, char **argv)
26 {
27 ARG_UNUSED(argc);
28 ARG_UNUSED(argv);
29 #if (CONFIG_KERNEL_SHELL_REBOOT_DELAY > 0)
30 k_sleep(K_MSEC(CONFIG_KERNEL_SHELL_REBOOT_DELAY));
31 #endif
32 sys_reboot(SYS_REBOOT_COLD);
33 return 0;
34 }
35
36 SHELL_STATIC_SUBCMD_SET_CREATE(sub_kernel_reboot,
37 SHELL_CMD(cold, NULL, "Cold reboot.", cmd_kernel_reboot_cold),
38 SHELL_CMD(warm, NULL, "Warm reboot.", cmd_kernel_reboot_warm),
39 SHELL_SUBCMD_SET_END /* Array terminated. */
40 );
41
42 KERNEL_CMD_ADD(reboot, &sub_kernel_reboot, "Reboot.", cmd_kernel_reboot_cold);
43