Split out code from the enormous main.c
Subsystems (3)
cover Split out code from the enormous main.c
A previous series created a way of using if () instead of #ifdef for controlling feature inclusion in U-Boot. The primary target of that series was common/main.c which is full of #ifdefs. That work was put on hold while the kbuild work was in progress.
Since kbuild is now complete, it is time to take another look. However, in the meantime main.c has not improved. It seems like a good idea to try to split the code out a bit, to make it more obvious what is happening in the U-Boot start-up.
This series splits main into two main program and a CLI (Command-line interpreter) parts. There are two CLIs - hush and simple, and each is put in its own file, with a new cli.c to unify them.
New files are also created for autoboot and bootretry functionality.
Overall this series makes it easier to read what is happening in main.c, and also clarifies the parser code.
Simon Glass (14):
Remove unnecessary use of hush header file Rename hush to cli_hush
move CLI prototypes to cli.h and add comments Split out simple parser and readline into separate files Add cli_ prefix to readline functions
Move autoboot code to autoboot.c
Move command line API into cli.c
Move bootretry code into bootretry.c and clean up Rename bootretry functions and remove #ifdefs
m68k: powerpc: Clean up do_mdm_init
Simplify the main loop
main: Hide the hush/simple details inside cli.c
main: Make the execution path a little clearer in main.c
main: Avoid unncessary strdup()/free()
arch/arm/cpu/arm926ejs/kirkwood/cpu.c | 1 -
arch/arm/cpu/arm926ejs/orion5x/cpu.c | 1 -
arch/m68k/lib/board.c | 7 -
arch/powerpc/lib/board.c | 8 -
board/ait/cam_enc_4xx/cam_enc_4xx.c | 4 +-
board/amcc/yucca/cmd_yucca.c | 21 +-
board/eltec/elppc/misc.c | 15 +-
board/eltec/mhpc/mhpc.c | 13 +-
board/hymod/hymod.c | 8 +-
board/hymod/input.c | 14 +-
board/keymile/common/common.c | 2 +-
board/keymile/common/ivm.c | 2 +-
board/mcc200/auto_update.c | 7 +-
common/Makefile | 20 +-
common/autoboot.c | 303 +++++++
common/board_r.c | 14 -
common/bootretry.c | 59 ++
common/cli.c | 194 +++++
common/{hush.c => cli_hush.c} | 17 +-
common/cli_readline.c | 621 ++++++++++++++
common/cli_simple.c | 337 ++++++++
common/cmd_bedbug.c | 29 +-
common/cmd_bootm.c | 4 -
common/cmd_bootmenu.c | 1 -
common/cmd_dcr.c | 3 +-
common/cmd_i2c.c | 17 +-
common/cmd_mem.c | 17 +-
common/cmd_nvedit.c | 5 +-
common/cmd_pci.c | 13 +-
common/main.c | 1527 +--------------------------------
common/menu.c | 6 +-
drivers/ddr/fsl/interactive.c | 8 +-
include/autoboot.h | 47 +
include/bootretry.h | 59 ++
include/cli.h | 149 ++++
include/{hush.h => cli_hush.h} | 4 +-
include/common.h | 7 +-
37 files changed, 1917 insertions(+), 1647 deletions(-)
create mode 100644 common/autoboot.c
create mode 100644 common/bootretry.c
create mode 100644 common/cli.c
rename common/{hush.c => cli_hush.c} (99%)
create mode 100644 common/cli_readline.c
create mode 100644 common/cli_simple.c
create mode 100644 include/autoboot.h
create mode 100644 include/bootretry.h
create mode 100644 include/cli.h
rename include/{hush.h => cli_hush.h} (93%)Signature · 1 line
1.9.1.423.g4596e3a
PATCH 1/14 Remove unnecessary use of hush header file
Some files include hush.h but don't actually use it. Remove this where possible.
---
arch/arm/cpu/arm926ejs/kirkwood/cpu.c | 1 - arch/arm/cpu/arm926ejs/orion5x/cpu.c | 1 - board/ait/cam_enc_4xx/cam_enc_4xx.c | 1 - board/mcc200/auto_update.c | 7 +------ common/cmd_bootm.c | 4 ---- common/cmd_bootmenu.c | 1 - 6 files changed, 1 insertion(+), 14 deletions(-)
arch/arm/cpu/arm926ejs/kirkwood/cpu.c +0 -1
@@ -13,7 +13,6 @@#include <asm/io.h> #include <asm/arch/cpu.h> #include <asm/arch/kirkwood.h> -#include <hush.h> #define BUFLEN 16
arch/arm/cpu/arm926ejs/orion5x/cpu.c +0 -1
@@ -15,7 +15,6 @@#include <asm/io.h> #include <u-boot/md5.h> #include <asm/arch/cpu.h> -#include <hush.h> #define BUFLEN 16
board/ait/cam_enc_4xx/cam_enc_4xx.c +0 -1
@@ -9,7 +9,6 @@#include <common.h> #include <errno.h> -#include <hush.h> #include <linux/mtd/nand.h> #include <nand.h> #include <miiphy.h>
board/mcc200/auto_update.c +1 -6
@@ -12,11 +12,6 @@#include <usb.h> #include <part.h> -#ifdef CONFIG_SYS_HUSH_PARSER -#include <hush.h> -#endif - -#ifdef CONFIG_AUTO_UPDATE #ifndef CONFIG_USB_OHCI
@@ -247,7 +242,7 @@ int au_do_update(int idx, long sz)/* parse_string_outer() runs off the end. */ addr[image_get_data_size (hdr)] =0 ; addr +=8 ; -parse_string_outer (addr,FLAG_PARSE_SEMICOLON ); +run_command_list (addr,-1 ,0 );return 0 ; }
common/cmd_bootm.c +0 -4
@@ -32,10 +32,6 @@#include <usb.h> #endif -#ifdef CONFIG_SYS_HUSH_PARSER -#include <hush.h> -#endif -#if defined(CONFIG_OF_LIBFDT )#include <libfdt.h> #include <fdt_support.h>
common/cmd_bootmenu.c +0 -1
@@ -8,7 +8,6 @@#include <command.h> #include <ansi.h> #include <menu.h> -#include <hush.h> #include <watchdog.h> #include <malloc.h> #include <linux/string.h>
Signature · 1 line
1.9.1.423.g4596e3a
PATCH 2/14 Rename hush to cli_hush
In reply to Simon GlassHush is a command-line interpreter, so rename it to make that clearer.
---
board/keymile/common/common.c | 2 +-
board/keymile/common/ivm.c | 2 +-
common/Makefile | 2 +-
common/{hush.c => cli_hush.c} | 4 ++--
common/main.c | 2 +-
include/{hush.h => cli_hush.h} | 4 ++--
6 files changed, 8 insertions(+), 8 deletions(-)
rename common/{hush.c => cli_hush.c} (99%)
rename include/{hush.h => cli_hush.h} (93%)board/keymile/common/common.c +1 -1
@@ -12,7 +12,7 @@#include <ioports.h> #include <command.h> #include <malloc.h> -#include <hush.h> +#include <cli_hush.h> #include <net.h> #include <netdev.h> #include <asm/io.h>
board/keymile/common/ivm.c +1 -1
@@ -6,7 +6,7 @@*/ #include <common.h> -#include <hush.h> +#include <cli_hush.h> #include <i2c.h> #include "common.h"
common/Makefile +1 -1
@@ -11,7 +11,7 @@ obj-y += main.o obj-y += command.o obj-y += exports.o obj-y += hash.o -obj-$(CONFIG_SYS_HUSH_PARSER) += hush.o +obj-$(CONFIG_SYS_HUSH_PARSER) += cli_hush.o obj-y += s_record.o obj-y += xyzModem.o obj-y += cmd_disk.o
common/cli_hush.c renamed from common/hush.c +2 -2
@@ -79,7 +79,7 @@#include <malloc.h> /* malloc, free, realloc*/ #include <linux/ctype.h> /* isalpha, isdigit */ #include <common.h> /* readline */ -#include <hush.h> +#include <cli_hush.h> #include <command.h> /* find_cmd */ #ifndef CONFIG_SYS_PROMPT_HUSH_PS2 #define CONFIG_SYS_PROMPT_HUSH_PS2 "> "
@@ -222,7 +222,7 @@ struct child_prog {#endif char **argv;/* program name and arguments */ /* was quoted when parsed; copy of struct o_string.nonnull field */ -int *argv_nonnull; +int *argv_nonnull;#ifdef __U_BOOT__int argc;/* number of program arguments */ #endif
common/main.c +1 -1
@@ -14,7 +14,7 @@#include <common.h> #include <command.h> #include <fdtdec.h> -#include <hush.h> +#include <cli_hush.h> #include <malloc.h> #include <menu.h> #include <post.h>
include/cli_hush.h renamed from include/hush.h +2 -2
@@ -5,8 +5,8 @@* SPDX-License-Identifier: GPL-2.0+ */ -#ifndef _HUSH_H_ -#define _HUSH_H_ +#ifndef _CLI_HUSH_H_ +#define _CLI_HUSH_H_#define FLAG_EXIT_FROM_LOOP 1#define FLAG_PARSE_SEMICOLON (1 << 1)/* symbol ';' is special for parser */
Signature · 1 line
1.9.1.423.g4596e3a
PATCH 3/14 move CLI prototypes to cli.h and add comments
In reply to Simon GlassMove the CLI prototypes from common.h to cli.h as part of an effort to reduce the size of common.h.
---
board/ait/cam_enc_4xx/cam_enc_4xx.c | 1 + board/amcc/yucca/cmd_yucca.c | 1 + board/eltec/elppc/misc.c | 1 + board/eltec/mhpc/mhpc.c | 1 + board/hymod/hymod.c | 1 + board/hymod/input.c | 1 + common/cli_hush.c | 1 + common/cmd_bedbug.c | 1 + common/cmd_dcr.c | 1 + common/cmd_i2c.c | 1 + common/cmd_mem.c | 1 + common/cmd_nvedit.c | 1 + common/cmd_pci.c | 1 + common/main.c | 1 + common/menu.c | 1 + drivers/ddr/fsl/interactive.c | 1 + include/cli.h | 102 ++++++++++++++++++++++++++++++++++++ include/common.h | 4 -- 18 files changed, 118 insertions(+), 4 deletions(-) create mode 100644 include/cli.h
board/ait/cam_enc_4xx/cam_enc_4xx.c +1 -0
@@ -8,6 +8,7 @@*/ #include <common.h> +#include <cli.h> #include <errno.h> #include <linux/mtd/nand.h> #include <nand.h>
board/amcc/yucca/cmd_yucca.c +1 -0
@@ -8,6 +8,7 @@*/ #include <common.h> +#include <cli.h> #include <command.h> #include "yucca.h" #include <i2c.h>
board/eltec/elppc/misc.c +1 -0
@@ -7,6 +7,7 @@/* includes */ #include <common.h> +#include <cli.h> #include <linux/ctype.h> #include <pci.h> #include <net.h>
board/eltec/mhpc/mhpc.c +1 -0
@@ -14,6 +14,7 @@* SPDX-License-Identifier: GPL-2.0+ */ #include <common.h> +#include <cli.h> #include <linux/ctype.h> #include <commproc.h> #include "mpc8xx.h"
board/hymod/hymod.c +1 -0
@@ -8,6 +8,7 @@*/ #include <common.h> +#include <cli.h> #include <mpc8260.h> #include <mpc8260_irq.h> #include <ioports.h>
board/hymod/input.c +1 -0
@@ -6,6 +6,7 @@*/ #include <common.h> +#include <cli.h> int hymod_get_serno (const char *prompt)
common/cli_hush.c +1 -0
@@ -79,6 +79,7 @@#include <malloc.h> /* malloc, free, realloc*/ #include <linux/ctype.h> /* isalpha, isdigit */ #include <common.h> /* readline */ +#include <cli.h> #include <cli_hush.h> #include <command.h> /* find_cmd */ #ifndef CONFIG_SYS_PROMPT_HUSH_PS2
common/cmd_bedbug.c +1 -0
@@ -3,6 +3,7 @@*/ #include <common.h> +#include <cli.h> #include <command.h> #include <linux/ctype.h> #include <net.h>
common/cmd_dcr.c +1 -0
@@ -10,6 +10,7 @@*/ #include <common.h> +#include <cli.h> #include <config.h> #include <command.h>
common/cmd_i2c.c +1 -0
@@ -66,6 +66,7 @@*/ #include <common.h> +#include <cli.h> #include <command.h> #include <edid.h> #include <environment.h>
common/cmd_mem.c +1 -0
@@ -12,6 +12,7 @@*/ #include <common.h> +#include <cli.h> #include <command.h> #ifdef CONFIG_HAS_DATAFLASH #include <dataflash.h>
common/cmd_nvedit.c +1 -0
@@ -25,6 +25,7 @@*/ #include <common.h> +#include <cli.h> #include <command.h> #include <environment.h> #include <search.h>
common/cmd_pci.c +1 -0
@@ -14,6 +14,7 @@*/ #include <common.h> +#include <cli.h> #include <command.h> #include <asm/processor.h> #include <asm/io.h>
common/main.c +1 -0
@@ -12,6 +12,7 @@/* #define DEBUG */ #include <common.h> +#include <cli.h> #include <command.h> #include <fdtdec.h> #include <cli_hush.h>
common/menu.c +1 -0
@@ -5,6 +5,7 @@*/ #include <common.h> +#include <cli.h> #include <malloc.h> #include <errno.h> #include <linux/list.h>
drivers/ddr/fsl/interactive.c +1 -0
@@ -12,6 +12,7 @@*/ #include <common.h> +#include <cli.h> #include <linux/ctype.h> #include <asm/types.h> #include <asm/io.h>
include/cli.h new file +102 -0
102 lines not on this page · raw message
include/common.h +0 -4
@@ -286,10 +286,6 @@ int run_command(const char *cmd, int flag);* @return 0 on success, or != 0 on error. */ int run_command_list (const char *cmd,int len,int flag); -int readline (const char *const prompt); -int readline_into_buffer (const char *const prompt,char *buffer, -int timeout); -int parse_line (char *,char *[]);void init_cmd_timeout (void );void reset_cmd_timeout (void );extern char console_buffer[];
Signature · 1 line
1.9.1.423.g4596e3a
PATCH 4/14 Split out simple parser and readline into separate files
In reply to Simon GlassIt doesn't make sense to have the simple parser and the readline code all in main. Split them out into separate files.
---
common/Makefile | 9 +- common/cli_readline.c | 670 ++++++++++++++++++++++++++++++++ common/cli_simple.c | 338 ++++++++++++++++ common/main.c | 1017 +------------------------------------------------ include/cli.h | 5 + 5 files changed, 1026 insertions(+), 1013 deletions(-) create mode 100644 common/cli_readline.c create mode 100644 common/cli_simple.c
common/Makefile +8 -1
@@ -11,7 +11,14 @@ obj-y += main.o obj-y += command.o obj-y += exports.o obj-y += hash.o -obj-$(CONFIG_SYS_HUSH_PARSER) += cli_hush.o +ifdef CONFIG_SYS_HUSH_PARSER +obj-y += cli_hush.o +endif + +# We always have this since drivers/ddr/fs/interactive.c needs it +obj-y += cli_simple.o + +obj-y += cli_readline.o obj-y += s_record.o obj-y += xyzModem.o obj-y += cmd_disk.o
common/cli_readline.c new file +670 -0
670 lines not on this page · raw message
common/cli_simple.c new file +338 -0
338 lines not on this page · raw message
common/main.c +5 -1012
1,085 lines not on this page · raw message
include/cli.h +5 -0
@@ -99,4 +99,9 @@ int readline_into_buffer(const char *const prompt, char *buffer, int timeout);*/ int parse_line (char *line,char *argv[]); +/** bootretry_dont_retry() - Indicate that we should not retry the boot */ +void bootretry_dont_retry (void ); + +#define endtick (seconds) (get_ticks() + (uint64_t)(seconds) * get_tbclk()) +#endif
Signature · 1 line
1.9.1.423.g4596e3a
PATCH 5/14 Add cli_ prefix to readline functions
In reply to Simon GlassThis makes it clear where the code resides.
---
board/ait/cam_enc_4xx/cam_enc_4xx.c | 2 +- board/amcc/yucca/cmd_yucca.c | 20 ++++++++++---------- board/eltec/elppc/misc.c | 14 +++++++------- board/eltec/mhpc/mhpc.c | 12 ++++++------ board/hymod/hymod.c | 2 +- board/hymod/input.c | 4 ++-- common/cli_hush.c | 4 ++-- common/cli_readline.c | 7 ++++--- common/cli_simple.c | 6 +++--- common/cmd_bedbug.c | 28 ++++++++++++++-------------- common/cmd_dcr.c | 2 +- common/cmd_i2c.c | 2 +- common/cmd_mem.c | 2 +- common/cmd_nvedit.c | 4 ++-- common/cmd_pci.c | 2 +- common/menu.c | 5 +++-- drivers/ddr/fsl/interactive.c | 7 ++++--- include/cli.h | 7 ++++--- 18 files changed, 67 insertions(+), 63 deletions(-)
board/ait/cam_enc_4xx/cam_enc_4xx.c +1 -1
@@ -777,7 +777,7 @@ static void ait_menu_read_env(char *name)sprintf (output,"%s old: %s value: " , name,getenv (name));memset (cbuf,0 ,CONFIG_SYS_CBSIZE ); - readret =readline_into_buffer (output, cbuf,0 ); + readret =cli_readline_into_buffer (output, cbuf,0 );if (readret >=0 ) { ret =setenv (name, cbuf);
board/amcc/yucca/cmd_yucca.c +10 -10
@@ -52,7 +52,7 @@ static int setBootStrapClock(cmd_tbl_t *cmdtp, int incrflag, int flag, do { printf("enter sys clock frequency 33 or 66 MHz or quit to abort\n"); - nbytes = readline (" ? "); + nbytes = cli_readline(" ? "); if (strcmp(console_buffer, "quit") == 0) return 0;
@@ -75,7 +75,7 @@ static int setBootStrapClock(cmd_tbl_t *cmdtp, int incrflag, int flag,printf ("enter cpu clock frequency 400, 500, 533 MHz or quit to abort\n" );#endif } - nbytes =readline (" ? " ); + nbytes =cli_readline (" ? " );if (strcmp (console_buffer,"quit" ) ==0 )return 0 ;
@@ -119,7 +119,7 @@ static int setBootStrapClock(cmd_tbl_t *cmdtp, int incrflag, int flag,printf ("enter plb clock frequency 133, 166 MHz or quit to abort\n" );#endif - nbytes =readline (" ? " ); + nbytes =cli_readline (" ? " );if (strcmp (console_buffer,"quit" ) ==0 )return 0 ;
@@ -143,7 +143,7 @@ static int setBootStrapClock(cmd_tbl_t *cmdtp, int incrflag, int flag, do { printf("enter Pci-X clock frequency 33, 66, 100 or 133 MHz or quit to abort\n"); - nbytes = readline (" ? "); + nbytes = cli_readline(" ? "); if (strcmp(console_buffer, "quit") == 0) return 0;
@@ -164,13 +164,13 @@ static int setBootStrapClock(cmd_tbl_t *cmdtp, int incrflag, int flag,printf ("Pci-X clk = %s MHz\n" , pcixClock); do { - printf("\npress [y] to write I2C bootstrap \n"); - printf("or [n] to abort. \n"); - printf("Don't forget to set board switches \n"); - printf("according to your choice before re-starting \n"); - printf("(refer to 440spe_uboot_kit_um_1_01.pdf) \n"); + printf("\npress [y] to write I2C bootstrap\n"); + printf("or [n] to abort.\n"); + printf("Don't forget to set board switches\n"); + printf("according to your choice before re-starting\n"); + printf("(refer to 440spe_uboot_kit_um_1_01.pdf)\n"); - nbytes = readline (" ? "); + nbytes = cli_readline(" ? "); if (strcmp(console_buffer, "n") == 0) return 0;
board/eltec/elppc/misc.c +7 -7
@@ -114,7 +114,7 @@ int misc_init_r (void)printf ("Press key:\n <c> to copy current revision info to nvram.\n" );printf (" <r> to reenter revision info.\n" );printf ("=> " ); -if (0 !=readline (NULL )) { +if (0 !=cli_readline (NULL )) {switch ((char )toupper (console_buffer[0 ])) {case 'C' : copyNv =1 ;
@@ -131,7 +131,7 @@ int misc_init_r (void)memcpy (buf, &eerev.revision[0 ][0 ],14 );/* save all revision info */ printf ("Enter revision number (0-9): %c " , eerev.revision[0 ][0 ]); -if (0 !=readline (NULL )) { +if (0 !=cli_readline (NULL )) { eerev.revision[0 ][0 ] = (char )toupper (console_buffer[0 ]);memcpy (&eerev.revision[1 ][0 ], buf,12 );/* shift rest of rev info */
@@ -139,14 +139,14 @@ int misc_init_r (void)printf ("Enter revision character (A-Z): %c " , eerev.revision[0 ][1 ]); -if (1 ==readline (NULL )) { +if (1 ==cli_readline (NULL )) { eerev.revision[0 ][1 ] = (char )toupper (console_buffer[0 ]); }printf ("Enter board name (V-XXXX-XXXX): %s " , (char *) &eerev.board); -if (11 ==readline (NULL )) { +if (11 ==cli_readline (NULL )) {for (i =0 ; i <11 ; i++) eerev.board[i] = (char )toupper (console_buffer[i]);
@@ -154,14 +154,14 @@ int misc_init_r (void) }printf ("Enter serial number: %s " , (char *) &eerev.serial); -if (6 ==readline (NULL )) { +if (6 ==cli_readline (NULL )) {for (i =0 ; i <6 ; i++) eerev.serial[i] = console_buffer[i]; eerev.serial[6 ] ='\0' ; }printf ("Enter ether node ID with leading zero (HEX): %02x%02x%02x%02x%02x%02x " , eerev.etheraddr[0 ], eerev.etheraddr[1 ], eerev.etheraddr[2 ], eerev.etheraddr[3 ], eerev.etheraddr[4 ], eerev.etheraddr[5 ]); -if (12 ==readline (NULL )) { +if (12 ==cli_readline (NULL )) {for (i =0 ; i <12 ; i +=2 ) eerev.etheraddr[i >> 1] = (char) (16 *
@@ -176,7 +176,7 @@ int misc_init_r (void) l =strlen ((char *) &eerev.text);printf ("Add to text section (max 64 chr): %s " , (char *) &eerev.text); -if (0 !=readline (NULL )) { +if (0 !=cli_readline (NULL )) {for (i = l; i <63 ; i++) eerev.text[i] = console_buffer[i - l]; eerev.text[63 ] ='\0' ;
board/eltec/mhpc/mhpc.c +6 -6
@@ -147,21 +147,21 @@ int misc_init_r (void)if (strncmp ((char *) &mhpcRevInfo.board[2 ],"MHPC" ,4 ) !=0 ) {printf ("Enter revision number (0-9): %c " , mhpcRevInfo.revision[0 ]); -if (0 !=readline (NULL )) { +if (0 !=cli_readline (NULL )) { mhpcRevInfo.revision[0 ] = (char )toupper (console_buffer[0 ]); }printf ("Enter revision character (A-Z): %c " , mhpcRevInfo.revision[1 ]); -if (1 ==readline (NULL )) { +if (1 ==cli_readline (NULL )) { mhpcRevInfo.revision[1 ] = (char )toupper (console_buffer[0 ]); }printf ("Enter board name (V-XXXX-XXXX): %s " , (char *) &mhpcRevInfo.board); -if (11 ==readline (NULL )) { +if (11 ==cli_readline (NULL )) {for (i =0 ; i <11 ; i++) { mhpcRevInfo.board[i] = (char )toupper (console_buffer[i]);
@@ -178,7 +178,7 @@ int misc_init_r (void) do { printf ("\nEnter sensor number (0-255): %d ", (int) mhpcRevInfo.sensor); - if (0 != readline (NULL)) { + if (0 != cli_readline(NULL)) { mhpcRevInfo.sensor = (unsigned char) simple_strtoul (console_buffer, NULL,
@@ -188,7 +188,7 @@ int misc_init_r (void)printf ("Enter serial number: %s " , (char *) &mhpcRevInfo.serial); -if (6 ==readline (NULL )) { +if (6 ==cli_readline (NULL )) {for (i =0 ; i <6 ; i++) { mhpcRevInfo.serial[i] = console_buffer[i]; }
@@ -196,7 +196,7 @@ int misc_init_r (void) }printf ("Enter ether node ID with leading zero (HEX): %02x%02x%02x%02x%02x%02x " , mhpcRevInfo.etheraddr[0 ], mhpcRevInfo.etheraddr[1 ], mhpcRevInfo.etheraddr[2 ], mhpcRevInfo.etheraddr[3 ], mhpcRevInfo.etheraddr[4 ], mhpcRevInfo.etheraddr[5 ]); -if (12 ==readline (NULL )) { +if (12 ==cli_readline (NULL )) {for (i =0 ; i <12 ; i +=2 ) { mhpcRevInfo.etheraddr[i >> 1] = (char) (16 *
board/hymod/hymod.c +1 -1
@@ -416,7 +416,7 @@ last_stage_init (void)#ifdef CONFIG_BOOT_RETRY_TIME /* -* we use the readline () function, but we also want +* we use the cli_readline() function, but we also want * command timeout enabled */ init_cmd_timeout ();
board/hymod/input.c +2 -2
@@ -19,7 +19,7 @@ hymod_get_serno (const char *prompt)reset_cmd_timeout ();#endif - n =readline (prompt); + n =cli_readline (prompt);if (n <0 )return (n);
@@ -47,7 +47,7 @@ hymod_get_ethaddr (void)reset_cmd_timeout ();#endif - n =readline ("Enter board ethernet address: " ); + n =cli_readline ("Enter board ethernet address: " );if (n <0 )return (n);
common/cli_hush.c +2 -2
@@ -1007,9 +1007,9 @@ static void get_user_input(struct in_str *i)#endif i->__promptme =1 ;if (i->promptmode ==1 ) { - n =readline (CONFIG_SYS_PROMPT ); + n =cli_readline (CONFIG_SYS_PROMPT ); }else { - n =readline (CONFIG_SYS_PROMPT_HUSH_PS2 ); + n =cli_readline (CONFIG_SYS_PROMPT_HUSH_PS2 ); }#ifdef CONFIG_BOOT_RETRY_TIME if (n ==-2 ) {
common/cli_readline.c +4 -3
@@ -484,7 +484,7 @@ static int cread_line(const char *const prompt, char *buf, unsigned int *len,/****************************************************************************/ -int readline (const char *const prompt) +int cli_readline (const char *const prompt) {/* * If console_buffer isn't 0-length the user will be prompted to modify
@@ -492,11 +492,12 @@ int readline(const char *const prompt)*/ console_buffer[0 ] ='\0' ; -return readline_into_buffer (prompt, console_buffer,0 ); +return cli_readline_into_buffer (prompt, console_buffer,0 ); } -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) {char *p = buffer;#ifdef CONFIG_CMDLINE_EDITING
common/cli_simple.c +3 -3
@@ -19,7 +19,7 @@ debug_cond(DEBUG_PARSER, fmt, ##args) -int parse_line(char *line, char *argv[]) +int cli_simple_parse_line(char *line, char *argv[]) { int nargs = 0;
@@ -238,7 +238,7 @@ int cli_simple_run_command(const char *cmd, int flag)process_macros (token, finaltoken);/* Extract arguments */ - argc =parse_line (finaltoken, argv); + argc =cli_simple_parse_line (finaltoken, argv);if (argc ==0 ) { rc =-1 ;/* no command at all */ continue ;
@@ -272,7 +272,7 @@ void cli_loop(void) reset_cmd_timeout(); }#endif - len =readline (CONFIG_SYS_PROMPT ); + len =cli_readline (CONFIG_SYS_PROMPT ); flag =0 ;/* assume no special flags for now */ if (len >0 )
common/cmd_bedbug.c +14 -14
@@ -20,7 +20,7 @@ extern int run_command __P ((const char *, int));ulong dis_last_addr =0 ;/* Last address disassembled */ ulong dis_last_len =20 ;/* Default disassembler length */ CPU_DEBUG_CTX bug_ctx;/* Bedbug context structure */ - +/* ====================================================================== * U-Boot's puts function does not append a newline, so the bedbug stuff
@@ -34,7 +34,7 @@ int bedbug_puts (const char *str)printf ("%s\r\n" , str);return 0 ; }/* bedbug_puts */ - +/* ======================================================================
@@ -66,7 +66,7 @@ void bedbug_init (void)return ; }/* bedbug_init */ - +/* ======================================================================
@@ -107,7 +107,7 @@ int do_bedbug_dis (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])U_BOOT_CMD (ds,3 ,1 , do_bedbug_dis,"disassemble memory" ,"ds <address> [# instructions]" ); - +/* ====================================================================== * Entry point from the interpreter to the assembler. Assembles * instructions in consecutive memory locations until a '.' (period) is
@@ -135,7 +135,7 @@ int do_bedbug_asm (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) F_RADHEX);sprintf (prompt,"%08lx: " , mem_addr); -readline (prompt); +cli_readline (prompt);if (console_buffer[0 ] &&strcmp (console_buffer,"." )) { if ((instr =
@@ -157,7 +157,7 @@ int do_bedbug_asm (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])U_BOOT_CMD (as,2 ,0 , do_bedbug_asm,"assemble memory" ,"as <address>" ); - +/* ====================================================================== * Used to set a break point from the interpreter. Simply calls into the * CPU-specific break point set routine.
@@ -178,7 +178,7 @@ U_BOOT_CMD (break, 3, 0, do_bedbug_break,"break <address> - Break at an address\n" "break off <bp#> - Disable breakpoint.\n" "break show - List breakpoints."); - +/* ====================================================================== * Called from the debug interrupt routine. Simply calls the CPU-specific * breakpoint handling routine.
@@ -193,7 +193,7 @@ void do_bedbug_breakpoint (struct pt_regs *regs)return ; }/* do_bedbug_breakpoint */ - +/* ======================================================================
@@ -226,7 +226,7 @@ void bedbug_main_loop (unsigned long addr, struct pt_regs *regs)/* A miniature main loop */ while (bug_ctx.stopped) { - len =readline (prompt_str); + len =cli_readline (prompt_str); flag =0 ;/* assume no special flags for now */
@@ -251,7 +251,7 @@ void bedbug_main_loop (unsigned long addr, struct pt_regs *regs)return ; }/* bedbug_main_loop */ - +/* ======================================================================
@@ -275,7 +275,7 @@ int do_bedbug_continue (cmd_tbl_t * cmdtp, int flag, int argc, char * const argvU_BOOT_CMD (continue,1 ,0 , do_bedbug_continue,"continue from a breakpoint" ,"" ); - +/* ====================================================================== * Interpreter command to continue to the next instruction, stepping into * subroutines. Works by calling the find_next_addr() routine to compute
@@ -306,7 +306,7 @@ int do_bedbug_step (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])U_BOOT_CMD (step,1 ,1 , do_bedbug_step,"single step execution." ,"" ); - +/* ====================================================================== * Interpreter command to continue to the next instruction, stepping over * subroutines. Works by calling the find_next_addr() routine to compute
@@ -337,7 +337,7 @@ int do_bedbug_next (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])U_BOOT_CMD (next,1 ,1 , do_bedbug_next,"single step execution, stepping over subroutines." ,"" ); - +/* ====================================================================== * Interpreter command to print the current stack. This assumes an EABI * architecture, so it starts with GPR R1 and works back up the stack.
@@ -382,7 +382,7 @@ int do_bedbug_stack (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])U_BOOT_CMD (where,1 ,1 , do_bedbug_stack,"Print the running stack." ,"" ); - +/* ====================================================================== * Interpreter command to dump the registers. Calls the CPU-specific * show registers routine.
common/cmd_dcr.c +1 -1
@@ -63,7 +63,7 @@ int do_setdcr (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) do { value = get_dcr (dcrn); printf ("%04x: %08lx", dcrn, value); - nbytes = readline (" ? "); + nbytes = cli_readline(" ? "); if (nbytes == 0) { /* * <CR> pressed as only input, don't modify current
common/cmd_i2c.c +1 -1
@@ -613,7 +613,7 @@ mod_i2c_mem(cmd_tbl_t *cmdtp, int incrflag, int flag, int argc, char * const argprintf (" %08lx" , data); } - nbytes =readline (" ? " ); + nbytes =cli_readline (" ? " );if (nbytes ==0 ) {/* * <CR> pressed as only input, don't modify current
common/cmd_mem.c +1 -1
@@ -1150,7 +1150,7 @@ mod_mem(cmd_tbl_t *cmdtp, int incrflag, int flag, int argc, char * const argv[])else printf (" %02x" , *((u8 *)ptr)); - nbytes =readline (" ? " ); + nbytes =cli_readline (" ? " );if (nbytes ==0 || (nbytes ==1 && console_buffer[0 ] =='-' )) {/* <CR> pressed as only input, don't modify current * location and move to next. "-" pressed will go back.
common/cmd_nvedit.c +2 -2
@@ -408,7 +408,7 @@ int do_env_ask(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])return 1 ;/* prompt for input */ - len =readline (message); + len =cli_readline (message);if (size < len) console_buffer[size] ='\0' ;
@@ -591,7 +591,7 @@ static int do_env_edit(cmd_tbl_t *cmdtp, int flag, int argc,else buffer[0 ] ='\0' ; -if (readline_into_buffer ("edit: " , buffer,0 ) <0 ) +if (cli_readline_into_buffer ("edit: " , buffer,0 ) <0 )return 1 ;return setenv (argv[1 ], buffer);
common/cmd_pci.c +1 -1
@@ -346,7 +346,7 @@ pci_cfg_modify (pci_dev_t bdf, ulong addr, ulong size, ulong value, int incrflagprintf (" %02x" , val1); } - nbytes =readline (" ? " ); + nbytes =cli_readline (" ? " );if (nbytes ==0 || (nbytes ==1 && console_buffer[0 ] =='-' )) {/* <CR> pressed as only input, don't modify current * location and move to next. "-" pressed will go back.
common/menu.c +3 -2
@@ -197,8 +197,9 @@ static inline int menu_interactive_choice(struct menu *m, void **choice)menu_display (m);if (!m->item_choice) { - readret =readline_into_buffer ("Enter choice: " , cbuf, - m->timeout /10 ); + readret =cli_readline_into_buffer ("Enter choice: " , + cbuf, + m->timeout /10 );if (readret >=0 ) { choice_item =menu_item_by_key (m, cbuf);
drivers/ddr/fsl/interactive.c +4 -3
@@ -1496,11 +1496,12 @@ unsigned long long fsl_ddr_interactive(fsl_ddr_info_t *pinfo, int var_is_set) }else {/* * No need to worry for buffer overflow here in -* this function; readline() maxes out at CFG_CBSIZE +* this function; cli_readline() maxes out at +* CFG_CBSIZE */ -readline_into_buffer (prompt, buffer,0 ); +cli_readline_into_buffer (prompt, buffer,0 ); } - argc =parse_line (buffer, argv); + argc =cli_simple_parse_line (buffer, argv);if (argc ==0 )continue ;
include/cli.h +4 -3
@@ -53,7 +53,7 @@ int cli_simple_run_command_list(char *cmd, int flag);* @prompt: Prompt to display * @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
@@ -78,7 +78,8 @@ int readline(const char *const prompt);* 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
@@ -97,7 +98,7 @@ int readline_into_buffer(const char *const prompt, char *buffer, int timeout);* @args: Array to hold arguments * @return number of arguments */ -int parse_line (char *line,char *argv[]); +int cli_simple_parse_line (char *line,char *argv[]);/** bootretry_dont_retry() - Indicate that we should not retry the boot */ void bootretry_dont_retry (void );
Signature · 1 line
1.9.1.423.g4596e3a
PATCH 6/14 Move autoboot code to autoboot.c
In reply to Simon GlassThe autoboot code is complex and long. It deserves its own file with a simple interface from main.c.
---
common/Makefile | 5 + common/autoboot.c | 363 ++++++++++++++++++++++++++++++++++++++++++++++++++++ common/main.c | 366 +---------------------------------------------------- include/autoboot.h | 23 ++++ 4 files changed, 393 insertions(+), 364 deletions(-) create mode 100644 common/autoboot.c create mode 100644 include/autoboot.h
common/Makefile +5 -0
@@ -23,6 +23,11 @@ obj-y += s_record.o obj-y += xyzModem.o obj-y += cmd_disk.o +# This option is not just y/n - it can have a numeric value +ifdef CONFIG_BOOTDELAY +obj-y += autoboot.o +endif + # boards obj-$(CONFIG_SYS_GENERIC_BOARD) += board_f.o obj-$(CONFIG_SYS_GENERIC_BOARD) += board_r.o
common/autoboot.c new file +363 -0
363 lines not on this page · raw message
common/main.c +2 -364
395 lines not on this page · raw message
include/autoboot.h new file +23 -0
@@ -0,0 +1,23 @@ +/* +* (C) Copyright 2000 +* Wolfgang Denk, DENX Software Engineering, wd at denx.de. +* +* Add to readline cmdline-editing by +* (C) Copyright 2005 +* JinHua Luo, GuangDong Linux Center, <[email protected]> +* +* SPDX-License-Identifier: GPL-2.0+ +*/ + +#ifndef __AUTOBOOT_H +#define __AUTOBOOT_H + +#ifdef CONFIG_BOOTDELAY +void bootdelay_process (void ); +#else +static inline void bootdelay_process (void ) +{ +} +#endif + +#endif
Signature · 1 line
1.9.1.423.g4596e3a
PATCH 7/14 Move command line API into cli.c
In reply to Simon GlassWe now have a single entry point to the CLI, whether simple or hush. Put this in its own file.
---
common/Makefile | 1 + common/cli.c | 106 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ common/main.c | 93 ------------------------------------------------- 3 files changed, 107 insertions(+), 93 deletions(-) create mode 100644 common/cli.c
common/Makefile +1 -0
@@ -18,6 +18,7 @@ endif # We always have this since drivers/ddr/fs/interactive.c needs it obj-y += cli_simple.o +obj-y += cli.o obj-y += cli_readline.o obj-y += s_record.o obj-y += xyzModem.o
common/cli.c new file +106 -0
106 lines not on this page · raw message
common/main.c +0 -93
102 lines not on this page · raw message
Signature · 1 line
1.9.1.423.g4596e3a
PATCH 8/14 Move bootretry code into bootretry.c and clean up
In reply to Simon GlassThis code is only used by one board, so it seems a shame to clutter up the readline code with it. Move it into its own file.
---
board/hymod/hymod.c | 1 + board/hymod/input.c | 1 + common/Makefile | 5 +++++ common/autoboot.c | 1 + common/bootretry.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++ common/cli_hush.c | 1 + common/cli_readline.c | 60 +++++---------------------------------------------- common/cli_simple.c | 1 + common/cmd_i2c.c | 1 + common/cmd_mem.c | 1 + common/cmd_pci.c | 1 + include/bootretry.h | 31 ++++++++++++++++++++++++++ include/common.h | 2 -- 13 files changed, 108 insertions(+), 57 deletions(-) create mode 100644 common/bootretry.c create mode 100644 include/bootretry.h
board/hymod/hymod.c +1 -0
@@ -8,6 +8,7 @@*/ #include <common.h> +#include <bootretry.h> #include <cli.h> #include <mpc8260.h> #include <mpc8260_irq.h>
board/hymod/input.c +1 -0
@@ -6,6 +6,7 @@*/ #include <common.h> +#include <bootretry.h> #include <cli.h> int
common/Makefile +5 -0
@@ -29,6 +29,11 @@ ifdef CONFIG_BOOTDELAY obj-y += autoboot.o endif +# This option is not just y/n - it can have a numeric value +ifdef CONFIG_BOOT_RETRY_TIME +obj-y += bootretry.o +endif + # boards obj-$(CONFIG_SYS_GENERIC_BOARD) += board_f.o obj-$(CONFIG_SYS_GENERIC_BOARD) += board_r.o
common/autoboot.c +1 -0
@@ -6,6 +6,7 @@*/ #include <common.h> +#include <bootretry.h> #include <cli.h> #include <fdtdec.h> #include <menu.h>
common/bootretry.c new file +59 -0
59 lines not on this page · raw message
common/cli_hush.c +1 -0
@@ -79,6 +79,7 @@#include <malloc.h> /* malloc, free, realloc*/ #include <linux/ctype.h> /* isalpha, isdigit */ #include <common.h> /* readline */ +#include <bootretry.h> #include <cli.h> #include <cli_hush.h> #include <command.h> /* find_cmd */
common/cli_readline.c +5 -55
89 lines not on this page · raw message
common/cli_simple.c +1 -0
@@ -10,6 +10,7 @@*/ #include <common.h> +#include <bootretry.h> #include <cli.h> #include <linux/ctype.h>
common/cmd_i2c.c +1 -0
@@ -66,6 +66,7 @@*/ #include <common.h> +#include <bootretry.h> #include <cli.h> #include <command.h> #include <edid.h>
common/cmd_mem.c +1 -0
@@ -12,6 +12,7 @@*/ #include <common.h> +#include <bootretry.h> #include <cli.h> #include <command.h> #ifdef CONFIG_HAS_DATAFLASH
common/cmd_pci.c +1 -0
@@ -14,6 +14,7 @@*/ #include <common.h> +#include <bootretry.h> #include <cli.h> #include <command.h> #include <asm/processor.h>
include/bootretry.h new file +31 -0
@@ -0,0 +1,31 @@ +/* +* (C) Copyright 2000 +* Wolfgang Denk, DENX Software Engineering, wd at denx.de. +* +* SPDX-License-Identifier: GPL-2.0+ +*/ + +#ifndef __bootretry_h +#define __bootretry_h + +#ifdef CONFIG_BOOT_RETRY_TIME +/** +* bootretry_tstc_timeout() - ensure we get a keypress before timeout +* +* Check for a keypress repeatedly, resetting the watchdog each time. If a +* keypress is not received within the command timeout, return an error. +* +* @return 0 if a key is received in time, -ETIMEDOUT if not +*/ +int bootretry_tstc_timeout (void ); +#else +static inline int bootretry_tstc_timeout (void ) +{ +return 0 ; +} +#endif + +void init_cmd_timeout (void ); +void reset_cmd_timeout (void ); + +#endif
include/common.h +0 -2
@@ -286,8 +286,6 @@ int run_command(const char *cmd, int flag);* @return 0 on success, or != 0 on error. */ int run_command_list (const char *cmd,int len,int flag); -void init_cmd_timeout (void ); -void reset_cmd_timeout (void );extern char console_buffer[];/* arch/$(ARCH)/lib/board.c */
Signature · 1 line
1.9.1.423.g4596e3a
PATCH 9/14 Rename bootretry functions and remove #ifdefs
In reply to Simon GlassAdd a bootretry_ prefix to these two functions, and remove the need for the #ifdef around everything (it moves to the Makefile).
---
board/hymod/hymod.c | 4 +--- board/hymod/input.c | 8 ++------ common/autoboot.c | 6 +----- common/bootretry.c | 4 ++-- common/cli_hush.c | 7 +------ common/cli_simple.c | 4 +--- common/cmd_i2c.c | 13 ++++--------- common/cmd_mem.c | 13 ++++--------- common/cmd_pci.c | 9 +++------ include/bootretry.h | 38 +++++++++++++++++++++++++++++++++----- include/cli.h | 3 --- 11 files changed, 52 insertions(+), 57 deletions(-)
board/hymod/hymod.c +1 -3
@@ -415,13 +415,11 @@ last_stage_init (void)hymod_conf_t *cp = &gd->bd->bi_hymod_conf;int rc; -#ifdef CONFIG_BOOT_RETRY_TIME /* * we use the cli_readline() function, but we also want * command timeout enabled */ -init_cmd_timeout (); -#endif +bootretry_init_cmd_timeout ();memset ((void *) cp,0 ,sizeof (*cp));
board/hymod/input.c +2 -6
@@ -16,9 +16,7 @@ hymod_get_serno (const char *prompt)int n, serno;char *p; -#ifdef CONFIG_BOOT_RETRY_TIME -reset_cmd_timeout (); -#endif +bootretry_reset_cmd_timeout (); n =cli_readline (prompt);
@@ -44,9 +42,7 @@ hymod_get_ethaddr (void)for (;;) {int n; -#ifdef CONFIG_BOOT_RETRY_TIME -reset_cmd_timeout (); -#endif +bootretry_reset_cmd_timeout (); n =cli_readline ("Enter board ethernet address: " );
common/autoboot.c +1 -5
@@ -113,11 +113,9 @@ static int abortboot_keyed(int bootdelay) delaykey[i].retry ?"delay" : "stop"); -# ifdef CONFIG_BOOT_RETRY_TIME /* don't retry auto boot */ if (!delaykey[i].retry)bootretry_dont_retry (); -# endif abort =1 ; } }
@@ -305,9 +303,7 @@ void bootdelay_process(void)#if defined(CONFIG_MENU_SHOW ) bootdelay =menu_show (bootdelay);#endif -# ifdef CONFIG_BOOT_RETRY_TIME -init_cmd_timeout (); -# endif /* CONFIG_BOOT_RETRY_TIME */ +bootretry_init_cmd_timeout ();#ifdef CONFIG_POST if (gd->flags &GD_FLG_POSTFAIL ) {
common/bootretry.c +2 -2
@@ -21,7 +21,7 @@ static int retry_time = -1; /* -1 so can call readline before main_loop *//*************************************************************************** * initialize command line timeout */ -void init_cmd_timeout (void ) +void bootretry_init_cmd_timeout (void ) {char *s =getenv ("bootretry" );
@@ -37,7 +37,7 @@ void init_cmd_timeout(void)/*************************************************************************** * reset command line timeout to retry_time seconds */ -void reset_cmd_timeout (void ) +void bootretry_reset_cmd_timeout (void ) { endtime =endtick (retry_time); }
common/cli_hush.c +1 -6
@@ -1000,12 +1000,7 @@ static void get_user_input(struct in_str *i)int n;static char the_command[CONFIG_SYS_CBSIZE ]; -#ifdef CONFIG_BOOT_RETRY_TIME -# ifndef CONFIG_RESET_TO_RETRY -# error "This currently only works with CONFIG_RESET_TO_RETRY enabled" -# endif -reset_cmd_timeout (); -#endif +bootretry_reset_cmd_timeout (); i->__promptme =1 ;if (i->promptmode ==1 ) { n =cli_readline (CONFIG_SYS_PROMPT );
common/cli_simple.c +1 -3
@@ -265,14 +265,12 @@ void cli_loop(void)int rc =1 ;for (;;) { -#ifdef CONFIG_BOOT_RETRY_TIME if (rc >=0 ) {/* Saw enough of a valid command to * restart the timeout. */ -reset_cmd_timeout (); +bootretry_reset_cmd_timeout (); } -#endif len =cli_readline (CONFIG_SYS_PROMPT ); flag =0 ;/* assume no special flags for now */
common/cmd_i2c.c +4 -9
@@ -564,9 +564,7 @@ mod_i2c_mem(cmd_tbl_t *cmdtp, int incrflag, int flag, int argc, char * const argif (argc !=3 )return CMD_RET_USAGE ; -#ifdef CONFIG_BOOT_RETRY_TIME -reset_cmd_timeout ();/* got a good command to get here */ -#endif +bootretry_reset_cmd_timeout ();/* got a good command to get here */ /* * We use the last specified parameters, unless new ones are * entered.
@@ -623,9 +621,8 @@ mod_i2c_mem(cmd_tbl_t *cmdtp, int incrflag, int flag, int argc, char * const argif (incrflag) addr += size; nbytes = size; -#ifdef CONFIG_BOOT_RETRY_TIME -reset_cmd_timeout ();/* good enough to not time out */ -#endif +/* good enough to not time out */ +bootretry_reset_cmd_timeout (); }#ifdef CONFIG_BOOT_RETRY_TIME else if (nbytes == -2)
@@ -642,12 +639,10 @@ mod_i2c_mem(cmd_tbl_t *cmdtp, int incrflag, int flag, int argc, char * const arg data =be32_to_cpu (data); nbytes = endp - console_buffer;if (nbytes) { -#ifdef CONFIG_BOOT_RETRY_TIME /* * good enough to not time out */ -reset_cmd_timeout (); -#endif +bootretry_reset_cmd_timeout ();if (i2c_write (chip, addr, alen, (uchar *)&data, size) !=0 )puts ("Error writing the chip.\n" );#ifdef CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS
common/cmd_mem.c +4 -9
@@ -1098,9 +1098,7 @@ mod_mem(cmd_tbl_t *cmdtp, int incrflag, int flag, int argc, char * const argv[])if (argc !=2 )return CMD_RET_USAGE ; -#ifdef CONFIG_BOOT_RETRY_TIME -reset_cmd_timeout ();/* got a good command to get here */ -#endif +bootretry_reset_cmd_timeout ();/* got a good command to get here */ /* We use the last specified parameters, unless new ones are * entered. */
@@ -1159,9 +1157,8 @@ mod_mem(cmd_tbl_t *cmdtp, int incrflag, int flag, int argc, char * const argv[])if (incrflag) addr += nbytes ? -size : size; nbytes =1 ; -#ifdef CONFIG_BOOT_RETRY_TIME -reset_cmd_timeout ();/* good enough to not time out */ -#endif +/* good enough to not time out */ +bootretry_reset_cmd_timeout (); }#ifdef CONFIG_BOOT_RETRY_TIME else if (nbytes == -2) {
@@ -1177,11 +1174,9 @@ mod_mem(cmd_tbl_t *cmdtp, int incrflag, int flag, int argc, char * const argv[])#endif nbytes = endp - console_buffer;if (nbytes) { -#ifdef CONFIG_BOOT_RETRY_TIME /* good enough to not time out */ -reset_cmd_timeout (); -#endif +bootretry_reset_cmd_timeout ();if (size ==4 ) *((u32 *)ptr) = i;#ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
common/cmd_pci.c +3 -6
@@ -355,9 +355,8 @@ pci_cfg_modify (pci_dev_t bdf, ulong addr, ulong size, ulong value, int incrflagif (incrflag) addr += nbytes ? -size : size; nbytes =1 ; -#ifdef CONFIG_BOOT_RETRY_TIME -reset_cmd_timeout ();/* good enough to not time out */ -#endif +/* good enough to not time out */ +bootretry_reset_cmd_timeout (); }#ifdef CONFIG_BOOT_RETRY_TIME else if (nbytes == -2) {
@@ -369,11 +368,9 @@ pci_cfg_modify (pci_dev_t bdf, ulong addr, ulong size, ulong value, int incrflag i =simple_strtoul (console_buffer, &endp,16 ); nbytes = endp - console_buffer;if (nbytes) { -#ifdef CONFIG_BOOT_RETRY_TIME /* good enough to not time out */ -reset_cmd_timeout (); -#endif +bootretry_reset_cmd_timeout ();pci_cfg_write (bdf, addr, size, i);if (incrflag) addr += size;
include/bootretry.h +33 -5
@@ -5,8 +5,8 @@* SPDX-License-Identifier: GPL-2.0+ */ -#ifndef __bootretry_h -#define __bootretry_h +#ifndef __BOOTRETRY_H +#define __BOOTRETRY_H#ifdef CONFIG_BOOT_RETRY_TIME /**
@@ -18,14 +18,42 @@* @return 0 if a key is received in time, -ETIMEDOUT if not */ int bootretry_tstc_timeout (void ); + +/** +* bootretry_init_cmd_timeout() - set up command timeout +* +* Get the required command timeout from the environment. +*/ +void bootretry_init_cmd_timeout (void ); + +/** +* bootretry_reset_cmd_timeout() - reset command timeout +* +* Reset the command timeout so that the user has a fresh start. This is +* typically used when input is received from the user. +*/ +void bootretry_reset_cmd_timeout (void ); + +/** bootretry_dont_retry() - Indicate that we should not retry the boot */ +void bootretry_dont_retry (void );#else static inline int bootretry_tstc_timeout (void ) {return 0 ; } -#endif -void init_cmd_timeout (void ); -void reset_cmd_timeout (void ); +static inline void bootretry_init_cmd_timeout (void ) +{ +} + +static inline void bootretry_reset_cmd_timeout (void ) +{ +} + +static inline void bootretry_dont_retry (void ) +{ +} + +#endif #endif
include/cli.h +0 -3
@@ -100,9 +100,6 @@ int cli_readline_into_buffer(const char *const prompt, char *buffer,*/ int cli_simple_parse_line (char *line,char *argv[]); -/** bootretry_dont_retry() - Indicate that we should not retry the boot */ -void bootretry_dont_retry (void ); -#define endtick (seconds) (get_ticks() + (uint64_t)(seconds) * get_tbclk())#endif
Signature · 1 line
1.9.1.423.g4596e3a
PATCH 10/14 m68k: powerpc: Clean up do_mdm_init
In reply to Simon GlassThis code seems unnecessarily complex. We really just need to check the global_data. Now that is it all in one place, and not arch-specific, this is pretty easy.
---
arch/m68k/lib/board.c | 7 ------- arch/powerpc/lib/board.c | 8 -------- common/board_r.c | 14 -------------- common/main.c | 11 ++++------- include/common.h | 1 + 5 files changed, 5 insertions(+), 36 deletions(-)
arch/m68k/lib/board.c +0 -7
@@ -629,13 +629,6 @@ void board_init_r (gd_t *id, ulong dest_addr) }#endif -#ifdef CONFIG_MODEM_SUPPORT - { -extern int do_mdm_init; - do_mdm_init = gd->do_mdm_init; - } -#endif -#ifdef CONFIG_WATCHDOG /* disable watchdog if environment is set */ if ((s =getenv ("watchdog" )) !=NULL ) {
arch/powerpc/lib/board.c +0 -8
@@ -976,14 +976,6 @@ void board_init_r(gd_t *id, ulong dest_addr)kbd_init ();#endif -#ifdef CONFIG_MODEM_SUPPORT - { -extern int do_mdm_init; - - do_mdm_init = gd->do_mdm_init; - } -#endif -/* Initialization complete - start the monitor */ /* main_loop() can return to retry autoboot, if so just run it again. */
common/board_r.c +0 -14
@@ -703,17 +703,6 @@ static int initr_kbd(void) }#endif -#ifdef CONFIG_MODEM_SUPPORT -static int initr_modem (void ) -{ -/* TODO: with new initcalls, move this into the driver */ -extern int do_mdm_init; - - do_mdm_init = gd->do_mdm_init; -return 0 ; -} -#endif -static int run_main_loop (void ) {#ifdef CONFIG_SANDBOX
@@ -928,9 +917,6 @@ init_fnc_t init_sequence_r[] = {#ifdef CONFIG_PS2KBD initr_kbd, #endif -#ifdef CONFIG_MODEM_SUPPORT - initr_modem, -#endif run_main_loop, };
common/main.c +4 -7
@@ -14,17 +14,14 @@#include <malloc.h> #include <version.h> +DECLARE_GLOBAL_DATA_PTR ; +/* * Board-specific Platform code can reimplement show_boot_progress () if needed */ void inline __show_boot_progress (int val) {}void show_boot_progress (int val) __attribute__((weak,alias ("__show_boot_progress" ))); -#ifdef CONFIG_MODEM_SUPPORT -int do_mdm_init =0 ; -extern void mdm_init (void );/* defined in board.c */ -#endif -void main_loop (void ) {#ifdef CONFIG_PREBOOT
@@ -34,8 +31,8 @@ void main_loop(void)bootstage_mark_name (BOOTSTAGE_ID_MAIN_LOOP ,"main_loop" );#ifdef CONFIG_MODEM_SUPPORT -debug ("DEBUG: main_loop: do_mdm_init=%d\n" , do_mdm_init); -if (do_mdm_init) { +debug ("DEBUG: main_loop: gd->do_mdm_init=%lu\n" , gd->do_mdm_init); +if (gd->do_mdm_init) {char *str =strdup (getenv ("mdm_cmd" ));setenv ("preboot" , str);/* set or delete definition */ if (str !=NULL )
include/common.h +1 -0
@@ -299,6 +299,7 @@ extern ulong monitor_flash_len;int mac_read_from_eeprom (void );extern u8 __dtb_dt_begin[];/* embedded device tree blob */ int set_cpu_clk_info (void ); +int mdm_init (void );#if defined(CONFIG_DISPLAY_CPUINFO )int print_cpuinfo (void );#else
Signature · 1 line
1.9.1.423.g4596e3a
PATCH 11/14 Simplify the main loop
In reply to Simon GlassThe main loop is easier to follow if the code is grouped into separate functions. Make this change, so that main_loop() is easier to read.
---
common/main.c | 47 ++++++++++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 21 deletions(-)
common/main.c +26 -21
@@ -22,14 +22,8 @@ DECLARE_GLOBAL_DATA_PTR;void inline __show_boot_progress (int val) {}void show_boot_progress (int val) __attribute__((weak,alias ("__show_boot_progress" ))); -void main_loop (void ) +static void modem_init (void ) { -#ifdef CONFIG_PREBOOT -char *p; -#endif - -bootstage_mark_name (BOOTSTAGE_ID_MAIN_LOOP ,"main_loop" ); -#ifdef CONFIG_MODEM_SUPPORT debug ("DEBUG: main_loop: gd->do_mdm_init=%lu\n" , gd->do_mdm_init);if (gd->do_mdm_init) {
@@ -40,22 +34,13 @@ void main_loop(void)mdm_init ();/* wait for modem connection */ }#endif /* CONFIG_MODEM_SUPPORT */ +} -#ifdef CONFIG_VERSION_VARIABLE - { -setenv ("ver" , version_string);/* set version variable */ - } -#endif /* CONFIG_VERSION_VARIABLE */ - -#ifdef CONFIG_SYS_HUSH_PARSER -u_boot_hush_start (); -#endif - -#if defined(CONFIG_HUSH_INIT_VAR ) -hush_init_var (); -#endif - +static void run_preboot_environment_command (void ) +{#ifdef CONFIG_PREBOOT +char *p; + p =getenv ("preboot" );if (p !=NULL ) {# ifdef CONFIG_AUTOBOOT_KEYED
@@ -69,6 +54,26 @@ void main_loop(void) # endif }#endif /* CONFIG_PREBOOT */ +} + +void main_loop (void ) +{ +bootstage_mark_name (BOOTSTAGE_ID_MAIN_LOOP ,"main_loop" ); + +modem_init (); +#ifdef CONFIG_VERSION_VARIABLE +setenv ("ver" , version_string);/* set version variable */ +#endif /* CONFIG_VERSION_VARIABLE */ + +#ifdef CONFIG_SYS_HUSH_PARSER +u_boot_hush_start (); +#endif + +#if defined(CONFIG_HUSH_INIT_VAR ) +hush_init_var (); +#endif + +run_preboot_environment_command ();#if defined(CONFIG_UPDATE_TFTP )update_tftp (0UL );
Signature · 1 line
1.9.1.423.g4596e3a
PATCH 12/14 main: Hide the hush/simple details inside cli.c
In reply to Simon GlassMove these details from main (which doesn't care which parser is used) to cli.c where they belong.
---
common/cli.c | 22 ++++++++++++++++++++++ common/cli_simple.c | 2 +- common/main.c | 16 ++-------------- include/cli.h | 13 ++++++++++++- 4 files changed, 37 insertions(+), 16 deletions(-)
common/cli.c +22 -0
@@ -104,3 +104,25 @@ int do_run(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) return 0; }#endif + +void cli_loop (void ) +{ +#ifdef CONFIG_SYS_HUSH_PARSER +parse_file_outer (); +/* This point is never reached */ +for (;;); +#else +cli_simple_loop (); +#endif /*CONFIG_SYS_HUSH_PARSER*/ +} + +void cli_init (void ) +{ +#ifdef CONFIG_SYS_HUSH_PARSER +u_boot_hush_start (); +#endif + +#if defined(CONFIG_HUSH_INIT_VAR ) +hush_init_var (); +#endif +}
common/cli_simple.c +1 -1
@@ -256,7 +256,7 @@ int cli_simple_run_command(const char *cmd, int flag)return rc ? rc : repeatable; } -void cli_loop (void ) +void cli_simple_loop (void ) {static char lastcommand[CONFIG_SYS_CBSIZE ] = {0 , };
common/main.c +2 -14
@@ -10,7 +10,6 @@#include <common.h> #include <autoboot.h> #include <cli.h> -#include <cli_hush.h> #include <malloc.h> #include <version.h>
@@ -65,13 +64,7 @@ void main_loop(void)setenv ("ver" , version_string);/* set version variable */ #endif /* CONFIG_VERSION_VARIABLE */ -#ifdef CONFIG_SYS_HUSH_PARSER -u_boot_hush_start (); -#endif - -#if defined(CONFIG_HUSH_INIT_VAR ) -hush_init_var (); -#endif +cli_init ();run_preboot_environment_command ();
@@ -83,11 +76,6 @@ void main_loop(void)/* * Main Loop for Monitor Command Processing */ -#ifdef CONFIG_SYS_HUSH_PARSER -parse_file_outer (); -/* This point is never reached */ -for (;;); -#else +cli_loop (); -#endif /*CONFIG_SYS_HUSH_PARSER*/ }
include/cli.h +12 -1
@@ -14,7 +14,7 @@* 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
@@ -100,6 +100,17 @@ int cli_readline_into_buffer(const char *const prompt, char *buffer,*/ int cli_simple_parse_line (char *line,char *argv[]); +/** +* 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
Signature · 1 line
1.9.1.423.g4596e3a
PATCH 13/14 main: Make the execution path a little clearer in main.c
In reply to Simon Glassbootdelay_process() never returns in some circumstances, whichs makes the control flow confusing. Change it so that the decision about how to execute the boot command is made in the main_loop() code, so it is easier to follow. Move CLI stuff to cli.c.
---
common/autoboot.c | 81 ++++++++---------------------------------------------- common/cli.c | 66 ++++++++++++++++++++++++++++++++++++++++++++ common/main.c | 12 +++++--- include/autoboot.h | 28 +++++++++++++++++-- include/cli.h | 33 ++++++++++++++++++++++ 5 files changed, 145 insertions(+), 75 deletions(-)
common/autoboot.c +12 -69
@@ -22,6 +22,9 @@ DECLARE_GLOBAL_DATA_PTR; #define debug_bootkeys(fmt, args...) \ debug_cond(DEBUG_BOOTKEYS, fmt, ##args) +/* Stored value of bootdelay, used by autoboot_command() */ +static int stored_bootdelay; +/*************************************************************************** * Watch for 'delay' seconds for autoboot stop or autoboot delay string. * returns: 0 - no key string, allow autoboot 1 - got key string, abort
@@ -205,57 +208,9 @@ static int abortboot(int bootdelay)#endif } -/* -* Runs the given boot command securely. Specifically: -* - Doesn't run the command with the shell (run_command or parse_string_outer), -* since that's a lot of code surface that an attacker might exploit. -* Because of this, we don't do any argument parsing--the secure boot command -* has to be a full-fledged u-boot command. -* - Doesn't check for keypresses before booting, since that could be a -* security hole; also disables Ctrl-C. -* - Doesn't allow the command to return. -* -* Upon any failures, this function will drop into an infinite loop after -* printing the error message to console. -*/ - -#if defined(CONFIG_OF_CONTROL ) -static void secure_boot_cmd (char *cmd) -{ -cmd_tbl_t *cmdtp; -int rc; - -if (!cmd) { -printf ("## Error: Secure boot command not specified\n" ); - goto err; - } - -/* Disable Ctrl-C just in case some command is used that checks it. */ -disable_ctrlc (1 ); - -/* Find the command directly. */ - cmdtp =find_cmd (cmd); -if (!cmdtp) { -printf ("## Error: \"%s\" not defined\n" , cmd); - goto err; - } - -/* Run the command, forcing no flags and faking argc and argv. */ - rc = (cmdtp->cmd)(cmdtp,0 ,1 , &cmd); - -/* Shouldn't ever return from boot command. */ -printf ("## Error: \"%s\" returned (code %d)\n" , cmd, rc); - -err: -/* -* Not a whole lot to do here. Rebooting won't help much, since we'll -* just end up right back here. Just loop. -*/ -hang (); -} -static void process_fdt_options (const void *blob) { +#if defined(CONFIG_OF_CONTROL )ulong addr;/* Add an env variable to point to a kernel payload, if available */
@@ -267,14 +222,11 @@ static void process_fdt_options(const void *blob) addr =fdtdec_get_config_int (gd->fdt_blob,"rootdisk-offset" ,0 );if (addr)setenv_addr ("rootaddr" , (void *)(CONFIG_SYS_TEXT_BASE + addr)); -}#endif /* CONFIG_OF_CONTROL */ +} -void bootdelay_process (void ) +const char *bootdelay_process (void ) { -#ifdef CONFIG_OF_CONTROL -char *env; -#endif char *s;int bootdelay;#ifdef CONFIG_BOOTCOUNT_LIMIT
@@ -318,27 +270,18 @@ void bootdelay_process(void) } else#endif /* CONFIG_BOOTCOUNT_LIMIT */ s =getenv ("bootcmd" ); -#ifdef CONFIG_OF_CONTROL -/* Allow the fdt to override the boot command */ - env =fdtdec_get_config_string (gd->fdt_blob,"bootcmd" ); -if (env) - s = env;process_fdt_options (gd->fdt_blob); + stored_bootdelay = bootdelay; -/* -* If the bootsecure option was chosen, use secure_boot_cmd(). -* Always use 'env' in this case, since bootsecure requres that the -* bootcmd was specified in the FDT too. -*/ -if (fdtdec_get_config_int (gd->fdt_blob,"bootsecure" ,0 )) -secure_boot_cmd (env); - -#endif /* CONFIG_OF_CONTROL */ +return s; +} +void autoboot_command (const char *s) +{debug ("### main_loop: bootcmd=\"%s\"\n" , s ? s :"<UNDEFINED>" ); -if (bootdelay !=-1 && s && !abortboot (bootdelay)) { +if (stored_bootdelay !=-1 && s && !abortboot (stored_bootdelay)) {#if defined(CONFIG_AUTOBOOT_KEYED ) && !defined(CONFIG_AUTOBOOT_KEYED_CTRLC )int prev =disable_ctrlc (1 );/* disable Control C checking */ #endif
common/cli.c +66 -0
80 lines not on this page · raw message
common/main.c +8 -4
@@ -55,8 +55,11 @@ static void run_preboot_environment_command(void)#endif /* CONFIG_PREBOOT */ } +/* We come here after U-Boot is initialised and ready to process commands */ void main_loop (void ) { +const char *s; +bootstage_mark_name (BOOTSTAGE_ID_MAIN_LOOP ,"main_loop" );modem_init ();
@@ -72,10 +75,11 @@ void main_loop(void)update_tftp (0UL );#endif /* CONFIG_UPDATE_TFTP */ -bootdelay_process (); -/* -* Main Loop for Monitor Command Processing -*/ + s =bootdelay_process (); +if (cli_process_fdt (&s)) +cli_secure_boot_cmd (s); + +autoboot_command (s);cli_loop (); }
include/autoboot.h +26 -2
@@ -13,9 +13,33 @@#define __AUTOBOOT_H#ifdef CONFIG_BOOTDELAY -void bootdelay_process (void ); +/** +* bootdelay_process() - process the bootd delay +* +* Process the boot delay, boot limit, then get the value of either +* bootcmd, failbootcmd or altbootcmd depending on the current state. +* Return this command so it can be executed. +* +* @return command to executed +*/ +const char *bootdelay_process (void ); + +/** +* autoboot_command() - run the autoboot command +* +* If enabled, run the autoboot command returned from bootdelay_process(). +* Also do the CONFIG_MENUKEY processing if enabled. +* +* @cmd: Command to run +*/ +void autoboot_command (const char *cmd);#else -static inline void bootdelay_process (void ) +static inline const char *bootdelay_process (void ) +{ +return NULL ; +} + +static inline void autoboot_command (const char *s) { }#endif
include/cli.h +33 -0
@@ -100,6 +100,39 @@ int cli_readline_into_buffer(const char *const prompt, char *buffer,*/ int cli_simple_parse_line (char *line,char *argv[]); +#ifdef CONFIG_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 *
Signature · 1 line
1.9.1.423.g4596e3a
PATCH 14/14 main: Avoid unncessary strdup()/free()
In reply to Simon GlassIt doesn't seem necessary to use memory allocation in this code. The setenv() will make a copy anyway.
---
common/main.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
common/main.c +2 -4
@@ -10,7 +10,6 @@#include <common.h> #include <autoboot.h> #include <cli.h> -#include <malloc.h> #include <version.h> DECLARE_GLOBAL_DATA_PTR ;
@@ -26,10 +25,9 @@ static void modem_init(void)#ifdef CONFIG_MODEM_SUPPORT debug ("DEBUG: main_loop: gd->do_mdm_init=%lu\n" , gd->do_mdm_init);if (gd->do_mdm_init) { -char *str =strdup (getenv ("mdm_cmd" )); +char *str =getenv ("mdm_cmd" ); +setenv ("preboot" , str);/* set or delete definition */ -if (str !=NULL ) -free (str);mdm_init ();/* wait for modem connection */ }#endif /* CONFIG_MODEM_SUPPORT */
Signature · 1 line
1.9.1.423.g4596e3a
cover Split out code from the enormous main.c
In reply to Simon GlassHi,
Quoted 20 lines · Simon Glass
A previous series created a way of using if () instead of #ifdef for controlling feature inclusion in U-Boot. The primary target of that series was
common/main.cwhich is full of #ifdefs. That work was put on hold while the kbuild work was in progress.Since kbuild is now complete, it is time to take another look. However, in the meantime
main.chas not improved. It seems like a good idea to try to split the code out a bit, to make it more obvious what is happening in the U-Boot start-up.This series splits main into two main program and a CLI (Command-line interpreter) parts. There are two CLIs - hush and simple, and each is put in its own file, with a new
cli.cto unify them.New files are also created for autoboot and bootretry functionality.
Overall this series makes it easier to read what is happening in
main.c, and also clarifies the parser code.
Quoted 15 lines
Simon Glass (14):
Remove unnecessary use of hush header file Rename hush tocli_hush
move CLI prototypes tocli.hand add comments Split out simple parser and readline into separate files Addcli_prefix to readline functions
Move autoboot code toautoboot.c
Move command line API intocli.c
Move bootretry code intobootretry.cand clean up Rename bootretry functions and remove #ifdefs
m68k: powerpc: Clean updo_mdm_init
Simplify the main loop
main: Hide the hush/simple details insidecli.c
main: Make the execution path a little clearer inmain.c
main: Avoid unncessary strdup()/free()
Any comments on this series please? Since it touches main it may be painful to rebase. Also I'm holding off on the autoconf stuff until I get some thoughts on this one.
Regards,
Simon
PATCH 1/14 Remove unnecessary use of hush header file
In reply to Simon GlassQuoted 4 lines · Simon Glass
Some files include
hush.hbut don't actually use it. Remove this where possible.Signed-off-by Simon Glass <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140530/7925dc6d/attachment.pgp>
PATCH 2/14 Rename hush to cli_hush
In reply to Simon GlassQuoted 3 lines · Simon Glass
Hush is a command-line interpreter, so rename it to make that clearer.
Signed-off-by Simon Glass <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140530/eec031e8/attachment.pgp>
PATCH 3/14 move CLI prototypes to cli.h and add comments
In reply to Simon GlassQuoted 4 lines · Simon Glass
Move the CLI prototypes from
common.htocli.has part of an effort to reduce the size ofcommon.h.Signed-off-by Simon Glass <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140530/98cda603/attachment.pgp>
PATCH 4/14 Split out simple parser and readline into separate files
In reply to Simon GlassQuoted 4 lines · Simon Glass
It doesn't make sense to have the simple parser and the readline code all in main. Split them out into separate files.
Signed-off-by Simon Glass <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140530/6b902795/attachment.pgp>
PATCH 5/14 Add cli_ prefix to readline functions
In reply to Simon GlassQuoted 3 lines · Simon Glass
This makes it clear where the code resides.
Signed-off-by Simon Glass <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140530/f83264ee/attachment.pgp>
PATCH 6/14 Move autoboot code to autoboot.c
In reply to Simon GlassQuoted 4 lines · Simon Glass
The autoboot code is complex and long. It deserves its own file with a simple interface from
main.c.Signed-off-by Simon Glass <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140530/b43f5402/attachment.pgp>
PATCH 7/14 Move command line API into cli.c
In reply to Simon GlassQuoted 4 lines · Simon Glass
We now have a single entry point to the CLI, whether simple or hush. Put this in its own file.
Signed-off-by Simon Glass <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140530/84515be8/attachment.pgp>
PATCH 8/14 Move bootretry code into bootretry.c and clean up
In reply to Simon GlassQuoted 4 lines · Simon Glass
This code is only used by one board, so it seems a shame to clutter up the readline code with it. Move it into its own file.
Signed-off-by Simon Glass <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140530/453a996d/attachment.pgp>
PATCH 9/14 Rename bootretry functions and remove #ifdefs
In reply to Simon GlassQuoted 4 lines · Simon Glass
Add a
bootretry_prefix to these two functions, and remove the need for the #ifdef around everything (it moves to theMakefile).Signed-off-by Simon Glass <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140530/96b91fbe/attachment.pgp>
PATCH 10/14 m68k: powerpc: Clean up do_mdm_init
In reply to Simon GlassQuoted 5 lines · Simon Glass
This code seems unnecessarily complex. We really just need to check the
global_data. Now that is it all in one place, and not arch-specific, this is pretty easy.Signed-off-by Simon Glass <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140530/e39e3587/attachment.pgp>
PATCH 11/14 Simplify the main loop
In reply to Simon GlassQuoted 4 lines · Simon Glass
The main loop is easier to follow if the code is grouped into separate functions. Make this change, so that
main_loop()is easier to read.Signed-off-by Simon Glass <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140530/9a8a7e2c/attachment.pgp>
PATCH 12/14 main: Hide the hush/simple details inside cli.c
In reply to Simon GlassQuoted 4 lines · Simon Glass
Move these details from main (which doesn't care which parser is used) to
cli.cwhere they belong.Signed-off-by Simon Glass <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140530/c95f4cb1/attachment.pgp>
PATCH 13/14 main: Make the execution path a little clearer in main.c
In reply to Simon GlassQuoted 6 lines · Simon Glass
bootdelay_process()never returns in some circumstances, whichs makes the control flow confusing. Change it so that the decision about how to execute the boot command is made in themain_loop()code, so it is easier to follow. Move CLI stuff tocli.c.Signed-off-by Simon Glass <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140530/ea4b3f05/attachment.pgp>
PATCH 14/14 main: Avoid unncessary strdup()/free()
In reply to Simon GlassQuoted 4 lines · Simon Glass
It doesn't seem necessary to use memory allocation in this code. The
setenv()will make a copy anyway.Signed-off-by Simon Glass <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140530/7d096c43/attachment.pgp>