]> www.infradead.org Git - users/rw/ppcboot.git/commitdiff
* Add "sleep" command
authorwdenk <wdenk>
Wed, 28 Nov 2001 15:34:37 +0000 (15:34 +0000)
committerwdenk <wdenk>
Wed, 28 Nov 2001 15:34:37 +0000 (15:34 +0000)
* Add loop constructs (for, while, until) to hush command interpreter

* Fix (most) variable problems with hush command interpreter

* Series of patches by Erik Theisen, 25 Nov 2001:

  Patch 8 of 9:
  - Add support for multiple i2c EEPROMs
  - Modified saveenv() handling

  Patch 9 of 9:
  - Various Wave 7 Optic specific configuration changes

17 files changed:
CHANGELOG
board/hymod/bsp.c
board/hymod/eeprom.c
board/w7o/config.mk
common/Makefile
common/cmd_eeprom.c
common/cmd_misc.c [new file with mode: 0644]
common/cmd_nvedit.c
common/command.c
common/hush.c
include/cmd_confdefs.h
include/cmd_eeprom.h
include/cmd_misc.h
include/config_TQM860L.h
include/config_W7OLMC.h
include/config_W7OLMG.h
include/ppcboot.h

index 5804a8681ff67286182a15f50bf49b5596add73b..4ffa757d131415a823c5b6bb3e2ac21e9f0822a1 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -56,6 +56,12 @@ To do:
 Modifications for 1.1.2:
 ======================================================================
 
+* Add "sleep" command
+
+* Add loop constructs (for, while, until) to hush command interpreter
+
+* Fix (most) variable problems with hush command interpreter
+
 * Series of patches by Erik Theisen, 25 Nov 2001:
 
   Patch 1 of 9:
@@ -126,6 +132,13 @@ Modifications for 1.1.2:
     errata about the serial divisor on all 405s.
   - Add watchdog support to cpu/ppc4xx/serial.c
 
+  Patch 8 of 9:
+  - Add support for multiple i2c EEPROMs
+  - Modified saveenv() handling
+
+  Patch 9 of 9:
+  - Various Wave 7 Optic specific configuration changes
+
 * Add I2C support for Xicor X40430 EEPROM (ICU862 board)
 
 * Fix comment and change overly conservative value in
index ac53756bfd0c4733e06aaeaf1c0ffb06b9356db8..1b65a10be3a09fce686396a1c5bc22c09940fd57 100644 (file)
@@ -295,7 +295,7 @@ do_eecl(cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[])
     }
     
     memset(data, 0, HYMOD_EEPROM_SIZE);
-    if (eeprom_write(offset, data, HYMOD_EEPROM_SIZE) != 0) rcode = 1;
+    if (eeprom_write(CFG_DEF_EEPROM_ADDR, offset, data, HYMOD_EEPROM_SIZE) != 0) rcode = 1;
     return rcode;
 }
 
index 1571f47c0a5b96b139959e71fde1ae5ac0344f66..013253298d16e4cf908534b2f10f9464d4b22af2 100644 (file)
@@ -40,7 +40,7 @@ eeprom_load(unsigned offset, hymod_eeprom_t *ep)
     crc = 0;
 
     hp = (hymod_eehdr_t *)data;
-    eeprom_read(offset, (uchar *)hp, sizeof (*hp));
+    eeprom_read(CFG_DEF_EEPROM_ADDR, offset, (uchar *)hp, sizeof (*hp));
     offset += sizeof (*hp);
 
     if (hp->id != HYMOD_EEPROM_ID || hp->ver > HYMOD_EEPROM_VER ||
@@ -48,10 +48,10 @@ eeprom_load(unsigned offset, hymod_eeprom_t *ep)
        return (0);
 
     dp = (uchar *)(hp + 1); edp = dp + len;
-    eeprom_read(offset, dp, len);
+    eeprom_read(CFG_DEF_EEPROM_ADDR, offset, dp, len);
     offset += len;
 
-    eeprom_read(offset, (uchar *)&crc, sizeof (ulong));
+    eeprom_read(CFG_DEF_EEPROM_ADDR, offset, (uchar *)&crc, sizeof (ulong));
 
     if (crc32(0, data, edp - data) != crc)
        return (0);
@@ -461,7 +461,7 @@ eeprom_fetch(unsigned offset, bd_t *bd, char *filename, ulong addr)
     memcpy(dp, &crc, sizeof (ulong));
     dp += sizeof (ulong);
 
-    eeprom_write(offset, data, dp - data);
+    eeprom_write(CFG_DEF_EEPROM_ADDR, offset, data, dp - data);
 
     return (1);
 }
index f402a86a41338de5d423dc7b820dcd6f89cf2191..006adced449576477f2cde78d44ca24edf192cb8 100644 (file)
@@ -26,4 +26,5 @@
 #
 
 #TEXT_BASE = 0xFFFE0000
-TEXT_BASE = 0xFFF80000
+#TEXT_BASE = 0xFFF80000
+TEXT_BASE = 0xFFFD0000
index ec5041d0efbdc691bde907c65403dd492b8a81eb..ffbda63b8c2f35ffd7f65b8e6c835a4763da581b 100644 (file)
@@ -32,8 +32,9 @@ COBJS = board.o main.o command.o environment.o bedbug.o \
          cmd_date.o cmd_dcr.o cmd_eeprom.o cmd_elf.o \
          cmd_fdc.o cmd_flash.o cmd_i2c.o \
          cmd_ide.o cmd_immap.o cmd_mem.o \
-         cmd_mii.o cmd_net.o cmd_nvedit.o \
-         cmd_pcmcia.o cmd_reginfo.o cmd_scsi.o \
+         cmd_mii.o cmd_misc.o cmd_net.o \
+         cmd_nvedit.o cmd_pcmcia.o \
+         cmd_reginfo.o cmd_scsi.o \
          console.o devices.o dlmalloc.o \
          flash.o hush.o kgdb.o \
          lists.o miiphybb.o miiphyutil.o \
index f1e520ebfcbbe4838334472076f452ba1d46a17f..ec854b4f4c138fc0b21d2085e0a6d0b77857c92d 100644 (file)
 #if (CONFIG_COMMANDS & CFG_CMD_EEPROM) || defined(CFG_ENV_IS_IN_EEPROM)
 
 extern void eeprom_init  (void);
-extern int  eeprom_read  (unsigned offset, uchar *buffer, unsigned cnt);
-extern int  eeprom_write (unsigned offset, uchar *buffer, unsigned cnt);
-
+extern int  eeprom_read  (unsigned dev_addr, unsigned offset,
+                         uchar *buffer, unsigned cnt);
+extern int  eeprom_write (unsigned dev_addr, unsigned offset,
+                         uchar *buffer, unsigned cnt);
 #endif
 
 
@@ -45,54 +46,50 @@ extern int  eeprom_write (unsigned offset, uchar *buffer, unsigned cnt);
 /* ------------------------------------------------------------------------- */
 
 #if (CONFIG_COMMANDS & CFG_CMD_EEPROM)
