Mercurial > ecos-v3_0-branch
changeset 2066:5d5572c64422
FIS fix from Stefan Sommerfeld, ANSI cursor keys from Gary Thomas
| author | gthomas |
|---|---|
| date | Thu, 08 Sep 2005 12:14:28 +0000 |
| parents | 376c93d0f526 |
| children | 5841ca1d8824 |
| files | packages/redboot/current/ChangeLog packages/redboot/current/cdl/redboot.cdl packages/redboot/current/doc/redboot.sgml packages/redboot/current/include/redboot.h packages/redboot/current/src/flash.c packages/redboot/current/src/io.c |
| diffstat | 6 files changed, 132 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/packages/redboot/current/ChangeLog +++ b/packages/redboot/current/ChangeLog @@ -1,3 +1,15 @@ +2005-09-08 Gary Thomas <gary@mlbassoc.com> + + * src/io.c: + * include/redboot.h: + * doc/redboot.sgml: + * cdl/redboot.cdl: Add support for ANSI keyboard cursor keys + such as HOME/END/Arrows + +2005-09-08 Stefan Sommerfeld <sommerfeld@mikrom.com> + * src/flash.c: Fix usage of "fis create", more arguments are optional + Set mem_base to mem_addr instead of flash_addr for a loaded image + 2005-09-03 Andrew Lunn <andrew.lunn@ascom.ch> * cdl/redboot.cdl: White space changes to aid readability.
--- a/packages/redboot/current/cdl/redboot.cdl +++ b/packages/redboot/current/cdl/redboot.cdl @@ -9,7 +9,7 @@ ## ------------------------------------------- ## This file is part of eCos, the Embedded Configurable Operating System. ## Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc. -## Copyright (C) 2002, 2003, 2004 Gary Thomas +## Copyright (C) 2002, 2003, 2004, 2005 Gary Thomas ## ## eCos is free software; you can redistribute it and/or modify it under ## the terms of the GNU General Public License as published by the Free @@ -153,6 +153,16 @@ cdl_package CYGPKG_REDBOOT { editting of the lines themselves." } + cdl_option CYGSEM_REDBOOT_CMD_LINE_ANSI_SEQUENCES { + display "Enable command line editing using ANSI arrows, etc" + flavor bool + default_value 1 + active_if CYGNUM_REDBOOT_CMD_LINE_EDITING != 0 + description " + If this option is enabled, RedBoot will accept standard ANSI key + sequences for cursor movement (along with the emacs style keys)." + } + cdl_option CYGBLD_REDBOOT_CMD_LINE_HISTORY { display "Enable history command and expansion" requires { CYGNUM_REDBOOT_CMD_LINE_EDITING > 0 } @@ -310,7 +320,7 @@ cdl_package CYGPKG_REDBOOT { make -priority 320 { <PREFIX>/bin/redboot.elf : $(PREFIX)/lib/target.ld $(PREFIX)/lib/vectors.o $(PREFIX)/lib/libtarget.a $(PREFIX)/lib/libextras.a @sh -c "mkdir -p $(dir $@)" - $(CC) -c $(INCLUDE_PATH) $(CFLAGS) -o $(PREFIX)/lib/version.o $(REPOSITORY)/$(PACKAGE)/src/version.c + $(CC) -c $(INCLUDE_PATH) $(ACTUAL_CFLAGS) -o $(PREFIX)/lib/version.o $(REPOSITORY)/$(PACKAGE)/src/version.c $(CC) $(LDFLAGS) -L$(PREFIX)/lib -Ttarget.ld -o $@ $(PREFIX)/lib/version.o }
--- a/packages/redboot/current/doc/redboot.sgml +++ b/packages/redboot/current/doc/redboot.sgml @@ -161,7 +161,7 @@ by typing the letter “A” whi erases the character to the left of the cursor. </para></listitem> <listitem><para> -<guibutton>^A</guibutton> +<guibutton>^A</guibutton> or <guibutton>HOME</guibutton> moves the cursor (insertion point) to the beginning of the line. </para></listitem> <listitem><para> @@ -169,30 +169,30 @@ moves the cursor (insertion point) to th erases all characters on the line from the cursor to the end. </para></listitem> <listitem><para> -<guibutton>^E</guibutton> +<guibutton>^E</guibutton> or <guibutton>END</guibutton> positions the cursor to the end of the line. </para></listitem> <listitem><para> -<guibutton>^D</guibutton> +<guibutton>^D</guibutton> or <guibutton>DELETE</guibutton> erases the character under the cursor. </para></listitem> <listitem><para> -<guibutton>^F</guibutton> +<guibutton>^F</guibutton> or <guibutton>RIGHT-ARROW</guibutton> moves the cursor one character to the right. </para></listitem> <listitem><para> -<guibutton>^B</guibutton> +<guibutton>^B</guibutton> or <guibutton>LEFT-ARROW</guibutton> moves the cursor one character to the left. </para></listitem> <listitem><para> -<guibutton>^P</guibutton> +<guibutton>^P</guibutton> or <guibutton>UP-ARROW</guibutton> replaces the current line by a previous line from the history buffer. A small number of lines can be kept as history. Using ^P (and ^N), the current line can be replaced by any one of the previously typed lines. </para></listitem> <listitem><para> -<guibutton>^N</guibutton> +<guibutton>^N</guibutton> or <guibutton>DOWN-ARROW</guibutton> replaces the current line by the next line from the history buffer. </para></listitem> </itemizedlist></para>
--- a/packages/redboot/current/include/redboot.h +++ b/packages/redboot/current/include/redboot.h @@ -9,7 +9,7 @@ // ------------------------------------------- // This file is part of eCos, the Embedded Configurable Operating System. // Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004 Red Hat, Inc. -// Copyright (C) 2002, 2003, 2004 Gary Thomas +// Copyright (C) 2002, 2003, 2004, 2005 Gary Thomas // // eCos is free software; you can redistribute it and/or modify it under // the terms of the GNU General Public License as published by the Free @@ -135,6 +135,8 @@ externC int strcasecmp(const char *s1, externC int strncasecmp(const char *s1, const char *s2, size_t len); externC void mon_write_char(char c); +externC bool mon_read_char_with_timeout(char *c); +externC void mon_set_read_char_timeout(int ms); externC bool verify_action(char *fmt, ...); externC bool verify_action_with_timeout(int timeout, char *fmt, ...);
--- a/packages/redboot/current/src/flash.c +++ b/packages/redboot/current/src/flash.c @@ -113,7 +113,7 @@ local_cmd_entry("load", ); local_cmd_entry("create", "Create an image", - "-b <mem_base> -l <image_length> [-s <data_length>]\n" + "[-b <mem_base>] [-l <image_length>] [-s <data_length>]\n" " [-f <flash_addr>] [-e <entry_point>] [-r <ram_addr>] [-n] <name>", fis_create, FIS_cmds @@ -940,7 +940,7 @@ fis_create(int argc, char *argv[]) memset(img, 0, sizeof(*img)); strcpy(img->name, name); img->flash_base = flash_addr; - img->mem_base = exec_addr_set ? exec_addr : (flash_addr_set ? flash_addr : mem_addr); + img->mem_base = exec_addr_set ? exec_addr : (mem_addr_set ? mem_addr : flash_addr); img->entry_point = entry_addr_set ? entry_addr : (CYG_ADDRESS)entry_address; // Hope it's been set img->size = length; img->data_length = img_size;
--- a/packages/redboot/current/src/io.c +++ b/packages/redboot/current/src/io.c @@ -9,7 +9,7 @@ // ------------------------------------------- // This file is part of eCos, the Embedded Configurable Operating System. // Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Red Hat, Inc. -// Copyright (C) 2002, 2003 Gary Thomas +// Copyright (C) 2002, 2003, 2005 Gary Thomas // // eCos is free software; you can redistribute it and/or modify it under // the terms of the GNU General Public License as published by the Free @@ -164,7 +164,7 @@ mon_read_char(char *c) static int _mon_timeout; #endif -static bool +bool mon_read_char_with_timeout(char *c) { bool res = false; @@ -216,7 +216,7 @@ mon_read_char_with_timeout(char *c) return res; } -static void +void mon_set_read_char_timeout(int ms) { hal_virtual_comm_table_t *__chan; @@ -339,6 +339,14 @@ static void expand_history(char *); // ^E - Move cursor to end of line // ^B - Move cursor back [previous character] // ^F - Move cursor forward [next character] +// "standard" arrow keys work as well +// left ^[[D == ^B +// right ^[[C == ^F +// up ^[[A == ^P +// down ^[[B == ^N +// home ^[[H/^[1~ == ^A +// end ^[[F/^[OF == ^E +// del ^[3~ == ^D // int _rb_gets_preloaded(char *buf, int buflen, int timeout) @@ -350,8 +358,12 @@ int static char last_ch = '\0'; int _timeout; #if CYGNUM_REDBOOT_CMD_LINE_EDITING != 0 - int _index = _cl_index; // Last saved line + int _index = _cl_index; // Last saved line char *xp; +#ifdef CYGSEM_REDBOOT_CMD_LINE_ANSI_SEQUENCES + int ansi_state = 0; // Used to drive ANSI parser + char ansi_char = '\0'; +#endif #endif // Display current buffer data @@ -387,8 +399,87 @@ int mon_read_char(&c); } *eol = '\0'; +#define CTRL(c) ((c)&0x1F) +#ifdef CYGSEM_REDBOOT_CMD_LINE_ANSI_SEQUENCES + // Special handling of ANSI keyboard sequences (arrows, etc) + if (c == 0x1B) { + // Leadin for ANSI keyboard sequence + ansi_state = 1; + continue; + } + switch (ansi_state) { + case 0: + // No ANSI sequence in progress + break; + case 1: + // ESC seen, look for '[' + if (c == '[') { + ansi_state = 2; + } else if (c == 'O') { + ansi_state = 4; + } else { + // Handle bad sequences? + ansi_state = 0; + } + continue; + case 2: + // ESC+[ seen, process key + ansi_state = 0; + switch (c) { + case 'A': + c = CTRL('P'); + break; + case 'B': + c = CTRL('N'); + break; + case 'C': + c = CTRL('F'); + break; + case 'D': + c = CTRL('B'); + break; + case 'F': + c = CTRL('E'); + break; + case 'H': + c = CTRL('A'); + break; + case '1': + ansi_char = CTRL('A'); + ansi_state = 3; + continue; + case '3': + ansi_char = CTRL('D'); + ansi_state = 3; + continue; + default: + // Handle bad sequences? + continue; + } + break; + case 3: + // Sequences like ^[[1~ == ^H + ansi_state = 0; + if (c == '~') { + c = ansi_char; + } else { + // Handle bad sequences? + continue; + } + break; + case 4: + // Sequences like ^[OF == ^E + ansi_state = 0; + if (c == 'F') { + c = CTRL('E'); + } else { + // Handle bad sequences? + continue; + } + break; + } +#endif switch (c) { -#define CTRL(c) ((c)&0x1F) #if CYGNUM_REDBOOT_CMD_LINE_EDITING != 0 case CTRL('P'): // Fetch the previous line into the buffer
