X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=include%2Fcli.h;h=ba5b8ebd36eb5caf156e24a6854e33a02eb57e18;hb=7b976f7a0b5ab18e3671d683f8092d7ddb0622b5;hp=0075bd44c94ada12471743d3a3b8270ed836ad14;hpb=18d66533ac773f59efc93e5c19971fad5e6af82f;p=platform%2Fkernel%2Fu-boot.git diff --git a/include/cli.h b/include/cli.h index 0075bd4..ba5b8eb 100644 --- a/include/cli.h +++ b/include/cli.h @@ -1,8 +1,7 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ /* * (C) Copyright 2014 Google, Inc * Simon Glass - * - * SPDX-License-Identifier: GPL-2.0+ */ #ifndef __CLI_H @@ -14,14 +13,14 @@ * This will return if we get a timeout waiting for a command. See * CONFIG_BOOT_RETRY_TIME. */ -void cli_loop(void); +void cli_simple_loop(void); /** * cli_simple_run_command() - Execute a command with the simple CLI * * @cmd: String containing the command to execute * @flag Flag value - see CMD_FLAG_... - * @return 1 - command executed, repeatable + * Return: 1 - command executed, repeatable * 0 - command executed but not repeatable, interrupted commands are * always considered not repeatable * -1 - not executed (unrecognized, bootd recursion or too many args) @@ -31,6 +30,16 @@ void cli_loop(void); int cli_simple_run_command(const char *cmd, int flag); /** + * cli_simple_process_macros() - Expand $() and ${} format env. variables + * + * @param input Input string possible containing $() / ${} vars + * @param output Output string with $() / ${} vars expanded + * @param max_size Maximum size of @output (including terminator) + * Return: 0 if OK, -ENOSPC if we ran out of space in @output + */ +int cli_simple_process_macros(const char *input, char *output, int max_size); + +/** * cli_simple_run_command_list() - Execute a list of command * * The commands should be separated by ; or \n and will be executed @@ -41,7 +50,7 @@ int cli_simple_run_command(const char *cmd, int flag); * * @param cmd String containing list of commands * @param flag Execution flags (CMD_FLAG_...) - * @return 0 on success, or != 0 on error. + * Return: 0 on success, or != 0 on error. */ int cli_simple_run_command_list(char *cmd, int flag); @@ -51,9 +60,9 @@ int cli_simple_run_command_list(char *cmd, int flag); * This is a convenience function which calls cli_readline_into_buffer(). * * @prompt: Prompt to display - * @return command line length excluding terminator, or -ve on error + * Return: command line length excluding terminator, or -ve on error */ -int readline(const char *const prompt); +int cli_readline(const char *const prompt); /** * readline_into_buffer() - read a line into a buffer @@ -73,12 +82,13 @@ int readline(const char *const prompt); * @prompt: Prompt to display * @buffer: Place to put the line that is entered * @timeout: Timeout in milliseconds, 0 if none - * @return command line length excluding terminator, or -ve on error: of the + * Return: command line length excluding terminator, or -ve on error: of the * timeout is exceeded (either CONFIG_BOOT_RETRY_TIME or the timeout * parameter), then -2 is returned. If a break is detected (Ctrl-C) then * -1 is returned. */ -int readline_into_buffer(const char *const prompt, char *buffer, int timeout); +int cli_readline_into_buffer(const char *const prompt, char *buffer, + int timeout); /** * parse_line() - split a command line down into separate arguments @@ -95,8 +105,54 @@ int readline_into_buffer(const char *const prompt, char *buffer, int timeout); * * @line: Command line to parse * @args: Array to hold arguments - * @return number of arguments + * Return: number of arguments */ -int parse_line(char *line, char *argv[]); +int cli_simple_parse_line(char *line, char *argv[]); + +#if CONFIG_IS_ENABLED(OF_CONTROL) +/** + * cli_process_fdt() - process the boot command from the FDT + * + * If bootcmmd is defined in the /config node of the FDT, we use that + * as the boot command. Further, if bootsecure is set to 1 (in the same + * node) then we return true, indicating that the command should be executed + * as securely as possible, avoiding the CLI parser. + * + * @cmdp: On entry, the command that will be executed if the FDT does + * not have a command. Returns the command to execute after + * checking the FDT. + * Return: true to execute securely, else false + */ +bool cli_process_fdt(const char **cmdp); + +/** cli_secure_boot_cmd() - execute a command as securely as possible + * + * This avoids using the parser, thus executing the command with the + * smallest amount of code. Parameters are not supported. + */ +void cli_secure_boot_cmd(const char *cmd); +#else +static inline bool cli_process_fdt(const char **cmdp) +{ + return false; +} + +static inline void cli_secure_boot_cmd(const char *cmd) +{ +} +#endif /* CONFIG_OF_CONTROL */ + +/** + * Go into the command loop + * + * This will return if we get a timeout waiting for a command, but only for + * the simple parser (not hush). See CONFIG_BOOT_RETRY_TIME. + */ +void cli_loop(void); + +/** Set up the command line interpreter ready for action */ +void cli_init(void); + +#define endtick(seconds) (get_ticks() + (uint64_t)(seconds) * get_tbclk()) #endif