-int do_eeprom (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[])
+int do_eeprom (cmd_tbl_t * cmdtp, bd_t * bd, int flag, int argc,
+                          char *argv[])
 {
-    int rcode = 0;
-    
-    switch (argc) {
-    default:
-       printf ("Usage:\n%s\n", cmdtp->usage);
-       return 1;
-    case 5:
-       /* 4 args */
-
-       if (strcmp(argv[1],"read") == 0) {
-               ulong addr = simple_strtoul(argv[2], NULL, 16);
-               ulong off  = simple_strtoul(argv[3], NULL, 16);
-               ulong cnt  = simple_strtoul(argv[4], NULL, 16);
-
-               printf ("\nEEPROM read: addr %08lx  off %04lx  count %ld ... ",
-                       addr, off, cnt);
+       const char *const fmt =
+               "\nEEPROM %s: dev_addr %lx  addr %08lx  off %04lx  count %ld ... ";
 
-#ifndef CONFIG_SPI
+#if defined(CFG_I2C_MULTI_EEPROMS)
+       if (argc == 6) {
+               ulong dev_addr = simple_strtoul (argv[2], NULL, 16);
+#else
+       if (argc == 5) {
+               ulong dev_addr = CFG_DEF_EEPROM_ADDR;
+#endif                                                 /* CFG_I2C_MULTI_EEPROMS */
+               ulong addr = simple_strtoul (argv[3], NULL, 16);
+               ulong off = simple_strtoul (argv[4], NULL, 16);
+               ulong cnt = simple_strtoul (argv[5], NULL, 16);
+
+# ifndef CONFIG_SPI
                eeprom_init ();
-#endif
-               rcode = eeprom_read (off, (uchar *)addr, cnt);
+# endif                                                        /* !CONFIG_SPI */
 
-               printf ("done\n");
-               return rcode;
+               if (strcmp (argv[1], "read") == 0) {
+                       int rcode;
 
-       } else if (strcmp(argv[1],"write") == 0) {
-               ulong addr = simple_strtoul(argv[2], NULL, 16);
-               ulong off  = simple_strtoul(argv[3], NULL, 16);
-               ulong cnt  = simple_strtoul(argv[4], NULL, 16);
+                       printf (fmt, argv[1], dev_addr, addr, off, cnt);
 
-               printf ("\nEEPROM write: addr %08lx  off %04lx  count %ld ... ",
-                       addr, off, cnt);
+                       rcode = eeprom_read (dev_addr, off, (uchar *) addr, cnt);
 
-#ifndef CONFIG_SPI
-               eeprom_init ();
-#endif
-               rcode = eeprom_write(off, (uchar *)addr, cnt);
+                       printf ("done\n");
+                       return rcode;
+               } else if (strcmp (argv[2], "write") == 0) {
+                       int rcode;
 
-               printf ("done\n");
-               return rcode;
+                       printf (fmt, argv[1], dev_addr, addr, off, cnt);
 
-       } else {
-               printf ("Usage:\n%s\n", cmdtp->usage);
+                       rcode = eeprom_write (dev_addr, off, (uchar *) addr, cnt);
+
+                       printf ("done\n");
+                       return rcode;
+               }
        }
+
+       printf ("Usage:\n%s\n", cmdtp->usage);
        return 1;
-    }
 }
 #endif /* CFG_CMD_EEPROM */
 
@@ -107,7 +104,7 @@ int do_eeprom (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[])
 
 #if (CONFIG_COMMANDS & CFG_CMD_EEPROM) || defined(CFG_ENV_IS_IN_EEPROM)
 
-int eeprom_read (unsigned offset, uchar *buffer, unsigned cnt)
+int eeprom_read (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt)
 {
        unsigned end = offset + cnt;
        unsigned blk_off;
@@ -138,9 +135,7 @@ int eeprom_read (unsigned offset, uchar *buffer, unsigned cnt)
                alen    = 3;
 #endif /* CONFIG_I2C_X, CONFIG_SPI_X */
 
-#ifdef CFG_I2C_EEPROM_ADDR
-               addr[0] |= CFG_I2C_EEPROM_ADDR; /* insert device address */
-#endif
+               addr[0] |= dev_addr;            /* insert device address */
 
                maxlen = 0x100 - blk_off;
                if (maxlen > I2C_RXTX_LEN)
@@ -168,7 +163,7 @@ int eeprom_read (unsigned offset, uchar *buffer, unsigned cnt)
  *   0x00000nxx for EEPROM address selectors and page number at n.
  */
 
-int eeprom_write (unsigned offset, uchar *buffer, unsigned cnt)
+int eeprom_write (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt)
 {
        unsigned end = offset + cnt;
        unsigned blk_off;
@@ -208,9 +203,7 @@ int eeprom_write (unsigned offset, uchar *buffer, unsigned cnt)
                alen    = 3;
 #endif /* CONFIG_I2C_X, CONFIG_SPI_X */
 
-#ifdef CFG_I2C_EEPROM_ADDR
-               addr[0] |= CFG_I2C_EEPROM_ADDR; /* insert device address */
-#endif
+               addr[0] |= dev_addr;            /* insert device address */
 
 #if defined(CFG_EEPROM_PAGE_WRITE_BITS)
 
diff --git a/common/cmd_misc.c b/common/cmd_misc.c
new file mode 100644 (file)
index 0000000..83aaeff
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * (C) Copyright 2001
+ * 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
+ */
+
+/*
+ * Misc functions
+ */
+#include <ppcboot.h>
+#include <command.h>
+
+#if (CONFIG_COMMANDS & CFG_CMD_MISC)
+
+int do_sleep (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[])
+{
+       ulong delay;
+
+       if (argc != 2) {
+               printf ("Usage:\n%s\n", cmdtp->usage);
+               return 1;
+       }
+
+       delay = simple_strtoul(argv[1], NULL, 10);
+
+       while (delay) {
+               int i;
+               for (i=0; i<1000; ++i) {
+                       if (ctrlc ()) {
+                               return (-1);
+                       }
+                       udelay (1000);
+               }
+               --delay;
+       }
+       return 0;
+}
+
+#endif /* CFG_CMD_MISC */
index de2aabd551eeb7603e490394efa5867b1803fcd3..8621c99d1eadb74bcb2b3cca1d8451c7d5061710 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * (C) Copyright 2000
+ * (C) Copyright 2000, 2001
  * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  *
  * (C) Copyright 2001 Sysgo Real-Time Solutions, GmbH <www.elinos.com>
@@ -307,7 +307,7 @@ void env_relocate (ulong offset)
                DEBUGF ("%s[%d] ENV is valid\n", __FUNCTION__,__LINE__);
 # if defined(CFG_ENV_IS_IN_EEPROM)
                DEBUGF ("%s[%d] read ENV from EEPROM\n", __FUNCTION__,__LINE__);
-               eeprom_read (CFG_ENV_OFFSET+offsetof(env_t,data),
+               eeprom_read (CFG_DEF_EEPROM_ADDR, CFG_ENV_OFFSET+offsetof(env_t,data),
                             env_ptr->data,
                             ENV_SIZE);
 #elif defined(CFG_ENV_IS_IN_NVRAM) && defined(CFG_NVRAM_ACCESS_ROUTINE)
@@ -380,10 +380,13 @@ static uchar get_env_char_eeprom (int index)
        init_data_t *idata = (init_data_t*)(CFG_INIT_RAM_ADDR+CFG_INIT_DATA_OFFSET);
 
        /* if the EEPROM crc was bad, use the default environment */
-       if (idata->env_valid)
-               eeprom_read (CFG_ENV_OFFSET+index+offsetof(env_t,data), &c, 1);
-       else
+       if (idata->env_valid) {
+               eeprom_read (CFG_DEF_EEPROM_ADDR,
+                            CFG_ENV_OFFSET+index+offsetof(env_t,data),
+                            &c, 1);
+       } else {
                c = default_environment[index];
+       }
 
        return (c);
 }
@@ -701,20 +704,21 @@ int do_askenv (cmd_tbl_t * cmdtp, bd_t * bd, int flag, int argc,
                break;
 
        default:        /* askenv envname message1 ... messagen size */
-               {
-                       int i;
-                       int pos = 0;
-
-                       for (i = 2; i < argc - 1; i++) {
-                               if (pos) {
-                                       message[pos++] = ' ';
-                               }
-                               strcpy (message+pos, argv[i]);
-                               pos += strlen(argv[i]);
+           {
+               int i;
+               int pos = 0;
+
+               for (i = 2; i < argc - 1; i++) {
+                       if (pos) {
+                               message[pos++] = ' ';
                        }
-                       message[pos] = '\0';
-                       size = simple_strtoul (argv[argc - 1], NULL, 10);
+                       strcpy (message+pos, argv[i]);
+                       pos += strlen(argv[i]);
                }
+               message[pos] = '\0';
+               size = simple_strtoul (argv[argc - 1], NULL, 10);
+           }
+               break;
        }
 
        if (size >= CFG_CBSIZE)
@@ -735,7 +739,7 @@ int do_askenv (cmd_tbl_t * cmdtp, bd_t * bd, int flag, int argc,
                len = 3;
        }
 
-       // Continue calling setenv code
+       /* Continue calling setenv code */
        return _do_setenv (bd, flag, len, local_args);
 }
 #endif /* CFG_CMD_ASKENV */
@@ -812,17 +816,17 @@ envmatch (uchar *s1, int i2)
        return(-1);
 }
 
+#define SAVESTR(type)  "Saving Enviroment to " #type "...\n"
 
 #ifdef CFG_ENV_IS_IN_NVRAM
+#define NVRAM_SAVESTR SAVESTR(NVRAM)
 
-int do_saveenv  (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[])
-{
+int saveenv(void)
+{        
        int rcode = 0;
-       printf ("Saving Environment to NVRAM...\n");
 
 #ifdef CFG_NVRAM_ACCESS_ROUTINE
        nvram_write((short)CFG_ENV_ADDR, env_ptr, CFG_ENV_SIZE);
-       rcode = 0;
 #else
        if (memcpy ((char *)CFG_ENV_ADDR, env_ptr, CFG_ENV_SIZE) == NULL)
                    rcode = 1 ;
@@ -831,19 +835,23 @@ int do_saveenv  (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[])
 }
 
 #elif CFG_ENV_IS_IN_EEPROM
+#define NVRAM_SAVESTR SAVESTR(EEPROM)
 
-int do_saveenv  (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[])
+int saveenv(void)
 {
-       printf ("Saving Environment to EEPROM...\n");
-       return eeprom_write (CFG_ENV_OFFSET, (uchar *)env_ptr, CFG_ENV_SIZE);
+       return (eeprom_write (CFG_DEF_EEPROM_ADDR,
+                             CFG_ENV_OFFSET,
+                             (uchar *)env_ptr, CFG_ENV_SIZE)
+               );
 }
 
 #else  /* !CFG_ENV_IS_IN_NVRAM, !CFG_ENV_IS_IN_EEPROM => Must be flash, then */
+#define NVRAM_SAVESTR SAVESTR(Flash)
 
 /* need both ENV and flash */
 #if ((CONFIG_COMMANDS & (CFG_CMD_ENV|CFG_CMD_FLASH)) == (CFG_CMD_ENV|CFG_CMD_FLASH))
 
-int do_saveenv  (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[])
+int saveenv(void)
 {
        int len, rc;
        ulong end_addr;
@@ -873,18 +881,16 @@ int do_saveenv  (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[])
 #else
        flash_sect_addr = flash_addr;
        len      = CFG_ENV_SIZE;
-# endif        /* CFG_ENV_SECT_SIZE */
+#endif /* CFG_ENV_SECT_SIZE */
 
        end_addr = (ulong)flash_sect_addr + len - 1;
 
        if (flash_sect_protect (0, (ulong)flash_sect_addr, end_addr))
                return 1;
 
-       printf ("Erasing Flash...");
        if (flash_sect_erase ((ulong)flash_sect_addr, end_addr))
                return 1;
 
-       printf ("Saving Environment to Flash...\n");
        switch (rc = flash_write(env_buffer, (ulong)flash_sect_addr, len)) {
        case 0: break;
        case 1: printf ("Timeout writing to Flash\n");
@@ -912,6 +918,21 @@ int do_saveenv  (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[])
 
 #endif /* CFG_ENV_IS_IN_NVRAM */
 
+#if defined(CFG_ENV_IS_IN_NVRAM) || defined(CFG_ENV_IS_IN_EEPROM) || \
+    ((CONFIG_COMMANDS & (CFG_CMD_ENV|CFG_CMD_FLASH)) == \
+      (CFG_CMD_ENV|CFG_CMD_FLASH))
+int do_saveenv  (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[])
+{
+       int rcode = 0;
+
+       printf (NVRAM_SAVESTR);
+       if (!saveenv())
+           rcode = 1;
+
+       return rcode;
+}
+#endif
+
 /************************************************************************
  * Initialize Environment use
  *
@@ -962,8 +983,9 @@ void env_init(init_data_t *idata)
        eeprom_init (); /* prepare for EEPROM read/write */
 
        /* read old CRC */
-       eeprom_read (CFG_ENV_OFFSET+offsetof(env_t,crc), (uchar *)&crc,
-                       sizeof(ulong));
+       eeprom_read (CFG_DEF_EEPROM_ADDR,
+                    CFG_ENV_OFFSET+offsetof(env_t,crc),
+                    (uchar *)&crc, sizeof(ulong));
 
        new = 0;
        len = ENV_SIZE;
@@ -971,7 +993,7 @@ void env_init(init_data_t *idata)
        while (len > 0) {
                int n = (len > sizeof(buf)) ? sizeof(buf) : len;
 
-               eeprom_read (CFG_ENV_OFFSET+off, buf, n);
+               eeprom_read (CFG_DEF_EEPROM_ADDR, CFG_ENV_OFFSET+off, buf, n);
                new = crc32 (new, buf, n);
                len -= n;
                off += n;
index bbcfc4b239c552d0d4f8ffe2a70d4a2286d399dc..87001f3a9e0f409a080627ef33eb6541015f3068 100644 (file)
@@ -277,11 +277,12 @@ cmd_tbl_t cmd_tbl[] = {
        CMD_TBL_SCCINFO
        CMD_TBL_SCSIBOOT
        CMD_TBL_SCSI
+       CMD_TBL_SETDCR
+       CMD_TBL_SETENV
        CMD_TBL_SIINFO
        CMD_TBL_SITINFO
        CMD_TBL_SIUINFO
-       CMD_TBL_SETDCR
-       CMD_TBL_SETENV
+       CMD_TBL_MISC            /* sleep */
        CMD_TBL_SMCINFO
        CMD_TBL_SPIINFO
        CMD_TBL_STACK
index d494adeceebc12f9cea5dc32669a3fb6f4705517..d76aa3ebee8998d887689deb24bbe30f0995fa07 100644 (file)
 #include <signal.h>
 
 /* #include <dmalloc.h> */
-#define DEBUG_SHELL 
+/* #define DEBUG_SHELL */
 
 #ifdef BB_VER
 #include "busybox.h"
 #undef BB_FEATURE_SH_FANCY_PROMPT
 #endif
 #endif
+#define SPECIAL_VAR_SYMBOL 03
 
 #ifdef __PPCBOOT__
 #define EXIT_SUCCESS 0
 #define EOF -1
 #define syntax() syntax_err()
 #define xstrdup strdup
-#define xmalloc malloc
-#define xrealloc realloc
 #define error_msg printf
 #else
 typedef enum {
@@ -143,6 +142,7 @@ typedef enum {
        REDIRECT_HEREIS    = 4,
        REDIRECT_IO        = 5
 } redir_type;
+
 /* The descrip member of this structure is only used to make debugging
  * output pretty */
 struct {int mode; int default_fd; char *descrip;} redir_table[] = {
@@ -176,7 +176,8 @@ typedef enum {
        RES_DO    = 9,
        RES_DONE  = 10,
        RES_XXXX  = 11,
-       RES_SNTX  = 12
+       RES_IN    = 12,
+       RES_SNTX  = 13
 } reserved_style;
 #define FLAG_END   (1<<RES_NONE)
 #define FLAG_IF    (1<<RES_IF)
@@ -189,6 +190,7 @@ typedef enum {
 #define FLAG_UNTIL (1<<RES_UNTIL)
 #define FLAG_DO    (1<<RES_DO)
 #define FLAG_DONE  (1<<RES_DONE)
+#define FLAG_IN    (1<<RES_IN)
 #define FLAG_START (1<<RES_XXXX)
 
 /* This holds pointers to the various results of parsing */
@@ -204,6 +206,7 @@ struct p_context {
        struct p_context *stack;
        /* How about quoting status? */
 };
+
 #ifndef __PPCBOOT__
 struct redir_struct {
        redir_type type;                        /* type of redirection */
@@ -213,6 +216,7 @@ struct redir_struct {
        glob_t word;                            /* *word.gl_pathv is the filename */
 };
 #endif
+
 struct child_prog {
 #ifndef __PPCBOOT__
        pid_t pid;                                      /* 0 if exited */
@@ -222,13 +226,14 @@ struct child_prog {
        int    argc;                            /* number of program arguments */ 
 #endif 
        struct pipe *group;                     /* if non-NULL, first in group or subshell */
-#ifndef __PPCBOOT__    
+#ifndef __PPCBOOT__
        int subshell;                           /* flag, non-zero if group must be forked */
        struct redir_struct *redirects; /* I/O redirections */
        glob_t glob_result;                     /* result of parameter globbing */
-       int is_stopped;                         /* is the program currently running? */ 
+       int is_stopped;                         /* is the program currently running? */
        struct pipe *family;            /* pointer back to the child's parent pipe */
-#endif         
+#endif
+       int sp;                         /* number of SPECIAL_VAR_SYMBOL */
 };
 
 struct pipe {
@@ -251,12 +256,14 @@ struct pipe {
        pipe_style followup;            /* PIPE_BG, PIPE_SEQ, PIPE_OR, PIPE_AND */
        reserved_style r_mode;          /* supports if, for, while, until */
 };
+
 #ifndef __PPCBOOT__
 struct close_me {
        int fd;
        struct close_me *next;
 };
 #endif
+
 struct variables {
        char *name;
        char *value;
@@ -293,6 +300,7 @@ static char *PS2;
 struct variables shell_ver = { "HUSH_VERSION", "0.01", 1, 1, 0 };
 struct variables *top_vars = &shell_ver;
 #else
+static int flag_repeat = 0;
 static bd_t *BD;
 static struct variables *top_vars ;
 #endif /*__PPCBOOT__ */
@@ -328,20 +336,23 @@ struct in_str {
 };
 #define b_getch(input) ((input)->get(input))
 #define b_peek(input) ((input)->peek(input))
+
 #ifndef __PPCBOOT__
 #define JOB_STATUS_FORMAT "[%d] %-22s %.40s\n"
+
 struct built_in_command {
        char *cmd;                                      /* name */
        char *descr;                            /* description */
        int (*function) (struct child_prog *);  /* function ptr */
 };
 #endif
+
 /* belongs in busybox.h */
 static inline int max(int a, int b) {
        return (a>b)?a:b;
 }
-/* This should be in utility.c */
 
+/* This should be in utility.c */
 #ifdef DEBUG_SHELL
 #ifndef __PPCBOOT__
 static void debug_printf(const char *format, ...)
@@ -349,7 +360,6 @@ static void debug_printf(const char *format, ...)
        va_list args;
        va_start(args, format);
        vfprintf(stderr, format, args);
-       printf(stderr, format, args);\r  
        va_end(args);
 }
 #else
@@ -359,6 +369,7 @@ static void debug_printf(const char *format, ...)
 static inline void debug_printf(const char *format, ...) { }
 #endif
 #define final_printf debug_printf
+
 #ifdef __PPCBOOT__
 static void syntax_err(void) {
         printf("syntax error\n");
@@ -368,6 +379,12 @@ static void __syntax(char *file, int line) {
        error_msg("syntax error %s:%d", file, line);
 }
 #define syntax() __syntax(__FILE__, __LINE__)
+#endif
+
+#ifdef __PPCBOOT__
+static void *xmalloc(size_t size);
+static void *xrealloc(void *ptr, size_t size);
+#else
 /* Index of subroutines: */
 /*   function prototypes for builtins */
 static int builtin_cd(struct child_prog *child);
@@ -446,9 +463,11 @@ static int redirect_opt_num(o_string *o);
 static int process_command_subs(o_string *dest, struct p_context *ctx, struct in_str *input, int subst_end);
 static int parse_group(o_string *dest, struct p_context *ctx, struct in_str *input, int ch);
 #endif
-static void lookup_param(o_string *dest, struct p_context *ctx, o_string *src);
+static char *lookup_param(char *src);
 static int handle_dollar(o_string *dest, struct p_context *ctx, struct in_str *input);
+#ifndef __PPCBOOT__
 static int parse_string(o_string *dest, struct p_context *ctx, const char *src);
+#endif
 static int parse_stream(o_string *dest, struct p_context *ctx, struct in_str *input0, int end_trigger);
 /*   setup: */
 #ifndef __PPCBOOT__
@@ -468,11 +487,14 @@ static void insert_bg_job(struct pipe *pi);
 static void remove_bg_job(struct pipe *pi);
 #endif
 /*     local variable support */
+static char **make_list_in(char **inp, char *name);
+static char *insert_var_value(char *inp);
 static char *get_local_var(const char *var);
 #ifndef __PPCBOOT__
 static void  unset_local_var(const char *name);
 #endif 
 static int set_local_var(const char *s, int flg_export);
+
 #ifndef __PPCBOOT__
 /* Table of built-in functions.  They can be forked or not, depending on
  * context: within pipes, they fork.  As simple commands, they do not.
@@ -827,6 +849,7 @@ static int builtin_not_written(struct child_prog *child)
        return EXIT_FAILURE;
 }
 #endif
+
 static int b_check_space(o_string *o, int len)
 {
        /* It would be easy to drop a more restrictive policy
@@ -915,6 +938,7 @@ static int static_peek(struct in_str *i)
 {
        return *i->p;
 }
+
 #ifndef __PPCBOOT__
 static inline void cmdedit_set_initial_prompt(void)
 {
@@ -947,13 +971,13 @@ static inline void setup_prompt_string(int promptmode, char **prompt_str)
        debug_printf("result %s\n",*prompt_str);
 }
 #endif
+
 static void get_user_input(struct in_str *i)
 {
-
 #ifndef __PPCBOOT__    
        char *prompt_str;
        static char the_command[BUFSIZ];
-       
+
        setup_prompt_string(i->promptmode, &prompt_str);
 #ifdef BB_FEATURE_COMMAND_EDITING
        /*
@@ -970,38 +994,38 @@ static void get_user_input(struct in_str *i)
        the_command[1]='\0';
 #endif
        fflush(stdout);
-       i->p = the_command;     
+       i->p = the_command;
 #else  
        extern char console_buffer[CFG_CBSIZE];
        int n;
-       static int flag_repeat = 0;
        static char the_command[CFG_CBSIZE];    
-       
+
+       i->__promptme = 1;
        if (i->promptmode == 1) {
                n = readline(CFG_PROMPT);
        } else { 
                n = readline(CFG_PROMPT_HUSH_PS2);
        }
        if (n == -1 ) {
+               flag_repeat = 0;
                i->__promptme = 0;
        }       
        n = strlen(console_buffer);
        console_buffer[n] = '\n';
        console_buffer[n+1]= '\0';
+       if (had_ctrlc()) flag_repeat = 0;
+       clear_ctrlc();
        if (i->promptmode == 1) {
                if (console_buffer[0] == '\n'&& flag_repeat == 0) {
-                       i->p = console_buffer;                  
+                       strcpy(the_command,console_buffer);
                }
                else {
                        if (console_buffer[0] != '\n') {
                                strcpy(the_command,console_buffer);
                                flag_repeat = 1;
                        }
-                       else {
-                               flag_repeat = 0;
-                       }       
-                       i->p = the_command;                     
                }
+               i->p = the_command;
        }
        else {
                if (console_buffer[0] != '\n') {
@@ -1014,14 +1038,15 @@ static void get_user_input(struct in_str *i)
                        else {
                                the_command[0] = '\n';
                                the_command[1] = '\0';
+                               flag_repeat = 0;
                        }
                }
                if (i->__promptme == 0) {
                        the_command[0] = '\n';
                        the_command[1] = '\0';
                }
-               i->p = console_buffer;          
-       }                               
+               i->p = console_buffer;
+       }
 #endif 
 }
 
@@ -1030,17 +1055,17 @@ static void get_user_input(struct in_str *i)
 static int file_get(struct in_str *i)
 {
        int ch;
+
        ch = 0;
-       
        /* If there is data waiting, eat it up */
        if (i->p && *i->p) {
                ch=*i->p++;
        } else {
                /* need to double check i->file because we might be doing something
-                * more complicated by now, like sourcing or substituting. */            
+                * more complicated by now, like sourcing or substituting. */
 #ifndef __PPCBOOT__             
                if (i->__promptme && interactive && i->file == stdin) {
-                       while(! i->p  || (interactive && strlen(i->p)==0) ) {
+                       while(! i->p || (interactive && strlen(i->p)==0) ) {
 #else
                        while(! i->p  || strlen(i->p)==0 ) {
 #endif                 
@@ -1051,13 +1076,14 @@ static int file_get(struct in_str *i)
                        i->__promptme = 0;
 #endif
                        if (i->p && *i->p) {
-                               ch=*i->p++;
+                               ch=*i->p++;
                        }
 #ifndef __PPCBOOT__                    
                } else {
                        ch = fgetc(i->file);
                }
-#endif         
+
+#endif
                debug_printf("b_getch: got a %d\n", ch);
        }
 #ifndef __PPCBOOT__    
@@ -1085,6 +1111,7 @@ static int file_peek(struct in_str *i)
        }
 #endif 
 }
+
 #ifndef __PPCBOOT__
 static void setup_file_in_str(struct in_str *i, FILE *f)
 #else
@@ -1102,13 +1129,14 @@ static void setup_file_in_str(struct in_str *i)
 }
 
 static void setup_string_in_str(struct in_str *i, const char *s)
-{       
+{
        i->peek = static_peek;
        i->get = static_get;
        i->__promptme=1;
        i->promptmode=1;
        i->p = s;
 }
+
 #ifndef __PPCBOOT__
 static void mark_open(int fd)
 {
@@ -1136,6 +1164,7 @@ static void close_all()
        }
        close_me_head = NULL;
 }
+
 /* squirrel != NULL means we squirrel away copies of stdin, stdout,
  * and stderr if they are redirected. */
 static int setup_redirects(struct child_prog *prog, int squirrel[])
@@ -1198,11 +1227,14 @@ static void restore_redirects(int squirrel[])
 static void pseudo_exec(struct child_prog *child)
 {
        int i, rcode;
+       char *p;
        struct built_in_command *x;
        if (child->argv) {
                for (i=0; is_assignment(child->argv[i]); i++) {
                        debug_printf("pid %d environment modification: %s\n",getpid(),child->argv[i]);
-                       putenv(strdup(child->argv[i]));
+                       p = insert_var_value(child->argv[i]);
+                       putenv(strdup(p));
+                       if (p != child->argv[i]) free(p);
                }
                child->argv+=i;  /* XXX this hack isn't so horrible, since we are about
                                        to exit, and therefore don't need to keep data
@@ -1446,6 +1478,7 @@ shell_terminal_error:
                return;
 }
 #endif
+
 /* run_pipe_real() starts all the jobs, but doesn't wait for anything
  * to finish.  See checkjobs().
  *
@@ -1462,27 +1495,30 @@ shell_terminal_error:
  * now has its stdout directed to the input of the appropriate pipe,
  * so this routine is noticeably simpler.
  */
-
 static int run_pipe_real(struct pipe *pi)
 {
-
        int i;
 #ifndef __PPCBOOT__    
        int nextin, nextout;
        int pipefds[2];                         /* pipefds[0] is for reading */
        struct child_prog *child;
        struct built_in_command *x;
+       char *p;
+       int n;
 #else  
        int nextin;
        int flag = 0;     
        struct child_prog *child;       
        cmd_tbl_t *cmdtp;
+       char *p;
+       int n;
 #endif 
 
        nextin = 0;
 #ifndef __PPCBOOT__    
        pi->pgrp = -1;
 #endif 
+
        /* Check if this is a simple builtin (not part of a pipe).
         * Builtins within pipes have to fork anyway, and are handled in
         * pseudo_exec.  "echo foo | read bar" doesn't work on bash, either.
@@ -1510,6 +1546,7 @@ static int run_pipe_real(struct pipe *pi)
                if (i!=0 && child->argv[i]==NULL) {
                        /* assignments, but no command: set the local environment */
                        for (i=0; child->argv[i]!=NULL; i++) {
+
                                /* Ok, this case is tricky.  We have to decide if this is a
                                 * local variable, or an already exported variable.  If it is
                                 * already exported, we have to export the new value.  If it is
@@ -1529,16 +1566,45 @@ static int run_pipe_real(struct pipe *pi)
                                }
 #endif
                                free(name);
-                               set_local_var(child->argv[i], export_me);
+                               p = insert_var_value(child->argv[i]);
+                               set_local_var(p, export_me);
+                               if (p != child->argv[i]) free(p);
                        }
                        return EXIT_SUCCESS;   /* don't worry about errors in set_local_var() yet */
                }
+               for (i = 0; is_assignment(child->argv[i]); i++) {
+                       p = insert_var_value(child->argv[i]);
+#ifndef __PPCBOOT__                    
+                       putenv(strdup(p));
+#else
+                       set_local_var(p, 0);
+#endif                         
+                       if (p != child->argv[i]) {
+                               child->sp--;
+                               free(p);
+                       }
+               }
+               if (child->sp) {
+                       char *p1 = NULL, *p2;
+                       int len = 0;
+                       /* make new string for parser */
+                       for (n = i; child->argv[n]; n++) {
+                               p2 = insert_var_value(child->argv[n]);
+                               p1 = xrealloc(p1, (len + 2 + strlen(p2)));
+                               strcpy(p1 + len, p2);
+                               strcat(p1, " ");
+                               len = strlen(p1);
+                               if (p2 != child->argv[n]) free(p2);
+                       }
+               parse_string_outer(p1);
+               free(p1);
+               return last_return_code;
+               }
 #ifndef __PPCBOOT__                            
                for (x = bltins; x->cmd; x++) {
                        if (strcmp(child->argv[i], x->cmd) == 0 ) {
-                       
-                               int squirrel[] = {-1, -1, -1};                          
-                               int rcode;                              
+                               int squirrel[] = {-1, -1, -1};
+                               int rcode;
                                if (x->function == builtin_exec && child->argv[i+1]==NULL) {
                                        debug_printf("magic exec\n");
                                        setup_redirects(child,NULL);
@@ -1548,13 +1614,13 @@ static int run_pipe_real(struct pipe *pi)
                                /* XXX setup_redirects acts on file descriptors, not FILEs.
                                 * This is perfect for work that comes after exec().
                                 * Is it really safe for inline use?  Experimentally,
-                                * things seem to work with glibc. */                            
+                                * things seem to work with glibc. */
                                setup_redirects(child, squirrel);
 #else                          
                        /* Look up command in command table */
                        if ((cmdtp = find_cmd(child->argv[i])) == NULL) {
                                printf ("Unknown command '%s' - try 'help'\n", child->argv[i]);
-                               return 1;       /* give up after bad command */
+                               return -1;      /* give up after bad command */
                        } else {
                                int rcode;              
 #if (CONFIG_COMMANDS & CFG_CMD_BOOTD)
@@ -1562,7 +1628,7 @@ static int run_pipe_real(struct pipe *pi)
                                if (cmdtp->cmd == do_bootd) {
                                        if (flag & CMD_FLAG_BOOTD) {
                                                printf ("'bootd' recursion detected\n");
-                                               return 1; 
+                                               return -1;
                                        }
                                else
                                        flag |= CMD_FLAG_BOOTD;
@@ -1571,16 +1637,9 @@ static int run_pipe_real(struct pipe *pi)
                                /* found - check max args */
                                if ((child->argc - i) > cmdtp->maxargs) {
                                        printf ("Usage:\n%s\n", cmdtp->usage);
-                                       return 1;
+                                       return -1;
                                }
 #endif         
-                               for (i=0; is_assignment(child->argv[i]); i++) {
-#ifndef __PPCBOOT__                            
-                                       putenv(strdup(child->argv[i]));
-#else
-                                       set_local_var(child->argv[i], 0);
-#endif                                 
-                               }
                                child->argv+=i;  /* XXX horrible hack */
 #ifndef __PPCBOOT__                                
                                rcode = x->function(child);
@@ -1598,7 +1657,7 @@ static int run_pipe_real(struct pipe *pi)
                }
 #ifndef __PPCBOOT__                                    
        }
-       
+
        for (i = 0; i < pi->num_progs; i++) {
                child = & (pi->progs[i]);
 
@@ -1679,10 +1738,57 @@ static int run_pipe_real(struct pipe *pi)
 
 static int run_list_real(struct pipe *pi)
 {
+       char *save_name = NULL;
+       char **list = NULL;
+       char **save_list = NULL;
+       struct pipe *rpipe;
+       int flag_rep = 0;
+#ifndef __PPCBOOT__    
+       int save_num_progs;
+#endif 
        int rcode=0;
+       int flag_restore = 0;
        int if_code=0, next_if_code=0;  /* need double-buffer to handle elif */
        reserved_style rmode, skip_more_in_this_rmode=RES_XXXX;
-       for (;pi;pi=pi->next) {
+       /* check syntax for "for" */
+       for (rpipe = pi; rpipe; rpipe = rpipe->next) {
+               if ((rpipe->r_mode == RES_IN ||
+                   rpipe->r_mode == RES_FOR) &&
+                   (rpipe->next == NULL)) {
+                               syntax();
+#ifdef __PPCBOOT__
+                               flag_repeat = 0;
+#endif                         
+                               return 1;
+               }               
+               if ((rpipe->r_mode == RES_IN && 
+                       (rpipe->next->r_mode == RES_IN && 
+                       rpipe->next->progs->argv != NULL))||
+                       (rpipe->r_mode == RES_FOR &&
+                       rpipe->next->r_mode != RES_IN)) { 
+                               syntax();
+#ifdef __PPCBOOT__
+                               flag_repeat = 0;
+#endif                         
+                               return 1;
+           }
+       }
+       for (; pi; pi = (flag_restore != 0) ? rpipe : pi->next) {
+               if (pi->r_mode == RES_WHILE || pi->r_mode == RES_UNTIL ||
+                       pi->r_mode == RES_FOR) {
+#ifdef __PPCBOOT__                     
+                               /* check Ctrl-C */
+                               ctrlc();        
+                               if ((had_ctrlc())) {
+                                       return 1;
+                               }
+#endif 
+                               flag_restore = 0;
+                               if (!rpipe) {
+                                       flag_rep = 0;
+                                       rpipe = pi;
+                               }
+               }
                rmode = pi->r_mode;
                debug_printf("rmode=%d  if_code=%d  next_if_code=%d skip_more=%d\n", rmode, if_code, next_if_code, skip_more_in_this_rmode);
                if (rmode == skip_more_in_this_rmode) continue;
@@ -1691,7 +1797,55 @@ static int run_list_real(struct pipe *pi)
                if (rmode == RES_THEN &&  if_code) continue;
                if (rmode == RES_ELSE && !if_code) continue;
                if (rmode == RES_ELIF && !if_code) continue;
+               if (rmode == RES_FOR && pi->num_progs) {
+                       if (!list) {
+                               /* if no variable values after "in" we skip "for" */            
+                               if (!pi->next->progs->argv) continue;
+                               /* create list of variable values */
+                               list = make_list_in(pi->next->progs->argv,
+                                       pi->progs->argv[0]);
+                               save_list = list;
+                               save_name = pi->progs->argv[0];
+                               pi->progs->argv[0] = NULL;
+                               flag_rep = 1;
+                       }       
+                       if (!(*list)) {
+                               free(pi->progs->argv[0]);
+                               free(save_list);
+                               list = NULL;
+                               flag_rep = 0;
+                               pi->progs->argv[0] = save_name;
+#ifndef __PPCBOOT__                            
+                               pi->progs->glob_result.gl_pathv[0] =
+                                       pi->progs->argv[0];
+#endif                             
+                               continue;
+                       } else {                        
+                               /* insert new value from list for variable */
+                               if (pi->progs->argv[0]) 
+                                       free(pi->progs->argv[0]);
+                               pi->progs->argv[0] = *list++;
+#ifndef __PPCBOOT__                        
+                               pi->progs->glob_result.gl_pathv[0] =
+                                       pi->progs->argv[0];
+#endif
+                       }
+               }               
+               if (rmode == RES_IN) continue;
+               if (rmode == RES_DO) {
+                       if (!flag_rep) continue;
+               }           
+               if ((rmode == RES_DONE)) {
+                       if (flag_rep) {
+                               flag_restore = 1;
+                       } else {
+                               rpipe = NULL;
+                       }
+               }               
                if (pi->num_progs == 0) continue;
+#ifndef __PPCBOOT__            
+               save_num_progs = pi->num_progs; /* save number of programs */
+#endif 
                rcode = run_pipe_real(pi);
                debug_printf("run_pipe_real returned %d\n",rcode);
 #ifndef __PPCBOOT__
@@ -1718,16 +1872,25 @@ static int run_list_real(struct pipe *pi)
                        }
                        debug_printf("checkjobs returned %d\n",rcode);
                }
-#endif
                last_return_code=rcode;
+#else
+               last_return_code=(rcode == 0) ? 0 : 1;
+#endif
+#ifndef __PPCBOOT__
+               pi->num_progs = save_num_progs; /* restore number of programs */
+#endif
                if ( rmode == RES_IF || rmode == RES_ELIF )
                        next_if_code=rcode;  /* can be overwritten a number of times */
+               if (rmode == RES_WHILE) 
+                       flag_rep = !last_return_code;
+               if (rmode == RES_UNTIL) 
+                       flag_rep = last_return_code;
                if ( (rcode==EXIT_SUCCESS && pi->followup==PIPE_OR) ||
                     (rcode!=EXIT_SUCCESS && pi->followup==PIPE_AND) )
                        skip_more_in_this_rmode=rmode;
 #ifndef __PPCBOOT__
                checkjobs(NULL);
-#endif
+#endif 
        }
        return rcode;
 }
@@ -1748,7 +1911,8 @@ static int free_pipe(struct pipe *pi, int indent)
        struct redir_struct *r, *rnext;
 #endif 
        int a, i, ret_code=0;
-       char *ind =  indenter(indent);
+       char *ind = indenter(indent);
+
 #ifndef __PPCBOOT__    
        if (pi->stopped_progs > 0)
                return ret_code;
@@ -1760,7 +1924,7 @@ static int free_pipe(struct pipe *pi, int indent)
                if (child->argv) {
                        for (a=0,p=child->argv; *p; a++,p++) {
                                final_printf("%s   argv[%d] = %s\n",ind,a,*p);
-                       }                       
+                       }
 #ifndef __PPCBOOT__                    
                        globfree(&child->glob_result);
 #else                  
@@ -1771,9 +1935,9 @@ static int free_pipe(struct pipe *pi, int indent)
                        child->argc = 0;
 #endif                 
                        child->argv=NULL;
-               } else if (child->group) {              
+               } else if (child->group) {
 #ifndef __PPCBOOT__            
-                       final_printf("%s   begin group (subshell:%d)\n",ind, child->subshell);
+                       final_printf("%s   begin group (subshell:%d)\n",ind, child->subshell);
 #endif                 
                        ret_code = free_pipe_list(child->group,indent+3);
                        final_printf("%s   end group\n",ind);
@@ -1782,9 +1946,7 @@ static int free_pipe(struct pipe *pi, int indent)
                }
 #ifndef __PPCBOOT__            
                for (r=child->redirects; r; r=rnext) {
-               
                        final_printf("%s   redirect %d%s", ind, r->fd, redir_table[r->type].descrip);
-                       
                        if (r->dup == -1) {
                                /* guard against the case >$FOO, where foo is unset or blank */
                                if (r->word.gl_pathv) {
@@ -1793,7 +1955,7 @@ static int free_pipe(struct pipe *pi, int indent)
                                }
                        } else {
                                final_printf("&%d\n", r->dup);
-                       }                       
+                       }
                        rnext=r->next;
                        free(r);
                }
@@ -1899,6 +2061,7 @@ static void globprint(glob_t *pglob)
                        pglob->gl_pathv[i], pglob->gl_pathv[i]);
 }
 #endif
+
 static int xglob(o_string *dest, int flags, glob_t *pglob)
 {
        int gr;
@@ -1934,6 +2097,7 @@ static int xglob(o_string *dest, int flags, glob_t *pglob)
        return gr;
 }
 #endif
+
 /* This is used to get/check local shell variables */
 static char *get_local_var(const char *s)
 {
@@ -1958,6 +2122,7 @@ static int set_local_var(const char *s, int flg_export)
        struct variables *cur;
 
        name=strdup(s);
+
 #ifdef __PPCBOOT__
        if (getenv(name) != NULL) {
                printf ("ERROR: "
@@ -2018,6 +2183,7 @@ static int set_local_var(const char *s, int flg_export)
                        }
                }
        }
+
 #ifndef __PPCBOOT__    
        if(result==0 && cur->flg_export==1) {
                *(value-1) = '=';
@@ -2032,6 +2198,7 @@ static int set_local_var(const char *s, int flg_export)
 #endif 
        return result;
 }
+
 #ifndef __PPCBOOT__
 static void unset_local_var(const char *name)
 {
@@ -2061,6 +2228,7 @@ static void unset_local_var(const char *name)
        }
 }
 #endif
+
 static int is_assignment(const char *s)
 {
        if (s==NULL || !isalpha(*s)) return 0;
@@ -2068,6 +2236,7 @@ static int is_assignment(const char *s)
        while(isalnum(*s) || *s=='_') ++s;
        return *s=='=';
 }
+
 #ifndef __PPCBOOT__
 /* the src parameter allows us to peek forward to a possible &n syntax
  * for file descriptor duplication, e.g., "2>&1".
@@ -2118,6 +2287,7 @@ static int setup_redirect(struct p_context *ctx, int fd, redir_type style,
        return 0;
 }
 #endif
+
 struct pipe *new_pipe(void) {
        struct pipe *pi;
        pi = xmalloc(sizeof(struct pipe));
@@ -2168,13 +2338,12 @@ int reserved_word(o_string *dest, struct p_context *ctx)
                { "elif",  RES_ELIF,  FLAG_THEN },
                { "else",  RES_ELSE,  FLAG_FI   },
                { "fi",    RES_FI,    FLAG_END  },
-#ifndef __PPCBOOT__
-               { "for",   RES_FOR,   FLAG_DO   | FLAG_START },
+               { "for",   RES_FOR,   FLAG_IN   | FLAG_START },
                { "while", RES_WHILE, FLAG_DO   | FLAG_START },
                { "until", RES_UNTIL, FLAG_DO   | FLAG_START },
+               { "in",    RES_IN,    FLAG_DO   },
                { "do",    RES_DO,    FLAG_DONE },
                { "done",  RES_DONE,  FLAG_END  }
-#endif
        };
        struct reserved_combo *r;
        for (r=reserved_list;
@@ -2185,6 +2354,13 @@ int reserved_word(o_string *dest, struct p_context *ctx)
                        if (r->flag & FLAG_START) {
                                struct p_context *new = xmalloc(sizeof(struct p_context));
                                debug_printf("push stack\n");
+                               if (ctx->w == RES_IN || ctx->w == RES_FOR) {
+                                       syntax();
+                                       free(new);
+                                       ctx->w = RES_SNTX;
+                                       b_reset(dest);
+                                       return 1;
+                               }
                                *new = *ctx;   /* physical copy */
                                initialize_context(ctx);
                                ctx->stack=new;
@@ -2199,6 +2375,7 @@ int reserved_word(o_string *dest, struct p_context *ctx)
                        if (ctx->old_flag & FLAG_END) {
                                struct p_context *old;
                                debug_printf("pop stack\n");
+                               done_pipe(ctx,PIPE_SEQ);
                                old = ctx->stack;
                                old->child->group = ctx->list_head;
 #ifndef __PPCBOOT__                            
@@ -2274,6 +2451,7 @@ static int done_word(o_string *dest, struct p_context *ctx)
        gr = xglob(dest, flags, glob_target);
        if (gr != 0) return 1;
 #endif 
+
        b_reset(dest);
 #ifndef __PPCBOOT__
        if (ctx->pending_redirect) {
@@ -2286,6 +2464,10 @@ static int done_word(o_string *dest, struct p_context *ctx)
                child->argv = glob_target->gl_pathv;
        }
 #endif
+       if (ctx->w == RES_FOR) {
+               done_word(dest,ctx);
+               done_pipe(ctx,PIPE_SEQ);
+       }
        return 0;
 }
 
@@ -2317,6 +2499,7 @@ static int done_command(struct p_context *ctx)
                debug_printf("done_command: initializing\n");
        }
        pi->progs = xrealloc(pi->progs, sizeof(*pi->progs) * (pi->num_progs+1));
+
        prog = pi->progs + pi->num_progs;
 #ifndef __PPCBOOT__    
        prog->redirects = NULL;
@@ -2330,7 +2513,9 @@ static int done_command(struct p_context *ctx)
        prog->glob_result.gl_pathv = NULL;
        prog->family = pi;
 #endif 
-       ctx->child=prog;
+       prog->sp = 0;
+       ctx->child = prog;
+
        /* but ctx->pipe and ctx->list_head remain unchanged */
        return 0;
 }
@@ -2349,6 +2534,7 @@ static int done_pipe(struct p_context *ctx, pipe_style type)
        done_command(ctx);  /* set up new pipe to accept commands */
        return 0;
 }
+
 #ifndef __PPCBOOT__
 /* peek ahead in the in_str to find out if we have a "&n" construct,
  * as in "2>&1", that represents duplicating a file descriptor.
@@ -2512,17 +2698,15 @@ static int parse_group(o_string *dest, struct p_context *ctx,
 
 /* basically useful version until someone wants to get fancier,
  * see the bash man page under "Parameter Expansion" */
-static void lookup_param(o_string *dest, struct p_context *ctx, o_string *src)
+static char *lookup_param(char *src)
 {
-       const char *p=NULL;
-
-       if (src->data) { 
-               p = getenv(src->data);
+       char *p=NULL;
+       if (src) { 
+               p = getenv(src);
                if (!p) 
-                       p = get_local_var(src->data);
+                       p = get_local_var(src);
        }
-       if (p) parse_string(dest, ctx, p);   /* recursion */
-       b_free(src);
+       return p;
 }
 
 /* return code: 0 for OK, 1 for syntax error */
@@ -2533,18 +2717,19 @@ static int handle_dollar(o_string *dest, struct p_context *ctx, struct in_str *i
 #else
        int advance=0;
 #endif         
-       o_string alt=NULL_O_STRING;
 #ifndef __PPCBOOT__    
        char sep[]=" ";
 #endif 
        int ch = input->peek(input);  /* first character after the $ */
        debug_printf("handle_dollar: ch=%c\n",ch);
        if (isalpha(ch)) {
+               b_addchr(dest, SPECIAL_VAR_SYMBOL);
+               ctx->child->sp++;
                while(ch=b_peek(input),isalnum(ch) || ch=='_') {
                        b_getch(input);
-                       b_addchr(&alt,ch);
+                       b_addchr(dest,ch);
                }
-               lookup_param(dest, ctx, &alt);
+               b_addchr(dest, SPECIAL_VAR_SYMBOL);
 #ifndef __PPCBOOT__
        } else if (isdigit(ch)) {
                i = ch-'0';  /* XXX is $0 special? */
@@ -2575,16 +2760,18 @@ static int handle_dollar(o_string *dest, struct p_context *ctx, struct in_str *i
                        break;
 #endif                 
                case '{':
+                       b_addchr(dest, SPECIAL_VAR_SYMBOL);
+                       ctx->child->sp++;
                        b_getch(input);
                        /* XXX maybe someone will try to escape the '}' */
                        while(ch=b_getch(input),ch!=EOF && ch!='}') {
-                               b_addchr(&alt,ch);
+                               b_addchr(dest,ch);
                        }
                        if (ch != '}') {
                                syntax();
                                return 1;
                        }
-                       lookup_param(dest, ctx, &alt);
+                       b_addchr(dest, SPECIAL_VAR_SYMBOL);
                        break;
 #ifndef __PPCBOOT__                    
                case '(':
@@ -2618,12 +2805,14 @@ static int handle_dollar(o_string *dest, struct p_context *ctx, struct in_str *i
        return 0;
 }
 
+#ifndef __PPCBOOT__
 int parse_string(o_string *dest, struct p_context *ctx, const char *src)
 {
        struct in_str foo;
        setup_string_in_str(&foo, src);
        return parse_stream(dest, ctx, &foo, '\0');
 }
+#endif
 
 /* return code is 0 for normal exit, 1 for syntax error */
 int parse_stream(o_string *dest, struct p_context *ctx,
@@ -2653,13 +2842,9 @@ int parse_stream(o_string *dest, struct p_context *ctx,
                        b_addqchr(dest, ch, dest->quote);
                } else {
                        if (m==2) {  /* unquoted IFS */
-#ifndef __PPCBOOT__                    
-                               done_word(dest, ctx);
-#else
-                               if (done_word(dest, ctx)) { 
+                               if (done_word(dest, ctx)) {
                                        return 1;
                                }       
-#endif                                                                 
                                /* If we aren't performing a substitution, treat a newline as a
                                 * command separator.  */
                                if (end_trigger != '\0' && ch=='\n')
@@ -2852,40 +3037,47 @@ int parse_stream_outer(struct in_str *inp, int end)
        struct p_context ctx;
        o_string temp=NULL_O_STRING;
        int rcode;
-
        do {
                initialize_context(&ctx);
                update_ifs_map();
-               inp->promptmode=1;              
+               inp->promptmode=1;
                rcode = parse_stream(&temp, &ctx, inp, '\n');
 #ifdef __PPCBOOT__             
-       if (rcode != 1) {
-#endif 
-               done_word(&temp, &ctx);
-               done_pipe(&ctx,PIPE_SEQ);
-               run_list(ctx.list_head);
-               b_free(&temp);
-#ifdef __PPCBOOT__             
-       } else {
-               if (ctx.old_flag != 0) {
-                       free(ctx.stack);
-                       b_reset(&temp);                                 
-               }
-               if (inp->__promptme == 0) printf("<INTERRUPT>\n");
-               inp->__promptme = 1;
-               temp.nonnull = 0;
-               temp.quote = 0;
-               inp->p = NULL;  
-               free_pipe_list(ctx.list_head,0);
-               b_free(&temp);                          
+               if (rcode == 1) flag_repeat = 0;
+#endif
+               if (rcode != 1) {
+                       done_word(&temp, &ctx);
+                       done_pipe(&ctx,PIPE_SEQ);
+#ifndef __PPCBOOT__
+                       run_list(ctx.list_head);
+#else
+                       rcode = run_list(ctx.list_head);
+                       if (rcode == -1) flag_repeat = 0;
+#endif
+               } else {
+                       if (ctx.old_flag != 0) {
+                               free(ctx.stack);
+                               b_reset(&temp);
+                       }       
+#ifdef __PPCBOOT__
+                       if (inp->__promptme == 0) printf("<INTERRUPT>\n");
+                       inp->__promptme = 1;
+#endif                 
+                       temp.nonnull = 0;
+                       temp.quote = 0;
+                       inp->p = NULL;
+                       free_pipe_list(ctx.list_head,0);
                }
+               b_free(&temp);
+#ifndef __PPCBOOT__
+       } while (rcode != -1);   /* loop on syntax errors, return on EOF */
+       return 0;
+#else
        } while (end != 1);
        return (rcode != 1) ? 0 : 1;
-#else
-       } while (rcode != -1);  /* loop on syntax errors, return on EOF */
-       return 0;
 #endif /* __PPCBOOT__ */
 }
+
 #ifndef __PPCBOOT__
 static int parse_string_outer(const char *s)
 #else
@@ -2893,12 +3085,12 @@ int parse_string_outer(char *s)
 #endif /* __PPCBOOT__ */
 {
        struct in_str input;
-
        setup_string_in_str(&input, s);
 #ifdef __PPCBOOT__
        if ( !s || !*s)
                return 1;
        return parse_stream_outer(&input, 1);
+
 #else
        return parse_stream_outer(&input);
 #endif /* __PPCBOOT__ */
@@ -2937,6 +3129,28 @@ int ppcboot_hush_start(bd_t *bd)
        parse_file_outer();
        return 1;
 }
+
+static void *xmalloc(size_t size) 
+{
+       void *p = NULL;
+       
+       if (!(p = malloc(size))) {
+           printf("ERROR : memory not allocated\n");
+           for(;;);
+       }    
+       return p;       
+}
+
+static void *xrealloc(void *ptr, size_t size) 
+{
+       void *p = NULL;
+       
+       if (!(p = realloc(ptr, size))) {
+           printf("ERROR : memory not allocated\n");
+           for(;;);
+       }    
+       return p;       
+}
 #endif /* __PPCBOOT__ */
 
 #ifndef __PPCBOOT__
@@ -3097,5 +3311,79 @@ final_return:
        return(opt?opt:last_return_code);
 }
 #endif
+
+static char *insert_var_value(char *inp)
+{
+       int res_str_len = 0;
+       int len;
+       int done = 0;
+       char *p, *p1, *res_str = NULL;
+       
+       while ((p = strchr(inp, SPECIAL_VAR_SYMBOL))) {
+               if (p != inp) {
+                       len = p - inp;
+                       res_str = xrealloc(res_str, (res_str_len + len));
+                       strncpy((res_str + res_str_len), inp, len);
+                       res_str_len += len;
+               }
+               inp = ++p;
+               p = strchr(inp, SPECIAL_VAR_SYMBOL);
+               *p = '\0';
+               if ((p1 = lookup_param(inp))) {
+                       len = res_str_len + strlen(p1);
+                       res_str = xrealloc(res_str, (1 + len));
+                       strcpy((res_str + res_str_len), p1);
+                       res_str_len = len;
+               } 
+               *p = SPECIAL_VAR_SYMBOL;
+               inp = ++p;
+               done = 1;
+       }
+       if (done) {
+               res_str = xrealloc(res_str, (1 + res_str_len + strlen(inp)));
+               strcat(res_str, inp);
+       }
+       return (res_str == NULL) ? inp : res_str;
+}
+
+static char **make_list_in(char **inp, char *name)
+{
+       int len, i;
+       int name_len = strlen(name);
+       int n = 0;
+       char **list = NULL;
+       char *p1, *p2, *p3;
+       
+       /* create list of variable values */    
+       for (i = 0; inp[i]; i++) {
+               p3 = insert_var_value(inp[i]);
+               p1 = p3;
+               while (*p1) {
+                       if ((*p1 == ' ')) {
+                               p1++;
+                               continue;
+                       }
+                       if ((p2 = strchr(p1, ' '))) {
+                               len = p2 - p1;
+                       } else {        
+                               len = strlen(p1);
+                               p2 = p1 + len;
+                       }
+                       /* we use n + 2 in realloc for list,because we add 
+                        * new element and then we will add NULL element */
+                       list = xrealloc(list, sizeof(*list) * (n + 2));                 
+                       list[n] = xmalloc(2 + name_len + len);
+                       strcpy(list[n], name);
+                       strcat(list[n], "=");
+                       strncat(list[n], p1, len);
+                       list[n++][name_len + len + 1] = '\0';
+                       p1 = p2;
+               }
+               if (p3 != inp[i]) free(p3);
+       }
+       list[n] = NULL;
+       return list;
+}      
+
 #endif /* CFG_HUSH_PARSER */
 /****************************************************************************/
index d74075f2f364e26009c6f4020a85623585503d63..2e339c035e7362eb0bb3bdfe50079d40a8259cd1 100644 (file)
 /*
  * Configurable monitor commands
  */
-#define CFG_CMD_BDI    0x00000001      /* bdinfo                       */
-#define CFG_CMD_LOADS  0x00000002      /* loads                        */
-#define CFG_CMD_LOADB  0x00000004      /* loadb                        */
-#define CFG_CMD_IMI    0x00000008      /* iminfo                       */
-#define CFG_CMD_CACHE  0x00000010      /* icache, dcache               */
-#define CFG_CMD_FLASH  0x00000020      /* flinfo, erase, protect       */
-#define CFG_CMD_MEMORY 0x00000040      /* md, mm, nm, mw, cp, cmp,     */
-                                       /* crc, base, loop, mtest       */
-#define CFG_CMD_NET    0x00000080      /* bootp, tftpboot, rarpboot    */
-#define CFG_CMD_ENV    0x00000100      /* saveenv                      */
-#define CFG_CMD_KGDB   0x00000200      /* kgdb                         */
-#define CFG_CMD_PCMCIA 0x00000400      /* PCMCIA support               */
-#define        CFG_CMD_IDE     0x00000800      /* IDE harddisk support         */
-#define        CFG_CMD_PCI     0x00001000      /* pciinfo                      */
-#define        CFG_CMD_IRQ     0x00002000      /* irqinfo                      */
-#define CFG_CMD_BOOTD  0x00004000      /* bootd                        */
-#define CFG_CMD_CONSOLE        0x00008000      /* coninfo                      */
-#define CFG_CMD_EEPROM 0x00010000      /* EEPROM read/write support    */
-#define        CFG_CMD_ASKENV  0x00020000      /* ask for env variable         */
-#define        CFG_CMD_RUN     0x00040000      /* run command in env variable  */
-#define        CFG_CMD_ECHO    0x00080000      /* echo arguments               */
-#define        CFG_CMD_I2C     0x00100000      /* I2C serial bus support       */
-#define        CFG_CMD_REGINFO 0x00200000      /* Register dump                */
-#define        CFG_CMD_IMMAP   0x00400000      /* IMMR dump support            */
-#define        CFG_CMD_DATE    0x00800000      /* support for RTC, date/time...*/
-#define CFG_CMD_DHCP   0x01000000      /* DHCP Support                 */
-#define CFG_CMD_BEDBUG  0x02000000      /* Include BedBug Debugger      */
-#define        CFG_CMD_FDC     0x04000000      /* Floppy Disk Support  */
-#define        CFG_CMD_SCSI    0x08000000      /* SCSI Support */
-#define        CFG_CMD_AUTOSCRIPT  0x10000000  /* Autoscript Support   */
-#define        CFG_CMD_MII     0x20000000      /* MII support                  */
-#define CFG_CMD_SETGETDCR   0x40000000 /* DCR support on 4xx           */
-#define        CFG_CMD_BSP     0x80000000      /* Board Specific functions     */
-
-#define CFG_CMD_ELF     0x0000000100000000      /* ELF (VxWorks) load/boot cmd  */
+#define CFG_CMD_BDI            0x00000001      /* bdinfo                       */
+#define CFG_CMD_LOADS          0x00000002      /* loads                        */
+#define CFG_CMD_LOADB          0x00000004      /* loadb                        */
+#define CFG_CMD_IMI            0x00000008      /* iminfo                       */
+#define CFG_CMD_CACHE          0x00000010      /* icache, dcache               */
+#define CFG_CMD_FLASH          0x00000020      /* flinfo, erase, protect       */
+#define CFG_CMD_MEMORY         0x00000040      /* md, mm, nm, mw, cp, cmp,     */
+                                               /* crc, base, loop, mtest       */
+#define CFG_CMD_NET            0x00000080      /* bootp, tftpboot, rarpboot    */
+#define CFG_CMD_ENV            0x00000100      /* saveenv                      */
+#define CFG_CMD_KGDB           0x00000200      /* kgdb                         */
+#define CFG_CMD_PCMCIA         0x00000400      /* PCMCIA support               */
+#define        CFG_CMD_IDE             0x00000800      /* IDE harddisk support         */
+#define        CFG_CMD_PCI             0x00001000      /* pciinfo                      */
+#define        CFG_CMD_IRQ             0x00002000      /* irqinfo                      */
+#define CFG_CMD_BOOTD          0x00004000      /* bootd                        */
+#define CFG_CMD_CONSOLE                0x00008000      /* coninfo                      */
+#define CFG_CMD_EEPROM         0x00010000      /* EEPROM read/write support    */
+#define        CFG_CMD_ASKENV          0x00020000      /* ask for env variable         */
+#define        CFG_CMD_RUN             0x00040000      /* run command in env variable  */
+#define        CFG_CMD_ECHO            0x00080000      /* echo arguments               */
+#define        CFG_CMD_I2C             0x00100000      /* I2C serial bus support       */
+#define        CFG_CMD_REGINFO         0x00200000      /* Register dump                */
+#define        CFG_CMD_IMMAP           0x00400000      /* IMMR dump support            */
+#define        CFG_CMD_DATE            0x00800000      /* support for RTC, date/time...*/
+#define CFG_CMD_DHCP           0x01000000      /* DHCP Support                 */
+#define CFG_CMD_BEDBUG         0x02000000      /* Include BedBug Debugger      */
+#define        CFG_CMD_FDC             0x04000000      /* Floppy Disk Support          */
+#define        CFG_CMD_SCSI            0x08000000      /* SCSI Support                 */
+#define        CFG_CMD_AUTOSCRIPT      0x10000000      /* Autoscript Support           */
+#define        CFG_CMD_MII             0x20000000      /* MII support                  */
+#define CFG_CMD_SETGETDCR      0x40000000      /* DCR support on 4xx           */
+#define        CFG_CMD_BSP             0x80000000      /* Board Specific functions     */
+
+#define CFG_CMD_ELF    0x0000000100000000      /* ELF (VxWorks) load/boot cmd  */
+#define CFG_CMD_MISC   0x0000000200000000      /* Misc functions like sleep etc*/
 
 #define CFG_CMD_ALL    0xFFFFFFFFFFFFFFFF      /* ALL commands                 */
 
index acc3f5b65cc85d05bcf23920d338f2f8b703b871..8940d6b3a9c6946eae7b54286489ce9a89d9184e 100644 (file)
 
 #if (CONFIG_COMMANDS & CFG_CMD_EEPROM)
 
+#ifdef CFG_I2C_MULTI_EEPROMS
+#define        CMD_TBL_EEPROM  MK_CMD_TBL_ENTRY(   \
+       "eeprom",       3,      6,      1,      do_eeprom,                      \
+       "eeprom  - EEPROM sub-system\n",                                        \
+       "read  devaddr addr off cnt\n"                                          \
+       "eeprom write devaddr addr off cnt\n"                                   \
+       "       - read/write `cnt' bytes from `devaddr` EEPROM at offset `off'\n" \
+),
+#else /* One EEPROM */
 #define        CMD_TBL_EEPROM  MK_CMD_TBL_ENTRY(                                       \
        "eeprom",       3,      5,      1,      do_eeprom,                      \
-       "eeprom  - EEPROM sub-system\n",                                                \
+       "eeprom  - EEPROM sub-system\n",                                        \
        "read  addr off cnt\n"                                                  \
        "eeprom write addr off cnt\n"                                           \
        "       - read/write `cnt' bytes at EEPROM offset `off'\n"              \
 ),
+#endif /* CFG_I2C_MULTI_EEPROMS */
 int do_eeprom (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[]);
 #else
 
index e3afb05c6338b321d7132f3fd7c12652f12992ca..7c0620d5322c36f15473fb60c3bec3b7e70f6d01 100644 (file)
@@ -58,4 +58,18 @@ int do_irqinfo (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[]);
 #define CMD_TBL_IRQINFO
 #endif  /* CONFIG_COMMANDS & CFG_CMD_IRQ */
 
+#if (CONFIG_COMMANDS & CFG_CMD_MISC)
+#define        CMD_TBL_MISC    MK_CMD_TBL_ENTRY(                                       \
+       "sleep",        5,      2,      2,      do_sleep,                       \
+       "sleep   - delay execution for some time\n",                            \
+       "N\n"                                                                   \
+       "    - delay execution for N seconds (N is _decimal_ !!!)\n"            \
+),
+
+/* Implemented in common/cmd_misc.c */
+int do_sleep (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[]);
+#else
+#define CMD_TBL_MISC
+#endif /* CFG_CMD_MISC */
+
 #endif /* _CMD_MISC_H */
index fa4767d24243e71fd033663aa62e12b8ff9d8b39..a0e97f64dee128dba76f03f8acf09d9daa2de423 100644 (file)
@@ -89,7 +89,7 @@
 #define        CFG_LONGHELP                    /* undef to save memory         */
 #define        CFG_PROMPT              "=> "   /* Monitor Command Prompt       */
 
-#undef CFG_HUSH_PARSER                 /* use "hush" command parser    */
+#define        CFG_HUSH_PARSER         1       /* use "hush" command parser    */
 #ifdef CFG_HUSH_PARSER
 #define        CFG_PROMPT_HUSH_PS2     "> "
 #endif
index cc99d745003971acb54633ae5a91f425a942cb3b..5737dd78056c3b6daf1b7576668bec8b8cd0b93a 100644 (file)
 #define CONFIG_BOOTDELAY       3               /* autoboot after 3 seconds     */
 
 #if 1
-#define CONFIG_BOOTCOMMAND     "bootvx"        /* autoboot command             */
+#define CONFIG_BOOTCOMMAND     "bootvx"        /* VxWorks boot command         */
 #else
 #define CONFIG_BOOTCOMMAND     "bootp"         /* autoboot command             */
 #endif
 
 #undef CONFIG_BOOTARGS
 
-#define CONFIG_LOADADDR                0x10000
+#define CONFIG_LOADADDR                F0080000
+
+#undef CONFIG_ETHADDR                          /* Default, overridden at boot  */
+#define CONFIG_IPADDR          192.168.1.1
+#define CONFIG_NETMASK         255.255.255.0
+#define CONFIG_SERVERIP                192.168.1.2
 
 #define CONFIG_LOADS_ECHO      1               /* echo on for serial download  */
-#define CFG_LOADS_BAUD_CHANGE  1               /* allow baudrate change        */
+#undef CFG_LOADS_BAUD_CHANGE                   /* disallow baudrate change     */
 
 #define CONFIG_MII             1               /* MII PHY management           */
 #define CONFIG_PHY_ADDR                0               /* PHY address                  */
 #include <cmd_confdefs.h>
 
 #undef CONFIG_WATCHDOG                         /* watchdog disabled            */
+#undef CONFIG_HW_WATCHDOG                      /* HW Watchdog, board specific */
 
 /*
  * Miscellaneous configurable options
  */
 #define CFG_LONGHELP                           /* undef to save memory         */
 #define CFG_PROMPT             "Wave7Optics> " /* Monitor Command Prompt       */
+#define  CFG_HUSH_PARSER                       /* Hush parse for ppcboot       */
+#ifdef  CFG_HUSH_PARSER 
+#define CFG_PROMPT_HUSH_PS2     "> "            
+#endif
 #if (CONFIG_COMMANDS & CFG_CMD_KGDB)
 #define CFG_CBSIZE             1024            /* Console I/O Buffer Size      */
 #else
 #define CFG_EXT_SERIAL_CLOCK   11059200        /* use external serial clock    */
 
 /* The following table includes the supported baudrates */
-#define CFG_BAUDRATE_TABLE     \
-       {50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800, 7200, \
-        9600, 19200, 14400, 28800, 33600, 38400, 57600, 76800, 115200, \
-        153600, 230400, 307200, 691200}
+#define CFG_BAUDRATE_TABLE     {9600}
 
 #define CFG_CLKS_IN_HZ         1               /* everything, incl board info, in Hz */
 
 #define CFG_LOAD_ADDR          0x100000        /* default load address         */
-#define CFG_EXTBDINFO          1               /* To use extended board_info (bd_t) */
+#define CFG_EXTBDINFO          1               /* use extended board_info (bd_t) */
 
 #define CFG_HZ                 1000            /* decrementer freq: 1 ms ticks */
 
 
 #define CONFIG_PCI                             /* include pci support          */
 #define CONFIG_PCI_HOST                PCI_HOST_AUTO   /* select pci host function     */
-#define CONFIG_PCI_PNP                         /* no pci plug-and-play         */
+#define CONFIG_PCI_PNP                         /* pci plug-and-play            */
 /* resource configuration      */
 #define CFG_PCI_SUBSYS_VENDORID 0x1014         /* PCI Vendor ID: IBM           */
 #define CFG_PCI_SUBSYS_DEVICEID 0x0156         /* PCI Device ID: 405GP         */
 #define CFG_PCI_PTM1LA         0x00000000      /* point to sdram               */
 #define CFG_PCI_PTM1MS         0x80000001      /* 2GB, enable hard-wired to 1  */
-#define CFG_PCI_PTM2LA         0xfff00000      /* point to flash               */
-#define CFG_PCI_PTM2MS         0xfff00001      /* 1MB, enable                  */
+#define CFG_PCI_PTM2LA         0x00000000      /* disabled             */
+#define CFG_PCI_PTM2MS         0x00000000      /* disabled             */
 
 /*-----------------------------------------------------------------------
  * Start addresses for the final memory configuration
  * Please note that CFG_SDRAM_BASE _must_ start at 0
  */
 #define CFG_SDRAM_BASE         0x00000000
-#define CFG_FLASH_BASE         0xFFF80000
+#define CFG_FLASH_BASE         0xFFFD0000
 #define CFG_MONITOR_BASE       CFG_FLASH_BASE
 #define CFG_MONITOR_LEN                (192 * 1024)    /* Reserve 196 kB for Monitor   */
 #define CFG_MALLOC_LEN         (128 * 1024)    /* Reserve 128 kB for malloc()  */
  * Flash EEPROM for environment
  */
 #define CFG_ENV_IS_IN_FLASH 1
-#define CFG_ENV_OFFSET         0x00050000      /* Offset of Environment Sector */
+#define CFG_ENV_OFFSET         0x00040000      /* Offset of Environment Sector */
 #define CFG_ENV_SIZE           0x10000         /* Total Size of env. sector    */
 
 #define CFG_ENV_SECT_SIZE      0x10000         /* see README - env sec tot sze */
 #endif
 
 /*-----------------------------------------------------------------------
- * I2C EEPROM (ATMEL 24C04N)
+ * I2C EEPROM (Catalyst CAT24WC08)
  */
 #undef CONFIG_I2C_X                            /* 8 bit access                 */
-#define CFG_I2C_EEPROM_ADDR    0x50            /* EEPROM ATMEL 24C04N          */
+#define CFG_I2C_EEPROM_ADDR    0x50            /* EEPROM Catalyst CAT24WC08            */
+#define CFG_I2C_MULTI_EEPROMS
 
 #define CONFIG_I2C
 
 #define CFG_INIT_RAM_ADDR      0x00df0000      /* inside of SDRAM              */
 #define CFG_INIT_RAM_END       0x0f00          /* End of used area in RAM      */
 #define CFG_INIT_DATA_SIZE     64              /* size in bytes reserved for initial data */
-#define CFG_INIT_DATA_OFFSET (CFG_INIT_RAM_END - CFG_INIT_DATA_SIZE)
-#define CFG_INIT_SP_OFFSET  CFG_INIT_DATA_OFFSET
+#define CFG_INIT_DATA_OFFSET   (CFG_INIT_RAM_END - CFG_INIT_DATA_SIZE)
+#define CFG_INIT_SP_OFFSET     CFG_INIT_DATA_OFFSET
 
 
 /*
index d387a05d656526ad4b1f522c37afc9e35401bef9..8e84321dc9823170e11d2b3013d182643aa8bd00 100644 (file)
 #define CONFIG_BOOTDELAY       3               /* autoboot after 3 seconds     */
 
 #if 1
-#define CONFIG_BOOTCOMMAND     "bootvx"        /* autoboot command             */
+#define CONFIG_BOOTCOMMAND     "bootvx"        /* VxWorks boot command         */
 #else
 #define CONFIG_BOOTCOMMAND     "bootp"         /* autoboot command             */
 #endif
 
 #undef CONFIG_BOOTARGS
 
-#define CONFIG_LOADADDR                0x10000
+#define CONFIG_LOADADDR                F0080000
+
+#undef CONFIG_ETHADDR                          /* Default, overridden at boot  */
+#define CONFIG_IPADDR          192.168.1.1
+#define CONFIG_NETMASK         255.255.255.0
+#define CONFIG_SERVERIP                192.168.1.2
 
 #define CONFIG_LOADS_ECHO      1               /* echo on for serial download  */
-#define CFG_LOADS_BAUD_CHANGE  1               /* allow baudrate change        */
+#undef CFG_LOADS_BAUD_CHANGE                   /* disallow baudrate change     */
 
 #define CONFIG_MII             1               /* MII PHY management           */
 #define CONFIG_PHY_ADDR                0               /* PHY address                  */
 
-#define CONFIG_RTC_M48T35A     1               /* ST Electronics M48 timekeeper*/
+#define CONFIG_RTC_M48T35A     1               /* ST Electronics M48 timekeeper */
 
 #define CONFIG_COMMANDS                \
        (CONFIG_CMD_DFL | CFG_CMD_PCI | CFG_CMD_IRQ | CFG_CMD_ASKENV | \
 #include <cmd_confdefs.h>
 
 #undef CONFIG_WATCHDOG                         /* watchdog disabled            */
+#undef CONFIG_HW_WATCHDOG                      /* HW Watchdog, board specific */
 
 /*
  * Miscellaneous configurable options
  */
 #define CFG_LONGHELP                           /* undef to save memory         */
 #define CFG_PROMPT             "Wave7Optics> " /* Monitor Command Prompt       */
+#define  CFG_HUSH_PARSER                       /* Hush parse for ppcboot       */
+#ifdef  CFG_HUSH_PARSER 
+#define CFG_PROMPT_HUSH_PS2     "> "            
+#endif
 #if (CONFIG_COMMANDS & CFG_CMD_KGDB)
 #define CFG_CBSIZE             1024            /* Console I/O Buffer Size      */
 #else
 #define CFG_EXT_SERIAL_CLOCK   11059200        /* use external serial clock    */
 
 /* The following table includes the supported baudrates */
-#define CFG_BAUDRATE_TABLE     \
-       {50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800, 7200, \
-        9600, 19200, 14400, 28800, 33600, 38400, 57600, 76800, 115200, \
-        153600, 230400, 307200, 691200}
+#define CFG_BAUDRATE_TABLE     {9600}
 
 #define CFG_CLKS_IN_HZ         1               /* everything, incl board info, in Hz */
 
 
 #define CONFIG_PCI                             /* include pci support          */
 #define CONFIG_PCI_HOST                PCI_HOST_AUTO   /* select pci host function     */
-#define CONFIG_PCI_PNP                         /* no pci plug-and-play         */
-/* resource configuration   */
+#define CONFIG_PCI_PNP                         /* pci plug-and-play            */
+/* resource configuration      */
 #define CFG_PCI_SUBSYS_VENDORID 0x1014         /* PCI Vendor ID: IBM           */
 #define CFG_PCI_SUBSYS_DEVICEID 0x0156         /* PCI Device ID: 405GP         */
 #define CFG_PCI_PTM1LA         0x00000000      /* point to sdram               */
 #define CFG_PCI_PTM1MS         0x80000001      /* 2GB, enable hard-wired to 1  */
-#define CFG_PCI_PTM2LA         0xfff00000      /* point to flash               */
-#define CFG_PCI_PTM2MS         0xfff00001      /* 1MB, enable                  */
+#define CFG_PCI_PTM2LA         0x00000000      /* disabled             */
+#define CFG_PCI_PTM2MS         0x00000000      /* disabled             */
 
 /*-----------------------------------------------------------------------
  * Start addresses for the final memory configuration
  * Please note that CFG_SDRAM_BASE _must_ start at 0
  */
 #define CFG_SDRAM_BASE         0x00000000
-#define CFG_FLASH_BASE         0xFFF80000
+#define CFG_FLASH_BASE         0xFFFD0000
 #define CFG_MONITOR_BASE       CFG_FLASH_BASE
 #define CFG_MONITOR_LEN                (192 * 1024)    /* Reserve 196 kB for Monitor   */
 #define CFG_MALLOC_LEN         (128 * 1024)    /* Reserve 128 kB for malloc()  */
  * Flash EEPROM for environment
  */
 #define CFG_ENV_IS_IN_FLASH 1
-#define CFG_ENV_OFFSET         0x00050000      /* Offset of Environment Sector */
+#define CFG_ENV_OFFSET         0x00040000      /* Offset of Environment Sector */
 #define CFG_ENV_SIZE           0x10000         /* Total Size of env. sector    */
 
 #define CFG_ENV_SECT_SIZE      0x10000         /* see README - env sec tot sze */
  */
 #undef CONFIG_I2C_X                            /* 8 bit access                 */
 #define CFG_I2C_EEPROM_ADDR    0x50            /* EEPROM ATMEL 24C04N          */
+#define CFG_I2C_MULTI_EEPROMS
 
 #define CONFIG_I2C
 
 #define CONFIG_PORT_ADDR       0xF0000500
 
 /*-----------------------------------------------------------------------
- * Definitions for initial stack pointer and data area
+ * Definitions for initial stack pointer and data area (in RAM)
  */
 #define CFG_INIT_RAM_ADDR      0x00df0000      /* inside of SDRAM              */
 #define CFG_INIT_RAM_END       0x0f00          /* End of used area in RAM      */
index aff0deec5c07352df2e1d4266c605b83609f336a..5467c98e5709b04a3f304027f83348a805816fa2 100644 (file)
@@ -194,6 +194,7 @@ void                env_relocate (ulong);
 char          *getenv (uchar *);
 int          getenv_r (uchar *name, uchar *buf, unsigned len);
 void inline    setenv (char *, char *);
+int         saveenv(void);
 
 #if defined(CONFIG_CPCI405)    || \
     defined(CONFIG_AR405)      || \
@@ -256,14 +257,24 @@ void      reset_phy     (void);
     defined(CONFIG_WALNUT405)
 /* $(BOARD)/eeprom.c */
 void eeprom_init  (void);
-int  eeprom_read  (unsigned offset, uchar *buffer, unsigned cnt);
-int  eeprom_write (unsigned offset, uchar *buffer, unsigned cnt);
+int  eeprom_read  (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt);
+int  eeprom_write (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt);
 # ifdef CONFIG_LWMON
 extern uchar pic_read  (uchar reg);
 extern void  pic_write (uchar reg, uchar val);
 # endif
 #endif
 
+/*
+ * Set this up regardless of board
+ * type, to prevent errors.
+ */
+#if defined(CONFIG_SPI) || !defined(CFG_I2C_EEPROM_ADDR)
+# define CFG_DEF_EEPROM_ADDR 0
+#else
+# define CFG_DEF_EEPROM_ADDR CFG_I2C_EEPROM_ADDR
+#endif /* CONFIG_SPI || !defined(CFG_I2C_EEPROM_ADDR) */
+
 #if defined(CONFIG_PCU_E) || defined(CONFIG_CCM)
 extern void spi_init_f (void);
 extern void spi_init_r (void);
@@ -382,9 +393,6 @@ int checkicache   (void);
 int    checkdcache   (void);
 void   upmconfig     (unsigned int, unsigned int *, unsigned int);
 ulong  get_tbclk     (void);
-#if defined(CONFIG_WATCHDOG)
-void   watchdog_reset(void);
-#endif /* CONFIG_WATCHDOG */
 
 /* $(CPU)/speed.c */
 #if defined(CONFIG_8260)
@@ -411,16 +419,6 @@ ulong      get_bus_freq  (ulong);
 void    get_sys_info  (PPC405_SYS_INFO *);
 #endif
 
-/* $(CPU)/cpu.c */
-#if defined(CONFIG_8xx)
-void reset_8xx_watchdog(volatile immap_t *immr);
-#endif
-
-/* $(CPU)/cpu.c */
-#if defined(CONFIG_4xx)
-void reset_4xx_watchdog(void);
-#endif
-
 /* $(CPU)/cpu_init.c */
 #if defined(CONFIG_8xx) || defined(CONFIG_8260)
 void   cpu_init_f    (volatile immap_t *immr);