Modifications for 1.1.0:
======================================================================
+* Add support for Fujitsu flash on TQM8260
+ Patch by Franz Sirl, 19 Oct 2001
+
* Updated GTH Board
Patch by Thomas Lange, 18 Oct 2001
if...then...else...fi conditionals or `&&' and '||' constructs
("shell scripts").
+ See the README file for information about implementation and usage.
+
* Modified all commands to provide return codes that can be used for
conditional command execution
printed when the command interpreter needs more input
to complete a command. Usually "> ".
+ Note:
+
+ In the current implementation, the local variables
+ space and global environment variables space are
+ separated. Local variables are those you define by
+ simply typing like `name=value'. To access a local
+ variable later on, you have write `$name' or
+ `${name}'; variable directly by typing say `$name' at
+ the command prompt.
+
+ Global environment variables are those you use
+ setenv/printenv to work with. To run a command stored
+ in such a variable, you need to use the run command,
+ and you must not use the '$' sign to access them.
+
+ To store commands and special characters in a
+ variable, please use double quotation marks
+ surrounding the whole text of the variable, instead
+ of the backslashes before semicolons and special
+ symbols.
+
+
Configuration Settings:
-----------------------
#if defined(CONFIG_AUTOSCRIPT) || \
(CONFIG_COMMANDS & CFG_CMD_AUTOSCRIPT)
+#ifdef CFG_HUSH_PARSER
+extern int parse_string_outer(char *s);
+#endif
+
extern image_header_t header; /* from cmd_bootm.c */
int
autoscript(bd_t *bd, ulong addr)
}
}
}
+#ifndef CFG_HUSH_PARSER
rcode = run_command(cmd, bd, 0);
+#else
+ rcode = parse_string_outer(cmd);
+#endif
free(cmd);
return rcode;
}
#include <rtc.h>
#endif
+#ifdef CFG_HUSH_PARSER
+extern int parse_string_outer(char *s);
+#endif
int gunzip (void *, int, unsigned char *, int *);
static void *zalloc(void *, unsigned, unsigned);
int do_bootd (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[])
{
int rcode = 0;
-
+#ifndef CFG_HUSH_PARSER
if (run_command (getenv ("bootcmd"), bd, flag) == -1) rcode = 1;
+#else
+ if (parse_string_outer(getenv("bootcmd")) != 0 ) rcode = 1;
+#endif
return rcode;
}
#endif
static unsigned int shell_terminal;
static char *PS1;
static char *PS2;
-#else
-static bd_t *BD;
-#endif
struct variables shell_ver = { "HUSH_VERSION", "0.01", 1, 1, 0 };
struct variables *top_vars = &shell_ver;
+#else
+static bd_t *BD;
+static struct variables *top_vars ;
+#endif /*__PPCBOOT__ */
#define B_CHUNK (100)
#define B_NOSPAC 1
static int parse_string(o_string *dest, struct p_context *ctx, const char *src);
static int parse_stream(o_string *dest, struct p_context *ctx, struct in_str *input0, int end_trigger);
/* setup: */
-static int parse_stream_outer(struct in_str *inp);
#ifndef __PPCBOOT__
+static int parse_stream_outer(struct in_str *inp);
static int parse_string_outer(const char *s);
static int parse_file_outer(FILE *f);
#else
+static int parse_stream_outer(struct in_str *inp, int end);
+int parse_string_outer(char *s);
int ppcboot_hush_start(bd_t *bd);
static int parse_file_outer(void);
#endif
*/
static int b_addqchr(o_string *o, int ch, int quote)
{
+#ifndef __PPCBOOT__
if (quote && strchr("*?[\\",ch)) {
int rc;
rc = b_addchr(o, '\\');
if (rc) return rc;
}
+#endif /* __PPCBOOT__ */
return b_addchr(o, ch);
}
/* most recursion does not come through here, the exeception is
* from builtin_source() */
+#ifndef __PPCBOOT__
int parse_stream_outer(struct in_str *inp)
+#else
+int parse_stream_outer(struct in_str *inp, int end)
+#endif /* __PPCBOOT__ */
{
struct p_context ctx;
o_string temp=NULL_O_STRING;
int rcode;
+
do {
initialize_context(&ctx);
update_ifs_map();
free_pipe_list(ctx.list_head,0);
b_free(&temp);
}
-#endif
+ } 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
+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__ */
}
-#endif
+
#ifndef __PPCBOOT__
static int parse_file_outer(FILE *f)
#else
struct in_str input;
#ifndef __PPCBOOT__
setup_file_in_str(&input, f);
-#else
- setup_file_in_str(&input);
-#endif
rcode = parse_stream_outer(&input);
+#else
+ setup_file_in_str(&input);
+ rcode = parse_stream_outer(&input, 0);
+#endif /* __PPCBOOT__ */
return rcode;
}
-#ifdef __PPCBOOT__
+#ifdef __PPCBOOT__
int ppcboot_hush_start(bd_t *bd)
{
- extern bd_t *BD;
+ extern bd_t *BD;
- BD = bd;
- parse_file_outer();
- return 1;
-}
-#endif
+ BD = bd;
+ top_vars = malloc(sizeof(struct variables));
+ top_vars->name = "HUSH_VERSION";
+ top_vars->value = "0.01";
+ top_vars->next = 0;
+ top_vars->flg_export = 0;
+ top_vars->flg_read_only = 1;
+ parse_file_outer();
+ return 1;
+}
+#endif /* __PPCBOOT__ */
+
#ifndef __PPCBOOT__
/* Make sure we have a controlling tty. If we get started under a job
* aware app (like bash for example), make sure we are now in charge so
#include <command.h>
#include <cmd_nvedit.h>
#include <cmd_bootm.h>
+#include <malloc.h>
#if defined(CONFIG_BOOT_RETRY_TIME) && defined(CONFIG_RESET_TO_RETRY)
#include <cmd_boot.h> /* for do_reset() prototype */
#endif
#ifdef CFG_HUSH_PARSER
-int ppcboot_hush_start(bd_t *bd);
+extern int ppcboot_hush_start(bd_t *bd);
+extern int parse_string_outer(char *s);
#endif
static char * delete_char (char *buffer, char *p, int *colp, int *np, int plen);
}
for (i=1; i<argc; ++i) {
- if (run_command (getenv (argv[i]), bd, flag) != -1) rcode = 1;
+#ifndef CFG_HUSH_PARSER
+ if (run_command (getenv (argv[i]), bd, flag) != -1) ++rcode;
+#else
+ if (parse_string_outer(getenv (argv[i])) == 0) ++rcode;
+#endif
}
- if (rcode == i) return 0;
- return rcode;
+ return ((rcode == i) ? 0 : 1);
}
#endif
#define CONFIG_RTC_MPC8xx /* use internal RTC of MPC8xx */
#define CONFIG_COMMANDS ( CONFIG_CMD_DFL | \
+ CFG_CMD_ASKENV | \
CFG_CMD_DHCP | \
CFG_CMD_IDE | \
CFG_CMD_DATE )
#define CFG_LONGHELP /* undef to save memory */
#define CFG_PROMPT "=> " /* Monitor Command Prompt */
-#define CFG_HUSH_PARSER
+#define CFG_HUSH_PARSER 1 /* use "hush" command parser */
#ifdef CFG_HUSH_PARSER
#define CFG_PROMPT_HUSH_PS2 "> "
#endif