summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorWolfgang Denk <wd@denx.de>2010-12-22 21:16:17 +0100
committerWolfgang Denk <wd@denx.de>2010-12-22 21:16:17 +0100
commitcdc51c294ad33879c4e57edf4c9d2155381b1d59 (patch)
treefc1c3f2c23a2507e91358a6a6dfa881965bf603f /common
parent250ef029844be2cb98635f265359396866d1749f (diff)
parentb8339e2b9f32663411dba0f48e25b23f542d53bc (diff)
downloadu-boot-imx-cdc51c294ad33879c4e57edf4c9d2155381b1d59.zip
u-boot-imx-cdc51c294ad33879c4e57edf4c9d2155381b1d59.tar.gz
u-boot-imx-cdc51c294ad33879c4e57edf4c9d2155381b1d59.tar.bz2
Merge branch 'next' of ../next
Diffstat (limited to 'common')
-rw-r--r--common/cmd_boot.c2
-rw-r--r--common/cmd_bootm.c1
-rw-r--r--common/cmd_date.c8
-rw-r--r--common/cmd_fdc.c4
-rw-r--r--common/cmd_fdos.c3
-rw-r--r--common/cmd_ide.c3
-rw-r--r--common/cmd_itest.c8
-rw-r--r--common/cmd_mii.c68
-rw-r--r--common/cmd_nand.c5
-rw-r--r--common/cmd_net.c4
-rw-r--r--common/cmd_nvedit.c38
-rw-r--r--common/cmd_onenand.c41
-rw-r--r--common/cmd_scsi.c3
-rw-r--r--common/cmd_usb.c3
-rw-r--r--common/command.c24
-rw-r--r--common/console.c4
-rw-r--r--common/env_common.c6
-rw-r--r--common/env_dataflash.c2
-rw-r--r--common/env_eeprom.c2
-rw-r--r--common/env_flash.c4
-rw-r--r--common/env_mmc.c2
-rw-r--r--common/env_nand.c4
-rw-r--r--common/env_nvram.c2
-rw-r--r--common/env_onenand.c2
-rw-r--r--common/env_sf.c4
-rw-r--r--common/hush.c8
-rw-r--r--common/image.c14
-rw-r--r--common/main.c10
-rw-r--r--common/stdio.c4
29 files changed, 129 insertions, 154 deletions
diff --git a/common/cmd_boot.c b/common/cmd_boot.c
index 72dacaa..7b603d3 100644
--- a/common/cmd_boot.c
+++ b/common/cmd_boot.c
@@ -67,8 +67,6 @@ U_BOOT_CMD(
" passing 'arg' as arguments"
);
-extern int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
-
U_BOOT_CMD(
reset, 1, 0, do_reset,
"Perform RESET of the CPU",
diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c
index 1a024f1..9873ee7 100644
--- a/common/cmd_bootm.c
+++ b/common/cmd_bootm.c
@@ -93,7 +93,6 @@ static int fit_check_kernel (const void *fit, int os_noffset, int verify);
static void *boot_get_kernel (cmd_tbl_t *cmdtp, int flag,int argc, char * const argv[],
bootm_headers_t *images, ulong *os_data, ulong *os_len);
-extern int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
/*
* Continue booting an OS image; caller already has:
diff --git a/common/cmd_date.c b/common/cmd_date.c
index 8dbf16d..f0fa02a 100644
--- a/common/cmd_date.c
+++ b/common/cmd_date.c
@@ -31,7 +31,7 @@
DECLARE_GLOBAL_DATA_PTR;
-const char *weekdays[] = {
+static const char * const weekdays[] = {
"Sun", "Mon", "Tues", "Wednes", "Thurs", "Fri", "Satur",
};
@@ -41,7 +41,7 @@ const char *weekdays[] = {
#define RELOC(a) a
#endif
-int mk_date (char *, struct rtc_time *);
+int mk_date (const char *, struct rtc_time *);
int do_date (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
@@ -106,7 +106,7 @@ int do_date (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
/*
* simple conversion of two-digit string with error checking
*/
-static int cnvrt2 (char *str, int *valp)
+static int cnvrt2 (const char *str, int *valp)
{
int val;
@@ -131,7 +131,7 @@ static int cnvrt2 (char *str, int *valp)
* Some basic checking for valid values is done, but this will not catch
* all possible error conditions.
*/
-int mk_date (char *datestr, struct rtc_time *tmp)
+int mk_date (const char *datestr, struct rtc_time *tmp)
{
int len, val;
char *ptr;
diff --git a/common/cmd_fdc.c b/common/cmd_fdc.c
index 831a07f..d373480 100644
--- a/common/cmd_fdc.c
+++ b/common/cmd_fdc.c
@@ -721,7 +721,6 @@ int do_fdcboot (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
image_header_t *hdr; /* used for fdc boot */
unsigned char boot_drive;
int i,nrofblk;
- char *ep;
int rcode = 0;
#if defined(CONFIG_FIT)
const void *fit_hdr = NULL;
@@ -824,9 +823,8 @@ int do_fdcboot (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
load_addr = addr;
/* Check if we should attempt an auto-start */
- if (((ep = getenv("autostart")) != NULL) && (strcmp(ep,"yes") == 0)) {
+ if (getenv_yesno("autostart")) {
char *local_args[2];
- extern int do_bootm (cmd_tbl_t *, int, int, char *[]);
local_args[0] = argv[0];
local_args[1] = NULL;
diff --git a/common/cmd_fdos.c b/common/cmd_fdos.c
index a8822d9..238abdd 100644
--- a/common/cmd_fdos.c
+++ b/common/cmd_fdos.c
@@ -99,9 +99,8 @@ int do_fdosboot(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
size, load_addr);
/* Check if we should attempt an auto-start */
- if (((ep = getenv("autostart")) != NULL) && (strcmp(ep,"yes") == 0)) {
+ if (getenv_yesno("autostart")) {
char *local_args[2];
- extern int do_bootm (cmd_tbl_t *, int, int, char *[]);
local_args[0] = argv[0];
local_args[1] = NULL;
printf ("Automatic boot of image at addr 0x%08lX ...\n", load_addr);
diff --git a/common/cmd_ide.c b/common/cmd_ide.c
index ea0f4a7..f627881 100644
--- a/common/cmd_ide.c
+++ b/common/cmd_ide.c
@@ -496,9 +496,8 @@ int do_diskboot (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
load_addr = addr;
/* Check if we should attempt an auto-start */
- if (((ep = getenv("autostart")) != NULL) && (strcmp(ep,"yes") == 0)) {
+ if (getenv_yesno("autostart")) {
char *local_args[2];
- extern int do_bootm (cmd_tbl_t *, int, int, char *[]);
local_args[0] = argv[0];
local_args[1] = NULL;
diff --git a/common/cmd_itest.c b/common/cmd_itest.c
index 8dd8927..fa6a0c3 100644
--- a/common/cmd_itest.c
+++ b/common/cmd_itest.c
@@ -46,7 +46,7 @@ struct op_tbl_s {
typedef struct op_tbl_s op_tbl_t;
-op_tbl_t op_table [] = {
+static const op_tbl_t op_table [] = {
{ "-lt", LT },
{ "<" , LT },
{ "-gt", GT },
@@ -62,8 +62,6 @@ op_tbl_t op_table [] = {
{ "<=" , LE },
};
-#define op_tbl_size (sizeof(op_table)/sizeof(op_table[0]))
-
static long evalexp(char *s, int w)
{
long l = 0;
@@ -138,12 +136,12 @@ static int arithcomp (char *s, char *t, int op, int w)
int binary_test (char *op, char *arg1, char *arg2, int w)
{
int len, i;
- op_tbl_t *optp;
+ const op_tbl_t *optp;
len = strlen(op);
for (optp = (op_tbl_t *)&op_table, i = 0;
- i < op_tbl_size;
+ i < ARRAY_SIZE(op_table);
optp++, i++) {
if ((strncmp (op, optp->op, len) == 0) && (len == strlen (optp->op))) {
diff --git a/common/cmd_mii.c b/common/cmd_mii.c
index 3ea493b..3fb0795 100644
--- a/common/cmd_mii.c
+++ b/common/cmd_mii.c
@@ -34,7 +34,7 @@ typedef struct _MII_reg_desc_t {
char * name;
} MII_reg_desc_t;
-MII_reg_desc_t reg_0_5_desc_tbl[] = {
+static const MII_reg_desc_t reg_0_5_desc_tbl[] = {
{ 0, "PHY control register" },
{ 1, "PHY status register" },
{ 2, "PHY ID 1 register" },
@@ -50,7 +50,7 @@ typedef struct _MII_field_desc_t {
char * name;
} MII_field_desc_t;
-MII_field_desc_t reg_0_desc_tbl[] = {
+static const MII_field_desc_t reg_0_desc_tbl[] = {
{ 15, 15, 0x01, "reset" },
{ 14, 14, 0x01, "loopback" },
{ 13, 6, 0x81, "speed selection" }, /* special */
@@ -63,7 +63,7 @@ MII_field_desc_t reg_0_desc_tbl[] = {
{ 5, 0, 0x3f, "(reserved)" }
};
-MII_field_desc_t reg_1_desc_tbl[] = {
+static const MII_field_desc_t reg_1_desc_tbl[] = {
{ 15, 15, 0x01, "100BASE-T4 able" },
{ 14, 14, 0x01, "100BASE-X full duplex able" },
{ 13, 13, 0x01, "100BASE-X half duplex able" },
@@ -82,17 +82,17 @@ MII_field_desc_t reg_1_desc_tbl[] = {
{ 0, 0, 0x01, "extended capabilities" },
};
-MII_field_desc_t reg_2_desc_tbl[] = {
+static const MII_field_desc_t reg_2_desc_tbl[] = {
{ 15, 0, 0xffff, "OUI portion" },
};
-MII_field_desc_t reg_3_desc_tbl[] = {
+static const MII_field_desc_t reg_3_desc_tbl[] = {
{ 15, 10, 0x3f, "OUI portion" },
{ 9, 4, 0x3f, "manufacturer part number" },
{ 3, 0, 0x0f, "manufacturer rev. number" },
};
-MII_field_desc_t reg_4_desc_tbl[] = {
+static const MII_field_desc_t reg_4_desc_tbl[] = {
{ 15, 15, 0x01, "next page able" },
{ 14, 14, 0x01, "reserved" },
{ 13, 13, 0x01, "remote fault" },
@@ -107,7 +107,7 @@ MII_field_desc_t reg_4_desc_tbl[] = {
{ 4, 0, 0x1f, "xxx to do" },
};
-MII_field_desc_t reg_5_desc_tbl[] = {
+static const MII_field_desc_t reg_5_desc_tbl[] = {
{ 15, 15, 0x01, "next page able" },
{ 14, 14, 0x01, "acknowledge" },
{ 13, 13, 0x01, "remote fault" },
@@ -121,39 +121,31 @@ MII_field_desc_t reg_5_desc_tbl[] = {
{ 5, 5, 0x01, "10BASE-T able" },
{ 4, 0, 0x1f, "xxx to do" },
};
-
-#define DESC0LEN (sizeof(reg_0_desc_tbl)/sizeof(reg_0_desc_tbl[0]))
-#define DESC1LEN (sizeof(reg_1_desc_tbl)/sizeof(reg_1_desc_tbl[0]))
-#define DESC2LEN (sizeof(reg_2_desc_tbl)/sizeof(reg_2_desc_tbl[0]))
-#define DESC3LEN (sizeof(reg_3_desc_tbl)/sizeof(reg_3_desc_tbl[0]))
-#define DESC4LEN (sizeof(reg_4_desc_tbl)/sizeof(reg_4_desc_tbl[0]))
-#define DESC5LEN (sizeof(reg_5_desc_tbl)/sizeof(reg_5_desc_tbl[0]))
-
typedef struct _MII_field_desc_and_len_t {
- MII_field_desc_t * pdesc;
+ const MII_field_desc_t *pdesc;
ushort len;
} MII_field_desc_and_len_t;
-MII_field_desc_and_len_t desc_and_len_tbl[] = {
- { reg_0_desc_tbl, DESC0LEN },
- { reg_1_desc_tbl, DESC1LEN },
- { reg_2_desc_tbl, DESC2LEN },
- { reg_3_desc_tbl, DESC3LEN },
- { reg_4_desc_tbl, DESC4LEN },
- { reg_5_desc_tbl, DESC5LEN },
+static const MII_field_desc_and_len_t desc_and_len_tbl[] = {
+ { reg_0_desc_tbl, ARRAY_SIZE(reg_0_desc_tbl) },
+ { reg_1_desc_tbl, ARRAY_SIZE(reg_1_desc_tbl) },
+ { reg_2_desc_tbl, ARRAY_SIZE(reg_2_desc_tbl) },
+ { reg_3_desc_tbl, ARRAY_SIZE(reg_3_desc_tbl) },
+ { reg_4_desc_tbl, ARRAY_SIZE(reg_4_desc_tbl) },
+ { reg_5_desc_tbl, ARRAY_SIZE(reg_5_desc_tbl) },
};
static void dump_reg(
ushort regval,
- MII_reg_desc_t * prd,
- MII_field_desc_and_len_t * pdl);
+ const MII_reg_desc_t *prd,
+ const MII_field_desc_and_len_t *pdl);
static int special_field(
ushort regno,
- MII_field_desc_t * pdesc,
+ const MII_field_desc_t *pdesc,
ushort regval);
-void MII_dump_0_to_5(
+static void MII_dump_0_to_5(
ushort regvals[6],
uchar reglo,
uchar reghi)
@@ -169,12 +161,12 @@ void MII_dump_0_to_5(
static void dump_reg(
ushort regval,
- MII_reg_desc_t * prd,
- MII_field_desc_and_len_t * pdl)
+ const MII_reg_desc_t *prd,
+ const MII_field_desc_and_len_t *pdl)
{
ulong i;
ushort mask_in_place;
- MII_field_desc_t * pdesc;
+ const MII_field_desc_t *pdesc;
printf("%u. (%04hx) -- %s --\n",
prd->regno, regval, prd->name);
@@ -217,7 +209,7 @@ static void dump_reg(
static int special_field(
ushort regno,
- MII_field_desc_t * pdesc,
+ const MII_field_desc_t *pdesc,
ushort regval)
{
if ((regno == 0) && (pdesc->lo == 6)) {
@@ -268,12 +260,12 @@ static int special_field(
return 0;
}
-char last_op[2];
-uint last_data;
-uint last_addr_lo;
-uint last_addr_hi;
-uint last_reg_lo;
-uint last_reg_hi;
+static char last_op[2];
+static uint last_data;
+static uint last_addr_lo;
+static uint last_addr_hi;
+static uint last_reg_lo;
+static uint last_reg_hi;
static void extract_range(
char * input,
@@ -292,7 +284,7 @@ static void extract_range(
}
/* ---------------------------------------------------------------- */
-int do_mii (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
+static int do_mii(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
char op[2];
unsigned char addrlo, addrhi, reglo, reghi;
diff --git a/common/cmd_nand.c b/common/cmd_nand.c
index 634d036..c547a68 100644
--- a/common/cmd_nand.c
+++ b/common/cmd_nand.c
@@ -711,7 +711,7 @@ static int nand_load_image(cmd_tbl_t *cmdtp, nand_info_t *nand,
ulong offset, ulong addr, char *cmd)
{
int r;
- char *ep, *s;
+ char *s;
size_t cnt;
image_header_t *hdr;
#if defined(CONFIG_FIT)
@@ -787,9 +787,8 @@ static int nand_load_image(cmd_tbl_t *cmdtp, nand_info_t *nand,
load_addr = addr;
/* Check if we should attempt an auto-start */
- if (((ep = getenv("autostart")) != NULL) && (strcmp(ep, "yes") == 0)) {
+ if (getenv_yesno("autostart")) {
char *local_args[2];
- extern int do_bootm(cmd_tbl_t *, int, int, char *[]);
local_args[0] = cmd;
local_args[1] = NULL;
diff --git a/common/cmd_net.c b/common/cmd_net.c
index 44d17db..973fa21 100644
--- a/common/cmd_net.c
+++ b/common/cmd_net.c
@@ -28,8 +28,6 @@
#include <command.h>
#include <net.h>
-extern int do_bootm (cmd_tbl_t *, int, int, char * const []);
-
static int netboot_common (proto_t, cmd_tbl_t *, int , char * const []);
int do_bootp (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
@@ -213,7 +211,7 @@ netboot_common (proto_t proto, cmd_tbl_t *cmdtp, int argc, char * const argv[])
flush_cache(load_addr, size);
/* Loading ok, check if we should attempt an auto-start */
- if (((s = getenv("autostart")) != NULL) && (strcmp(s,"yes") == 0)) {
+ if (getenv_yesno("autostart")) {
char *local_args[2];
local_args[0] = argv[0];
local_args[1] = NULL;
diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c
index dcc93c1..f8c7976 100644
--- a/common/cmd_nvedit.c
+++ b/common/cmd_nvedit.c
@@ -111,7 +111,7 @@ static int env_print(char *name)
e.key = name;
e.data = NULL;
- ep = hsearch (e, FIND);
+ hsearch_r(e, FIND, &ep, &env_htab);
if (ep == NULL)
return 0;
len = printf ("%s=%s\n", ep->key, ep->data);
@@ -119,7 +119,7 @@ static int env_print(char *name)
}
/* print whole list */
- len = hexport('\n', &res, 0);
+ len = hexport_r(&env_htab, '\n', &res, 0);
if (len > 0) {
puts(res);
@@ -184,7 +184,7 @@ int _do_env_set (int flag, int argc, char * const argv[])
*/
e.key = name;
e.data = NULL;
- ep = hsearch (e, FIND);
+ hsearch_r(e, FIND, &ep, &env_htab);
/* Check for console redirection */
if (strcmp(name,"stdin") == 0) {
@@ -267,7 +267,7 @@ int _do_env_set (int flag, int argc, char * const argv[])
/* Delete only ? */
if ((argc < 3) || argv[2] == NULL) {
- int rc = hdelete(name);
+ int rc = hdelete_r(name, &env_htab);
return !rc;
}
@@ -293,7 +293,7 @@ int _do_env_set (int flag, int argc, char * const argv[])
e.key = name;
e.data = value;
- ep = hsearch(e, ENTER);
+ hsearch_r(e, ENTER, &ep, &env_htab);
free(value);
if (!ep) {
printf("## Error inserting \"%s\" variable, errno=%d\n",
@@ -456,7 +456,7 @@ char *getenv (char *name)
e.key = name;
e.data = NULL;
- ep = hsearch (e, FIND);
+ hsearch_r(e, FIND, &ep, &env_htab);
return (ep ? ep->data : NULL);
}
@@ -651,7 +651,7 @@ static int do_env_export(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv
}
if (sep) { /* export as text file */
- len = hexport(sep, &addr, size);
+ len = hexport_r(&env_htab, sep, &addr, size);
if (len < 0) {
error("Cannot export environment: errno = %d\n",
errno);
@@ -670,7 +670,7 @@ static int do_env_export(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv
else /* export as raw binary data */
res = addr;
- len = hexport('\0', &res, ENV_SIZE);
+ len = hexport_r(&env_htab, '\0', &res, ENV_SIZE);
if (len < 0) {
error("Cannot export environment: errno = %d\n",
errno);
@@ -790,7 +790,7 @@ static int do_env_import(cmd_tbl_t * cmdtp, int flag, int argc, char * const arg
addr = (char *)ep->data;
}
- if (himport(addr, size, sep, del ? 0 : H_NOCLEAR) == 0) {
+ if (himport_r(&env_htab, addr, size, sep, del ? 0 : H_NOCLEAR) == 0) {
error("Environment import failed: errno = %d\n", errno);
return 1;
}
@@ -883,29 +883,32 @@ U_BOOT_CMD(
*/
#if defined(CONFIG_CMD_EDITENV)
-U_BOOT_CMD(
+U_BOOT_CMD_COMPLETE(
editenv, 2, 0, do_env_edit,
"edit environment variable",
"name\n"
- " - edit environment variable 'name'"
+ " - edit environment variable 'name'",
+ var_complete
);
#endif
-U_BOOT_CMD(
+U_BOOT_CMD_COMPLETE(
printenv, CONFIG_SYS_MAXARGS, 1, do_env_print,
"print environment variables",
"\n - print values of all environment variables\n"
"printenv name ...\n"
- " - print value of environment variable 'name'"
+ " - print value of environment variable 'name'",
+ var_complete
);
-U_BOOT_CMD(
+U_BOOT_CMD_COMPLETE(
setenv, CONFIG_SYS_MAXARGS, 0, do_env_set,
"set environment variables",
"name value ...\n"
" - set environment variable 'name' to 'value ...'\n"
"setenv name\n"
- " - delete environment variable 'name'"
+ " - delete environment variable 'name'",
+ var_complete
);
#if defined(CONFIG_CMD_ASKENV)
@@ -926,10 +929,11 @@ U_BOOT_CMD(
#endif
#if defined(CONFIG_CMD_RUN)
-U_BOOT_CMD(
+U_BOOT_CMD_COMPLETE(
run, CONFIG_SYS_MAXARGS, 1, do_run,
"run commands in an environment variable",
"var [...]\n"
- " - run the commands in the environment variable(s) 'var'"
+ " - run the commands in the environment variable(s) 'var'",
+ var_complete
);
#endif
diff --git a/common/cmd_onenand.c b/common/cmd_onenand.c
index cb2ba70..a27adaa 100644
--- a/common/cmd_onenand.c
+++ b/common/cmd_onenand.c
@@ -112,8 +112,32 @@ static int onenand_block_read(loff_t from, size_t len,
return 0;
}
+static int onenand_write_oneblock_withoob(loff_t to, const u_char * buf,
+ size_t *retlen)
+{
+ struct mtd_oob_ops ops = {
+ .len = mtd->writesize,
+ .ooblen = mtd->oobsize,
+ .mode = MTD_OOB_AUTO,
+ };
+ int page, ret = 0;
+ for (page = 0; page < (mtd->erasesize / mtd->writesize); page ++) {
+ ops.datbuf = (u_char *)buf;
+ buf += mtd->writesize;
+ ops.oobbuf = (u_char *)buf;
+ buf += mtd->oobsize;
+ ret = mtd->write_oob(mtd, to, &ops);
+ if (ret)
+ break;
+ to += mtd->writesize;
+ }
+
+ *retlen = (ret) ? 0 : mtd->erasesize;
+ return ret;
+}
+
static int onenand_block_write(loff_t to, size_t len,
- size_t *retlen, const u_char * buf)
+ size_t *retlen, const u_char * buf, int withoob)
{
struct onenand_chip *this = mtd->priv;
int blocks = len >> this->erase_shift;
@@ -140,7 +164,10 @@ static int onenand_block_write(loff_t to, size_t len,
goto next;
}
- ret = mtd->write(mtd, ofs, blocksize, &_retlen, buf);
+ if (!withoob)
+ ret = mtd->write(mtd, ofs, blocksize, &_retlen, buf);
+ else
+ ret = onenand_write_oneblock_withoob(ofs, buf, &_retlen);
if (ret) {
printk("Write failed 0x%x, %d", (u32)ofs, ret);
skip_ofs += blocksize;
@@ -386,19 +413,22 @@ static int do_onenand_write(cmd_tbl_t * cmdtp, int flag, int argc, char * const
{
ulong addr, ofs;
size_t len;
- int ret = 0;
+ int ret = 0, withoob = 0;
size_t retlen = 0;
if (argc < 3)
return cmd_usage(cmdtp);
+ if (strncmp(argv[0] + 6, "yaffs", 5) == 0)
+ withoob = 1;
+
addr = (ulong)simple_strtoul(argv[1], NULL, 16);
printf("\nOneNAND write: ");
if (arg_off_size(argc - 2, argv + 2, &ofs, &len) != 0)
return 1;
- ret = onenand_block_write(ofs, len, &retlen, (u8 *)addr);
+ ret = onenand_block_write(ofs, len, &retlen, (u8 *)addr, withoob);
printf(" %d bytes written: %s\n", retlen, ret ? "ERROR" : "OK");
@@ -521,6 +551,7 @@ static cmd_tbl_t cmd_onenand_sub[] = {
U_BOOT_CMD_MKENT(bad, 1, 0, do_onenand_bad, "", ""),
U_BOOT_CMD_MKENT(read, 4, 0, do_onenand_read, "", ""),
U_BOOT_CMD_MKENT(write, 4, 0, do_onenand_write, "", ""),
+ U_BOOT_CMD_MKENT(write.yaffs, 4, 0, do_onenand_write, "", ""),
U_BOOT_CMD_MKENT(erase, 3, 0, do_onenand_erase, "", ""),
U_BOOT_CMD_MKENT(test, 3, 0, do_onenand_test, "", ""),
U_BOOT_CMD_MKENT(dump, 2, 0, do_onenand_dump, "", ""),
@@ -560,7 +591,7 @@ U_BOOT_CMD(
"info - show available OneNAND devices\n"
"onenand bad - show bad blocks\n"
"onenand read[.oob] addr off size\n"
- "onenand write addr off size\n"
+ "onenand write[.yaffs] addr off size\n"
" read/write 'size' bytes starting at offset 'off'\n"
" to/from memory address 'addr', skipping bad blocks.\n"
"onenand erase [force] [off size] - erase 'size' bytes from\n"
diff --git a/common/cmd_scsi.c b/common/cmd_scsi.c
index 6b937f9..63a46de 100644
--- a/common/cmd_scsi.c
+++ b/common/cmd_scsi.c
@@ -327,9 +327,8 @@ int do_scsiboot (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
flush_cache (addr, (cnt+1)*info.blksz);
/* Check if we should attempt an auto-start */
- if (((ep = getenv("autostart")) != NULL) && (strcmp(ep,"yes") == 0)) {
+ if (getenv_yesno("autostart")) {
char *local_args[2];
- extern int do_bootm (cmd_tbl_t *, int, int, char *[]);
local_args[0] = argv[0];
local_args[1] = NULL;
printf ("Automatic boot of image at addr 0x%08lX ...\n", addr);
diff --git a/common/cmd_usb.c b/common/cmd_usb.c
index 226ea0d..8439198 100644
--- a/common/cmd_usb.c
+++ b/common/cmd_usb.c
@@ -488,9 +488,8 @@ int do_usbboot(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
flush_cache(addr, (cnt+1)*info.blksz);
/* Check if we should attempt an auto-start */
- if (((ep = getenv("autostart")) != NULL) && (strcmp(ep, "yes") == 0)) {
+ if (getenv_yesno("autostart")) {
char *local_args[2];
- extern int do_bootm(cmd_tbl_t *, int, int, char *[]);
local_args[0] = argv[0];
local_args[1] = NULL;
printf("Automatic boot of image at addr 0x%08lX ...\n", addr);
diff --git a/common/command.c b/common/command.c
index 0b1a3fb..ef4a081 100644
--- a/common/command.c
+++ b/common/command.c
@@ -177,30 +177,6 @@ int var_complete(int argc, char * const argv[], char last_char, int maxv, char *
return 0;
}
-static void install_auto_complete_handler(const char *cmd,
- int (*complete)(int argc, char * const argv[], char last_char, int maxv, char *cmdv[]))
-{
- cmd_tbl_t *cmdtp;
-
- cmdtp = find_cmd(cmd);
- if (cmdtp == NULL)
- return;
-
- cmdtp->complete = complete;
-}
-
-void install_auto_complete(void)
-{
-#if defined(CONFIG_CMD_EDITENV)
- install_auto_complete_handler("editenv", var_complete);
-#endif
- install_auto_complete_handler("printenv", var_complete);
- install_auto_complete_handler("setenv", var_complete);
-#if defined(CONFIG_CMD_RUN)
- install_auto_complete_handler("run", var_complete);
-#endif
-}
-
/*************************************************************************************/
static int complete_cmdv(int argc, char * const argv[], char last_char, int maxv, char *cmdv[])
diff --git a/common/console.c b/common/console.c
index 7e01886..8c650e0 100644
--- a/common/console.c
+++ b/common/console.c
@@ -479,7 +479,7 @@ inline void dbg(const char *fmt, ...)
/** U-Boot INIT FUNCTIONS *************************************************/
-struct stdio_dev *search_device(int flags, char *name)
+struct stdio_dev *search_device(int flags, const char *name)
{
struct stdio_dev *dev;
@@ -491,7 +491,7 @@ struct stdio_dev *search_device(int flags, char *name)
return NULL;
}
-int console_assign(int file, char *devname)
+int console_assign(int file, const char *devname)
{
int flag;
struct stdio_dev *dev;
diff --git a/common/env_common.c b/common/env_common.c
index a276efc..ae710e5 100644
--- a/common/env_common.c
+++ b/common/env_common.c
@@ -129,6 +129,8 @@ uchar default_environment[] = {
"\0"
};
+struct hsearch_data env_htab;
+
static uchar env_get_char_init (int index)
{
uchar c;
@@ -187,7 +189,7 @@ void set_default_env(const char *s)
puts("Using default environment\n\n");
}
- if (himport((char *)default_environment,
+ if (himport_r(&env_htab, (char *)default_environment,
sizeof(default_environment), '\0', 0) == 0) {
error("Environment import failed: errno = %d\n", errno);
}
@@ -213,7 +215,7 @@ int env_import(const char *buf, int check)
}
}
- if (himport((char *)ep->data, ENV_SIZE, '\0', 0)) {
+ if (himport_r(&env_htab, (char *)ep->data, ENV_SIZE, '\0', 0)) {
gd->flags |= GD_FLG_ENV_READY;
return 1;
}
diff --git a/common/env_dataflash.c b/common/env_dataflash.c
index 270f2b3..1d57079 100644
--- a/common/env_dataflash.c
+++ b/common/env_dataflash.c
@@ -68,7 +68,7 @@ int saveenv(void)
char *res;
res = (char *)&env_new.data;
- len = hexport('\0', &res, ENV_SIZE);
+ len = hexport_r(&env_htab, '\0', &res, ENV_SIZE);
if (len < 0) {
error("Cannot export environment: errno = %d\n", errno);
return 1;
diff --git a/common/env_eeprom.c b/common/env_eeprom.c
index 792b44f..0a179ad 100644
--- a/common/env_eeprom.c
+++ b/common/env_eeprom.c
@@ -143,7 +143,7 @@ int saveenv(void)
BUG_ON(env_ptr != NULL);
res = (char *)&env_new.data;
- len = hexport('\0', &res, ENV_SIZE);
+ len = hexport_r(&env_htab, '\0', &res, ENV_SIZE);
if (len < 0) {
error("Cannot export environment: errno = %d\n", errno);
return 1;
diff --git a/common/env_flash.c b/common/env_flash.c
index 54c0bfe..456f2e8 100644
--- a/common/env_flash.c
+++ b/common/env_flash.c
@@ -155,7 +155,7 @@ int saveenv(void)
}
res = (char *)&env_new.data;
- len = hexport('\0', &res, ENV_SIZE);
+ len = hexport_r(&env_htab, '\0', &res, ENV_SIZE);
if (len < 0) {
error("Cannot export environment: errno = %d\n", errno);
goto done;
@@ -289,7 +289,7 @@ int saveenv(void)
goto done;
res = (char *)&env_new.data;
- len = hexport('\0', &res, ENV_SIZE);
+ len = hexport_r(&env_htab, '\0', &res, ENV_SIZE);
if (len < 0) {
error("Cannot export environment: errno = %d\n", errno);
goto done;
diff --git a/common/env_mmc.c b/common/env_mmc.c
index 7c9392c..71dcc4c 100644
--- a/common/env_mmc.c
+++ b/common/env_mmc.c
@@ -107,7 +107,7 @@ int saveenv(void)
return 1;
res = (char *)&env_new.data;
- len = hexport('\0', &res, ENV_SIZE);
+ len = hexport_r(&env_htab, '\0', &res, ENV_SIZE);
if (len < 0) {
error("Cannot export environment: errno = %d\n", errno);
return 1;
diff --git a/common/env_nand.c b/common/env_nand.c
index 7f6c917..2682f07 100644
--- a/common/env_nand.c
+++ b/common/env_nand.c
@@ -199,7 +199,7 @@ int saveenv(void)
return 1;
res = (char *)&env_new.data;
- len = hexport('\0', &res, ENV_SIZE);
+ len = hexport_r(&env_htab, '\0', &res, ENV_SIZE);
if (len < 0) {
error("Cannot export environment: errno = %d\n", errno);
return 1;
@@ -256,7 +256,7 @@ int saveenv(void)
return 1;
res = (char *)&env_new.data;
- len = hexport('\0', &res, ENV_SIZE);
+ len = hexport_r(&env_htab, '\0', &res, ENV_SIZE);
if (len < 0) {
error("Cannot export environment: errno = %d\n", errno);
return 1;
diff --git a/common/env_nvram.c b/common/env_nvram.c
index 6e90f2b..544ce47 100644
--- a/common/env_nvram.c
+++ b/common/env_nvram.c
@@ -94,7 +94,7 @@ int saveenv(void)
int rcode = 0;
res = (char *)&env_new.data;
- len = hexport('\0', &res, ENV_SIZE);
+ len = hexport_r(&env_htab, '\0', &res, ENV_SIZE);
if (len < 0) {
error("Cannot export environment: errno = %d\n", errno);
return 1;
diff --git a/common/env_onenand.c b/common/env_onenand.c
index 02cb535..5e04a06 100644
--- a/common/env_onenand.c
+++ b/common/env_onenand.c
@@ -109,7 +109,7 @@ int saveenv(void)
};
res = (char *)&env_new.data;
- len = hexport('\0', &res, ENV_SIZE);
+ len = hexport_r(&env_htab, '\0', &res, ENV_SIZE);
if (len < 0) {
error("Cannot export environment: errno = %d\n", errno);
return 1;
diff --git a/common/env_sf.c b/common/env_sf.c
index 47c6a70..41cc00a 100644
--- a/common/env_sf.c
+++ b/common/env_sf.c
@@ -92,7 +92,7 @@ int saveenv(void)
}
res = (char *)&env_new.data;
- len = hexport('\0', &res, ENV_SIZE);
+ len = hexport_r(&env_htab, '\0', &res, ENV_SIZE);
if (len < 0) {
error("Cannot export environment: errno = %d\n", errno);
return 1;
@@ -308,7 +308,7 @@ int saveenv(void)
}
res = (char *)&env_new.data;
- len = hexport('\0', &res, ENV_SIZE);
+ len = hexport_r(&env_htab, '\0', &res, ENV_SIZE);
if (len < 0) {
error("Cannot export environment: errno = %d\n", errno);
goto done;
diff --git a/common/hush.c b/common/hush.c
index 2188fd4..8021a68 100644
--- a/common/hush.c
+++ b/common/hush.c
@@ -93,8 +93,6 @@
#include <common.h> /* readline */
#include <hush.h>
#include <command.h> /* find_cmd */
-/*cmd_boot.c*/
-extern int do_bootd (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]); /* do_bootd */
#endif
#ifndef __U_BOOT__
#include <ctype.h> /* isalpha, isdigit */
@@ -1023,9 +1021,7 @@ static void get_user_input(struct in_str *i)
static char the_command[CONFIG_SYS_CBSIZE];
#ifdef CONFIG_BOOT_RETRY_TIME
-# ifdef CONFIG_RESET_TO_RETRY
- extern int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
-# else
+# ifndef CONFIG_RESET_TO_RETRY
# error "This currently only works with CONFIG_RESET_TO_RETRY enabled"
# endif
reset_cmd_timeout();
@@ -1681,8 +1677,6 @@ static int run_pipe_real(struct pipe *pi)
} else {
int rcode;
#if defined(CONFIG_CMD_BOOTD)
- extern int do_bootd (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
-
/* avoid "bootd" recursion */
if (cmdtp->cmd == do_bootd) {
if (flag & CMD_FLAG_BOOTD) {
diff --git a/common/image.c b/common/image.c
index 42f5b79..f63a2ff 100644
--- a/common/image.c
+++ b/common/image.c
@@ -74,7 +74,7 @@ static const image_header_t* image_get_ramdisk (ulong rd_addr, uint8_t arch,
#include <image.h>
#endif /* !USE_HOSTCC*/
-static table_entry_t uimage_arch[] = {
+static const table_entry_t uimage_arch[] = {
{ IH_ARCH_INVALID, NULL, "Invalid ARCH", },
{ IH_ARCH_ALPHA, "alpha", "Alpha", },
{ IH_ARCH_ARM, "arm", "ARM", },
@@ -96,7 +96,7 @@ static table_entry_t uimage_arch[] = {
{ -1, "", "", },
};
-static table_entry_t uimage_os[] = {
+static const table_entry_t uimage_os[] = {
{ IH_OS_INVALID, NULL, "Invalid OS", },
{ IH_OS_LINUX, "linux", "Linux", },
#if defined(CONFIG_LYNXKDI) || defined(USE_HOSTCC)
@@ -129,7 +129,7 @@ static table_entry_t uimage_os[] = {
{ -1, "", "", },
};
-static table_entry_t uimage_type[] = {
+static const table_entry_t uimage_type[] = {
{ IH_TYPE_INVALID, NULL, "Invalid Image", },
{ IH_TYPE_FILESYSTEM, "filesystem", "Filesystem Image", },
{ IH_TYPE_FIRMWARE, "firmware", "Firmware", },
@@ -144,7 +144,7 @@ static table_entry_t uimage_type[] = {
{ -1, "", "", },
};
-static table_entry_t uimage_comp[] = {
+static const table_entry_t uimage_comp[] = {
{ IH_COMP_NONE, "none", "uncompressed", },
{ IH_COMP_BZIP2, "bzip2", "bzip2 compressed", },
{ IH_COMP_GZIP, "gzip", "gzip compressed", },
@@ -516,7 +516,7 @@ static void genimg_print_time (time_t timestamp)
* long entry name if translation succeeds
* msg otherwise
*/
-char *get_table_entry_name (table_entry_t *table, char *msg, int id)
+char *get_table_entry_name(const table_entry_t *table, char *msg, int id)
{
for (; table->id >= 0; ++table) {
if (table->id == id)
@@ -563,10 +563,10 @@ const char *genimg_get_comp_name (uint8_t comp)
* entry id if translation succeeds
* -1 otherwise
*/
-int get_table_entry_id (table_entry_t *table,
+int get_table_entry_id(const table_entry_t *table,
const char *table_name, const char *name)
{
- table_entry_t *t;
+ const table_entry_t *t;
#ifdef USE_HOSTCC
int first = 1;
diff --git a/common/main.c b/common/main.c
index d97ccd7..42f4d02 100644
--- a/common/main.c
+++ b/common/main.c
@@ -50,12 +50,6 @@ DECLARE_GLOBAL_DATA_PTR;
void inline __show_boot_progress (int val) {}
void show_boot_progress (int val) __attribute__((weak, alias("__show_boot_progress")));
-#if defined(CONFIG_BOOT_RETRY_TIME) && defined(CONFIG_RESET_TO_RETRY)
-extern int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]); /* for do_reset() prototype */
-#endif
-
-extern int do_bootd (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
-
#if defined(CONFIG_UPDATE_TFTP)
void update_tftp (void);
#endif /* CONFIG_UPDATE_TFTP */
@@ -342,10 +336,6 @@ void main_loop (void)
hush_init_var ();
#endif
-#ifdef CONFIG_AUTO_COMPLETE
- install_auto_complete();
-#endif
-
#ifdef CONFIG_PREBOOT
if ((p = getenv ("preboot")) != NULL) {
# ifdef CONFIG_AUTOBOOT_KEYED
diff --git a/common/stdio.c b/common/stdio.c
index ab7c5ab..b20772c 100644
--- a/common/stdio.c
+++ b/common/stdio.c
@@ -105,7 +105,7 @@ struct list_head* stdio_get_list(void)
return &(devs.list);
}
-struct stdio_dev* stdio_get_by_name(char* name)
+struct stdio_dev* stdio_get_by_name(const char *name)
{
struct list_head *pos;
struct stdio_dev *dev;
@@ -155,7 +155,7 @@ int stdio_register (struct stdio_dev * dev)
* returns 0 if success, -1 if device is assigned and 1 if devname not found
*/
#ifdef CONFIG_SYS_STDIO_DEREGISTER
-int stdio_deregister(char *devname)
+int stdio_deregister(const char *devname)
{
int l;
struct list_head *pos;