summaryrefslogtreecommitdiffstats
path: root/commands
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2011-12-07 12:03:13 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2011-12-07 12:03:13 +0100
commit0ee6847f7b6d396d3756f6ecd0781a00b9cca980 (patch)
tree1f1bed639ac0bbc9091685538c791b4648f4c342 /commands
parent61b62f6d33d55c9b89ba8a6fbae84cb9c33e342a (diff)
parent8b3d10265da20b8be6138799cee704d53dee1c63 (diff)
downloadbarebox-0ee6847f7b6d396d3756f6ecd0781a00b9cca980.tar.gz
barebox-0ee6847f7b6d396d3756f6ecd0781a00b9cca980.tar.xz
Merge branch 'next'
Diffstat (limited to 'commands')
-rw-r--r--commands/Kconfig55
-rw-r--r--commands/Makefile6
-rw-r--r--commands/bootm.c340
-rw-r--r--commands/cp.c26
-rw-r--r--commands/iminfo.c71
-rw-r--r--commands/iomem.c56
-rw-r--r--commands/magicvar.c20
-rw-r--r--commands/uncompress.c (renamed from commands/unlzo.c)23
8 files changed, 287 insertions, 310 deletions
diff --git a/commands/Kconfig b/commands/Kconfig
index 18ab840916..ebc9c7f2d0 100644
--- a/commands/Kconfig
+++ b/commands/Kconfig
@@ -107,6 +107,12 @@ config CMD_TIME
checking for ctrl-c, so the time command can be used with commands
which are interruptible with ctrl-c.
+config CMD_LINUX_EXEC
+ bool "linux exec"
+ depends on LINUX
+ help
+ This command executes a command on the Linux host.
+
endmenu
menu "file commands "
@@ -215,6 +221,13 @@ config CMD_MEMINFO
tristate
prompt "meminfo"
+config CMD_IOMEM
+ tristate
+ prompt "iomem"
+ help
+ Show information about iomem usage. Pendant to 'cat /proc/iomem'
+ under Linux.
+
config CMD_MEMORY
bool
default y
@@ -292,23 +305,17 @@ config CMD_BOOTM
select CRC32
prompt "bootm"
-config CMD_BOOTM_ZLIB
- bool
- depends on CMD_BOOTM
- select ZLIB
- prompt "bootm with zlib support"
-
-config CMD_BOOTM_BZLIB
- bool
- depends on CMD_BOOTM
- select BZLIB
- prompt "bootm with bzlib support"
-
config CMD_BOOTM_SHOW_TYPE
bool
depends on CMD_BOOTM
prompt "show image information"
+config CMD_IMINFO
+ bool
+ prompt "iminfo"
+ help
+ Show information about uImages
+
config CMD_BOOTZ
tristate
default y
@@ -383,6 +390,20 @@ config CMD_HELP
default y
prompt "help"
+config CMD_MAGICVAR
+ tristate
+ prompt "magicvar"
+ help
+ barebox has some shell variables with special meanings. This
+ command shows the available magic variables.
+
+config CMD_MAGICVAR_HELP
+ bool
+ prompt "display description"
+ depends on CMD_MAGICVAR
+ help
+ Also display a description to the magic variables
+
config CMD_DEVINFO
tristate
default y
@@ -414,13 +435,13 @@ config CMD_GPIO
include gpio_set_value, gpio_get_value, gpio_direction_input and
gpio_direction_output commands to control gpios.
-config CMD_UNLZO
+config CMD_UNCOMPRESS
bool
- select LZO_DECOMPRESS
- prompt "unlzo"
+ prompt "uncompress"
help
- Say yes here to get the unlzo command. lzo is a fast compression
- algorithm by Markus Franz Xaver Johannes Oberhumer.
+ Say yes here to get the uncompress command. uncompress handles
+ lzo, gzip and bzip2 compressed files depending on the compiled
+ in compression libraries
config CMD_I2C
bool
diff --git a/commands/Makefile b/commands/Makefile
index 5c519169c3..aa013de107 100644
--- a/commands/Makefile
+++ b/commands/Makefile
@@ -1,4 +1,5 @@
obj-$(CONFIG_CMD_BOOTM) += bootm.o
+obj-$(CONFIG_CMD_IMINFO) += iminfo.o
obj-$(CONFIG_CMD_LINUX16) += linux16.o
obj-$(CONFIG_CMD_LOADB) += loadb.o xyzModem.o
obj-$(CONFIG_CMD_LOADY) += loadb.o xyzModem.o
@@ -47,7 +48,7 @@ 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
+obj-$(CONFIG_CMD_UNCOMPRESS) += uncompress.o
obj-$(CONFIG_CMD_I2C) += i2c.o
obj-$(CONFIG_CMD_UBI) += ubi.o
obj-$(CONFIG_CMD_MENU) += menu.o
@@ -58,3 +59,6 @@ obj-$(CONFIG_CMD_LED_TRIGGER) += trigger.o
obj-$(CONFIG_CMD_USB) += usb.o
obj-$(CONFIG_CMD_TIME) += time.o
obj-$(CONFIG_CMD_OFTREE) += oftree.o
+obj-$(CONFIG_CMD_MAGICVAR) += magicvar.o
+obj-$(CONFIG_CMD_IOMEM) += iomem.o
+obj-$(CONFIG_CMD_LINUX_EXEC) += linux_exec.o
diff --git a/commands/bootm.c b/commands/bootm.c
index f11138afba..859ec28a26 100644
--- a/commands/bootm.c
+++ b/commands/bootm.c
@@ -30,8 +30,6 @@
#include <command.h>
#include <image.h>
#include <malloc.h>
-#include <zlib.h>
-#include <bzlib.h>
#include <environment.h>
#include <asm/byteorder.h>
#include <xfuncs.h>
@@ -42,59 +40,10 @@
#include <boot.h>
#include <rtc.h>
#include <init.h>
+#include <magicvar.h>
+#include <uncompress.h>
#include <asm-generic/memory_layout.h>
-/*
- * Continue booting an OS image; caller already has:
- * - copied image header to global variable `header'
- * - checked header magic number, checksums (both header & image),
- * - verified image architecture (PPC) and type (KERNEL or MULTI),
- * - loaded (first part of) image to header load address,
- * - disabled interrupts.
- */
-typedef void boot_os_Fcn(struct command *cmdtp, int flag,
- int argc, char *argv[],
- ulong addr, /* of image to boot */
- ulong *len_ptr, /* multi-file image length table */
- int verify); /* getenv("verify")[0] != 'n' */
-
-#ifndef CFG_BOOTM_LEN
-#define CFG_BOOTM_LEN 0x800000 /* use 8MByte as default max gunzip size */
-#endif
-
-#ifdef CONFIG_SILENT_CONSOLE
-static void
-fixup_silent_linux ()
-{
- char buf[256], *start, *end;
- char *cmdline = getenv ("bootargs");
-
- /* Only fix cmdline when requested */
- if (!(gd->flags & GD_FLG_SILENT))
- return;
-
- debug ("before silent fix-up: %s\n", cmdline);
- if (cmdline) {
- if ((start = strstr (cmdline, "console=")) != NULL) {
- end = strchr (start, ' ');
- strncpy (buf, cmdline, (start - cmdline + 8));
- if (end)
- strcpy (buf + (start - cmdline + 8), end);
- else
- buf[start - cmdline + 8] = '\0';
- } else {
- strcpy (buf, cmdline);
- strcat (buf, " console=");
- }
- } else {
- strcpy (buf, "console=");
- }
-
- setenv ("bootargs", buf);
- debug ("after silent fix-up: %s\n", buf);
-}
-#endif /* CONFIG_SILENT_CONSOLE */
-
struct image_handle_data* image_handle_data_get_by_num(struct image_handle* handle, int num)
{
if (!handle || num < 0 || num >= handle->nb_data_entries)
@@ -108,50 +57,27 @@ int relocate_image(struct image_handle *handle, void *load_address)
image_header_t *hdr = &handle->header;
unsigned long len = image_get_size(hdr);
struct image_handle_data *iha;
- unsigned long data;
-
-#if defined CONFIG_CMD_BOOTM_ZLIB || defined CONFIG_CMD_BOOTM_BZLIB
- uint unc_len = CFG_BOOTM_LEN;
-#endif
+ void *data;
+ int ret;
iha = image_handle_data_get_by_num(handle, 0);
- data = (unsigned long)(iha->data);
+ data = iha->data;
switch (image_get_comp(hdr)) {
case IH_COMP_NONE:
- if(image_get_load(hdr) == data) {
+ if (load_address == data) {
printf (" XIP ... ");
} else {
- memmove ((void *) image_get_load(hdr), (uchar *)data, len);
+ memmove(load_address, data, len);
}
break;
-#ifdef CONFIG_CMD_BOOTM_ZLIB
- case IH_COMP_GZIP:
- printf (" Uncompressing ... ");
- if (gunzip (load_address, unc_len,
- (uchar *)data, &len) != 0)
- return -1;
- break;
-#endif
-#ifdef CONFIG_CMD_BOOTM_BZLIB
- case IH_COMP_BZIP2:
+ default:
printf (" Uncompressing ... ");
- /*
- * If we've got less than 4 MB of malloc() space,
- * use slower decompression algorithm which requires
- * at most 2300 KB of memory.
- */
- if (BZ2_bzBuffToBuffDecompress (load_address,
- &unc_len, (char *)data, len,
- MALLOC_SIZE < (4096 * 1024), 0)
- != BZ_OK)
- return -1;
+ ret = uncompress(data, len, NULL, NULL, load_address, NULL,
+ uncompress_err_stdout);
+ if (ret)
+ return ret;
break;
-#endif
- default:
- printf("Unimplemented compression type %d\n",
- image_get_comp(hdr));
- return -1;
}
return 0;
@@ -168,7 +94,7 @@ int register_image_handler(struct image_handler *handler)
/*
* generate a image_handle from a multi_image
- * this image_handle can be free by unmap_image
+ * this image_handle can be freed by unmap_image
*/
static struct image_handle *get_fake_image_handle(struct image_data *data, int num)
{
@@ -188,118 +114,53 @@ static struct image_handle *get_fake_image_handle(struct image_data *data, int n
return handle;
}
-static int initrd_handler_parse_options(struct image_data *data, int opt,
- char *optarg)
-{
- uint32_t initrd_start;
-
- switch(opt) {
- case 'L':
- if (!data->initrd) {
- eprintf("Warning -L ingnored. Specify the initrd first\n");
- break;
- }
- initrd_start = simple_strtoul(optarg, NULL, 0);
- printf("initrd_start=0x%x\n", initrd_start);
- data->initrd->header.ih_load = cpu_to_uimage(initrd_start);
- break;
- case 'r':
- printf("use initrd %s\n", optarg);
- /* check for multi image @<num> */
- if (optarg[0] == '@') {
- int num = simple_strtol(optarg + 1, NULL, 0);
-
- data->initrd = get_fake_image_handle(data, num);
- } else {
- data->initrd = map_image(optarg, data->verify);
- }
- if (!data->initrd)
- return -1;
- break;
- default:
- return 1;
- }
-
- return 0;
-}
-
-static struct image_handler initrd_handler = {
- .cmdline_options = "r:L:",
- .cmdline_parse = initrd_handler_parse_options,
- .help_string = " -r <initrd> specify an initrd image\n"
- " -L <load addr> specify initrd load address",
-};
-
-static int initrd_register_image_handler(void)
-{
- return register_image_handler(&initrd_handler);
-}
-
-late_initcall(initrd_register_image_handler);
-
-static int handler_parse_options(struct image_data *data, int opt, char *optarg)
-{
- struct image_handler *handler;
- int ret;
-
- list_for_each_entry(handler, &handler_list, list) {
- if (!handler->cmdline_parse)
- continue;
-
- ret = handler->cmdline_parse(data, opt, optarg);
- if (ret > 0)
- continue;
-
- return ret;
- }
-
- return -1;
-}
-
static int do_bootm(struct command *cmdtp, int argc, char *argv[])
{
int opt;
image_header_t *os_header;
- struct image_handle *os_handle, *initrd_handle = NULL;
+ struct image_handle *os_handle = NULL;
struct image_handler *handler;
struct image_data data;
- char options[53]; /* worst case: whole alphabet with colons */
+ int ret = 1;
memset(&data, 0, sizeof(struct image_data));
data.verify = 1;
+ data.initrd_address = ~0;
- /* Collect options from registered handlers */
- strcpy(options, "nh");
- list_for_each_entry(handler, &handler_list, list) {
- if (handler->cmdline_options)
- strcat(options, handler->cmdline_options);
- }
-
- while((opt = getopt(argc, argv, options)) > 0) {
+ while ((opt = getopt(argc, argv, "nr:L:")) > 0) {
switch(opt) {
case 'n':
data.verify = 0;
break;
- case 'h':
- printf("bootm advanced options:\n");
-
- list_for_each_entry(handler, &handler_list, list) {
- if (handler->help_string)
- printf("%s\n", handler->help_string);
+ case 'L':
+ data.initrd_address = simple_strtoul(optarg, NULL, 0);
+ break;
+ case 'r':
+ printf("use initrd %s\n", optarg);
+ /* check for multi image @<num> */
+ if (optarg[0] == '@') {
+ int num = simple_strtol(optarg + 1, NULL, 0);
+
+ data.initrd = get_fake_image_handle(&data, num);
+ } else {
+ data.initrd = map_image(optarg, data.verify);
}
-
- return 0;
+ if (!data.initrd)
+ goto err_out;
+ break;
default:
break;
}
}
- if (optind == argc)
- return COMMAND_ERROR_USAGE;
+ if (optind == argc) {
+ ret = COMMAND_ERROR_USAGE;
+ goto err_out;
+ }
os_handle = map_image(argv[optind], data.verify);
if (!os_handle)
- return 1;
+ goto err_out;
data.os = os_handle;
os_header = &os_handle->header;
@@ -310,31 +171,35 @@ static int do_bootm(struct command *cmdtp, int argc, char *argv[])
goto err_out;
}
- optind = 0;
-
- while((opt = getopt(argc, argv, options)) > 0) {
- switch(opt) {
- case 'h':
- case 'n':
- break;
- default:
- if (!handler_parse_options(&data, opt, optarg))
- continue;
-
- return 1;
- }
- }
-
/*
* We have reached the point of no return: we are going to
* overwrite all exception vector code, so we cannot easily
* recover from any failures any more...
*/
- disable_interrupts();
-
puts ("OK\n");
+ /*
+ * FIXME: we do not check at all whether
+ * - we will write the image to sdram
+ * - we overwrite ourselves
+ * - kernel and initrd overlap
+ */
+ ret = relocate_image(data.os, (void *)image_get_load(os_header));
+ if (ret)
+ goto err_out;
+
+ if (data.initrd) {
+ if (data.initrd && data.initrd_address == ~0)
+ data.initrd_address = uimage_to_cpu(data.initrd->header.ih_load);
+
+ data.initrd_size = image_get_data_size(&data.initrd->header);
+
+ ret = relocate_image(data.initrd, (void *)data.initrd_address);
+ if (ret)
+ goto err_out;
+ }
+
/* loop through the registered handlers */
list_for_each_entry(handler, &handler_list, list) {
if (image_get_os(os_header) == handler->image_type) {
@@ -350,15 +215,17 @@ static int do_bootm(struct command *cmdtp, int argc, char *argv[])
err_out:
if (os_handle)
unmap_image(os_handle);
- if (initrd_handle)
- unmap_image(initrd_handle);
- return 1;
+ if (data.initrd)
+ unmap_image(data.initrd);
+ return ret;
}
BAREBOX_CMD_HELP_START(bootm)
-BAREBOX_CMD_HELP_USAGE("bootm [-n] image\n")
+BAREBOX_CMD_HELP_USAGE("bootm [OPTIONS] image\n")
BAREBOX_CMD_HELP_SHORT("Boot an application image.\n")
BAREBOX_CMD_HELP_OPT ("-n", "Do not verify the image (speeds up boot process)\n")
+BAREBOX_CMD_HELP_OPT ("-r <initrd>","specify an initrd image\n")
+BAREBOX_CMD_HELP_OPT ("-L <load addr>","specify initrd load address")
BAREBOX_CMD_HELP_END
BAREBOX_CMD_START(bootm)
@@ -367,84 +234,7 @@ BAREBOX_CMD_START(bootm)
BAREBOX_CMD_HELP(cmd_bootm_help)
BAREBOX_CMD_END
-/**
- * @page bootm_command
-
-\todo What does bootm do, what kind of image does it boot?
-
- */
-
-#ifdef CONFIG_CMD_IMI
-static int do_iminfo(struct command *cmdtp, int argc, char *argv[])
-{
- int arg;
- ulong addr;
- int rcode=0;
-
- if (argc < 2) {
- return image_info (load_addr);
- }
-
- for (arg=1; arg <argc; ++arg) {
- addr = simple_strtoul(argv[arg], NULL, 16);
- if (image_info (addr) != 0) rcode = 1;
- }
- return rcode;
-}
-
-static int image_info (ulong addr)
-{
- ulong data, len, checksum;
- image_header_t *hdr = &header;
-
- printf ("\n## Checking Image at %08lx ...\n", addr);
-
- /* Copy header so we can blank CRC field for re-calculation */
- memmove (&header, (char *)addr, image_get_header_size());
-
- if (image_get_magic(hdr) != IH_MAGIC) {
- puts (" Bad Magic Number\n");
- return 1;
- }
-
- data = (ulong)&header;
- len = image_get_header_size();
-
- checksum = image_get_hcrc(hdr);
- hdr->ih_hcrc = 0;
-
- if (crc32 (0, (uchar *)data, len) != checksum) {
- puts (" Bad Header Checksum\n");
- return 1;
- }
-
- /* for multi-file images we need the data part, too */
- print_image_hdr ((image_header_t *)addr);
-
- data = addr + image_get_header_size();
- len = image_get_size(hdr);
-
- puts (" Verifying Checksum ... ");
- if (crc32 (0, (uchar *)data, len) != image_get_dcrc(hdr)) {
- puts (" Bad Data CRC\n");
- return 1;
- }
- puts ("OK\n");
- return 0;
-}
-
-BAREBOX_CMD_HELP_START(iminfo)
-BAREBOX_CMD_HELP_USAGE("iminfo\n")
-BAREBOX_CMD_HELP_SHORT("Print header information for an application image.\n")
-BAREBOX_CMD_HELP_END
-
-BAREBOX_CMD_START(iminfo)
- .cmd = do_iminfo,
- .usage = "print header information for an application image",
- BAREBOX_CMD_HELP(cmd_iminfo_help)
-BAREBOX_CMD_END
-
-#endif /* CONFIG_CMD_IMI */
+BAREBOX_MAGICVAR(bootargs, "Linux Kernel parameters");
#ifdef CONFIG_BZLIB
void bz_internal_error(int errcode)
diff --git a/commands/cp.c b/commands/cp.c
index 342810528b..f78e3de013 100644
--- a/commands/cp.c
+++ b/commands/cp.c
@@ -32,6 +32,7 @@
#include <fs.h>
#include <malloc.h>
#include <libgen.h>
+#include <getopt.h>
/**
* @param[in] cmdtp FIXME
@@ -44,8 +45,21 @@ static int do_cp(struct command *cmdtp, int argc, char *argv[])
struct stat statbuf;
int last_is_dir = 0;
int i;
+ int opt;
+ int verbose = 0;
+ int argc_min;
- if (argc < 3)
+ while ((opt = getopt(argc, argv, "v")) > 0) {
+ switch (opt) {
+ case 'v':
+ verbose = 1;
+ break;
+ }
+ }
+
+ argc_min = optind + 2;
+
+ if (argc < argc_min)
return COMMAND_ERROR_USAGE;
if (!stat(argv[argc - 1], &statbuf)) {
@@ -53,21 +67,21 @@ static int do_cp(struct command *cmdtp, int argc, char *argv[])
last_is_dir = 1;
}
- if (argc > 3 && !last_is_dir) {
+ if (argc > argc_min && !last_is_dir) {
printf("cp: target `%s' is not a directory\n", argv[argc - 1]);
return 1;
}
- for (i = 1; i < argc - 1; i++) {
+ for (i = optind; i < argc - 1; i++) {
if (last_is_dir) {
char *dst;
dst = concat_path_file(argv[argc - 1], basename(argv[i]));
- ret = copy_file(argv[i], dst);
+ ret = copy_file(argv[i], dst, verbose);
if (ret)
goto out;
free(dst);
} else {
- ret = copy_file(argv[i], argv[argc - 1]);
+ ret = copy_file(argv[i], argv[argc - 1], verbose);
if (ret)
goto out;
}
@@ -79,7 +93,7 @@ out:
}
BAREBOX_CMD_HELP_START(cp)
-BAREBOX_CMD_HELP_USAGE("cp <source> <destination>\n")
+BAREBOX_CMD_HELP_USAGE("cp [-v] <source> <destination>\n")
BAREBOX_CMD_HELP_SHORT("copy file from <source> to <destination>.\n")
BAREBOX_CMD_HELP_END
diff --git a/commands/iminfo.c b/commands/iminfo.c
new file mode 100644
index 0000000000..2fde9bc09c
--- /dev/null
+++ b/commands/iminfo.c
@@ -0,0 +1,71 @@
+#include <common.h>
+#include <command.h>
+#include <image.h>
+#include <fs.h>
+#include <malloc.h>
+#include <fcntl.h>
+#include <errno.h>
+
+static int image_info(image_header_t *hdr)
+{
+ u32 len, checksum;
+
+ if (image_get_magic(hdr) != IH_MAGIC) {
+ puts (" Bad Magic Number\n");
+ return 1;
+ }
+
+ len = image_get_header_size();
+
+ checksum = image_get_hcrc(hdr);
+ hdr->ih_hcrc = 0;
+
+ if (crc32 (0, hdr, len) != checksum) {
+ puts (" Bad Header Checksum\n");
+ return 1;
+ }
+
+ image_print_contents(hdr, NULL);
+
+ return 0;
+}
+
+static int do_iminfo(struct command *cmdtp, int argc, char *argv[])
+{
+ int rcode = 1;
+ int fd;
+ int ret;
+ image_header_t hdr;
+
+ if (argc != 2)
+ return COMMAND_ERROR_USAGE;
+
+ fd = open(argv[1], O_RDONLY);
+ if (fd < 0) {
+ perror("open");
+ return 1;
+ }
+
+ ret = read(fd, &hdr, sizeof(image_header_t));
+ if (ret != sizeof(image_header_t))
+ goto err_out;
+
+ printf("Image at %s:\n", argv[1]);
+ image_info(&hdr);
+
+err_out:
+ close(fd);
+
+ return rcode;
+}
+
+BAREBOX_CMD_HELP_START(iminfo)
+BAREBOX_CMD_HELP_USAGE("iminfo\n")
+BAREBOX_CMD_HELP_SHORT("Print header information for an application image.\n")
+BAREBOX_CMD_HELP_END
+
+BAREBOX_CMD_START(iminfo)
+ .cmd = do_iminfo,
+ .usage = "print header information for an application image",
+ BAREBOX_CMD_HELP(cmd_iminfo_help)
+BAREBOX_CMD_END
diff --git a/commands/iomem.c b/commands/iomem.c
new file mode 100644
index 0000000000..78566c1f5b
--- /dev/null
+++ b/commands/iomem.c
@@ -0,0 +1,56 @@
+/*
+ * iomem.c - barebox iomem command
+ *
+ * Copyright (c) 2011 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.
+ */
+#include <common.h>
+#include <command.h>
+
+static void __print_resources(struct resource *res, int indent)
+{
+ struct resource *r;
+ int i;
+
+ for (i = 0; i < indent; i++)
+ printf(" ");
+
+ printf("0x%08x - 0x%08x (size 0x%08x) %s\n", res->start,
+ res->start + res->size - 1,
+ res->size, res->name);
+
+ list_for_each_entry(r, &res->children, sibling)
+ __print_resources(r, indent + 1);
+}
+
+static void print_resources(struct resource *res)
+{
+ __print_resources(res, 0);
+}
+
+static int do_iomem(struct command *cmdtp, int argc, char *argv[])
+{
+ print_resources(&iomem_resource);
+
+ return 0;
+}
+
+BAREBOX_CMD_START(iomem)
+ .cmd = do_iomem,
+ .usage = "show iomem usage",
+BAREBOX_CMD_END
diff --git a/commands/magicvar.c b/commands/magicvar.c
new file mode 100644
index 0000000000..31606d2afa
--- /dev/null
+++ b/commands/magicvar.c
@@ -0,0 +1,20 @@
+#include <common.h>
+#include <command.h>
+#include <magicvar.h>
+
+static int do_magicvar(struct command *cmdtp, int argc, char *argv[])
+{
+ struct magicvar *m;
+
+ for (m = &__barebox_magicvar_start;
+ m != &__barebox_magicvar_end;
+ m++)
+ printf("%-32s %s\n", m->name, m->description);
+
+ return 0;
+}
+
+BAREBOX_CMD_START(magicvar)
+ .cmd = do_magicvar,
+ .usage = "List information about magic variables",
+BAREBOX_CMD_END
diff --git a/commands/unlzo.c b/commands/uncompress.c
index 0b6dd4b961..fff62275bb 100644
--- a/commands/unlzo.c
+++ b/commands/uncompress.c
@@ -1,5 +1,5 @@
/*
- * unlzo.c - uncompress a lzo compressed file
+ * uncompress.c - uncompress a lzo compressed file
*
* Copyright (c) 2010 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix
*
@@ -25,11 +25,11 @@
#include <errno.h>
#include <fcntl.h>
#include <fs.h>
-#include <lzo.h>
+#include <uncompress.h>
-static int do_unlzo(struct command *cmdtp, int argc, char *argv[])
+static int do_uncompress(struct command *cmdtp, int argc, char *argv[])
{
- int from, to, ret, retlen;
+ int from, to, ret;
if (argc != 3)
return COMMAND_ERROR_USAGE;
@@ -47,7 +47,8 @@ static int do_unlzo(struct command *cmdtp, int argc, char *argv[])
goto exit_close;
}
- ret = unlzo(from, to, &retlen);
+ ret = uncompress_fd_to_fd(from, to, uncompress_err_stdout);
+
if (ret)
printf("failed to decompress\n");
@@ -57,13 +58,13 @@ exit_close:
return ret;
}
-static const __maybe_unused char cmd_unlzo_help[] =
-"Usage: unlzo <infile> <outfile>\n"
-"Uncompress a lzo compressed file\n";
+static const __maybe_unused char cmd_uncompress_help[] =
+"Usage: uncompress <infile> <outfile>\n"
+"Uncompress a compressed file\n";
-BAREBOX_CMD_START(unlzo)
- .cmd = do_unlzo,
+BAREBOX_CMD_START(uncompress)
+ .cmd = do_uncompress,
.usage = "lzop <infile> <outfile>",
- BAREBOX_CMD_HELP(cmd_unlzo_help)
+ BAREBOX_CMD_HELP(cmd_uncompress_help)
BAREBOX_CMD_END