1 /*
2  * Copyright (c) 2024 Espressif Systems (Shanghai) Co., Ltd.
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #if defined(CONFIG_IPM) || defined(CONFIG_MBOX)
8 
9 #include <stdlib.h>
10 
11 #include <zephyr/device.h>
12 #include <zephyr/shell/shell.h>
13 #include <zephyr/sys/printk.h>
14 
15 /* Command usage info. */
16 #define START_HELP ("<cmd>\n\nStart the APPCPU")
17 #define STOP_HELP  ("<cmd>\n\nStop the APPCPU")
18 
19 void esp_appcpu_image_start(unsigned int hdr_offset);
20 void esp_appcpu_image_stop(void);
21 
cmd_appcpu_start(const struct shell * sh,size_t argc,char * argv[])22 static int cmd_appcpu_start(const struct shell *sh, size_t argc, char *argv[])
23 {
24 	ARG_UNUSED(sh);
25 	ARG_UNUSED(argc);
26 	ARG_UNUSED(argv);
27 
28 	printk("start appcpu\n");
29 
30 	esp_appcpu_image_start(0x20);
31 
32 	return 0;
33 }
34 
cmd_appcpu_stop(const struct shell * sh,size_t argc,char * argv[])35 static int cmd_appcpu_stop(const struct shell *sh, size_t argc, char *argv[])
36 {
37 	ARG_UNUSED(sh);
38 	ARG_UNUSED(argc);
39 	ARG_UNUSED(argv);
40 
41 	printk("stop appcpu\n");
42 
43 	esp_appcpu_image_stop();
44 
45 	return 0;
46 }
47 
48 SHELL_STATIC_SUBCMD_SET_CREATE(sub_amp,
49 			       /* Alphabetically sorted to ensure correct Tab autocompletion. */
50 			       SHELL_CMD_ARG(appstart, NULL, START_HELP, cmd_appcpu_start, 1, 0),
51 			       SHELL_CMD_ARG(appstop, NULL, STOP_HELP, cmd_appcpu_stop, 1, 0),
52 			       SHELL_SUBCMD_SET_END /* Array terminated. */
53 );
54 
55 SHELL_CMD_REGISTER(amp, &sub_amp, "AMP debug commands.", NULL);
56 #endif
57