1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
// Copyright (c) 2016-2017, Intel Corporation.
#ifndef __SHELL__STATE__H__
#define __SHELL__STATE__H__
// We are not expecting to return the command line
#define RET_OK_NO_RET 1
// All went fine, print the shell prompt
#define RET_OK 0
#define RET_ERROR -1
#define RET_UNKNOWN -2
/**
* @brief State of the shell to control the data flow
* and transactions.
*/
enum
{
kShellTransferRaw = (1 << 0),
kShellTransferIhex = (1 << 1),
kShellTransferSnapshot = (1 << 2),
kShellCaptureRaw = (1 << 3),
kShellEvalJavascript = (1 << 4),
};
/**
* @brief Typedef callback for the command
*
* @param buf Raw buffer containing the rest of the parameters from the last command
* @return RET_OK, RET_ERROR, RET_UNKNOWN
*/
typedef int32_t(*ashell_cmd)(char *buf);
struct ashell_cmd
{
const char *cmd_name;
const char *syntax;
ashell_cmd cb;
};
/**
* @brief Current state of the shell
*/
struct shell_state_config
{
uint32_t state_flags;
};
/**
* @brief Main callback from the UART containing the line in the buffer for processing.
*
* @param buf Zero terminated string, length of the buffer.
* @return RET_OK, RET_ERROR, RET_UNKNOWN
*/
int32_t ashell_main_state(char *buf, uint32_t len);
/**
* @brief Gets called when main loop starts and runs the JavaScript file found in
* boot.cfg. If no file exists, it simply exits and ashell starts normally.
*/
void ashell_run_boot_cfg();
int32_t ashell_help(char *buf);
#endif
|