diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2012-09-05 12:59:58 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2012-09-05 12:59:58 +0200 |
commit | f63576730bc30d75f42298dbfc021406f294f358 (patch) | |
tree | 2a4ff19c5cdabd3e05f66a902c0051de8a02ad4d /arch | |
parent | 6662e16dbbe426933a09d0564943b43fa10b9457 (diff) | |
parent | 3e63938ecd2f48520a28e2fed937e87528ad6373 (diff) | |
download | barebox-f63576730bc30d75f42298dbfc021406f294f358.tar.gz barebox-f63576730bc30d75f42298dbfc021406f294f358.tar.xz |
Merge branch 'for-next/sandbox'
Diffstat (limited to 'arch')
-rw-r--r-- | arch/sandbox/board/board.c | 2 | ||||
-rw-r--r-- | arch/sandbox/include/asm/io.h | 7 | ||||
-rw-r--r-- | arch/sandbox/os/common.c | 87 |
3 files changed, 64 insertions, 32 deletions
diff --git a/arch/sandbox/board/board.c b/arch/sandbox/board/board.c index d2f0667c98..6bccd2cb6d 100644 --- a/arch/sandbox/board/board.c +++ b/arch/sandbox/board/board.c @@ -29,7 +29,7 @@ static struct device_d tap_device = { .id = DEVICE_ID_DYNAMIC, - .name = "tap", + .name = "tap", }; static int devices_init(void) diff --git a/arch/sandbox/include/asm/io.h b/arch/sandbox/include/asm/io.h index da84fa5f6b..8ca164f214 100644 --- a/arch/sandbox/include/asm/io.h +++ b/arch/sandbox/include/asm/io.h @@ -1 +1,6 @@ -/* nothing */ +#ifndef __ASM_SANDBOX_IO_H +#define __ASM_SANDBOX_IO_H + +#include <asm-generic/io.h> + +#endif /* __ASM_SANDBOX_IO_H */ diff --git a/arch/sandbox/os/common.c b/arch/sandbox/os/common.c index 92b7dbb2c7..e296574c93 100644 --- a/arch/sandbox/os/common.c +++ b/arch/sandbox/os/common.c @@ -271,33 +271,29 @@ err_out: static void print_usage(const char*); +static struct option long_options[] = { + {"help", 0, 0, 'h'}, + {"malloc", 1, 0, 'm'}, + {"image", 1, 0, 'i'}, + {"env", 1, 0, 'e'}, + {"stdout", 1, 0, 'O'}, + {"stdin", 1, 0, 'I'}, + {0, 0, 0, 0}, +}; + +static const char optstring[] = "hm:i:e:O:I:"; + int main(int argc, char *argv[]) { void *ram; int opt, ret, fd; int malloc_size = 8 * 1024 * 1024; char str[6]; - int fdno = 0, envno = 0; - - ram = malloc(malloc_size); - if (!ram) { - printf("unable to get malloc space\n"); - exit(1); - } - mem_malloc_init(ram, ram + malloc_size - 1); + int fdno = 0, envno = 0, option_index = 0; while (1) { - int option_index = 0; - static struct option long_options[] = { - {"help", 0, 0, 'h'}, - {"image", 1, 0, 'i'}, - {"env", 1, 0, 'e'}, - {"stdout", 1, 0, 'O'}, - {"stdin", 1, 0, 'I'}, - {0, 0, 0, 0}, - }; - - opt = getopt_long(argc, argv, "hi:e:O:I:", + option_index = 0; + opt = getopt_long(argc, argv, optstring, long_options, &option_index); if (opt == -1) @@ -307,18 +303,7 @@ int main(int argc, char *argv[]) case 'h': print_usage(basename(argv[0])); exit(0); - case 'i': - sprintf(str, "fd%d", fdno); - ret = add_image(optarg, str); - if (ret) - exit(1); - fdno++; - break; case 'm': - /* This option is broken. add_image needs malloc, so - * mem_alloc_init() has to be called before option - * parsing - */ malloc_size = strtoul(optarg, NULL, 0); break; case 'e': @@ -351,6 +336,47 @@ int main(int argc, char *argv[]) } } + ram = malloc(malloc_size); + if (!ram) { + printf("unable to get malloc space\n"); + exit(1); + } + mem_malloc_init(ram, ram + malloc_size - 1); + + /* reset getopt */ + optind = 1; + + while (1) { + option_index = 0; + opt = getopt_long(argc, argv, optstring, + long_options, &option_index); + + if (opt == -1) + break; + + switch (opt) { + case 'h': + break; + case 'm': + break; + case 'i': + sprintf(str, "fd%d", fdno); + ret = add_image(optarg, str); + if (ret) + exit(1); + fdno++; + break; + case 'e': + break; + case 'O': + break; + case 'I': + break; + default: + exit(1); + } + } + barebox_register_console("console", fileno(stdin), fileno(stdout)); rawmode(); @@ -371,6 +397,7 @@ static void print_usage(const char *prgname) "Usage: %s [OPTIONS]\n" "Start barebox.\n\n" "Options:\n\n" +" -m, " " -i, --image=<file> Map an image file to barebox. This option can be given\n" " multiple times. The files will show up as\n" " /dev/fd0 ... /dev/fdx under barebox.\n" |