Mercurial > ecos-v3_0-branch
diff packages/redboot/current/src/parse.c @ 2257:467fd46113f3
* src/fs/fileio.c (do_list): Use getcwd for current directory,
rather than "." which may not be implemented in the FS.
* src/parse.c (redboot_exec): Conditionalise use of
__mem_fault_handler to only be when stubs are included.
(error_handler): Ditto for this function.
* src/main.c (cyg_start): Conditionalise use of
__mem_fault_handler to only be when stubs are included.
(do_go): Ditto.
(error_handler): Ditto for this function.
* src/fs/fileio.c (do_mkdir, do_deldir, do_del, do_write): Added
some extra argument checking to these functions.
* src/fs/fileio.c (do_mount): Only support -f with "legacy" flash
block devices.
Clear mount table on failure.
(do_move): Silence rename undefined warning.
(do_write): Silence warnings.
(do_info): Support longer device names.
* src/decompress.c (ZLIB_COMPRESSION_OVERHEAD):
Increase substantially if jffs2 is present.
* src/fs/fileio.c: Fixed some bugs in handling of mounts. The
strings used in the mount table must be copied, otherwise the
mount table is corrupted by later commands. Also toughened up some
error testing.
* doc/redboot_cmds.sgml: Added file mode documentation to load
command.
* doc/redboot_cmds.sgml: Added documentation of filesystem access
commands.
* src/fs/fileio.c (do_write): Added O_TRUNC to the open call to
ensure that the file is resized to fit the new data.
* src/fs/fileio.c: Significantly reorganized to present an
interface similar to the fis commands. Added a variety of command
to manipulate files and directories in a filesystem.
* src/parse.c: Added redboot_exec() to provide an internal
interface for executing RedBoot commands. Added err_printf() which
allows an error message to be printed before longjumping out to an
enclosing call to redboot_exec(). Where redboot_exec() is not
involved, it just behaves like diag_printf().
* src/main.c: Removed unnecessary delay during startup. Changed
diag_printf() in do_go() into err_printf().
* src/load.c: Changed some calls to diag_printf() to err_printf().
* src/net/net_io.c: Changed init priority to RedBoot_INIT_NET.
* include/redboot.h: Added some extra initialization
priorities. Added prototypes for redboot_exec() and err_printf().
| author | jlarmour |
|---|---|
| date | Thu, 20 Jul 2006 20:27:47 +0000 |
| parents | 13ba50dd5a8e |
| children | 6cbecf3cc2e4 |
line wrap: on
line diff
--- a/packages/redboot/current/src/parse.c +++ b/packages/redboot/current/src/parse.c @@ -9,6 +9,7 @@ // ------------------------------------------- // This file is part of eCos, the Embedded Configurable Operating System. // Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc. +// Copyright (C) 2004, 2005, 2006 eCosCentric Limited // // eCos 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 @@ -32,16 +33,13 @@ // // This exception does not invalidate any other reasons why a work based on // this file might be covered by the GNU General Public License. -// -// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc. -// at http://sources.redhat.com/ecos/ecos-license/ // ------------------------------------------- //####ECOSGPLCOPYRIGHTEND#### //========================================================================== //#####DESCRIPTIONBEGIN#### // // Author(s): gthomas -// Contributors: gthomas +// Contributors: gthomas, eCosCentric // Date: 2000-07-14 // Purpose: // Description: @@ -193,6 +191,97 @@ cmd_usage(struct cmd *tab, struct cmd *t } } +// +// Handle illegal memory accesses (and other abort conditions) +// +static hal_jmp_buf error_jmpbuf; +static cyg_bool redboot_exec_call = false; +#ifdef CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS +__externC void* volatile __mem_fault_handler; + +static void error_handler(void) +{ + hal_longjmp(error_jmpbuf, 1); +} +#endif + +// Routine to allow code to invoke RedBoot commands. This is useful +// during initialization and in platform specific code. +// +// Call it like this: +// +// result = redboot_exec( "load", "-m", "file", "foo", 0 ); +// +// Note the terminating zero. The result will be zero if the command +// succeeded, and <0 if something went wrong. + +#define ARGV_MAX 20 +int redboot_exec( char *command, ... ) +{ + int argc; + char *argv[ARGV_MAX+1]; + va_list ap; + struct cmd *cmd; + int result = 0; + + va_start(ap, command); + + argv[0] = command; + for( argc = 1; argc < ARGV_MAX; argc++ ) + { + char *arg = va_arg(ap, char *); + if( arg == 0 ) + break; + argv[argc] = arg; + } + argv[argc] = NULL; + + if(( cmd = cmd_search(__RedBoot_CMD_TAB__, &__RedBoot_CMD_TAB_END__, command) )) + { + // Try to handle aborts - messy because of the stack unwinding... +#ifdef CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS + __mem_fault_handler = error_handler; +#endif + redboot_exec_call = true; + if (hal_setjmp(error_jmpbuf)) + result = -1; + else + (cmd->fun)(argc, argv); + + redboot_exec_call = false; +#ifdef CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS + __mem_fault_handler = 0; +#endif + } + else + result = -1; + + va_end(ap); + + return result; +} + +externC void err_printf( char *fmt, ... ) +{ + va_list ap; + + va_start(ap, fmt); + + diag_vprintf( fmt, ap ); + + va_end(ap); + + // If we are not in redboot_exec() just return as usual. If we are + // inside a call to redboot_exec(), longjump out to terminate the command. + + if( redboot_exec_call ) + { + diag_printf("err_printf: aborting command\n"); + hal_longjmp(error_jmpbuf, 1); + } +} + + // Option processing // Initialize option table entry (required because these entries
