diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2013-12-06 08:23:24 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2013-12-06 08:23:24 +0100 |
commit | e9ea6eeaabb15258dbeefe06a421fca8c2fe9baa (patch) | |
tree | 075fbf70c17a50190c3fb290eb6b362177f0d1e5 /common | |
parent | 18aa86831ed72380b7c2edba3c27bbf7a999da76 (diff) | |
parent | 1e7f2bd25c28b36c7c40ed4797b2a21cc4e1502e (diff) | |
download | barebox-e9ea6eeaabb15258dbeefe06a421fca8c2fe9baa.tar.gz barebox-e9ea6eeaabb15258dbeefe06a421fca8c2fe9baa.tar.xz |
Merge branch 'for-next/misc'
Conflicts:
scripts/Makefile
Diffstat (limited to 'common')
-rw-r--r-- | common/Kconfig | 20 | ||||
-rw-r--r-- | common/console.c | 1 | ||||
-rw-r--r-- | common/globalvar.c | 1 | ||||
-rw-r--r-- | common/memory_display.c | 1 | ||||
-rw-r--r-- | common/memtest.c | 1 | ||||
-rw-r--r-- | common/misc.c | 1 | ||||
-rw-r--r-- | common/partitions/dos.c | 92 | ||||
-rw-r--r-- | common/startup.c | 1 |
8 files changed, 106 insertions, 12 deletions
diff --git a/common/Kconfig b/common/Kconfig index 06edbc2ba4..99a24a0f8f 100644 --- a/common/Kconfig +++ b/common/Kconfig @@ -285,6 +285,7 @@ config SIMPLE_READLINE config LONGHELP bool + depends on !SHELL_NONE prompt "Enable long help texts" config CBSIZE @@ -292,11 +293,6 @@ config CBSIZE prompt "Buffer size for input from the Console" default 1024 -config MAXARGS - int - prompt "max. Number of arguments accepted for monitor commands" - default 16 - choice prompt "Select your shell" @@ -328,6 +324,12 @@ choice at the end of the barebox startup process. endchoice +config MAXARGS + int + depends on SHELL_SIMPLE + prompt "max. Number of arguments accepted for monitor commands" + default 16 + config GLOB bool prompt "hush globbing support" @@ -364,6 +366,7 @@ config HUSH_GETOPT This enables a getopt function builtin to hush. config CMDLINE_EDITING + depends on !SHELL_NONE bool prompt "Enable command line editing" @@ -617,6 +620,13 @@ config BAREBOXENV_TARGET 'bareboxenv' is a tool to access the barebox environment from a running Linux system. Say yes here to build it for the target. +config BAREBOXCRC32_TARGET + bool + prompt "build bareboxcrc32 tool for target" + help + 'bareboxcrc32' is a userspacetool to generate the crc32 checksums the same way + barebox does. Say yes here to build it for the target. + config POLLER bool "generic polling infrastructure" diff --git a/common/console.c b/common/console.c index 56bc864ad1..329bc72493 100644 --- a/common/console.c +++ b/common/console.c @@ -25,6 +25,7 @@ #include <console.h> #include <driver.h> #include <fs.h> +#include <of.h> #include <init.h> #include <clock.h> #include <kfifo.h> diff --git a/common/globalvar.c b/common/globalvar.c index 41ce06e468..1f9b0cc1ee 100644 --- a/common/globalvar.c +++ b/common/globalvar.c @@ -1,6 +1,7 @@ #include <common.h> #include <malloc.h> #include <globalvar.h> +#include <errno.h> #include <init.h> #include <environment.h> #include <magicvar.h> diff --git a/common/memory_display.c b/common/memory_display.c index 7e4f4da622..c8ae57a594 100644 --- a/common/memory_display.c +++ b/common/memory_display.c @@ -1,4 +1,5 @@ #include <common.h> +#include <errno.h> #define DISP_LINE_LEN 16 diff --git a/common/memtest.c b/common/memtest.c index 22178cfea2..5303c92f62 100644 --- a/common/memtest.c +++ b/common/memtest.c @@ -25,6 +25,7 @@ #include <memory.h> #include <types.h> #include <sizes.h> +#include <errno.h> #include <memtest.h> static const resource_size_t bitpattern[] = { diff --git a/common/misc.c b/common/misc.c index f73f4cfe99..65f3306bee 100644 --- a/common/misc.c +++ b/common/misc.c @@ -22,6 +22,7 @@ #include <magicvar.h> #include <globalvar.h> #include <environment.h> +#include <of.h> int errno; EXPORT_SYMBOL(errno); diff --git a/common/partitions/dos.c b/common/partitions/dos.c index 31b1ed60d1..37addfd2ef 100644 --- a/common/partitions/dos.c +++ b/common/partitions/dos.c @@ -27,19 +27,23 @@ * @param table partition table * @return sector count */ -static int disk_guess_size(struct device_d *dev, struct partition_entry *table) +static uint64_t disk_guess_size(struct device_d *dev, + struct partition_entry *table) { uint64_t size = 0; int i; for (i = 0; i < 4; i++) { - if (table[i].partition_start != 0) { - size += get_unaligned_le32(&table[i].partition_start) - size; - size += get_unaligned_le32(&table[i].partition_size); + if (get_unaligned_le32(&table[i].partition_start) != 0) { + uint64_t part_end = get_unaligned_le32(&table[i].partition_start) + + get_unaligned_le32(&table[i].partition_size); + + if (size < part_end) + size = part_end; } } - return (int)size; + return size; } static void *read_mbr(struct block_device *blk) @@ -105,19 +109,71 @@ static int dos_get_disk_signature(struct param_d *p, void *_priv) if (!buf) return -EIO; - priv->signature = le32_to_cpup((__le32 *)(buf + 0x1b8)); + priv->signature = get_unaligned_le32(buf + 0x1b8); free(buf); return 0; } +static void dos_extended_partition(struct block_device *blk, struct partition_desc *pd, + struct partition *partition) +{ + uint8_t *buf = dma_alloc(SECTOR_SIZE); + uint32_t ebr_sector = partition->first_sec; + struct partition_entry *table = (struct partition_entry *)&buf[0x1be]; + + while (pd->used_entries < ARRAY_SIZE(pd->parts)) { + int rc, i; + int n = pd->used_entries; + + dev_dbg(blk->dev, "expect EBR in sector %x\n", ebr_sector); + + rc = block_read(blk, buf, ebr_sector, 1); + if (rc != 0) { + dev_err(blk->dev, "Cannot read EBR partition table\n"); + goto out; + } + + /* sanity checks */ + if (buf[0x1fe] != 0x55 || buf[0x1ff] != 0xaa) { + dev_err(blk->dev, "sector %x doesn't contain an EBR signature\n", ebr_sector); + goto out; + } + + for (i = 0x1de; i < 0x1fe; ++i) + if (buf[i]) { + dev_err(blk->dev, "EBR's third or fourth partition non-empty\n"); + goto out; + } + /* /sanity checks */ + + /* the first entry defines the extended partition */ + pd->parts[n].first_sec = ebr_sector + + get_unaligned_le32(&table[0].partition_start); + pd->parts[n].size = get_unaligned_le32(&table[0].partition_size); + pd->parts[n].dos_partition_type = table[0].type; + pd->used_entries++; + + /* the second entry defines the start of the next ebr if != 0 */ + if (get_unaligned_le32(&table[1].partition_start)) + ebr_sector = partition->first_sec + + get_unaligned_le32(&table[1].partition_start); + else + break; + } + +out: + dma_free(buf); + return; +} + /** * Check if a DOS like partition describes this block device * @param blk Block device to register to * @param pd Where to store the partition information * - * It seems at least on ARM this routine canot use temp. stack space for the + * It seems at least on ARM this routine cannot use temp. stack space for the * sector. So, keep the malloc/free. */ static void dos_partition(void *buf, struct block_device *blk, @@ -125,6 +181,7 @@ static void dos_partition(void *buf, struct block_device *blk, { struct partition_entry *table; struct partition pentry; + struct partition *extended_partition = NULL; uint8_t *buffer = buf; int i; struct disk_signature_priv *dsp; @@ -146,11 +203,32 @@ static void dos_partition(void *buf, struct block_device *blk, pd->parts[n].size = pentry.size; pd->parts[n].dos_partition_type = pentry.dos_partition_type; pd->used_entries++; + /* + * Partitions of type 0x05 and 0x0f (and some more) + * contain extended partitions. Only check for type 0x0f + * here as this is the easiest to parse and common + * enough. + */ + if (pentry.dos_partition_type == 0x0f) { + if (!extended_partition) + extended_partition = &pd->parts[n]; + else + /* + * An DOS MBR must only contain a single + * extended partition. Just ignore all + * but the first. + */ + dev_warn(blk->dev, "Skipping additional extended partition\n"); + } + } else { dev_dbg(blk->dev, "Skipping empty partition %d\n", i); } } + if (extended_partition) + dos_extended_partition(blk, pd, extended_partition); + dsp = xzalloc(sizeof(*dsp)); dsp->blk = blk; diff --git a/common/startup.c b/common/startup.c index 2e0a4ba3dc..74c7735e31 100644 --- a/common/startup.c +++ b/common/startup.c @@ -35,6 +35,7 @@ #include <malloc.h> #include <debug_ll.h> #include <fs.h> +#include <errno.h> #include <linux/stat.h> #include <envfs.h> #include <asm/sections.h> |