summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/cmd_bmp.c6
-rw-r--r--common/cmd_dtt.c2
-rw-r--r--common/cmd_irq.c2
-rw-r--r--common/cmd_itest.c2
-rw-r--r--common/cmd_led.c2
-rw-r--r--common/cmd_mtdparts.c54
-rw-r--r--common/cmd_nvedit.c2
-rw-r--r--common/cmd_pxe.c84
-rw-r--r--common/cmd_sandbox.c4
-rw-r--r--common/cmd_setexpr.c2
-rw-r--r--common/cmd_tsi148.c2
-rw-r--r--common/cmd_ubi.c79
-rw-r--r--common/cmd_universe.c2
-rw-r--r--common/env_common.c2
-rw-r--r--common/env_dataflash.c50
-rw-r--r--common/env_eeprom.c2
-rw-r--r--common/env_embedded.c2
-rw-r--r--common/env_fat.c2
-rw-r--r--common/env_flash.c2
-rw-r--r--common/env_mmc.c11
-rw-r--r--common/env_nand.c2
-rw-r--r--common/env_nowhere.c2
-rw-r--r--common/env_nvram.c2
-rw-r--r--common/env_remote.c2
-rw-r--r--common/env_ubi.c2
-rw-r--r--common/iomux.c2
-rw-r--r--common/lcd.c2
-rw-r--r--common/main.c2
28 files changed, 176 insertions, 154 deletions
diff --git a/common/cmd_bmp.c b/common/cmd_bmp.c
index c093fefd4c3..cc904c25356 100644
--- a/common/cmd_bmp.c
+++ b/common/cmd_bmp.c
@@ -121,9 +121,9 @@ static int do_bmp_display(cmd_tbl_t * cmdtp, int flag, int argc, char * const ar
break;
case 4:
addr = simple_strtoul(argv[1], NULL, 16);
- x = simple_strtoul(argv[2], NULL, 10);
- y = simple_strtoul(argv[3], NULL, 10);
- break;
+ x = simple_strtoul(argv[2], NULL, 10);
+ y = simple_strtoul(argv[3], NULL, 10);
+ break;
default:
return CMD_RET_USAGE;
}
diff --git a/common/cmd_dtt.c b/common/cmd_dtt.c
index 7257f10fb17..f2e750f2f16 100644
--- a/common/cmd_dtt.c
+++ b/common/cmd_dtt.c
@@ -2,7 +2,7 @@
* (C) Copyright 2001
* Erik Theisen, Wave 7 Optics, etheisen@mindspring.com
*
- * SPDX-License-Identifier: GPL-2.0+
+ * SPDX-License-Identifier: GPL-2.0+
*/
#include <common.h>
diff --git a/common/cmd_irq.c b/common/cmd_irq.c
index a91d0bf1fcd..02da450f673 100644
--- a/common/cmd_irq.c
+++ b/common/cmd_irq.c
@@ -1,7 +1,7 @@
/*
* Copyright 2008 Freescale Semiconductor, Inc.
*
- * SPDX-License-Identifier: GPL-2.0+
+ * SPDX-License-Identifier: GPL-2.0+
*/
#include <common.h>
diff --git a/common/cmd_itest.c b/common/cmd_itest.c
index 10d53a063be..29f8076f825 100644
--- a/common/cmd_itest.c
+++ b/common/cmd_itest.c
@@ -2,7 +2,7 @@
* (C) Copyright 2003
* Tait Electronics Limited, Christchurch, New Zealand
*
- * SPDX-License-Identifier: GPL-2.0+
+ * SPDX-License-Identifier: GPL-2.0+
*/
/*
diff --git a/common/cmd_led.c b/common/cmd_led.c
index c48603cada5..172bc30bd6f 100644
--- a/common/cmd_led.c
+++ b/common/cmd_led.c
@@ -7,7 +7,7 @@
* (C) Copyright 2008
* Ulf Samuelsson <ulf.samuelsson@atmel.com>
*
- * SPDX-License-Identifier: GPL-2.0+
+ * SPDX-License-Identifier: GPL-2.0+
*/
#include <common.h>
diff --git a/common/cmd_mtdparts.c b/common/cmd_mtdparts.c
index f791372de15..40b6333ebf4 100644
--- a/common/cmd_mtdparts.c
+++ b/common/cmd_mtdparts.c
@@ -93,13 +93,13 @@
DECLARE_GLOBAL_DATA_PTR;
/* special size referring to all the remaining space in a partition */
-#define SIZE_REMAINING 0xFFFFFFFF
+#define SIZE_REMAINING (~0llu)
/* special offset value, it is used when not provided by user
*
* this value is used temporarily during parsing, later such offests
* are recalculated */
-#define OFFSET_NOT_SPECIFIED 0xFFFFFFFF
+#define OFFSET_NOT_SPECIFIED (~0llu)
/* minimum partition size */
#define MIN_PART_SIZE 4096
@@ -160,9 +160,9 @@ static int device_del(struct mtd_device *dev);
* @param retptr output pointer to next char after parse completes (output)
* @return resulting unsigned int
*/
-static unsigned long memsize_parse (const char *const ptr, const char **retptr)
+static u64 memsize_parse (const char *const ptr, const char **retptr)
{
- unsigned long ret = simple_strtoul(ptr, (char **)retptr, 0);
+ u64 ret = simple_strtoull(ptr, (char **)retptr, 0);
switch (**retptr) {
case 'G':
@@ -193,20 +193,20 @@ static unsigned long memsize_parse (const char *const ptr, const char **retptr)
* @param buf output buffer
* @param size size to be converted to string
*/
-static void memsize_format(char *buf, u32 size)
+static void memsize_format(char *buf, u64 size)
{
#define SIZE_GB ((u32)1024*1024*1024)
#define SIZE_MB ((u32)1024*1024)
#define SIZE_KB ((u32)1024)
if ((size % SIZE_GB) == 0)
- sprintf(buf, "%ug", size/SIZE_GB);
+ sprintf(buf, "%llug", size/SIZE_GB);
else if ((size % SIZE_MB) == 0)
- sprintf(buf, "%um", size/SIZE_MB);
+ sprintf(buf, "%llum", size/SIZE_MB);
else if (size % SIZE_KB == 0)
- sprintf(buf, "%uk", size/SIZE_KB);
+ sprintf(buf, "%lluk", size/SIZE_KB);
else
- sprintf(buf, "%u", size);
+ sprintf(buf, "%llu", size);
}
/**
@@ -310,6 +310,7 @@ static int part_validate_eraseblock(struct mtdids *id, struct part_info *part)
struct mtd_info *mtd = NULL;
int i, j;
ulong start;
+ u64 offset, size;
if (get_mtd_info(id->type, id->num, &mtd))
return 1;
@@ -321,14 +322,16 @@ static int part_validate_eraseblock(struct mtdids *id, struct part_info *part)
* Only one eraseregion (NAND, OneNAND or uniform NOR),
* checking for alignment is easy here
*/
- if ((unsigned long)part->offset % mtd->erasesize) {
+ offset = part->offset;
+ if (do_div(offset, mtd->erasesize)) {
printf("%s%d: partition (%s) start offset"
"alignment incorrect\n",
MTD_DEV_TYPE(id->type), id->num, part->name);
return 1;
}
- if (part->size % mtd->erasesize) {
+ size = part->size;
+ if (do_div(size, mtd->erasesize)) {
printf("%s%d: partition (%s) size alignment incorrect\n",
MTD_DEV_TYPE(id->type), id->num, part->name);
return 1;
@@ -395,7 +398,7 @@ static int part_validate(struct mtdids *id, struct part_info *part)
part->size = id->size - part->offset;
if (part->offset > id->size) {
- printf("%s: offset %08x beyond flash size %08x\n",
+ printf("%s: offset %08llx beyond flash size %08llx\n",
id->mtd_id, part->offset, id->size);
return 1;
}
@@ -578,8 +581,8 @@ static int part_add(struct mtd_device *dev, struct part_info *part)
static int part_parse(const char *const partdef, const char **ret, struct part_info **retpart)
{
struct part_info *part;
- unsigned long size;
- unsigned long offset;
+ u64 size;
+ u64 offset;
const char *name;
int name_len;
unsigned int mask_flags;
@@ -598,7 +601,7 @@ static int part_parse(const char *const partdef, const char **ret, struct part_i
} else {
size = memsize_parse(p, &p);
if (size < MIN_PART_SIZE) {
- printf("partition size too small (%lx)\n", size);
+ printf("partition size too small (%llx)\n", size);
return 1;
}
}
@@ -670,14 +673,14 @@ static int part_parse(const char *const partdef, const char **ret, struct part_i
part->auto_name = 0;
} else {
/* auto generated name in form of size@offset */
- sprintf(part->name, "0x%08lx@0x%08lx", size, offset);
+ sprintf(part->name, "0x%08llx@0x%08llx", size, offset);
part->auto_name = 1;
}
part->name[name_len - 1] = '\0';
INIT_LIST_HEAD(&part->link);
- debug("+ partition: name %-22s size 0x%08x offset 0x%08x mask flags %d\n",
+ debug("+ partition: name %-22s size 0x%08llx offset 0x%08llx mask flags %d\n",
part->name, part->size,
part->offset, part->mask_flags);
@@ -693,7 +696,7 @@ static int part_parse(const char *const partdef, const char **ret, struct part_i
* @param size a pointer to the size of the mtd device (output)
* @return 0 if device is valid, 1 otherwise
*/
-static int mtd_device_validate(u8 type, u8 num, u32 *size)
+static int mtd_device_validate(u8 type, u8 num, u64 *size)
{
struct mtd_info *mtd = NULL;
@@ -826,7 +829,7 @@ static int device_parse(const char *const mtd_dev, const char **ret, struct mtd_
LIST_HEAD(tmp_list);
struct list_head *entry, *n;
u16 num_parts;
- u32 offset;
+ u64 offset;
int err = 1;
debug("===device_parse===\n");
@@ -1071,7 +1074,8 @@ static int generate_mtdparts(char *buf, u32 buflen)
struct part_info *part, *prev_part;
char *p = buf;
char tmpbuf[32];
- u32 size, offset, len, part_cnt;
+ u64 size, offset;
+ u32 len, part_cnt;
u32 maxlen = buflen - 1;
debug("--- generate_mtdparts ---\n");
@@ -1270,7 +1274,7 @@ static void print_partition_table(void)
list_for_each(pentry, &dev->parts) {
part = list_entry(pentry, struct part_info, link);
- printf("%2d: %-20s0x%08x\t0x%08x\t%d\n",
+ printf("%2d: %-20s0x%08llx\t0x%08llx\t%d\n",
part_num, part->name, part->size,
part->offset, part->mask_flags);
#endif /* defined(CONFIG_CMD_MTDPARTS_SHOW_NET_SIZES) */
@@ -1297,7 +1301,7 @@ static void list_partitions(void)
if (current_mtd_dev) {
part = mtd_part_info(current_mtd_dev, current_mtd_partnum);
if (part) {
- printf("\nactive partition: %s%d,%d - (%s) 0x%08x @ 0x%08x\n",
+ printf("\nactive partition: %s%d,%d - (%s) 0x%08llx @ 0x%08llx\n",
MTD_DEV_TYPE(current_mtd_dev->id->type),
current_mtd_dev->id->num, current_mtd_partnum,
part->name, part->size, part->offset);
@@ -1397,7 +1401,7 @@ static int delete_partition(const char *id)
if (find_dev_and_part(id, &dev, &pnum, &part) == 0) {
- debug("delete_partition: device = %s%d, partition %d = (%s) 0x%08x@0x%08x\n",
+ debug("delete_partition: device = %s%d, partition %d = (%s) 0x%08llx@0x%08llx\n",
MTD_DEV_TYPE(dev->id->type), dev->id->num, pnum,
part->name, part->size, part->offset);
@@ -1589,7 +1593,7 @@ static int parse_mtdids(const char *const ids)
struct list_head *entry, *n;
struct mtdids *id_tmp;
u8 type, num;
- u32 size;
+ u64 size;
int ret = 1;
debug("\n---parse_mtdids---\nmtdids = %s\n\n", ids);
@@ -1663,7 +1667,7 @@ static int parse_mtdids(const char *const ids)
id->mtd_id[mtd_id_len - 1] = '\0';
INIT_LIST_HEAD(&id->link);
- debug("+ id %s%d\t%16d bytes\t%s\n",
+ debug("+ id %s%d\t%16lld bytes\t%s\n",
MTD_DEV_TYPE(id->type), id->num,
id->size, id->mtd_id);
diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c
index 778dca5af9f..ba9ba16972c 100644
--- a/common/cmd_nvedit.c
+++ b/common/cmd_nvedit.c
@@ -7,7 +7,7 @@
*
* Copyright 2011 Freescale Semiconductor, Inc.
*
- * SPDX-License-Identifier: GPL-2.0+
+ * SPDX-License-Identifier: GPL-2.0+
*/
/*
diff --git a/common/cmd_pxe.c b/common/cmd_pxe.c
index c5f4a221b8c..79d3a061f53 100644
--- a/common/cmd_pxe.c
+++ b/common/cmd_pxe.c
@@ -114,16 +114,16 @@ static int get_bootfile_path(const char *file_path, char *bootfile_path,
return 1;
}
-static int (*do_getfile)(const char *file_path, char *file_addr);
+static int (*do_getfile)(cmd_tbl_t *cmdtp, const char *file_path, char *file_addr);
-static int do_get_tftp(const char *file_path, char *file_addr)
+static int do_get_tftp(cmd_tbl_t *cmdtp, const char *file_path, char *file_addr)
{
char *tftp_argv[] = {"tftp", NULL, NULL, NULL};
tftp_argv[1] = file_addr;
tftp_argv[2] = (void *)file_path;
- if (do_tftpb(NULL, 0, 3, tftp_argv))
+ if (do_tftpb(cmdtp, 0, 3, tftp_argv))
return -ENOENT;
return 1;
@@ -131,27 +131,27 @@ static int do_get_tftp(const char *file_path, char *file_addr)
static char *fs_argv[5];
-static int do_get_ext2(const char *file_path, char *file_addr)
+static int do_get_ext2(cmd_tbl_t *cmdtp, const char *file_path, char *file_addr)
{
#ifdef CONFIG_CMD_EXT2
fs_argv[0] = "ext2load";
fs_argv[3] = file_addr;
fs_argv[4] = (void *)file_path;
- if (!do_ext2load(NULL, 0, 5, fs_argv))
+ if (!do_ext2load(cmdtp, 0, 5, fs_argv))
return 1;
#endif
return -ENOENT;
}
-static int do_get_fat(const char *file_path, char *file_addr)
+static int do_get_fat(cmd_tbl_t *cmdtp, const char *file_path, char *file_addr)
{
#ifdef CONFIG_CMD_FAT
fs_argv[0] = "fatload";
fs_argv[3] = file_addr;
fs_argv[4] = (void *)file_path;
- if (!do_fat_fsload(NULL, 0, 5, fs_argv))
+ if (!do_fat_fsload(cmdtp, 0, 5, fs_argv))
return 1;
#endif
return -ENOENT;
@@ -165,7 +165,7 @@ static int do_get_fat(const char *file_path, char *file_addr)
*
* Returns 1 for success, or < 0 on error.
*/
-static int get_relfile(const char *file_path, void *file_addr)
+static int get_relfile(cmd_tbl_t *cmdtp, const char *file_path, void *file_addr)
{
size_t path_len;
char relfile[MAX_TFTP_PATH_LEN+1];
@@ -194,7 +194,7 @@ static int get_relfile(const char *file_path, void *file_addr)
sprintf(addr_buf, "%p", file_addr);
- return do_getfile(relfile, addr_buf);
+ return do_getfile(cmdtp, relfile, addr_buf);
}
/*
@@ -204,13 +204,13 @@ static int get_relfile(const char *file_path, void *file_addr)
*
* Returns 1 on success, or < 0 for error.
*/
-static int get_pxe_file(const char *file_path, void *file_addr)
+static int get_pxe_file(cmd_tbl_t *cmdtp, const char *file_path, void *file_addr)
{
unsigned long config_file_size;
char *tftp_filesize;
int err;
- err = get_relfile(file_path, file_addr);
+ err = get_relfile(cmdtp, file_path, file_addr);
if (err < 0)
return err;
@@ -241,7 +241,7 @@ static int get_pxe_file(const char *file_path, void *file_addr)
*
* Returns 1 on success or < 0 on error.
*/
-static int get_pxelinux_path(const char *file, void *pxefile_addr_r)
+static int get_pxelinux_path(cmd_tbl_t *cmdtp, const char *file, void *pxefile_addr_r)
{
size_t base_len = strlen(PXELINUX_DIR);
char path[MAX_TFTP_PATH_LEN+1];
@@ -254,7 +254,7 @@ static int get_pxelinux_path(const char *file, void *pxefile_addr_r)
sprintf(path, PXELINUX_DIR "%s", file);
- return get_pxe_file(path, pxefile_addr_r);
+ return get_pxe_file(cmdtp, path, pxefile_addr_r);
}
/*
@@ -262,7 +262,7 @@ static int get_pxelinux_path(const char *file, void *pxefile_addr_r)
*
* Returns 1 on success or < 0 on error.
*/
-static int pxe_uuid_path(void *pxefile_addr_r)
+static int pxe_uuid_path(cmd_tbl_t *cmdtp, void *pxefile_addr_r)
{
char *uuid_str;
@@ -271,7 +271,7 @@ static int pxe_uuid_path(void *pxefile_addr_r)
if (!uuid_str)
return -ENOENT;
- return get_pxelinux_path(uuid_str, pxefile_addr_r);
+ return get_pxelinux_path(cmdtp, uuid_str, pxefile_addr_r);
}
/*
@@ -280,7 +280,7 @@ static int pxe_uuid_path(void *pxefile_addr_r)
*
* Returns 1 on success or < 0 on error.
*/
-static int pxe_mac_path(void *pxefile_addr_r)
+static int pxe_mac_path(cmd_tbl_t *cmdtp, void *pxefile_addr_r)
{
char mac_str[21];
int err;
@@ -290,7 +290,7 @@ static int pxe_mac_path(void *pxefile_addr_r)
if (err < 0)
return err;
- return get_pxelinux_path(mac_str, pxefile_addr_r);
+ return get_pxelinux_path(cmdtp, mac_str, pxefile_addr_r);
}
/*
@@ -300,7 +300,7 @@ static int pxe_mac_path(void *pxefile_addr_r)
*
* Returns 1 on success or < 0 on error.
*/
-static int pxe_ipaddr_paths(void *pxefile_addr_r)
+static int pxe_ipaddr_paths(cmd_tbl_t *cmdtp, void *pxefile_addr_r)
{
char ip_addr[9];
int mask_pos, err;
@@ -308,7 +308,7 @@ static int pxe_ipaddr_paths(void *pxefile_addr_r)
sprintf(ip_addr, "%08X", ntohl(NetOurIP));
for (mask_pos = 7; mask_pos >= 0; mask_pos--) {
- err = get_pxelinux_path(ip_addr, pxefile_addr_r);
+ err = get_pxelinux_path(cmdtp, ip_addr, pxefile_addr_r);
if (err > 0)
return err;
@@ -359,16 +359,16 @@ do_pxe_get(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
* Keep trying paths until we successfully get a file we're looking
* for.
*/
- if (pxe_uuid_path((void *)pxefile_addr_r) > 0 ||
- pxe_mac_path((void *)pxefile_addr_r) > 0 ||
- pxe_ipaddr_paths((void *)pxefile_addr_r) > 0) {
+ if (pxe_uuid_path(cmdtp, (void *)pxefile_addr_r) > 0 ||
+ pxe_mac_path(cmdtp, (void *)pxefile_addr_r) > 0 ||
+ pxe_ipaddr_paths(cmdtp, (void *)pxefile_addr_r) > 0) {
printf("Config file found\n");
return 0;
}
while (pxe_default_paths[i]) {
- if (get_pxelinux_path(pxe_default_paths[i],
+ if (get_pxelinux_path(cmdtp, pxe_default_paths[i],
(void *)pxefile_addr_r) > 0) {
printf("Config file found\n");
return 0;
@@ -388,7 +388,7 @@ do_pxe_get(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
*
* Returns 1 on success or < 0 on error.
*/
-static int get_relfile_envaddr(const char *file_path, const char *envaddr_name)
+static int get_relfile_envaddr(cmd_tbl_t *cmdtp, const char *file_path, const char *envaddr_name)
{
unsigned long file_addr;
char *envaddr;
@@ -401,7 +401,7 @@ static int get_relfile_envaddr(const char *file_path, const char *envaddr_name)
if (strict_strtoul(envaddr, 16, &file_addr) < 0)
return -EINVAL;
- return get_relfile(file_path, (void *)file_addr);
+ return get_relfile(cmdtp, file_path, (void *)file_addr);
}
/*
@@ -599,7 +599,7 @@ static int label_boot(cmd_tbl_t *cmdtp, struct pxe_label *label)
}
if (label->initrd) {
- if (get_relfile_envaddr(label->initrd, "ramdisk_addr_r") < 0) {
+ if (get_relfile_envaddr(cmdtp, label->initrd, "ramdisk_addr_r") < 0) {
printf("Skipping %s for failure retrieving initrd\n",
label->name);
return 1;
@@ -613,7 +613,7 @@ static int label_boot(cmd_tbl_t *cmdtp, struct pxe_label *label)
bootm_argv[2] = "-";
}
- if (get_relfile_envaddr(label->kernel, "kernel_addr_r") < 0) {
+ if (get_relfile_envaddr(cmdtp, label->kernel, "kernel_addr_r") < 0) {
printf("Skipping %s for failure retrieving kernel\n",
label->name);
return 1;
@@ -673,7 +673,7 @@ static int label_boot(cmd_tbl_t *cmdtp, struct pxe_label *label)
/* if fdt label is defined then get fdt from server */
if (bootm_argv[3] && label->fdt) {
- if (get_relfile_envaddr(label->fdt, "fdt_addr_r") < 0) {
+ if (get_relfile_envaddr(cmdtp, label->fdt, "fdt_addr_r") < 0) {
printf("Skipping %s for failure retrieving fdt\n",
label->name);
return 1;
@@ -950,7 +950,7 @@ static int parse_integer(char **c, int *dst)
return 1;
}
-static int parse_pxefile_top(char *p, struct pxe_menu *cfg, int nest_level);
+static int parse_pxefile_top(cmd_tbl_t *cmdtp, char *p, struct pxe_menu *cfg, int nest_level);
/*
* Parse an include statement, and retrieve and parse the file it mentions.
@@ -960,7 +960,7 @@ static int parse_pxefile_top(char *p, struct pxe_menu *cfg, int nest_level);
* include, nest_level has already been incremented and doesn't need to be
* incremented here.
*/
-static int handle_include(char **c, char *base,
+static int handle_include(cmd_tbl_t *cmdtp, char **c, char *base,
struct pxe_menu *cfg, int nest_level)
{
char *include_path;
@@ -975,14 +975,14 @@ static int handle_include(char **c, char *base,
return err;
}
- err = get_pxe_file(include_path, base);
+ err = get_pxe_file(cmdtp, include_path, base);
if (err < 0) {
printf("Couldn't retrieve %s\n", include_path);
return err;
}
- return parse_pxefile_top(base, cfg, nest_level);
+ return parse_pxefile_top(cmdtp, base, cfg, nest_level);
}
/*
@@ -995,7 +995,7 @@ static int handle_include(char **c, char *base,
* nest_level should be 1 when parsing the top level pxe file, 2 when parsing
* a file it includes, 3 when parsing a file included by that file, and so on.
*/
-static int parse_menu(char **c, struct pxe_menu *cfg, char *b, int nest_level)
+static int parse_menu(cmd_tbl_t *cmdtp, char **c, struct pxe_menu *cfg, char *b, int nest_level)
{
struct token t;
char *s = *c;
@@ -1010,7 +1010,7 @@ static int parse_menu(char **c, struct pxe_menu *cfg, char *b, int nest_level)
break;
case T_INCLUDE:
- err = handle_include(c, b + strlen(b) + 1, cfg,
+ err = handle_include(cmdtp, c, b + strlen(b) + 1, cfg,
nest_level + 1);
break;
@@ -1172,7 +1172,7 @@ static int parse_label(char **c, struct pxe_menu *cfg)
*
* Returns 1 on success, < 0 on error.
*/
-static int parse_pxefile_top(char *p, struct pxe_menu *cfg, int nest_level)
+static int parse_pxefile_top(cmd_tbl_t *cmdtp, char *p, struct pxe_menu *cfg, int nest_level)
{
struct token t;
char *s, *b, *label_name;
@@ -1194,7 +1194,7 @@ static int parse_pxefile_top(char *p, struct pxe_menu *cfg, int nest_level)
switch (t.type) {
case T_MENU:
cfg->prompt = 1;
- err = parse_menu(&p, cfg, b, nest_level);
+ err = parse_menu(cmdtp, &p, cfg, b, nest_level);
break;
case T_TIMEOUT:
@@ -1219,7 +1219,7 @@ static int parse_pxefile_top(char *p, struct pxe_menu *cfg, int nest_level)
break;
case T_INCLUDE:
- err = handle_include(&p, b + ALIGN(strlen(b), 4), cfg,
+ err = handle_include(cmdtp, &p, b + ALIGN(strlen(b), 4), cfg,
nest_level + 1);
break;
@@ -1276,7 +1276,7 @@ static void destroy_pxe_menu(struct pxe_menu *cfg)
* files it includes). The resulting pxe_menu struct can be free()'d by using
* the destroy_pxe_menu() function.
*/
-static struct pxe_menu *parse_pxefile(char *menucfg)
+static struct pxe_menu *parse_pxefile(cmd_tbl_t *cmdtp, char *menucfg)
{
struct pxe_menu *cfg;
@@ -1289,7 +1289,7 @@ static struct pxe_menu *parse_pxefile(char *menucfg)
INIT_LIST_HEAD(&cfg->labels);
- if (parse_pxefile_top(menucfg, cfg, 1) < 0) {
+ if (parse_pxefile_top(cmdtp, menucfg, cfg, 1) < 0) {
destroy_pxe_menu(cfg);
return NULL;
}
@@ -1446,7 +1446,7 @@ do_pxe_boot(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
return 1;
}
- cfg = parse_pxefile((char *)(pxefile_addr_r));
+ cfg = parse_pxefile(cmdtp, (char *)(pxefile_addr_r));
if (cfg == NULL) {
printf("Error parsing config file\n");
@@ -1544,12 +1544,12 @@ int do_sysboot(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
return 1;
}
- if (get_pxe_file(filename, (void *)pxefile_addr_r) < 0) {
+ if (get_pxe_file(cmdtp, filename, (void *)pxefile_addr_r) < 0) {
printf("Error reading config file\n");
return 1;
}
- cfg = parse_pxefile((char *)(pxefile_addr_r));
+ cfg = parse_pxefile(cmdtp, (char *)(pxefile_addr_r));
if (cfg == NULL) {
printf("Error parsing config file\n");
diff --git a/common/cmd_sandbox.c b/common/cmd_sandbox.c
index 75eb23adf2f..8d59364b636 100644
--- a/common/cmd_sandbox.c
+++ b/common/cmd_sandbox.c
@@ -10,7 +10,7 @@
static int do_sandbox_load(cmd_tbl_t *cmdtp, int flag, int argc,
char * const argv[])
{
- return do_load(cmdtp, flag, argc, argv, FS_TYPE_SANDBOX, 16);
+ return do_load(cmdtp, flag, argc, argv, FS_TYPE_SANDBOX);
}
static int do_sandbox_ls(cmd_tbl_t *cmdtp, int flag, int argc,
@@ -22,7 +22,7 @@ static int do_sandbox_ls(cmd_tbl_t *cmdtp, int flag, int argc,
static int do_sandbox_save(cmd_tbl_t *cmdtp, int flag, int argc,
char * const argv[])
{
- return do_save(cmdtp, flag, argc, argv, FS_TYPE_SANDBOX, 16);
+ return do_save(cmdtp, flag, argc, argv, FS_TYPE_SANDBOX);
}
static cmd_tbl_t cmd_sandbox_sub[] = {
diff --git a/common/cmd_setexpr.c b/common/cmd_setexpr.c
index 1fc080b9b57..926339b9f17 100644
--- a/common/cmd_setexpr.c
+++ b/common/cmd_setexpr.c
@@ -2,7 +2,7 @@
* Copyright 2008 Freescale Semiconductor, Inc.
* Copyright 2013 Wolfgang Denk <wd@denx.de>
*
- * SPDX-License-Identifier: GPL-2.0+
+ * SPDX-License-Identifier: GPL-2.0+
*/
/*
diff --git a/common/cmd_tsi148.c b/common/cmd_tsi148.c
index 317ba50fd19..dc488b2b3e5 100644
--- a/common/cmd_tsi148.c
+++ b/common/cmd_tsi148.c
@@ -5,7 +5,7 @@
*
* (C) Copyright 2003 Stefan Roese, stefan.roese@esd-electronics.com
*
- * SPDX-License-Identifier: GPL-2.0+
+ * SPDX-License-Identifier: GPL-2.0+
*/
#include <common.h>
diff --git a/common/cmd_ubi.c b/common/cmd_ubi.c
index 5ba4feb485b..122ba7e171c 100644
--- a/common/cmd_ubi.c
+++ b/common/cmd_ubi.c
@@ -167,7 +167,7 @@ bad:
return err;
}
-static int ubi_create_vol(char *volume, int size, int dynamic)
+static int ubi_create_vol(char *volume, int64_t size, int dynamic)
{
struct ubi_mkvol_req req;
int err;
@@ -191,7 +191,7 @@ static int ubi_create_vol(char *volume, int size, int dynamic)
printf("verify_mkvol_req failed %d\n", err);
return err;
}
- printf("Creating %s volume %s of size %d\n",
+ printf("Creating %s volume %s of size %lld\n",
dynamic ? "dynamic" : "static", volume, size);
/* Call real ubi create volume */
return ubi_create_volume(ubi, &req);
@@ -266,28 +266,15 @@ out_err:
return err;
}
-int ubi_volume_write(char *volume, void *buf, size_t size)
+int ubi_volume_continue_write(char *volume, void *buf, size_t size)
{
int err = 1;
- int rsvd_bytes = 0;
struct ubi_volume *vol;
vol = ubi_find_volume(volume);
if (vol == NULL)
return ENODEV;
- rsvd_bytes = vol->reserved_pebs * (ubi->leb_size - vol->data_pad);
- if (size < 0 || size > rsvd_bytes) {
- printf("size > volume size! Aborting!\n");
- return EINVAL;
- }
-
- err = ubi_start_update(ubi, vol, size);
- if (err < 0) {
- printf("Cannot start volume update\n");
- return -err;
- }
-
err = ubi_more_update_data(ubi, vol, buf, size);
if (err < 0) {
printf("Couldnt or partially wrote data\n");
@@ -314,6 +301,37 @@ int ubi_volume_write(char *volume, void *buf, size_t size)
return 0;
}
+int ubi_volume_begin_write(char *volume, void *buf, size_t size,
+ size_t full_size)
+{
+ int err = 1;
+ int rsvd_bytes = 0;
+ struct ubi_volume *vol;
+
+ vol = ubi_find_volume(volume);
+ if (vol == NULL)
+ return ENODEV;
+
+ rsvd_bytes = vol->reserved_pebs * (ubi->leb_size - vol->data_pad);
+ if (size < 0 || size > rsvd_bytes) {
+ printf("size > volume size! Aborting!\n");
+ return EINVAL;
+ }
+
+ err = ubi_start_update(ubi, vol, full_size);
+ if (err < 0) {
+ printf("Cannot start volume update\n");
+ return -err;
+ }
+
+ return ubi_volume_continue_write(volume, buf, size);
+}
+
+int ubi_volume_write(char *volume, void *buf, size_t size)
+{
+ return ubi_volume_begin_write(volume, buf, size, size);
+}
+
int ubi_volume_read(char *volume, char *buf, size_t size)
{
int err, lnum, off, len, tbuf_size;
@@ -498,7 +516,7 @@ int ubi_part(char *part_name, const char *vid_header_offset)
static int do_ubi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
- size_t size = 0;
+ int64_t size = 0;
ulong addr = 0;
if (argc < 2)
@@ -558,13 +576,13 @@ static int do_ubi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
}
/* E.g., create volume size */
if (argc == 4) {
- size = simple_strtoul(argv[3], NULL, 16);
+ size = simple_strtoull(argv[3], NULL, 16);
argc--;
}
/* Use maximum available size */
if (!size) {
- size = ubi->avail_pebs * ubi->leb_size;
- printf("No size specified -> Using max size (%u)\n", size);
+ size = (int64_t)ubi->avail_pebs * ubi->leb_size;
+ printf("No size specified -> Using max size (%lld)\n", size);
}
/* E.g., create volume */
if (argc == 3)
@@ -588,9 +606,22 @@ static int do_ubi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
addr = simple_strtoul(argv[2], NULL, 16);
size = simple_strtoul(argv[4], NULL, 16);
- ret = ubi_volume_write(argv[3], (void *)addr, size);
+ if (strlen(argv[1]) == 10 &&
+ strncmp(argv[1] + 5, ".part", 5) == 0) {
+ if (argc < 6) {
+ ret = ubi_volume_continue_write(argv[3],
+ (void *)addr, size);
+ } else {
+ size_t full_size;
+ full_size = simple_strtoul(argv[5], NULL, 16);
+ ret = ubi_volume_begin_write(argv[3],
+ (void *)addr, size, full_size);
+ }
+ } else {
+ ret = ubi_volume_write(argv[3], (void *)addr, size);
+ }
if (!ret) {
- printf("%d bytes written to volume %s\n", size,
+ printf("%lld bytes written to volume %s\n", size,
argv[3]);
}
@@ -613,7 +644,7 @@ static int do_ubi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
}
if (argc == 3) {
- printf("Read %d bytes from volume %s to %lx\n", size,
+ printf("Read %lld bytes from volume %s to %lx\n", size,
argv[3], addr);
return ubi_volume_read(argv[3], (char *)addr, size);
@@ -636,6 +667,8 @@ U_BOOT_CMD(
" - create volume name with size\n"
"ubi write[vol] address volume size"
" - Write volume from address with size\n"
+ "ubi write.part address volume size [fullsize]\n"
+ " - Write part of a volume from address\n"
"ubi read[vol] address volume [size]"
" - Read volume to address with size\n"
"ubi remove[vol] volume"
diff --git a/common/cmd_universe.c b/common/cmd_universe.c
index ad156138453..c9310363f10 100644
--- a/common/cmd_universe.c
+++ b/common/cmd_universe.c
@@ -1,7 +1,7 @@
/*
* (C) Copyright 2003 Stefan Roese, stefan.roese@esd-electronics.com
*
- * SPDX-License-Identifier: GPL-2.0+
+ * SPDX-License-Identifier: GPL-2.0+
*/
#include <common.h>
diff --git a/common/env_common.c b/common/env_common.c
index 1ac337730c3..c0bfc2f5db3 100644
--- a/common/env_common.c
+++ b/common/env_common.c
@@ -5,7 +5,7 @@
* (C) Copyright 2001 Sysgo Real-Time Solutions, GmbH <www.elinos.com>
* Andreas Heppel <aheppel@sysgo.de>
*
- * SPDX-License-Identifier: GPL-2.0+
+ * SPDX-License-Identifier: GPL-2.0+
*/
#include <common.h>
diff --git a/common/env_dataflash.c b/common/env_dataflash.c
index 5f21d5c38e5..b53b87e9587 100644
--- a/common/env_dataflash.c
+++ b/common/env_dataflash.c
@@ -29,11 +29,25 @@ uchar env_get_char_spec(int index)
void env_relocate_spec(void)
{
+ ulong crc, new = 0;
+ unsigned off;
char buf[CONFIG_ENV_SIZE];
+ /* Read old CRC */
+ read_dataflash(CONFIG_ENV_ADDR + offsetof(env_t, crc),
+ sizeof(ulong), (char *)&crc);
+
+ /* Read whole environment */
read_dataflash(CONFIG_ENV_ADDR, CONFIG_ENV_SIZE, buf);
- env_import(buf, 1);
+ /* Calculate the CRC */
+ off = offsetof(env_t, data);
+ new = crc32(new, (unsigned char *)(buf + off), ENV_SIZE);
+
+ if (crc == new)
+ env_import(buf, 1);
+ else
+ set_default_env("!bad CRC");
}
#ifdef CONFIG_ENV_OFFSET_REDUND
@@ -67,37 +81,9 @@ int saveenv(void)
*/
int env_init(void)
{
- ulong crc, len = ENV_SIZE, new = 0;
- unsigned off;
- uchar buf[64];
-
- if (gd->env_valid)
- return 0;
-
- AT91F_DataflashInit(); /* prepare for DATAFLASH read/write */
-
- /* read old CRC */
- read_dataflash(CONFIG_ENV_ADDR + offsetof(env_t, crc),
- sizeof(ulong), (char *)&crc);
-
- off = offsetof(env_t, data);
- while (len > 0) {
- int n = (len > sizeof(buf)) ? sizeof(buf) : len;
-
- read_dataflash(CONFIG_ENV_ADDR + off, n, (char *)buf);
-
- new = crc32(new, buf, n);
- len -= n;
- off += n;
- }
-
- if (crc == new) {
- gd->env_addr = offsetof(env_t, data);
- gd->env_valid = 1;
- } else {
- gd->env_addr = (ulong)&default_environment[0];
- gd->env_valid = 0;
- }
+ /* use default */
+ gd->env_addr = (ulong)&default_environment[0];
+ gd->env_valid = 1;
return 0;
}
diff --git a/common/env_eeprom.c b/common/env_eeprom.c
index 149370f8348..0dcdd1fc808 100644
--- a/common/env_eeprom.c
+++ b/common/env_eeprom.c
@@ -5,7 +5,7 @@
* (C) Copyright 2001 Sysgo Real-Time Solutions, GmbH <www.elinos.com>
* Andreas Heppel <aheppel@sysgo.de>
*
- * SPDX-License-Identifier: GPL-2.0+
+ * SPDX-License-Identifier: GPL-2.0+
*/
#include <common.h>
diff --git a/common/env_embedded.c b/common/env_embedded.c
index 91d8ba308d2..1c4f915b796 100644
--- a/common/env_embedded.c
+++ b/common/env_embedded.c
@@ -2,7 +2,7 @@
* (C) Copyright 2001
* Erik Theisen, Wave 7 Optics, etheisen@mindspring.com.
*
- * SPDX-License-Identifier: GPL-2.0+
+ * SPDX-License-Identifier: GPL-2.0+
*/
#ifndef __ASSEMBLY__
diff --git a/common/env_fat.c b/common/env_fat.c
index e114921c4ac..708fd13dc72 100644
--- a/common/env_fat.c
+++ b/common/env_fat.c
@@ -4,7 +4,7 @@
* Author:
* Maximilian Schwerin <mvs@tigris.de>
*
- * SPDX-License-Identifier: GPL-2.0+
+ * SPDX-License-Identifier: GPL-2.0+
*/
#include <common.h>
diff --git a/common/env_flash.c b/common/env_flash.c
index d4a0e18c3d4..7d5a4cfc8aa 100644
--- a/common/env_flash.c
+++ b/common/env_flash.c
@@ -5,7 +5,7 @@
* (C) Copyright 2001 Sysgo Real-Time Solutions, GmbH <www.elinos.com>
* Andreas Heppel <aheppel@sysgo.de>
- * SPDX-License-Identifier: GPL-2.0+
+ * SPDX-License-Identifier: GPL-2.0+
*/
/* #define DEBUG */
diff --git a/common/env_mmc.c b/common/env_mmc.c
index 65aafa9cac2..045428c6ec9 100644
--- a/common/env_mmc.c
+++ b/common/env_mmc.c
@@ -1,7 +1,7 @@
/*
* (C) Copyright 2008-2011 Freescale Semiconductor, Inc.
*
- * SPDX-License-Identifier: GPL-2.0+
+ * SPDX-License-Identifier: GPL-2.0+
*/
/* #define DEBUG */
@@ -192,11 +192,12 @@ void env_relocate_spec(void)
u32 offset1, offset2;
int read1_fail = 0, read2_fail = 0;
int crc1_ok = 0, crc2_ok = 0;
- env_t *ep, *tmp_env1, *tmp_env2;
+ env_t *ep;
int ret;
- tmp_env1 = (env_t *)malloc(CONFIG_ENV_SIZE);
- tmp_env2 = (env_t *)malloc(CONFIG_ENV_SIZE);
+ ALLOC_CACHE_ALIGN_BUFFER(env_t, tmp_env1, 1);
+ ALLOC_CACHE_ALIGN_BUFFER(env_t, tmp_env2, 1);
+
if (tmp_env1 == NULL || tmp_env2 == NULL) {
puts("Can't allocate buffers for environment\n");
ret = 1;
@@ -266,8 +267,6 @@ err:
if (ret)
set_default_env(NULL);
- free(tmp_env1);
- free(tmp_env2);
#endif
}
#else /* ! CONFIG_ENV_OFFSET_REDUND */
diff --git a/common/env_nand.c b/common/env_nand.c
index 75309621b03..695a9eebb01 100644
--- a/common/env_nand.c
+++ b/common/env_nand.c
@@ -11,7 +11,7 @@
* (C) Copyright 2001 Sysgo Real-Time Solutions, GmbH <www.elinos.com>
* Andreas Heppel <aheppel@sysgo.de>
*
- * SPDX-License-Identifier: GPL-2.0+
+ * SPDX-License-Identifier: GPL-2.0+
*/
#include <common.h>
diff --git a/common/env_nowhere.c b/common/env_nowhere.c
index c411e8cfe7b..bdc1ed5e676 100644
--- a/common/env_nowhere.c
+++ b/common/env_nowhere.c
@@ -5,7 +5,7 @@
* (C) Copyright 2001 Sysgo Real-Time Solutions, GmbH <www.elinos.com>
* Andreas Heppel <aheppel@sysgo.de>
- * SPDX-License-Identifier: GPL-2.0+
+ * SPDX-License-Identifier: GPL-2.0+
*/
#include <common.h>
diff --git a/common/env_nvram.c b/common/env_nvram.c
index 49144220b18..0866cde924b 100644
--- a/common/env_nvram.c
+++ b/common/env_nvram.c
@@ -5,7 +5,7 @@
* (C) Copyright 2001 Sysgo Real-Time Solutions, GmbH <www.elinos.com>
* Andreas Heppel <aheppel@sysgo.de>
- * SPDX-License-Identifier: GPL-2.0+
+ * SPDX-License-Identifier: GPL-2.0+
*/
/*
diff --git a/common/env_remote.c b/common/env_remote.c
index 1b6609b9094..eb977ee1fe8 100644
--- a/common/env_remote.c
+++ b/common/env_remote.c
@@ -1,7 +1,7 @@
/*
* (C) Copyright 2011-2012 Freescale Semiconductor, Inc.
*
- * SPDX-License-Identifier: GPL-2.0+
+ * SPDX-License-Identifier: GPL-2.0+
*/
/* #define DEBUG */
diff --git a/common/env_ubi.c b/common/env_ubi.c
index f24a96c3e9c..c0828a47d32 100644
--- a/common/env_ubi.c
+++ b/common/env_ubi.c
@@ -2,7 +2,7 @@
* (c) Copyright 2012 by National Instruments,
* Joe Hershberger <joe.hershberger@ni.com>
*
- * SPDX-License-Identifier: GPL-2.0+
+ * SPDX-License-Identifier: GPL-2.0+
*/
#include <common.h>
diff --git a/common/iomux.c b/common/iomux.c
index cf4da457075..62bdec61aaf 100644
--- a/common/iomux.c
+++ b/common/iomux.c
@@ -2,7 +2,7 @@
* (C) Copyright 2008
* Gary Jennejohn, DENX Software Engineering GmbH, garyj@denx.de.
*
- * SPDX-License-Identifier: GPL-2.0+
+ * SPDX-License-Identifier: GPL-2.0+
*/
#include <common.h>
diff --git a/common/lcd.c b/common/lcd.c
index 990650c7ef3..5dd79481212 100644
--- a/common/lcd.c
+++ b/common/lcd.c
@@ -4,7 +4,7 @@
* (C) Copyright 2001-2002
* Wolfgang Denk, DENX Software Engineering -- wd@denx.de
*
- * SPDX-License-Identifier: GPL-2.0+
+ * SPDX-License-Identifier: GPL-2.0+
*/
/************************************************************************/
diff --git a/common/main.c b/common/main.c
index ae37fee46d9..6f475f0cca8 100644
--- a/common/main.c
+++ b/common/main.c
@@ -365,7 +365,7 @@ static void process_boot_delay(void)
#ifdef CONFIG_BOOTCOUNT_LIMIT
if (bootlimit && (bootcount > bootlimit)) {
printf ("Warning: Bootlimit (%u) exceeded. Using altbootcmd.\n",
- (unsigned)bootlimit);
+ (unsigned)bootlimit);
s = getenv ("altbootcmd");
}
else