summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/Makefile8
-rw-r--r--common/circbuf.c110
-rw-r--r--common/cmd_bmp.c2
-rw-r--r--common/cmd_bootm.c31
-rw-r--r--common/cmd_cache.c4
-rw-r--r--common/cmd_date.c6
-rw-r--r--common/cmd_echo.c58
-rw-r--r--common/cmd_exit.c42
-rw-r--r--common/cmd_fdt.c14
-rw-r--r--common/cmd_help.c50
-rw-r--r--common/cmd_i2c.c12
-rw-r--r--common/cmd_ide.c4
-rw-r--r--common/cmd_irq.c9
-rw-r--r--common/cmd_license.c5
-rw-r--r--common/cmd_mem.c2
-rw-r--r--common/cmd_mgdisk.c4
-rw-r--r--common/cmd_misc.c11
-rw-r--r--common/cmd_nand.c12
-rw-r--r--common/cmd_onenand.c4
-rw-r--r--common/cmd_test.c173
-rw-r--r--common/cmd_usb.c44
-rw-r--r--common/cmd_version.c40
-rw-r--r--common/command.c233
-rw-r--r--common/dlmalloc.c6
-rw-r--r--common/env_onenand.c19
-rw-r--r--common/exports.c58
-rw-r--r--common/image.c5
-rw-r--r--common/usb.c35
-rw-r--r--common/usb_kbd.c22
-rw-r--r--common/usb_storage.c115
30 files changed, 628 insertions, 510 deletions
diff --git a/common/Makefile b/common/Makefile
index 3781738..7784180 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -29,7 +29,6 @@ AOBJS =
# core
COBJS-y += main.o
-COBJS-y += circbuf.o
COBJS-y += console.o
COBJS-y += command.o
COBJS-y += dlmalloc.o
@@ -45,7 +44,9 @@ COBJS-y += xyzModem.o
# core command
COBJS-y += cmd_boot.o
COBJS-y += cmd_bootm.o
+COBJS-y += cmd_help.o
COBJS-y += cmd_nvedit.o
+COBJS-y += cmd_version.o
# environment
COBJS-y += env_common.o
@@ -84,9 +85,11 @@ COBJS-$(CONFIG_CMD_DIAG) += cmd_diag.o
endif
COBJS-$(CONFIG_CMD_DISPLAY) += cmd_display.o
COBJS-$(CONFIG_CMD_DTT) += cmd_dtt.o
+COBJS-$(CONFIG_CMD_ECHO) += cmd_echo.o
COBJS-$(CONFIG_ENV_IS_IN_EEPROM) += cmd_eeprom.o
COBJS-$(CONFIG_CMD_EEPROM) += cmd_eeprom.o
COBJS-$(CONFIG_CMD_ELF) += cmd_elf.o
+COBJS-$(CONFIG_SYS_HUSH_PARSER) += cmd_exit.o
COBJS-$(CONFIG_CMD_EXT2) += cmd_ext2.o
COBJS-$(CONFIG_CMD_FAT) += cmd_fat.o
COBJS-$(CONFIG_CMD_FDC)$(CONFIG_CMD_FDOS) += cmd_fdc.o
@@ -116,7 +119,7 @@ COBJS-$(CONFIG_CMD_MISC) += cmd_misc.o
COBJS-$(CONFIG_CMD_MMC) += cmd_mmc.o
COBJS-$(CONFIG_MP) += cmd_mp.o
COBJS-$(CONFIG_CMD_MTDPARTS) += cmd_mtdparts.o
-COBJS-y += cmd_nand.o
+COBJS-$(CONFIG_CMD_NAND) += cmd_nand.o
COBJS-$(CONFIG_CMD_NET) += cmd_net.o
COBJS-$(CONFIG_CMD_ONENAND) += cmd_onenand.o
COBJS-$(CONFIG_CMD_OTP) += cmd_otp.o
@@ -135,6 +138,7 @@ COBJS-$(CONFIG_CMD_SPI) += cmd_spi.o
COBJS-$(CONFIG_CMD_SPIBOOTLDR) += cmd_spibootldr.o
COBJS-$(CONFIG_CMD_STRINGS) += cmd_strings.o
COBJS-$(CONFIG_CMD_TERMINAL) += cmd_terminal.o
+COBJS-$(CONFIG_SYS_HUSH_PARSER) += cmd_test.o
COBJS-$(CONFIG_CMD_TSI148) += cmd_tsi148.o
COBJS-$(CONFIG_CMD_UBI) += cmd_ubi.o
COBJS-$(CONFIG_CMD_UBIFS) += cmd_ubifs.o
diff --git a/common/circbuf.c b/common/circbuf.c
deleted file mode 100644
index 2332c63..0000000
--- a/common/circbuf.c
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * (C) Copyright 2003
- * Gerry Hamel, geh@ti.com, Texas Instruments
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * 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 <malloc.h>
-
-#include <circbuf.h>
-
-
-int buf_init (circbuf_t * buf, unsigned int size)
-{
- assert (buf != NULL);
-
- buf->size = 0;
- buf->totalsize = size;
- buf->data = (char *) malloc (sizeof (char) * size);
- assert (buf->data != NULL);
-
- buf->top = buf->data;
- buf->tail = buf->data;
- buf->end = &(buf->data[size]);
-
- return 1;
-}
-
-int buf_free (circbuf_t * buf)
-{
- assert (buf != NULL);
- assert (buf->data != NULL);
-
- free (buf->data);
- memset (buf, 0, sizeof (circbuf_t));
-
- return 1;
-}
-
-int buf_pop (circbuf_t * buf, char *dest, unsigned int len)
-{
- unsigned int i;
- char *p = buf->top;
-
- assert (buf != NULL);
- assert (dest != NULL);
-
- /* Cap to number of bytes in buffer */
- if (len > buf->size)
- len = buf->size;
-
- for (i = 0; i < len; i++) {
- dest[i] = *p++;
- /* Bounds check. */
- if (p == buf->end) {
- p = buf->data;
- }
- }
-
- /* Update 'top' pointer */
- buf->top = p;
- buf->size -= len;
-
- return len;
-}
-
-int buf_push (circbuf_t * buf, const char *src, unsigned int len)
-{
- /* NOTE: this function allows push to overwrite old data. */
- unsigned int i;
- char *p = buf->tail;
-
- assert (buf != NULL);
- assert (src != NULL);
-
- for (i = 0; i < len; i++) {
- *p++ = src[i];
- if (p == buf->end) {
- p = buf->data;
- }
- /* Make sure pushing too much data just replaces old data */
- if (buf->size < buf->totalsize) {
- buf->size++;
- } else {
- buf->top++;
- if (buf->top == buf->end) {
- buf->top = buf->data;
- }
- }
- }
-
- /* Update 'tail' pointer */
- buf->tail = p;
-
- return len;
-}
diff --git a/common/cmd_bmp.c b/common/cmd_bmp.c
index faa10a4..74ab24c 100644
--- a/common/cmd_bmp.c
+++ b/common/cmd_bmp.c
@@ -35,8 +35,6 @@
static int bmp_info (ulong addr);
static int bmp_display (ulong addr, int x, int y);
-int gunzip(void *, int, unsigned char *, unsigned long *);
-
/*
* Allocate and decompress a BMP image using gunzip().
*
diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c
index 8f83598..94ddac3 100644
--- a/common/cmd_bootm.c
+++ b/common/cmd_bootm.c
@@ -57,9 +57,12 @@
#include <lzma/LzmaTools.h>
#endif /* CONFIG_LZMA */
+#ifdef CONFIG_LZO
+#include <linux/lzo.h>
+#endif /* CONFIG_LZO */
+
DECLARE_GLOBAL_DATA_PTR;
-extern int gunzip (void *dst, int dstlen, unsigned char *src, unsigned long *lenp);
#ifndef CONFIG_SYS_BOOTM_LEN
#define CONFIG_SYS_BOOTM_LEN 0x800000 /* use 8MByte as default max gunzip size */
#endif
@@ -129,7 +132,7 @@ int do_bootelf (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
static boot_os_fn do_bootm_integrity;
#endif
-boot_os_fn * boot_os[] = {
+static boot_os_fn *boot_os[] = {
#ifdef CONFIG_BOOTM_LINUX
[IH_OS_LINUX] = do_bootm_linux,
#endif
@@ -405,6 +408,24 @@ static int bootm_load_os(image_info_t os, ulong *load_end, int boot_progress)
*load_end = load + unc_len;
break;
#endif /* CONFIG_LZMA */
+#ifdef CONFIG_LZO
+ case IH_COMP_LZO:
+ printf (" Uncompressing %s ... ", type_name);
+
+ int ret = lzop_decompress((const unsigned char *)image_start,
+ image_len, (unsigned char *)load,
+ &unc_len);
+ if (ret != LZO_E_OK) {
+ printf ("LZO: uncompress or overwrite error %d "
+ "- must RESET board to recover\n", ret);
+ if (boot_progress)
+ show_boot_progress (-6);
+ return BOOTM_ERR_RESET;
+ }
+
+ *load_end = load + unc_len;
+ break;
+#endif /* CONFIG_LZO */
default:
printf ("Unimplemented compression type %d\n", comp);
return BOOTM_ERR_UNIMPLEMENTED;
@@ -453,8 +474,8 @@ cmd_tbl_t cmd_bootm_sub[] = {
#ifdef CONFIG_OF_LIBFDT
U_BOOT_CMD_MKENT(fdt, 0, 1, (void *)BOOTM_STATE_FDT, "", ""),
#endif
- U_BOOT_CMD_MKENT(bdt, 0, 1, (void *)BOOTM_STATE_OS_BD_T, "", ""),
U_BOOT_CMD_MKENT(cmdline, 0, 1, (void *)BOOTM_STATE_OS_CMDLINE, "", ""),
+ U_BOOT_CMD_MKENT(bdt, 0, 1, (void *)BOOTM_STATE_OS_BD_T, "", ""),
U_BOOT_CMD_MKENT(prep, 0, 1, (void *)BOOTM_STATE_OS_PREP, "", ""),
U_BOOT_CMD_MKENT(go, 0, 1, (void *)BOOTM_STATE_OS_GO, "", ""),
};
@@ -524,7 +545,7 @@ int do_bootm_subcommand (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
}
break;
#endif
-#ifdef CONFIG_OF_LIBFDT
+#if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_SYS_BOOTMAPSZ)
case BOOTM_STATE_FDT:
{
ulong bootmap_base = getenv_bootm_low();
@@ -1000,8 +1021,8 @@ U_BOOT_CMD(
#if defined(CONFIG_OF_LIBFDT)
"\tfdt - relocate flat device tree\n"
#endif
- "\tbdt - OS specific bd_t processing\n"
"\tcmdline - OS specific command line processing/setup\n"
+ "\tbdt - OS specific bd_t processing\n"
"\tprep - OS specific prep before relocation or go\n"
"\tgo - start OS"
);
diff --git a/common/cmd_cache.c b/common/cmd_cache.c
index 0dfa336..1202258 100644
--- a/common/cmd_cache.c
+++ b/common/cmd_cache.c
@@ -27,8 +27,6 @@
#include <common.h>
#include <command.h>
-#if defined(CONFIG_CMD_CACHE)
-
static int on_off (const char *);
int do_icache ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
@@ -108,5 +106,3 @@ U_BOOT_CMD(
"[on, off]\n"
" - enable or disable data (writethrough) cache"
);
-
-#endif
diff --git a/common/cmd_date.c b/common/cmd_date.c
index 9f50f89..3141a39 100644
--- a/common/cmd_date.c
+++ b/common/cmd_date.c
@@ -71,9 +71,9 @@ int do_date (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
/* and write to RTC */
rcode = rtc_set (&tm);
if(rcode)
- puts("## Set date failled\n");
+ puts("## Set date failed\n");
} else {
- puts("## Get date failled\n");
+ puts("## Get date failed\n");
}
}
/* FALL TROUGH */
@@ -81,7 +81,7 @@ int do_date (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
rcode = rtc_get (&tm);
if (rcode) {
- puts("## Get date failled\n");
+ puts("## Get date failed\n");
break;
}
diff --git a/common/cmd_echo.c b/common/cmd_echo.c
new file mode 100644
index 0000000..3ec4d48
--- /dev/null
+++ b/common/cmd_echo.c
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2000-2009
+ * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+ *
+ * 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 as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * 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>
+
+int do_echo(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
+{
+ int i;
+ int putnl = 1;
+
+ for (i = 1; i < argc; i++) {
+ char *p = argv[i], c;
+
+ if (i > 1)
+ putc(' ');
+ while ((c = *p++) != '\0') {
+ if (c == '\\' && *p == 'c') {
+ putnl = 0;
+ p++;
+ } else {
+ putc(c);
+ }
+ }
+ }
+
+ if (putnl)
+ putc('\n');
+
+ return 0;
+}
+
+U_BOOT_CMD(
+ echo, CONFIG_SYS_MAXARGS, 1, do_echo,
+ "echo args to console",
+ "[args..]\n"
+ " - echo args to console; \\c suppresses newline"
+);
diff --git a/common/cmd_exit.c b/common/cmd_exit.c
new file mode 100644
index 0000000..ed876d8
--- /dev/null
+++ b/common/cmd_exit.c
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2000-2009
+ * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+ *
+ * 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 as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * 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>
+
+int do_exit(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
+{
+ int r;
+
+ r = 0;
+ if (argc > 1)
+ r = simple_strtoul(argv[1], NULL, 10);
+
+ return -r - 2;
+}
+
+U_BOOT_CMD(
+ exit, 2, 1, do_exit,
+ "exit script",
+ ""
+);
diff --git a/common/cmd_fdt.c b/common/cmd_fdt.c
index 919a0bf..5df79ae 100644
--- a/common/cmd_fdt.c
+++ b/common/cmd_fdt.c
@@ -364,13 +364,8 @@ int do_fdt (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
} else if (strncmp(argv[1], "me", 2) == 0) {
uint64_t addr, size;
int err;
-#ifdef CONFIG_SYS_64BIT_STRTOUL
- addr = simple_strtoull(argv[2], NULL, 16);
- size = simple_strtoull(argv[3], NULL, 16);
-#else
- addr = simple_strtoul(argv[2], NULL, 16);
- size = simple_strtoul(argv[3], NULL, 16);
-#endif
+ addr = simple_strtoull(argv[2], NULL, 16);
+ size = simple_strtoull(argv[3], NULL, 16);
err = fdt_fixup_memory(working_fdt, addr, size);
if (err < 0)
return err;
@@ -402,13 +397,8 @@ int do_fdt (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
} else if (argv[2][0] == 'a') {
uint64_t addr, size;
int err;
-#ifdef CONFIG_SYS_64BIT_STRTOUL
addr = simple_strtoull(argv[3], NULL, 16);
size = simple_strtoull(argv[4], NULL, 16);
-#else
- addr = simple_strtoul(argv[3], NULL, 16);
- size = simple_strtoul(argv[4], NULL, 16);
-#endif
err = fdt_add_mem_rsv(working_fdt, addr, size);
if (err < 0) {
diff --git a/common/cmd_help.c b/common/cmd_help.c
new file mode 100644
index 0000000..e860dfb
--- /dev/null
+++ b/common/cmd_help.c
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2000-2009
+ * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+ *
+ * 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 as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * 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>
+
+int do_help(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
+{
+ return _do_help(&__u_boot_cmd_start,
+ &__u_boot_cmd_end - &__u_boot_cmd_start,
+ cmdtp, flag, argc, argv);
+}
+
+U_BOOT_CMD(
+ help, CONFIG_SYS_MAXARGS, 1, do_help,
+ "print command description/usage",
+ "\n"
+ " - print brief description of all commands\n"
+ "help command ...\n"
+ " - print detailed usage of 'command'"
+);
+
+/* This does not use the U_BOOT_CMD macro as ? can't be used in symbol names */
+cmd_tbl_t __u_boot_cmd_question_mark Struct_Section = {
+ "?", CONFIG_SYS_MAXARGS, 1, do_help,
+ "alias for 'help'",
+#ifdef CONFIG_SYS_LONGHELP
+ ""
+#endif /* CONFIG_SYS_LONGHELP */
+};
diff --git a/common/cmd_i2c.c b/common/cmd_i2c.c
index 8f0fc9e..62cbd33 100644
--- a/common/cmd_i2c.c
+++ b/common/cmd_i2c.c
@@ -315,10 +315,6 @@ int do_i2c_mw ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
/*
* Wait for the write to complete. The write can take
* up to 10mSec (we allow a little more time).
- *
- * On some chips, while the write is in progress, the
- * chip doesn't respond. This apparently isn't a
- * universal feature so we don't take advantage of it.
*/
/*
* No write delay with FRAM devices.
@@ -326,14 +322,6 @@ int do_i2c_mw ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
#if !defined(CONFIG_SYS_I2C_FRAM)
udelay(11000);
#endif
-
-#if 0
- for (timeout = 0; timeout < 10; timeout++) {
- udelay(2000);
- if (i2c_probe(chip) == 0)
- break;
- }
-#endif
}
return (0);
diff --git a/common/cmd_ide.c b/common/cmd_ide.c
index ec9a1df..093ca9f 100644
--- a/common/cmd_ide.c
+++ b/common/cmd_ide.c
@@ -1354,7 +1354,7 @@ ulong ide_read (int device, lbaint_t blknr, ulong blkcnt, void *buffer)
}
if ((c&(ATA_STAT_DRQ|ATA_STAT_BUSY|ATA_STAT_ERR)) != ATA_STAT_DRQ) {
-#if defined(CONFIG_SYS_64BIT_LBA) && defined(CONFIG_SYS_64BIT_VSPRINTF)
+#if defined(CONFIG_SYS_64BIT_LBA)
printf ("Error (no IRQ) dev %d blk %Ld: status 0x%02x\n",
device, blknr, c);
#else
@@ -1444,7 +1444,7 @@ ulong ide_write (int device, lbaint_t blknr, ulong blkcnt, void *buffer)
c = ide_wait (device, IDE_TIME_OUT); /* can't take over 500 ms */
if ((c&(ATA_STAT_DRQ|ATA_STAT_BUSY|ATA_STAT_ERR)) != ATA_STAT_DRQ) {
-#if defined(CONFIG_SYS_64BIT_LBA) && defined(CONFIG_SYS_64BIT_VSPRINTF)
+#if defined(CONFIG_SYS_64BIT_LBA)
printf ("Error (no IRQ) dev %d blk %Ld: status 0x%02x\n",
device, blknr, c);
#else
diff --git a/common/cmd_irq.c b/common/cmd_irq.c
index 4604a5a..2c7e6bb 100644
--- a/common/cmd_irq.c
+++ b/common/cmd_irq.c
@@ -47,3 +47,12 @@ U_BOOT_CMD(
"enable or disable interrupts",
"[on, off]"
);
+
+/* Implemented in $(CPU)/interrupts.c */
+int do_irqinfo (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
+
+U_BOOT_CMD(
+ irqinfo, 1, 1, do_irqinfo,
+ "print information about IRQs",
+ ""
+);
diff --git a/common/cmd_license.c b/common/cmd_license.c
index 141215b..85a4871 100644
--- a/common/cmd_license.c
+++ b/common/cmd_license.c
@@ -23,15 +23,12 @@
#include <common.h>
-#if defined(CONFIG_CMD_LICENSE)
-
/* COPYING is currently 15951 bytes in size */
#define LICENSE_MAX 20480
#include <command.h>
#include <malloc.h>
#include <license.h>
-int gunzip(void *, int, unsigned char *, unsigned long *);
int do_license(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
{
@@ -56,5 +53,3 @@ U_BOOT_CMD(license, 1, 1, do_license,
"print GPL license text",
""
);
-
-#endif /* CONFIG_CMD_LICENSE */
diff --git a/common/cmd_mem.c b/common/cmd_mem.c
index a34b342..1839330 100644
--- a/common/cmd_mem.c
+++ b/common/cmd_mem.c
@@ -1225,8 +1225,6 @@ int do_sha1sum(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
#endif
#ifdef CONFIG_CMD_UNZIP
-int gunzip (void *, int, unsigned char *, unsigned long *);
-
int do_unzip ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
{
unsigned long src, dst;
diff --git a/common/cmd_mgdisk.c b/common/cmd_mgdisk.c
index aadc335..3ba62f6 100644
--- a/common/cmd_mgdisk.c
+++ b/common/cmd_mgdisk.c
@@ -24,8 +24,6 @@
#include <common.h>
#include <command.h>
-#if defined (CONFIG_CMD_MG_DISK)
-
#include <mg_disk.h>
int do_mg_disk_cmd (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
@@ -72,5 +70,3 @@ U_BOOT_CMD(
" - sector read : mgd readsec [sector] [to] [counts]\n"
" - sector write : mgd writesec [from] [sector] [counts]"
);
-
-#endif
diff --git a/common/cmd_misc.c b/common/cmd_misc.c
index b97537e..b0ced2f 100644
--- a/common/cmd_misc.c
+++ b/common/cmd_misc.c
@@ -49,17 +49,6 @@ int do_sleep (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
return 0;
}
-/* Implemented in $(CPU)/interrupts.c */
-#if defined(CONFIG_CMD_IRQ)
-int do_irqinfo (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
-
-U_BOOT_CMD(
- irqinfo, 1, 1, do_irqinfo,
- "print information about IRQs",
- ""
-);
-#endif
-
U_BOOT_CMD(
sleep , 2, 1, do_sleep,
"delay execution for some time",
diff --git a/common/cmd_nand.c b/common/cmd_nand.c
index 158a55f..075a8af 100644
--- a/common/cmd_nand.c
+++ b/common/cmd_nand.c
@@ -9,18 +9,7 @@
*/
#include <common.h>
-
-
-/*
- *
- * New NAND support
- *
- */
-#include <common.h>
#include <linux/mtd/mtd.h>
-
-#if defined(CONFIG_CMD_NAND)
-
#include <command.h>
#include <watchdog.h>
#include <malloc.h>
@@ -686,4 +675,3 @@ U_BOOT_CMD(nboot, 4, 1, do_nandboot,
"boot from NAND device",
"[partition] | [[[loadAddr] dev] offset]"
);
-#endif
diff --git a/common/cmd_onenand.c b/common/cmd_onenand.c
index 9090940..565257c 100644
--- a/common/cmd_onenand.c
+++ b/common/cmd_onenand.c
@@ -19,10 +19,6 @@
#include <asm/io.h>
-#if !defined(CONFIG_SYS_64BIT_VSPRINTF)
-#warning Please define CONFIG_SYS_64BIT_VSPRINTF for correct output!
-#endif
-
static struct mtd_info *mtd;
static loff_t next_ofs;
diff --git a/common/cmd_test.c b/common/cmd_test.c
new file mode 100644
index 0000000..d886f89
--- /dev/null
+++ b/common/cmd_test.c
@@ -0,0 +1,173 @@
+/*
+ * Copyright 2000-2009
+ * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+ *
+ * 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 as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * 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>
+
+int do_test(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
+{
+ char **ap;
+ int left, adv, expr, last_expr, neg, last_cmp;
+
+ /* args? */
+ if (argc < 3)
+ return 1;
+
+#if 0
+ {
+ printf("test:");
+ left = 1;
+ while (argv[left])
+ printf(" %s", argv[left++]);
+ }
+#endif
+
+ last_expr = 0;
+ left = argc - 1; ap = argv + 1;
+ if (left > 0 && strcmp(ap[0], "!") == 0) {
+ neg = 1;
+ ap++;
+ left--;
+ } else
+ neg = 0;
+
+ expr = -1;
+ last_cmp = -1;
+ last_expr = -1;
+ while (left > 0) {
+
+ if (strcmp(ap[0], "-o") == 0 || strcmp(ap[0], "-a") == 0)
+ adv = 1;
+ else if (strcmp(ap[0], "-z") == 0 || strcmp(ap[0], "-n") == 0)
+ adv = 2;
+ else
+ adv = 3;
+
+ if (left < adv) {
+ expr = 1;
+ break;
+ }
+
+ if (adv == 1) {
+ if (strcmp(ap[0], "-o") == 0) {
+ last_expr = expr;
+ last_cmp = 0;
+ } else if (strcmp(ap[0], "-a") == 0) {
+ last_expr = expr;
+ last_cmp = 1;
+ } else {
+ expr = 1;
+ break;
+ }
+ }
+
+ if (adv == 2) {
+ if (strcmp(ap[0], "-z") == 0)
+ expr = strlen(ap[1]) == 0 ? 1 : 0;
+ else if (strcmp(ap[0], "-n") == 0)
+ expr = strlen(ap[1]) == 0 ? 0 : 1;
+ else {
+ expr = 1;
+ break;
+ }
+
+ if (last_cmp == 0)
+ expr = last_expr || expr;
+ else if (last_cmp == 1)
+ expr = last_expr && expr;
+ last_cmp = -1;
+ }
+
+ if (adv == 3) {
+ if (strcmp(ap[1], "=") == 0)
+ expr = strcmp(ap[0], ap[2]) == 0;
+ else if (strcmp(ap[1], "!=") == 0)
+ expr = strcmp(ap[0], ap[2]) != 0;
+ else if (strcmp(ap[1], ">") == 0)
+ expr = strcmp(ap[0], ap[2]) > 0;
+ else if (strcmp(ap[1], "<") == 0)
+ expr = strcmp(ap[0], ap[2]) < 0;
+ else if (strcmp(ap[1], "-eq") == 0)
+ expr = simple_strtol(ap[0], NULL, 10) == simple_strtol(ap[2], NULL, 10);
+ else if (strcmp(ap[1], "-ne") == 0)
+ expr = simple_strtol(ap[0], NULL, 10) != simple_strtol(ap[2], NULL, 10);
+ else if (strcmp(ap[1], "-lt") == 0)
+ expr = simple_strtol(ap[0], NULL, 10) < simple_strtol(ap[2], NULL, 10);
+ else if (strcmp(ap[1], "-le") == 0)
+ expr = simple_strtol(ap[0], NULL, 10) <= simple_strtol(ap[2], NULL, 10);
+ else if (strcmp(ap[1], "-gt") == 0)
+ expr = simple_strtol(ap[0], NULL, 10) > simple_strtol(ap[2], NULL, 10);
+ else if (strcmp(ap[1], "-ge") == 0)
+ expr = simple_strtol(ap[0], NULL, 10) >= simple_strtol(ap[2], NULL, 10);
+ else {
+ expr = 1;
+ break;
+ }
+
+ if (last_cmp == 0)
+ expr = last_expr || expr;
+ else if (last_cmp == 1)
+ expr = last_expr && expr;
+ last_cmp = -1;
+ }
+
+ ap += adv; left -= adv;
+ }
+
+ if (neg)
+ expr = !expr;
+
+ expr = !expr;
+
+ debug (": returns %d\n", expr);
+
+ return expr;
+}
+
+U_BOOT_CMD(
+ test, CONFIG_SYS_MAXARGS, 1, do_test,
+ "minimal test like /bin/sh",
+ "[args..]"
+);
+
+int do_false(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
+{
+ return 1;
+}
+
+U_BOOT_CMD(
+ false, CONFIG_SYS_MAXARGS, 1, do_false,
+ "do nothing, unsuccessfully",
+ NULL
+);
+
+int do_true(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
+{
+ return 0;
+}
+
+U_BOOT_CMD(
+ true, CONFIG_SYS_MAXARGS, 1, do_true,
+ "do nothing, successfully",
+ NULL
+);
diff --git a/common/cmd_usb.c b/common/cmd_usb.c
index 7b8ee6b..9de515c 100644
--- a/common/cmd_usb.c
+++ b/common/cmd_usb.c
@@ -157,7 +157,7 @@ void usb_display_desc(struct usb_device *dev)
{
if (dev->descriptor.bDescriptorType == USB_DT_DEVICE) {
printf("%d: %s, USB Revision %x.%x\n", dev->devnum,
- usb_get_class_desc(dev->config.if_desc[0].bInterfaceClass),
+ usb_get_class_desc(dev->config.if_desc[0].desc.bInterfaceClass),
(dev->descriptor.bcdUSB>>8) & 0xff,
dev->descriptor.bcdUSB & 0xff);
@@ -174,7 +174,7 @@ void usb_display_desc(struct usb_device *dev)
} else {
printf(" - Class: (from Interface) %s\n",
usb_get_class_desc(
- dev->config.if_desc[0].bInterfaceClass));
+ dev->config.if_desc[0].desc.bInterfaceClass));
}
printf(" - PacketSize: %d Configurations: %d\n",
dev->descriptor.bMaxPacketSize0,
@@ -187,14 +187,14 @@ void usb_display_desc(struct usb_device *dev)
}
-void usb_display_conf_desc(struct usb_config_descriptor *config,
+void usb_display_conf_desc(struct usb_configuration_descriptor *config,
struct usb_device *dev)
{
printf(" Configuration: %d\n", config->bConfigurationValue);
printf(" - Interfaces: %d %s%s%dmA\n", config->bNumInterfaces,
(config->bmAttributes & 0x40) ? "Self Powered " : "Bus Powered ",
(config->bmAttributes & 0x20) ? "Remote Wakeup " : "",
- config->MaxPower*2);
+ config->bMaxPower*2);
if (config->iConfiguration) {
printf(" - ");
usb_display_string(dev, config->iConfiguration);
@@ -246,16 +246,16 @@ void usb_display_ep_desc(struct usb_endpoint_descriptor *epdesc)
/* main routine to diasplay the configs, interfaces and endpoints */
void usb_display_config(struct usb_device *dev)
{
- struct usb_config_descriptor *config;
- struct usb_interface_descriptor *ifdesc;
+ struct usb_config *config;
+ struct usb_interface *ifdesc;
struct usb_endpoint_descriptor *epdesc;
int i, ii;
config = &dev->config;
- usb_display_conf_desc(config, dev);
+ usb_display_conf_desc(&config->desc, dev);
for (i = 0; i < config->no_of_if; i++) {
ifdesc = &config->if_desc[i];
- usb_display_if_desc(ifdesc, dev);
+ usb_display_if_desc(&ifdesc->desc, dev);
for (ii = 0; ii < ifdesc->no_of_ep; ii++) {
epdesc = &ifdesc->ep_desc[ii];
usb_display_ep_desc(epdesc);
@@ -319,9 +319,9 @@ void usb_show_tree_graph(struct usb_device *dev, char *pre)
pre[index++] = has_child ? '|' : ' ';
pre[index] = 0;
printf(" %s (%s, %dmA)\n", usb_get_class_desc(
- dev->config.if_desc[0].bInterfaceClass),
+ dev->config.if_desc[0].desc.bInterfaceClass),
portspeed(dev->speed),
- dev->config.MaxPower * 2);
+ dev->config.desc.bMaxPower * 2);
if (strlen(dev->mf) || strlen(dev->prod) || strlen(dev->serial))
printf(" %s %s %s %s\n", pre, dev->mf, dev->prod, dev->serial);
printf(" %s\n", pre);
@@ -642,6 +642,28 @@ int do_usb(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
return 1;
}
}
+ if (strcmp(argv[1], "write") == 0) {
+ if (usb_stor_curr_dev < 0) {
+ printf("no current device selected\n");
+ return 1;
+ }
+ if (argc == 5) {
+ unsigned long addr = simple_strtoul(argv[2], NULL, 16);
+ unsigned long blk = simple_strtoul(argv[3], NULL, 16);
+ unsigned long cnt = simple_strtoul(argv[4], NULL, 16);
+ unsigned long n;
+ printf("\nUSB write: device %d block # %ld, count %ld"
+ " ... ", usb_stor_curr_dev, blk, cnt);
+ stor_dev = usb_stor_get_dev(usb_stor_curr_dev);
+ n = stor_dev->block_write(usb_stor_curr_dev, blk, cnt,
+ (ulong *)addr);
+ printf("%ld blocks write: %s\n", n,
+ (n == cnt) ? "OK" : "ERROR");
+ if (n == cnt)
+ return 0;
+ return 1;
+ }
+ }
if (strncmp(argv[1], "dev", 3) == 0) {
if (argc == 3) {
int dev = (int)simple_strtoul(argv[2], NULL, 10);
@@ -687,6 +709,8 @@ U_BOOT_CMD(
" devices\n"
"usb read addr blk# cnt - read `cnt' blocks starting at block `blk#'\n"
" to memory address `addr'"
+ "usb write addr blk# cnt - write `cnt' blocks starting at block `blk#'\n"
+ " from memory address `addr'"
);
diff --git a/common/cmd_version.c b/common/cmd_version.c
new file mode 100644
index 0000000..7f165c7
--- /dev/null
+++ b/common/cmd_version.c
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2000-2009
+ * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+ *
+ * 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 as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * 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>
+
+extern char version_string[];
+
+int do_version(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
+{
+ printf("\n%s\n", version_string);
+
+ return 0;
+}
+
+U_BOOT_CMD(
+ version, 1, 1, do_version,
+ "print monitor version",
+ ""
+);
diff --git a/common/command.c b/common/command.c
index b57f8df..0c66b7a 100644
--- a/common/command.c
+++ b/common/command.c
@@ -28,206 +28,6 @@
#include <common.h>
#include <command.h>
-int
-do_version (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
-{
- extern char version_string[];
- printf ("\n%s\n", version_string);
- return 0;
-}
-
-U_BOOT_CMD(
- version, 1, 1, do_version,
- "print monitor version",
- ""
-);
-
-#if defined(CONFIG_CMD_ECHO)
-
-int
-do_echo (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
-{
- int i, putnl = 1;
-
- for (i = 1; i < argc; i++) {
- char *p = argv[i], c;
-
- if (i > 1)
- putc(' ');
- while ((c = *p++) != '\0') {
- if (c == '\\' && *p == 'c') {
- putnl = 0;
- p++;
- } else {
- putc(c);
- }
- }
- }
-
- if (putnl)
- putc('\n');
- return 0;
-}
-
-U_BOOT_CMD(
- echo, CONFIG_SYS_MAXARGS, 1, do_echo,
- "echo args to console",
- "[args..]\n"
- " - echo args to console; \\c suppresses newline"
-);
-
-#endif
-
-#ifdef CONFIG_SYS_HUSH_PARSER
-
-int
-do_test (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
-{
- char **ap;
- int left, adv, expr, last_expr, neg, last_cmp;
-
- /* args? */
- if (argc < 3)
- return 1;
-
-#if 0
- {
- printf("test:");
- left = 1;
- while (argv[left])
- printf(" %s", argv[left++]);
- }
-#endif
-
- last_expr = 0;
- left = argc - 1; ap = argv + 1;
- if (left > 0 && strcmp(ap[0], "!") == 0) {
- neg = 1;
- ap++;
- left--;
- } else
- neg = 0;
-
- expr = -1;
- last_cmp = -1;
- last_expr = -1;
- while (left > 0) {
-
- if (strcmp(ap[0], "-o") == 0 || strcmp(ap[0], "-a") == 0)
- adv = 1;
- else if (strcmp(ap[0], "-z") == 0 || strcmp(ap[0], "-n") == 0)
- adv = 2;
- else
- adv = 3;
-
- if (left < adv) {
- expr = 1;
- break;
- }
-
- if (adv == 1) {
- if (strcmp(ap[0], "-o") == 0) {
- last_expr = expr;
- last_cmp = 0;
- } else if (strcmp(ap[0], "-a") == 0) {
- last_expr = expr;
- last_cmp = 1;
- } else {
- expr = 1;
- break;
- }
- }
-
- if (adv == 2) {
- if (strcmp(ap[0], "-z") == 0)
- expr = strlen(ap[1]) == 0 ? 1 : 0;
- else if (strcmp(ap[0], "-n") == 0)
- expr = strlen(ap[1]) == 0 ? 0 : 1;
- else {
- expr = 1;
- break;
- }
-
- if (last_cmp == 0)
- expr = last_expr || expr;
- else if (last_cmp == 1)
- expr = last_expr && expr;
- last_cmp = -1;
- }
-
- if (adv == 3) {
- if (strcmp(ap[1], "=") == 0)
- expr = strcmp(ap[0], ap[2]) == 0;
- else if (strcmp(ap[1], "!=") == 0)
- expr = strcmp(ap[0], ap[2]) != 0;
- else if (strcmp(ap[1], ">") == 0)
- expr = strcmp(ap[0], ap[2]) > 0;
- else if (strcmp(ap[1], "<") == 0)
- expr = strcmp(ap[0], ap[2]) < 0;
- else if (strcmp(ap[1], "-eq") == 0)
- expr = simple_strtol(ap[0], NULL, 10) == simple_strtol(ap[2], NULL, 10);
- else if (strcmp(ap[1], "-ne") == 0)
- expr = simple_strtol(ap[0], NULL, 10) != simple_strtol(ap[2], NULL, 10);
- else if (strcmp(ap[1], "-lt") == 0)
- expr = simple_strtol(ap[0], NULL, 10) < simple_strtol(ap[2], NULL, 10);
- else if (strcmp(ap[1], "-le") == 0)
- expr = simple_strtol(ap[0], NULL, 10) <= simple_strtol(ap[2], NULL, 10);
- else if (strcmp(ap[1], "-gt") == 0)
- expr = simple_strtol(ap[0], NULL, 10) > simple_strtol(ap[2], NULL, 10);
- else if (strcmp(ap[1], "-ge") == 0)
- expr = simple_strtol(ap[0], NULL, 10) >= simple_strtol(ap[2], NULL, 10);
- else {
- expr = 1;
- break;
- }
-
- if (last_cmp == 0)
- expr = last_expr || expr;
- else if (last_cmp == 1)
- expr = last_expr && expr;
- last_cmp = -1;
- }
-
- ap += adv; left -= adv;
- }
-
- if (neg)
- expr = !expr;
-
- expr = !expr;
-
- debug (": returns %d\n", expr);
-
- return expr;
-}
-
-U_BOOT_CMD(
- test, CONFIG_SYS_MAXARGS, 1, do_test,
- "minimal test like /bin/sh",
- "[args..]"
-);
-
-int
-do_exit (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
-{
- int r;
-
- r = 0;
- if (argc > 1)
- r = simple_strtoul(argv[1], NULL, 10);
-
- return -r - 2;
-}
-
-U_BOOT_CMD(
- exit, 2, 1, do_exit,
- "exit script",
- ""
-);
-
-
-#endif
-
/*
* Use puts() instead of printf() to avoid printf buffer overflow
* for long help messages
@@ -297,39 +97,6 @@ int _do_help (cmd_tbl_t *cmd_start, int cmd_items, cmd_tbl_t * cmdtp, int
return rcode;
}
-int do_help (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
-{
- return _do_help(&__u_boot_cmd_start,
- &__u_boot_cmd_end - &__u_boot_cmd_start,
- cmdtp, flag, argc, argv);
-}
-
-
-U_BOOT_CMD(
- help, CONFIG_SYS_MAXARGS, 1, do_help,
- "print online help",
- "[command ...]\n"
- " - show help information (for 'command')\n"
- "'help' prints online help for the monitor commands.\n\n"
- "Without arguments, it prints a short usage message for all commands.\n\n"
- "To get detailed help information for specific commands you can type\n"
- "'help' with one or more command names as arguments."
-);
-
-/* This does not use the U_BOOT_CMD macro as ? can't be used in symbol names */
-#ifdef CONFIG_SYS_LONGHELP
-cmd_tbl_t __u_boot_cmd_question_mark Struct_Section = {
- "?", CONFIG_SYS_MAXARGS, 1, do_help,
- "alias for 'help'",
- ""
-};
-#else
-cmd_tbl_t __u_boot_cmd_question_mark Struct_Section = {
- "?", CONFIG_SYS_MAXARGS, 1, do_help,
- "alias for 'help'"
-};
-#endif /* CONFIG_SYS_LONGHELP */
-
/***************************************************************************
* find command table entry for a command
*/
diff --git a/common/dlmalloc.c b/common/dlmalloc.c
index ca088a1..735b344 100644
--- a/common/dlmalloc.c
+++ b/common/dlmalloc.c
@@ -1522,11 +1522,6 @@ void *sbrk(ptrdiff_t increment)
return (void *)old;
}
-#ifndef CONFIG_X86
-/*
- * x86 boards use a slightly different init sequence thus they implement
- * their own version of mem_malloc_init()
- */
void mem_malloc_init(ulong start, ulong size)
{
mem_malloc_start = start;
@@ -1535,7 +1530,6 @@ void mem_malloc_init(ulong start, ulong size)
memset((void *)mem_malloc_start, 0, size);
}
-#endif
/* field-extraction macros */
diff --git a/common/env_onenand.c b/common/env_onenand.c
index dcf09de..cf997bf 100644
--- a/common/env_onenand.c
+++ b/common/env_onenand.c
@@ -60,12 +60,18 @@ uchar env_get_char_spec(int index)
void env_relocate_spec(void)
{
struct mtd_info *mtd = &onenand_mtd;
+#ifdef CONFIG_ENV_ADDR_FLEX
+ struct onenand_chip *this = &onenand_chip;
+#endif
loff_t env_addr;
int use_default = 0;
size_t retlen;
env_addr = CONFIG_ENV_ADDR;
-
+#ifdef CONFIG_ENV_ADDR_FLEX
+ if (FLEXONENAND(this))
+ env_addr = CONFIG_ENV_ADDR_FLEX;
+#endif
/* Check OneNAND exist */
if (mtd->writesize)
/* Ignore read fail */
@@ -91,6 +97,9 @@ void env_relocate_spec(void)
int saveenv(void)
{
struct mtd_info *mtd = &onenand_mtd;
+#ifdef CONFIG_ENV_ADDR_FLEX
+ struct onenand_chip *this = &onenand_chip;
+#endif
loff_t env_addr = CONFIG_ENV_ADDR;
struct erase_info instr = {
.callback = NULL,
@@ -98,6 +107,14 @@ int saveenv(void)
size_t retlen;
instr.len = CONFIG_ENV_SIZE;
+#ifdef CONFIG_ENV_ADDR_FLEX
+ if (FLEXONENAND(this)) {
+ env_addr = CONFIG_ENV_ADDR_FLEX;
+ instr.len = CONFIG_ENV_SIZE_FLEX;
+ instr.len <<= onenand_mtd.eraseregions[0].numblocks == 1 ?
+ 1 : 0;
+ }
+#endif
instr.addr = env_addr;
instr.mtd = mtd;
if (mtd->erase(mtd, &instr)) {
diff --git a/common/exports.c b/common/exports.c
index b3b6e1f..60bba75 100644
--- a/common/exports.c
+++ b/common/exports.c
@@ -12,38 +12,34 @@ unsigned long get_version(void)
return XF_VERSION;
}
-void jumptable_init (void)
-{
- int i;
-
- gd->jt = (void **) malloc (XF_MAX * sizeof (void *));
- for (i = 0; i < XF_MAX; i++)
- gd->jt[i] = (void *) dummy;
+/* Reuse _exports.h with a little trickery to avoid bitrot */
+#define EXPORT_FUNC(sym) gd->jt[XF_##sym] = (void *)sym;
- gd->jt[XF_get_version] = (void *) get_version;
- gd->jt[XF_malloc] = (void *) malloc;
- gd->jt[XF_free] = (void *) free;
- gd->jt[XF_getenv] = (void *) getenv;
- gd->jt[XF_setenv] = (void *) setenv;
- gd->jt[XF_get_timer] = (void *) get_timer;
- gd->jt[XF_simple_strtoul] = (void *) simple_strtoul;
- gd->jt[XF_udelay] = (void *) udelay;
- gd->jt[XF_simple_strtol] = (void *) simple_strtol;
- gd->jt[XF_strcmp] = (void *) strcmp;
-#if defined(CONFIG_I386) || defined(CONFIG_PPC)
- gd->jt[XF_install_hdlr] = (void *) irq_install_handler;
- gd->jt[XF_free_hdlr] = (void *) irq_free_handler;
-#endif /* I386 || PPC */
-#if defined(CONFIG_CMD_I2C)
- gd->jt[XF_i2c_write] = (void *) i2c_write;
- gd->jt[XF_i2c_read] = (void *) i2c_read;
+#if !defined(CONFIG_I386) && !defined(CONFIG_PPC)
+# define install_hdlr dummy
+# define free_hdlr dummy
+#else /* kludge for non-standard function naming */
+# define install_hdlr irq_install_handler
+# define free_hdlr irq_free_handler
+#endif
+#ifndef CONFIG_CMD_I2C
+# define i2c_write dummy
+# define i2c_read dummy
#endif
-#ifdef CONFIG_CMD_SPI
- gd->jt[XF_spi_init] = (void *) spi_init;
- gd->jt[XF_spi_setup_slave] = (void *) spi_setup_slave;
- gd->jt[XF_spi_free_slave] = (void *) spi_free_slave;
- gd->jt[XF_spi_claim_bus] = (void *) spi_claim_bus;
- gd->jt[XF_spi_release_bus] = (void *) spi_release_bus;
- gd->jt[XF_spi_xfer] = (void *) spi_xfer;
+#ifndef CONFIG_CMD_SPI
+# define spi_init dummy
+# define spi_setup_slave dummy
+# define spi_free_slave dummy
+# define spi_claim_bus dummy
+# define spi_release_bus dummy
+# define spi_xfer dummy
#endif
+#ifndef CONFIG_HAS_UID
+# define forceenv dummy
+#endif
+
+void jumptable_init(void)
+{
+ gd->jt = malloc(XF_MAX * sizeof(void *));
+#include <_exports.h>
}
diff --git a/common/image.c b/common/image.c
index 6eaf41e..82e7aa4 100644
--- a/common/image.c
+++ b/common/image.c
@@ -148,6 +148,7 @@ static table_entry_t uimage_comp[] = {
{ IH_COMP_BZIP2, "bzip2", "bzip2 compressed", },
{ IH_COMP_GZIP, "gzip", "gzip compressed", },
{ IH_COMP_LZMA, "lzma", "lzma compressed", },
+ { IH_COMP_LZO, "lzo", "lzo compressed", },
{ -1, "", "", },
};
@@ -435,11 +436,7 @@ phys_size_t getenv_bootm_size(void)
char *s = getenv ("bootm_size");
if (s) {
phys_size_t tmp;
-#ifdef CONFIG_SYS_64BIT_STRTOUL
tmp = (phys_size_t)simple_strtoull (s, NULL, 16);
-#else
- tmp = (phys_size_t)simple_strtoul (s, NULL, 16);
-#endif
return tmp;
}
diff --git a/common/usb.c b/common/usb.c
index 87fca70..eef4b34 100644
--- a/common/usb.c
+++ b/common/usb.c
@@ -299,8 +299,8 @@ int usb_set_maxpacket(struct usb_device *dev)
{
int i, ii;
- for (i = 0; i < dev->config.bNumInterfaces; i++)
- for (ii = 0; ii < dev->config.if_desc[i].bNumEndpoints; ii++)
+ for (i = 0; i < dev->config.desc.bNumInterfaces; i++)
+ for (ii = 0; ii < dev->config.if_desc[i].desc.bNumEndpoints; ii++)
usb_set_maxpacket_ep(dev,
&dev->config.if_desc[i].ep_desc[ii]);
@@ -330,14 +330,14 @@ int usb_parse_config(struct usb_device *dev, unsigned char *buffer, int cfgno)
return -1;
}
memcpy(&dev->config, buffer, buffer[0]);
- le16_to_cpus(&(dev->config.wTotalLength));
+ le16_to_cpus(&(dev->config.desc.wTotalLength));
dev->config.no_of_if = 0;
- index = dev->config.bLength;
+ index = dev->config.desc.bLength;
/* Ok the first entry must be a configuration entry,
* now process the others */
head = (struct usb_descriptor_header *) &buffer[index];
- while (index + 1 < dev->config.wTotalLength) {
+ while (index + 1 < dev->config.desc.wTotalLength) {
switch (head->bDescriptorType) {
case USB_DT_INTERFACE:
if (((struct usb_interface_descriptor *) \
@@ -350,7 +350,7 @@ int usb_parse_config(struct usb_device *dev, unsigned char *buffer, int cfgno)
dev->config.if_desc[ifno].no_of_ep = 0;
dev->config.if_desc[ifno].num_altsetting = 1;
curr_if_num =
- dev->config.if_desc[ifno].bInterfaceNumber;
+ dev->config.if_desc[ifno].desc.bInterfaceNumber;
} else {
/* found alternate setting for the interface */
dev->config.if_desc[ifno].num_altsetting++;
@@ -440,10 +440,9 @@ int usb_get_configuration_no(struct usb_device *dev,
{
int result;
unsigned int tmp;
- struct usb_config_descriptor *config;
+ struct usb_configuration_descriptor *config;
-
- config = (struct usb_config_descriptor *)&buffer[0];
+ config = (struct usb_configuration_descriptor *)&buffer[0];
result = usb_get_descriptor(dev, USB_DT_CONFIG, cfgno, buffer, 9);
if (result < 9) {
if (result < 0)
@@ -489,11 +488,11 @@ int usb_set_address(struct usb_device *dev)
*/
int usb_set_interface(struct usb_device *dev, int interface, int alternate)
{
- struct usb_interface_descriptor *if_face = NULL;
+ struct usb_interface *if_face = NULL;
int ret, i;
- for (i = 0; i < dev->config.bNumInterfaces; i++) {
- if (dev->config.if_desc[i].bInterfaceNumber == interface) {
+ for (i = 0; i < dev->config.desc.bNumInterfaces; i++) {
+ if (dev->config.if_desc[i].desc.bInterfaceNumber == interface) {
if_face = &dev->config.if_desc[i];
break;
}
@@ -897,7 +896,7 @@ int usb_new_device(struct usb_device *dev)
usb_parse_config(dev, &tmpbuf[0], 0);
usb_set_maxpacket(dev);
/* we set the default configuration here */
- if (usb_set_configuration(dev, dev->config.bConfigurationValue)) {
+ if (usb_set_configuration(dev, dev->config.desc.bConfigurationValue)) {
printf("failed to set default configuration " \
"len %d, status %lX\n", dev->act_len, dev->status);
return -1;
@@ -1347,21 +1346,21 @@ int usb_hub_configure(struct usb_device *dev)
int usb_hub_probe(struct usb_device *dev, int ifnum)
{
- struct usb_interface_descriptor *iface;
+ struct usb_interface *iface;
struct usb_endpoint_descriptor *ep;
int ret;
iface = &dev->config.if_desc[ifnum];
/* Is it a hub? */
- if (iface->bInterfaceClass != USB_CLASS_HUB)
+ if (iface->desc.bInterfaceClass != USB_CLASS_HUB)
return 0;
/* Some hubs have a subclass of 1, which AFAICT according to the */
/* specs is not defined, but it works */
- if ((iface->bInterfaceSubClass != 0) &&
- (iface->bInterfaceSubClass != 1))
+ if ((iface->desc.bInterfaceSubClass != 0) &&
+ (iface->desc.bInterfaceSubClass != 1))
return 0;
/* Multiple endpoints? What kind of mutant ninja-hub is this? */
- if (iface->bNumEndpoints != 1)
+ if (iface->desc.bNumEndpoints != 1)
return 0;
ep = &iface->ep_desc[0];
/* Output endpoint? Curiousier and curiousier.. */
diff --git a/common/usb_kbd.c b/common/usb_kbd.c
index b458d77..9957dcc 100644
--- a/common/usb_kbd.c
+++ b/common/usb_kbd.c
@@ -229,7 +229,7 @@ int usb_kbd_deregister(void)
static void usb_kbd_setled(struct usb_device *dev)
{
- struct usb_interface_descriptor *iface;
+ struct usb_interface *iface;
iface = &dev->config.if_desc[0];
leds=0;
if(scroll_lock!=0)
@@ -242,7 +242,7 @@ static void usb_kbd_setled(struct usb_device *dev)
leds|=1;
usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
USB_REQ_SET_REPORT, USB_TYPE_CLASS | USB_RECIP_INTERFACE,
- 0x200, iface->bInterfaceNumber,(void *)&leds, 1, 0);
+ 0x200, iface->desc.bInterfaceNumber, (void *)&leds, 1, 0);
}
@@ -348,17 +348,21 @@ static int usb_kbd_irq(struct usb_device *dev)
/* probes the USB device dev for keyboard type */
static int usb_kbd_probe(struct usb_device *dev, unsigned int ifnum)
{
- struct usb_interface_descriptor *iface;
+ struct usb_interface *iface;
struct usb_endpoint_descriptor *ep;
int pipe,maxp;
if (dev->descriptor.bNumConfigurations != 1) return 0;
iface = &dev->config.if_desc[ifnum];
- if (iface->bInterfaceClass != 3) return 0;
- if (iface->bInterfaceSubClass != 1) return 0;
- if (iface->bInterfaceProtocol != 1) return 0;
- if (iface->bNumEndpoints != 1) return 0;
+ if (iface->desc.bInterfaceClass != 3)
+ return 0;
+ if (iface->desc.bInterfaceSubClass != 1)
+ return 0;
+ if (iface->desc.bInterfaceProtocol != 1)
+ return 0;
+ if (iface->desc.bNumEndpoints != 1)
+ return 0;
ep = &iface->ep_desc[0];
@@ -367,9 +371,9 @@ static int usb_kbd_probe(struct usb_device *dev, unsigned int ifnum)
USB_KBD_PRINTF("USB KBD found set protocol...\n");
/* ok, we found a USB Keyboard, install it */
/* usb_kbd_get_hid_desc(dev); */
- usb_set_protocol(dev, iface->bInterfaceNumber, 0);
+ usb_set_protocol(dev, iface->desc.bInterfaceNumber, 0);
USB_KBD_PRINTF("USB KBD found set idle...\n");
- usb_set_idle(dev, iface->bInterfaceNumber, REPEAT_RATE, 0);
+ usb_set_idle(dev, iface->desc.bInterfaceNumber, REPEAT_RATE, 0);
memset(&new[0], 0, 8);
memset(&old[0], 0, 8);
repeat_delay=0;
diff --git a/common/usb_storage.c b/common/usb_storage.c
index 19613f2..a8642c9 100644
--- a/common/usb_storage.c
+++ b/common/usb_storage.c
@@ -168,6 +168,8 @@ int usb_storage_probe(struct usb_device *dev, unsigned int ifnum,
struct us_data *ss);
unsigned long usb_stor_read(int device, unsigned long blknr,
unsigned long blkcnt, void *buffer);
+unsigned long usb_stor_write(int device, unsigned long blknr,
+ unsigned long blkcnt, const void *buffer);
struct usb_device * usb_get_dev_index(int index);
void uhci_show_temp_int_td(void);
@@ -227,6 +229,7 @@ int usb_stor_scan(int mode)
usb_dev_desc[i].dev = i;
usb_dev_desc[i].part_type = PART_TYPE_UNKNOWN;
usb_dev_desc[i].block_read = usb_stor_read;
+ usb_dev_desc[i].block_write = usb_stor_write;
}
usb_max_devs = 0;
@@ -964,6 +967,22 @@ static int usb_read_10(ccb *srb, struct us_data *ss, unsigned long start,
return ss->transport(srb, ss);
}
+static int usb_write_10(ccb *srb, struct us_data *ss, unsigned long start,
+ unsigned short blocks)
+{
+ memset(&srb->cmd[0], 0, 12);
+ srb->cmd[0] = SCSI_WRITE10;
+ srb->cmd[2] = ((unsigned char) (start >> 24)) & 0xff;
+ srb->cmd[3] = ((unsigned char) (start >> 16)) & 0xff;
+ srb->cmd[4] = ((unsigned char) (start >> 8)) & 0xff;
+ srb->cmd[5] = ((unsigned char) (start)) & 0xff;
+ srb->cmd[7] = ((unsigned char) (blocks >> 8)) & 0xff;
+ srb->cmd[8] = (unsigned char) blocks & 0xff;
+ srb->cmdlen = 12;
+ USB_STOR_PRINTF("write10: start %lx blocks %x\n", start, blocks);
+ return ss->transport(srb, ss);
+}
+
#ifdef CONFIG_USB_BIN_FIXUP
/*
@@ -1065,12 +1084,92 @@ retry_it:
return blkcnt;
}
+#define USB_MAX_WRITE_BLK 20
+
+unsigned long usb_stor_write(int device, unsigned long blknr,
+ unsigned long blkcnt, const void *buffer)
+{
+ unsigned long start, blks, buf_addr;
+ unsigned short smallblks;
+ struct usb_device *dev;
+ int retry, i;
+ ccb *srb = &usb_ccb;
+
+ if (blkcnt == 0)
+ return 0;
+
+ device &= 0xff;
+ /* Setup device */
+ USB_STOR_PRINTF("\nusb_write: dev %d \n", device);
+ dev = NULL;
+ for (i = 0; i < USB_MAX_DEVICE; i++) {
+ dev = usb_get_dev_index(i);
+ if (dev == NULL)
+ return 0;
+ if (dev->devnum == usb_dev_desc[device].target)
+ break;
+ }
+
+ usb_disable_asynch(1); /* asynch transfer not allowed */
+
+ srb->lun = usb_dev_desc[device].lun;
+ buf_addr = (unsigned long)buffer;
+ start = blknr;
+ blks = blkcnt;
+ if (usb_test_unit_ready(srb, (struct us_data *)dev->privptr)) {
+ printf("Device NOT ready\n Request Sense returned %02X %02X"
+ " %02X\n", srb->sense_buf[2], srb->sense_buf[12],
+ srb->sense_buf[13]);
+ return 0;
+ }
+
+ USB_STOR_PRINTF("\nusb_write: dev %d startblk %lx, blccnt %lx"
+ " buffer %lx\n", device, start, blks, buf_addr);
+
+ do {
+ /* If write fails retry for max retry count else
+ * return with number of blocks written successfully.
+ */
+ retry = 2;
+ srb->pdata = (unsigned char *)buf_addr;
+ if (blks > USB_MAX_WRITE_BLK)
+ smallblks = USB_MAX_WRITE_BLK;
+ else
+ smallblks = (unsigned short) blks;
+retry_it:
+ if (smallblks == USB_MAX_WRITE_BLK)
+ usb_show_progress();
+ srb->datalen = usb_dev_desc[device].blksz * smallblks;
+ srb->pdata = (unsigned char *)buf_addr;
+ if (usb_write_10(srb, (struct us_data *)dev->privptr, start,
+ smallblks)) {
+ USB_STOR_PRINTF("Write ERROR\n");
+ usb_request_sense(srb, (struct us_data *)dev->privptr);
+ if (retry--)
+ goto retry_it;
+ blkcnt -= blks;
+ break;
+ }
+ start += smallblks;
+ blks -= smallblks;
+ buf_addr += srb->datalen;
+ } while (blks != 0);
+
+ USB_STOR_PRINTF("usb_write: end startblk %lx, blccnt %x buffer %lx\n",
+ start, smallblks, buf_addr);
+
+ usb_disable_asynch(0); /* asynch transfer allowed */
+ if (blkcnt >= USB_MAX_WRITE_BLK)
+ printf("\n");
+ return blkcnt;
+
+}
/* Probe to see if a new device is actually a Storage device */
int usb_storage_probe(struct usb_device *dev, unsigned int ifnum,
struct us_data *ss)
{
- struct usb_interface_descriptor *iface;
+ struct usb_interface *iface;
int i;
unsigned int flags = 0;
@@ -1094,9 +1193,9 @@ int usb_storage_probe(struct usb_device *dev, unsigned int ifnum,
#endif
if (dev->descriptor.bDeviceClass != 0 ||
- iface->bInterfaceClass != USB_CLASS_MASS_STORAGE ||
- iface->bInterfaceSubClass < US_SC_MIN ||
- iface->bInterfaceSubClass > US_SC_MAX) {
+ iface->desc.bInterfaceClass != USB_CLASS_MASS_STORAGE ||
+ iface->desc.bInterfaceSubClass < US_SC_MIN ||
+ iface->desc.bInterfaceSubClass > US_SC_MAX) {
/* if it's not a mass storage, we go no further */
return 0;
}
@@ -1119,8 +1218,8 @@ int usb_storage_probe(struct usb_device *dev, unsigned int ifnum,
ss->subclass = subclass;
ss->protocol = protocol;
} else {
- ss->subclass = iface->bInterfaceSubClass;
- ss->protocol = iface->bInterfaceProtocol;
+ ss->subclass = iface->desc.bInterfaceSubClass;
+ ss->protocol = iface->desc.bInterfaceProtocol;
}
/* set the handler pointers based on the protocol */
@@ -1153,7 +1252,7 @@ int usb_storage_probe(struct usb_device *dev, unsigned int ifnum,
* An optional interrupt is OK (necessary for CBI protocol).
* We will ignore any others.
*/
- for (i = 0; i < iface->bNumEndpoints; i++) {
+ for (i = 0; i < iface->desc.bNumEndpoints; i++) {
/* is it an BULK endpoint? */
if ((iface->ep_desc[i].bmAttributes &
USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_BULK) {
@@ -1178,7 +1277,7 @@ int usb_storage_probe(struct usb_device *dev, unsigned int ifnum,
ss->ep_in, ss->ep_out, ss->ep_int);
/* Do some basic sanity checks, and bail if we find a problem */
- if (usb_set_interface(dev, iface->bInterfaceNumber, 0) ||
+ if (usb_set_interface(dev, iface->desc.bInterfaceNumber, 0) ||
!ss->ep_in || !ss->ep_out ||
(ss->protocol == US_PR_CBI && ss->ep_int == 0)) {
USB_STOR_PRINTF("Problems with device\n");