diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2010-04-06 08:44:32 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2010-04-06 08:44:32 +0200 |
commit | eed255609dc6b657599c09b2b02aadc20ea54882 (patch) | |
tree | 628095d169f1875a4a551ca9100913db1e408d3f /commands | |
parent | 9c3df274acbd5b08502833516fb327c98c359937 (diff) | |
parent | f5ad08466d4958f3db3f9fc47a36f003051802b6 (diff) | |
download | barebox-eed255609dc6b657599c09b2b02aadc20ea54882.tar.gz barebox-eed255609dc6b657599c09b2b02aadc20ea54882.tar.xz |
Merge branch 'next'
Diffstat (limited to 'commands')
-rw-r--r-- | commands/Kconfig | 14 | ||||
-rw-r--r-- | commands/Makefile | 1 | ||||
-rw-r--r-- | commands/echo.c | 19 | ||||
-rw-r--r-- | commands/go.c | 19 | ||||
-rw-r--r-- | commands/unlzo.c | 69 |
5 files changed, 113 insertions, 9 deletions
diff --git a/commands/Kconfig b/commands/Kconfig index bb264fc173..0c09f91643 100644 --- a/commands/Kconfig +++ b/commands/Kconfig @@ -118,6 +118,12 @@ config CMD_ECHO default y prompt "echo" +config CMD_ECHO_E + bool + depends on CMD_ECHO + select PROCESS_ESCAPE_SEQUENCE + prompt "support -e option to echo" + endmenu menu "memory " @@ -300,4 +306,12 @@ config CMD_GPIO include gpio_set_value, gpio_get_value, gpio_direction_input and gpio_direction_output commands to control gpios. +config CMD_UNLZO + bool + select LZO_DECOMPRESS + prompt "unlzo" + help + Say yes here to get the unlzo command. lzo is a fast compression + algorithm by Markus Franz Xaver Johannes Oberhumer. + endmenu diff --git a/commands/Makefile b/commands/Makefile index b32fa05d30..74b099414f 100644 --- a/commands/Makefile +++ b/commands/Makefile @@ -47,3 +47,4 @@ obj-$(CONFIG_CMD_INSMOD) += insmod.o obj-$(CONFIG_CMD_BMP) += bmp.o obj-$(CONFIG_USB_GADGET_DFU) += dfu.o obj-$(CONFIG_CMD_GPIO) += gpio.o +obj-$(CONFIG_CMD_UNLZO) += unlzo.o diff --git a/commands/echo.c b/commands/echo.c index d5640a0f02..dfa14d67b9 100644 --- a/commands/echo.c +++ b/commands/echo.c @@ -25,6 +25,7 @@ #include <fs.h> #include <fcntl.h> #include <errno.h> +#include <libbb.h> static int do_echo(struct command *cmdtp, int argc, char *argv[]) { @@ -32,7 +33,10 @@ static int do_echo(struct command *cmdtp, int argc, char *argv[]) int fd = stdout, opt, newline = 1; char *file = NULL; int oflags = O_WRONLY | O_CREAT; - +#ifdef CONFIG_CMD_ECHO_E + char str[CONFIG_CBSIZE]; + int process_escape = 0; +#endif /* We can't use getopt() here because we want to * echo all things we don't understand. */ @@ -62,6 +66,11 @@ static int do_echo(struct command *cmdtp, int argc, char *argv[]) goto no_optarg_out; optind++; break; +#ifdef CONFIG_CMD_ECHO_E + case 'e': + process_escape = 1; + break; +#endif default: goto exit_parse; } @@ -80,7 +89,13 @@ exit_parse: for (i = optind; i < argc; i++) { if (i > optind) fputc(fd, ' '); - fputs(fd, argv[i]); +#ifdef CONFIG_CMD_ECHO_E + if (process_escape) { + process_escape_sequence(argv[i], str, CONFIG_CBSIZE); + fputs(fd, str); + } else +#endif + fputs(fd, argv[i]); } if (newline) diff --git a/commands/go.c b/commands/go.c index 588d6fcd68..02629402ad 100644 --- a/commands/go.c +++ b/commands/go.c @@ -35,6 +35,7 @@ static int do_go(struct command *cmdtp, int argc, char *argv[]) void *addr; int rcode = 1; int fd = -1; + int (*func)(int argc, char *argv[]); if (argc < 2) return COMMAND_ERROR_USAGE; @@ -54,17 +55,21 @@ static int do_go(struct command *cmdtp, int argc, char *argv[]) } else addr = (void *)simple_strtoul(argv[1], NULL, 16); - printf ("## Starting application at 0x%08lX ...\n", addr); + printf("## Starting application at 0x%08lX ...\n", addr); console_flush(); -#ifdef ARCH_HAS_EXECUTE - rcode = arch_execute(addr, argc, &argv[1]); -#else - rcode = ((ulong (*)(int, char *[]))addr) (--argc, &argv[1]); -#endif + func = addr; - printf ("## Application terminated, rcode = 0x%lX\n", rcode); + shutdown_barebox(); + func(argc - 1, &argv[1]); + + /* + * The application returned. Since we have shutdown barebox and + * we know nothing about the state of the cpu/memory we can't + * do anything here. + */ + while (1); out: if (fd > 0) close(fd); diff --git a/commands/unlzo.c b/commands/unlzo.c new file mode 100644 index 0000000000..0b6dd4b961 --- /dev/null +++ b/commands/unlzo.c @@ -0,0 +1,69 @@ +/* + * unlzo.c - uncompress a lzo compressed file + * + * Copyright (c) 2010 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix + * + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include <common.h> +#include <command.h> +#include <errno.h> +#include <fcntl.h> +#include <fs.h> +#include <lzo.h> + +static int do_unlzo(struct command *cmdtp, int argc, char *argv[]) +{ + int from, to, ret, retlen; + + if (argc != 3) + return COMMAND_ERROR_USAGE; + + from = open(argv[1], O_RDONLY); + if (from < 0) { + perror("open"); + return 1; + } + + to = open(argv[2], O_WRONLY | O_CREAT); + if (to < 0) { + perror("open"); + ret = 1; + goto exit_close; + } + + ret = unlzo(from, to, &retlen); + if (ret) + printf("failed to decompress\n"); + + close(to); +exit_close: + close(from); + return ret; +} + +static const __maybe_unused char cmd_unlzo_help[] = +"Usage: unlzo <infile> <outfile>\n" +"Uncompress a lzo compressed file\n"; + +BAREBOX_CMD_START(unlzo) + .cmd = do_unlzo, + .usage = "lzop <infile> <outfile>", + BAREBOX_CMD_HELP(cmd_unlzo_help) +BAREBOX_CMD_END + |