This is the mail archive of the ecos-patches@sourceware.org mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RedBoot 'fs' additions


In our desire to avoid unnecessary forking, eCosCentric are contributing additions to the redboot 'fs' command, since it's easy to foresee someone adding the same extensions in future with a different incompatible syntax. As well as src/fs/fileio.c, there are some infrastructural changes in a few other files to support the fileio.c changes.

Checked in.

Jifl
--
eCosCentric    http://www.eCosCentric.com/    The eCos and RedBoot experts
------["The best things in life aren't things."]------      Opinions==mine
Index: ChangeLog
===================================================================
RCS file: /cvs/ecos/ecos/packages/redboot/current/ChangeLog,v
retrieving revision 1.245
diff -u -5 -p -r1.245 ChangeLog
--- ChangeLog	24 May 2006 12:24:46 -0000	1.245
+++ ChangeLog	20 Jul 2006 20:23:10 -0000
@@ -38,10 +38,15 @@
 	feature, disabled by default.
 	* cdl/main.c (cyg_start): Assert check to see if we have 
 	overflowed the workspace.
 	* doc/redboot_cmds.sgml: Document new flag.
 	
+2006-02-24  Jonathan Larmour  <jifl@eCosCentric.com>
+
+	* src/fs/fileio.c (do_list): Use getcwd for current directory,
+	rather than "." which may not be implemented in the FS.
+
 2006-02-17  Andrew Lunn  <andrew.lunn@ascom.ch>
 
 	* src/flash.c (fis_lock & fis_unlock): Allow compilation without
 	FIS being enabled.
 	* src/flash.c (fis_update_directory): When reading/writing flash
@@ -53,10 +58,21 @@
 
 2005-10-17  Gary Thomas  <gary@mlbassoc.com>
 
 	* src/iomem.c (do_iopeek): Correct number of options.
 
+2005-09-13  Jonathan Larmour  <jifl@eCosCentric.com>
+
+	* 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.
+
 2005-09-09  Andrew Dyer  <adyer@righthandtech.com>
  
  	* src/load.c: add calls to redboot_getc_terminate before exiting
  	load_elf_image() in various error scenarios, change the final call
  	to redboot_getc_terminate to have the error flag set.  This will
@@ -182,29 +198,88 @@
 2005-03-07 Alexander Neundorf <alexander.neundorf@jenoptik.com>
 
         * src/net/arp.c: use correct sizeof(rt->enet_addr) in
 	__arp_lookup()
 	
+2005-01-26  Nick Garnett  <nickg@ecoscentric.com>
+
+	* src/fs/fileio.c (do_mkdir, do_deldir, do_del, do_write): Added
+	some extra argument checking to these functions.
+
 2005-01-22  Andrew Lunn  <andrew.lunn@ascom.ch>
 
 	* src/main.c (cyg_start): Fix compiler warning with 
 	HAL_THREAD_INIT_CONTEXT and the worspace end address.
 	* src/fs/disk.c (find_dos_partitions): Removed unused variable.
 
+2005-01-19  Jonathan Larmour  <jifl@eCosCentric.com>
+
+	* 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.
+
 2005-01-05  David Vrabel  <dvrabel@arcom.com>
 
 	* src/fs/fileio.c (do_ls): Remove useless "getcwd" message.
  	* src/net/bootp.c (__bootp_find_local_ip): Only print the
  	"waiting for BOOTP" message when after first retry.
 	
+2004-12-17  Nick Garnett  <nickg@ecoscentric.com>
+
+	* 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.
+
+2004-12-16  Nick Garnett  <nickg@ecoscentric.com>
+
+	* doc/redboot_cmds.sgml: Added file mode documentation to load
+	command.
+
 2004-12-01  Andrea Michelotti  <amichelotti@atmel.com>
 
 	* main.c :
 	* mfill.c: 
 	* mcmp.c : Changes required for use with GCC v4 - cast as lvalue
 	is no longer supported.
 
+2004-11-26  Nick Garnett  <nickg@ecoscentric.com>
+
+	* 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.
+
+2004-11-24  Nick Garnett  <nickg@ecoscentric.com>
+
+	* 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().
+
 2004-11-09  Ian Campbell  <icampbell@arcom.com>
 
 	* cdl/redboot.cdl, doc/redboot_cmds.sgml, src/iomem.c: Add support
 	for iopeek and iopoke commands to allow access to the I/O regions.
 
Index: doc/redboot_cmds.sgml
===================================================================
RCS file: /cvs/ecos/ecos/packages/redboot/current/doc/redboot_cmds.sgml,v
retrieving revision 1.14
diff -u -5 -p -r1.14 redboot_cmds.sgml
--- doc/redboot_cmds.sgml	25 Feb 2006 14:21:12 -0000	1.14
+++ doc/redboot_cmds.sgml	20 Jul 2006 20:23:15 -0000
@@ -1287,13 +1287,14 @@ IP: 192.168.1.32, Default server: 192.16
 	<arg>-m
           <group>
             <arg choice="req"><group>
               <arg>xmodem</arg>
               <arg>ymodem</arg>
-            </group></arg>
-            <arg>tftp</arg>
-            <arg>disk</arg>
+              <arg>tftp</arg>
+              <arg>disk</arg>
+              <arg>file</arg></group>
+            </arg>
 	  </group>
         </arg>  
 	<arg>-h <replaceable> server_IP_address</replaceable></arg>
 	<arg>-f <replaceable> location</replaceable></arg>
 	<arg>-b <replaceable> location</replaceable></arg>
@@ -1368,10 +1369,17 @@ serial download method since it would in
 	      <entry></entry>
 	      <entry>Transfer data from a local disk.</entry>	     
 	      <entry><acronym>TFTP</acronym></entry>	     
 	    </row>
 	    <row>
+	      <entry>-m file</entry>	     
+	      <entry></entry>
+	      <entry>Transfer data from a local filesystem such as
+	             JFFS2 or FAT.</entry>	     
+	      <entry><acronym>TFTP</acronym></entry>	     
+	    </row>
+	    <row>
 	      <entry>-h <replaceable>server_IP_address</replaceable></entry>	     
 	      <entry>Numeric IP or DNS name</entry>
 	      <entry>The IP address of the <acronym>TFTP</acronym> or <acronym>HTTP</acronym> server.</entry>	     
 	      <entry>Value set by <command>ip_address</command></entry>	     
 	    </row>
@@ -1449,10 +1457,18 @@ Load an ELF file from /dev/hda1 which sh
 <screen>
 RedBoot> <userinput>load -mode disk hda1:hello.elf</userinput>
 Entry point: 0x00020000, address range: 0x00020000-0x0002fd70
 </screen>
       </para>
+      <para>
+Load an ELF file from /jffs2/applications which should be a directory
+in a JFFS2 filesystem:
+<screen>
+RedBoot> <userinput>load -mode file /jffs2/applications/hello.elf</userinput>
+Entry point: 0x00020000, address range: 0x00020000-0x0002fd70
+</screen>
+      </para>
     </refsect1>
   </refentry>
 
 <!-- ******** mcmp *************************************************** -->
   <refentry id="mcmp-command">
@@ -2792,12 +2808,770 @@ RedBoot> <userinput>fis write -b 0x0606f
 ... Program from 0x0606f000-0x0607f000 at 0x00020000: .
 </screen>
 </para>
 </refsect1>
 </refentry>
+</sect1>
+
+<sect1 id="filesystem-commands">
+<title>Filesystem Interface</title>
+
+<para>
+<indexterm><primary>commands</primary><secondary>filesystem access
+</secondary></indexterm><indexterm><primary>filesystem commands</primary>
+</indexterm><indexterm><primary>commands</primary><secondary>fs</secondary>
+</indexterm><indexterm><primary>fs commands</primary></indexterm>
+
+If the platform has access to secondary storage, then RedBoot may be
+able to access a filesystem stored on this device. RedBoot can access
+FAT filesystems stored on IDE disks or CompactFlash devices and can
+use JFFS2 filesystems stored in FLASH memory. The
+<command>fs</command> command is used to manipulate files on
+filesystems. Applications may be loaded into memory using the
+<emphasis>file</emphasis> mode of the <command>load</command> command.
+</para>
+
+<!-- ******** fs info ************************************************ -->
+
+<refentry id="fs-info-command">
+  <refnamediv>
+    <refname>fs info</refname>
+    <refpurpose>Print filesystem information</refpurpose>
+  </refnamediv>
+  <refsynopsisdiv>
+    <cmdsynopsis>
+      <command>fs info</command>
+    </cmdsynopsis>
+  </refsynopsisdiv>
+  <refsect1>
+    <title>Arguments</title>
+      <para>
+        The command takes no arguments.
+      </para>
+  </refsect1>
+  <refsect1>
+    <title>Description</title>
+<para>This command prints information about the filesystems that are
+available. Three lists are produced. The first is a list of the
+filsystem implementations available in RedBoot; names from this list
+may be used in the <parameter>-t</parameter> option to the <command>fs
+mount</command> command. The second list describes the block devices
+that are available for mounting a filesystem; names from this list may
+be used in the <parameter>-d</parameter> option to the <command>fs
+mount</command> command. The last list describes the filesystems that
+are already mounted.
+</para>
+</refsect1>
+
+  <refsect1>
+    <title>Examples</title>
+    <para>
+<screen>
+RedBoot> <userinput>fs info</userinput>                                                                
+Filesystems available:                                                          
+ramfs                                                                           
+jffs2
+
+Devices available:
+/dev/flash1
+
+Mounted filesystems:                                                            
+         Device Filesystem Mounted on                                           
+    &lt;undefined&gt;      ramfs /
+    /dev/flash1      jffs2 /flash
+RedBoot></screen>
+    </para>
+  </refsect1>
+</refentry>
+
+<!-- ******** fs mount ************************************************ -->
+
+<refentry id="fs-mount-command">
+  <refnamediv>
+    <refname>fs mount</refname>
+    <refpurpose>Mount a filesystem</refpurpose>
+  </refnamediv>
+  <refsynopsisdiv>
+    <cmdsynopsis>
+      <command>fs mount</command>
+      <arg choice="opt">-d <replaceable>device</replaceable></arg>
+      <arg choice="req">-t <replaceable>fstype</replaceable></arg>
+      <arg choice="req">mountpoint</arg>
+    </cmdsynopsis>
+  </refsynopsisdiv>
+  <refsect1>
+    <title>Arguments</title>
+    <informaltable frame="all">
+      <tgroup cols="4" colsep="1" rowsep="1" align="left">
+        <colspec colname="c1">
+        <colspec colname="c2">
+        <colspec colname="c3">
+        <colspec colname="c4">
+        <thead>
+          <row>
+            <entry>Name</entry>
+            <entry>Type</entry>
+            <entry>Description</entry>
+            <entry>Default</entry>
+          </row>
+        </thead>
+        <tbody>
+          <row>
+            <entry><replaceable>device</replaceable></entry>
+            <entry>Number</entry>
+            <entry>Device containing filsystem to mount.</entry>
+            <entry>undefined</entry>
+          </row>
+          <row>
+            <entry><replaceable>fstype</replaceable></entry>
+            <entry>Number</entry>
+            <entry>Filesystem type.</entry>
+            <entry></entry>
+          </row>
+	    <row>
+	      <entry><replaceable>mountpoint</replaceable></entry>
+	      <entry>String</entry>
+	      <entry>Pathname for filesystem root.</entry>
+	      <entry>/</entry>
+	    </row>
+        </tbody>
+      </tgroup>
+    </informaltable>
+  </refsect1>
+  <refsect1>
+    <title>Description</title>
+<para>This command is used make a filesystem available for access with
+the filesystem access commands. Three things need to be defined to do
+this. First, the name of the device on which the filesystem is stored
+needs to be given to the <parameter>-d</parameter> option. Secondly,
+the type of filesystem it is needs to be given to the
+<parameter>-t</parameter> option. Finally, the pathname by which the
+new filesystem will be accessed needs to be supplied. Following a
+successful mount, the root of the filesystem will be accessible
+at the mountpoint.
+</para>
+</refsect1>
+
+  <refsect1>
+    <title>Examples</title>
+<para>Mount a JFF2 partititon:
+<screen>
+RedBoot> <userinput>fs info</userinput>                                                                
+Filesystems available:                                                          
+ramfs                                                                           
+jffs2
+
+Devices available:
+/dev/flash1
+
+Mounted filesystems:                                                            
+         Device Filesystem Mounted on                                           
+    &lt;undefined&gt;      ramfs /
+RedBoot> <userinput>fs mount -d /dev/flash1 -t jffs2 /flash</userinput>
+RedBoot> <userinput>fs info</userinput>                                                                
+Filesystems available:                                                          
+ramfs                                                                           
+jffs2
+
+Devices available:
+/dev/flash1
+
+Mounted filesystems:                                                            
+         Device Filesystem Mounted on                                           
+    &lt;undefined&gt;      ramfs /
+    /dev/flash1      jffs2 /flash
+RedBoot>
+</screen>
+    </para>
+  </refsect1>
+</refentry>
+
+<!-- ******** fs umount ************************************************ -->
+
+<refentry id="fs-umount-command">
+  <refnamediv>
+    <refname>fs umount</refname>
+    <refpurpose>Unmount filesystem</refpurpose>
+  </refnamediv>
+  <refsynopsisdiv>
+    <cmdsynopsis>
+      <command>fs umount</command>
+      <arg choice="req"><replaceable>mountpoint</replaceable></arg>
+    </cmdsynopsis>
+  </refsynopsisdiv>
+  <refsect1>
+    <title>Arguments</title>
+    <informaltable frame="all">
+      <tgroup cols="4" colsep="1" rowsep="1" align="left">
+        <colspec colname="c1">
+        <colspec colname="c2">
+        <colspec colname="c3">
+        <colspec colname="c4">
+        <thead>
+          <row>
+            <entry>Name</entry>
+            <entry>Type</entry>
+            <entry>Description</entry>
+            <entry>Default</entry>
+          </row>
+        </thead>
+        <tbody>
+	    <row>
+	      <entry><replaceable>mountpoint</replaceable></entry>
+	      <entry>String</entry>
+	      <entry>Mountpoint of filesystem to unmount.</entry>
+	      <entry></entry>
+	    </row>
+        </tbody>
+      </tgroup>
+    </informaltable>
+  </refsect1>
+  <refsect1>
+    <title>Description</title>
+<para>This command removes a filesystem from being accessible using
+the filesystem commands. The single argument needs to be the
+mountpoint that was used when mounting the filesystem. This command
+will fail if the current directory is currently within the filesystem
+to be unmounted.
+</para>
+</refsect1>
+
+  <refsect1>
+    <title>Examples</title>
+<para>Unmount a JFF2 partititon:
+<screen>
+RedBoot> <userinput>fs info</userinput>                                                                
+Filesystems available:                                                          
+ramfs                                                                           
+jffs2
+
+Devices available:
+/dev/flash1
+
+Mounted filesystems:                                                            
+         Device Filesystem Mounted on                                           
+    &lt;undefined&gt;      ramfs /
+    /dev/flash1      jffs2 /flash
+RedBoot> <userinput>fs umount /flash</userinput>
+RedBoot> <userinput>fs info</userinput>                                                                
+Filesystems available:                                                          
+ramfs                                                                           
+jffs2
+
+Devices available:
+/dev/flash1
+
+Mounted filesystems:                                                            
+         Device Filesystem Mounted on                                           
+    &lt;undefined&gt;      ramfs /
+RedBoot>
+</screen>
+    </para>
+  </refsect1>
+</refentry>
+
+<!-- ******** fs cd ************************************************ -->
+
+<refentry id="fs-cd-command">
+  <refnamediv>
+    <refname>fs cd</refname>
+    <refpurpose>Change filesystem directory</refpurpose>
+  </refnamediv>
+  <refsynopsisdiv>
+    <cmdsynopsis>
+      <command>fs cd</command>
+      <arg choice="opt"><replaceable>directory</replaceable></arg>
+    </cmdsynopsis>
+  </refsynopsisdiv>
+  <refsect1>
+    <title>Arguments</title>
+    <informaltable frame="all">
+      <tgroup cols="4" colsep="1" rowsep="1" align="left">
+        <colspec colname="c1">
+        <colspec colname="c2">
+        <colspec colname="c3">
+        <colspec colname="c4">
+        <thead>
+          <row>
+            <entry>Name</entry>
+            <entry>Type</entry>
+            <entry>Description</entry>
+            <entry>Default</entry>
+          </row>
+        </thead>
+        <tbody>
+	    <row>
+	      <entry><replaceable>directory</replaceable></entry>
+	      <entry>String</entry>
+	      <entry>Pathname to directory to change to.</entry>
+	      <entry>Root directory</entry>
+	    </row>
+        </tbody>
+      </tgroup>
+    </informaltable>
+  </refsect1>
+  <refsect1>
+    <title>Description</title>
+<para>This command changes the current filesystem
+directory. Subsequent filesystem commands will be executed in the new
+directory. If no argument is given, then the current directory is set
+back to the root of the filesystem name space.
+</para>
+</refsect1>
+
+  <refsect1>
+    <title>Examples</title>
+    <para>Change current directory:
+<screen>
+RedBoot> <userinput>fs list</userinput>
+212416 d---------  3 size    128 .
+212416 d---------  3 size    128 ..
+211392 d---------  2 size     96 tests
+210368 ----------  1 size   4096 image
+RedBoot> <userinput>fs cd tests</userinput>
+RedBoot> <userinput>fs list</userinput>
+211392 d---------  2 size     96 .                                              
+212416 d---------  3 size    128 ..                                             
+205760 ----------  1 size  16384 test1                                          
+RedBoot>
+</screen>
+    </para>
+  </refsect1>
+</refentry>
+
+<!-- ******** fs mkdir ************************************************ -->
+
+<refentry id="fs-mkdir-command">
+  <refnamediv>
+    <refname>fs mkdir</refname>
+    <refpurpose>Create filesystem directory</refpurpose>
+  </refnamediv>
+  <refsynopsisdiv>
+    <cmdsynopsis>
+      <command>fs mkdir</command>
+      <arg choice="req"><replaceable>directory</replaceable></arg>
+    </cmdsynopsis>
+  </refsynopsisdiv>
+  <refsect1>
+    <title>Arguments</title>
+    <informaltable frame="all">
+      <tgroup cols="4" colsep="1" rowsep="1" align="left">
+        <colspec colname="c1">
+        <colspec colname="c2">
+        <colspec colname="c3">
+        <colspec colname="c4">
+        <thead>
+          <row>
+            <entry>Name</entry>
+            <entry>Type</entry>
+            <entry>Description</entry>
+            <entry>Default</entry>
+          </row>
+        </thead>
+        <tbody>
+	    <row>
+	      <entry><replaceable>directory</replaceable></entry>
+	      <entry>String</entry>
+	      <entry>Pathname to directory to delete.</entry>
+	      <entry></entry>
+	    </row>
+        </tbody>
+      </tgroup>
+    </informaltable>
+  </refsect1>
+  <refsect1>
+    <title>Description</title>
+<para>This command creates (makes) a directory in the filesystem.
+</para>
+</refsect1>
+
+  <refsect1>
+    <title>Examples</title>
+    <para>Create directory:
+<screen>
+RedBoot> <userinput>fs list</userinput>                                                                
+212416 d---------  2 size    128 .                                              
+212416 d---------  2 size    128 ..                                             
+210368 ----------  1 size   4096 image                                          
+RedBoot> <userinput>fs mkdir tests</userinput>                                                         
+RedBoot> <userinput>fs list</userinput>                                                                
+212416 d---------  3 size    128 .                                              
+212416 d---------  3 size    128 ..                                             
+211392 d---------  2 size     64 tests                                          
+210368 ----------  1 size   4096 image                                          
+RedBoot>
+</screen>
+    </para>
+  </refsect1>
+</refentry>
+
+<!-- ******** fs deldir ************************************************ -->
+
+<refentry id="fs-deldir-command">
+  <refnamediv>
+    <refname>fs deldir</refname>
+    <refpurpose>Delete filesystem directory</refpurpose>
+  </refnamediv>
+  <refsynopsisdiv>
+    <cmdsynopsis>
+      <command>fs deldir</command>
+      <arg choice="req"><replaceable>directory</replaceable></arg>
+    </cmdsynopsis>
+  </refsynopsisdiv>
+  <refsect1>
+    <title>Arguments</title>
+    <informaltable frame="all">
+      <tgroup cols="4" colsep="1" rowsep="1" align="left">
+        <colspec colname="c1">
+        <colspec colname="c2">
+        <colspec colname="c3">
+        <colspec colname="c4">
+        <thead>
+          <row>
+            <entry>Name</entry>
+            <entry>Type</entry>
+            <entry>Description</entry>
+            <entry>Default</entry>
+          </row>
+        </thead>
+        <tbody>
+	    <row>
+	      <entry><replaceable>directory</replaceable></entry>
+	      <entry>String</entry>
+	      <entry>Pathname to directory to delete.</entry>
+	      <entry></entry>
+	    </row>
+        </tbody>
+      </tgroup>
+    </informaltable>
+  </refsect1>
+  <refsect1>
+    <title>Description</title>
+<para>This command deletes a directory from the filesystem. If the
+directory contains files or other directories then this command will
+fail.
+</para>
+</refsect1>
+
+  <refsect1>
+    <title>Examples</title>
+    <para>Delete directory:
+<screen>
+RedBoot> <userinput>fs list</userinput>                                                                
+212416 d---------  3 size    128 .                                              
+212416 d---------  3 size    128 ..                                             
+211392 d---------  2 size     96 tests                                          
+210368 ----------  1 size   4096 image                                          
+RedBoot> <userinput>fs deldir tests</userinput>                                                        
+RedBoot> <userinput>fs list</userinput>                                                                
+212416 d---------  2 size    128 .                                              
+212416 d---------  2 size    128 ..                                             
+210368 ----------  1 size   4096 image                                          
+RedBoot>
+</screen>
+    </para>
+  </refsect1>
+</refentry>
+
+<!-- ******** fs del ************************************************ -->
+
+<refentry id="fs-del-command">
+  <refnamediv>
+    <refname>fs del</refname>
+    <refpurpose>Delete file</refpurpose>
+  </refnamediv>
+  <refsynopsisdiv>
+    <cmdsynopsis>
+      <command>fs del</command>
+      <arg choice="req"><replaceable>file</replaceable></arg>
+    </cmdsynopsis>
+  </refsynopsisdiv>
+  <refsect1>
+    <title>Arguments</title>
+    <informaltable frame="all">
+      <tgroup cols="4" colsep="1" rowsep="1" align="left">
+        <colspec colname="c1">
+        <colspec colname="c2">
+        <colspec colname="c3">
+        <colspec colname="c4">
+        <thead>
+          <row>
+            <entry>Name</entry>
+            <entry>Type</entry>
+            <entry>Description</entry>
+            <entry>Default</entry>
+          </row>
+        </thead>
+        <tbody>
+	    <row>
+	      <entry><replaceable>file</replaceable></entry>
+	      <entry>String</entry>
+	      <entry>Pathname of file to delete.</entry>
+	      <entry></entry>
+	    </row>
+        </tbody>
+      </tgroup>
+    </informaltable>
+  </refsect1>
+  <refsect1>
+    <title>Description</title>
+<para>This command deletes a file from the filesystem.
+</para>
+</refsect1>
+
+  <refsect1>
+    <title>Examples</title>
+    <para>Change current directory:
+<screen>
+RedBoot> <userinput>fs list tests</userinput>                                                          
+211392 d---------  2 size     96 .                                              
+212416 d---------  3 size    128 ..                                             
+205760 ----------  1 size  16384 test1                                          
+RedBoot> <userinput>fs del tests/test1</userinput>                                                     
+RedBoot> <userinput>fs list tests</userinput>                                                          
+211392 d---------  2 size     96 .                                              
+212416 d---------  3 size    128 ..                                             
+RedBoot> 
+</screen>
+    </para>
+  </refsect1>
+</refentry>
+
+<!-- ******** fs move ************************************************ -->
+
+<refentry id="fs-move-command">
+  <refnamediv>
+    <refname>fs move</refname>
+    <refpurpose>Move file</refpurpose>
+  </refnamediv>
+  <refsynopsisdiv>
+    <cmdsynopsis>
+      <command>fs move</command>
+      <arg choice="req"><replaceable>source</replaceable></arg>
+      <arg choice="req"><replaceable>dest</replaceable></arg>
+    </cmdsynopsis>
+  </refsynopsisdiv>
+  <refsect1>
+    <title>Arguments</title>
+    <informaltable frame="all">
+      <tgroup cols="4" colsep="1" rowsep="1" align="left">
+        <colspec colname="c1">
+        <colspec colname="c2">
+        <colspec colname="c3">
+        <colspec colname="c4">
+        <thead>
+          <row>
+            <entry>Name</entry>
+            <entry>Type</entry>
+            <entry>Description</entry>
+            <entry>Default</entry>
+          </row>
+        </thead>
+        <tbody>
+	    <row>
+	      <entry><replaceable>source</replaceable></entry>
+	      <entry>String</entry>
+	      <entry>Pathname of file to move.</entry>
+	      <entry></entry>
+	    </row>
+	    <row>
+	      <entry><replaceable>dest</replaceable></entry>
+	      <entry>String</entry>
+	      <entry>Pathname to new file location.</entry>
+	      <entry></entry>
+	    </row>
+        </tbody>
+      </tgroup>
+    </informaltable>
+  </refsect1>
+  <refsect1>
+    <title>Description</title>
+<para>This command moves a file within a filesystem. This command will
+fail if the destination file already exists, or is in a different
+filesystem.
+</para>
+</refsect1>
+
+  <refsect1>
+    <title>Examples</title>
+    <para>Rename a file:
+<screen>
+RedBoot> <userinput>fs list tests</userinput>                                                          
+211392 d---------  2 size     96 .                                              
+212416 d---------  3 size    128 ..                                             
+205760 ----------  1 size  12288 test1                                          
+RedBoot> <userinput>fs move tests/test1 tests/test2</userinput>                                        
+RedBoot> <userinput>fs list tests</userinput>                                                                
+211392 d---------  2 size    128 .                                              
+212416 d---------  3 size    128 ..                                             
+205760 ----------  1 size  12288 test2                                          
+RedBoot>
+</screen>
+    </para>
+  </refsect1>
+</refentry>
+
+<!-- ******** fs list ************************************************ -->
+
+<refentry id="fs-list-command">
+  <refnamediv>
+    <refname>fs list</refname>
+    <refpurpose>List filesystem directory</refpurpose>
+  </refnamediv>
+  <refsynopsisdiv>
+    <cmdsynopsis>
+      <command>fs list</command>
+      <arg choice="opt"><replaceable>directory</replaceable></arg>
+    </cmdsynopsis>
+  </refsynopsisdiv>
+  <refsect1>
+    <title>Arguments</title>
+    <informaltable frame="all">
+      <tgroup cols="4" colsep="1" rowsep="1" align="left">
+        <colspec colname="c1">
+        <colspec colname="c2">
+        <colspec colname="c3">
+        <colspec colname="c4">
+        <thead>
+          <row>
+            <entry>Name</entry>
+            <entry>Type</entry>
+            <entry>Description</entry>
+            <entry>Default</entry>
+          </row>
+        </thead>
+        <tbody>
+	    <row>
+	      <entry><replaceable>directory</replaceable></entry>
+	      <entry>String</entry>
+	      <entry>Pathname to directory to list.</entry>
+	      <entry>Current directory</entry>
+	    </row>
+        </tbody>
+      </tgroup>
+    </informaltable>
+  </refsect1>
+  <refsect1>
+    <title>Description</title>
+<para>This command prints a list of the contents of the named
+directory. Each line of the listing starts with the file's inode
+number, which is its address in the filesystem. Following is a set of
+UNIX-like access flags, the first character of this will be a
+&rdquo;d&ldquo; if this entry is a directory. The third item indicates
+the number of links to the file. Following this is the size of the
+file in bytes and the last item is its name.
+</para>
+</refsect1>
+
+  <refsect1>
+    <title>Examples</title>
+    <para>List the current directory:
+<screen>
+RedBoot> <userinput>fs list</userinput>
+212416 d---------  3 size    128 .                                              
+212416 d---------  3 size    128 ..                                             
+211392 ----------  1 size   4096 image                                          
+206784 d---------  2 size     96 tests
+RedBoot>
+</screen>
+    </para>
+<para>
+List a subdirectory:
+<screen>
+RedBoot> fs list tests                                                            
+206784 d---------  2 size     96 .                                              
+212416 d---------  3 size    128 ..                                             
+205760 ----------  1 size  16384 test1                                          
+RedBoot>
+</screen>
+</para>
+  </refsect1>
+</refentry>
+
+<!-- ******** fs write ************************************************ -->
+
+<refentry id="fs-write-command">
+  <refnamediv>
+    <refname>fs write</refname>
+    <refpurpose>Write to filesystem</refpurpose>
+  </refnamediv>
+  <refsynopsisdiv>
+    <cmdsynopsis>
+      <command>fs write</command>
+      <arg choice="opt">-b <replaceable>mem_address</replaceable></arg>
+      <arg choice="opt">-l <replaceable>length</replaceable></arg>
+      <arg choice="req">name</arg>
+    </cmdsynopsis>
+  </refsynopsisdiv>
+  <refsect1>
+    <title>Arguments</title>
+    <informaltable frame="all">
+      <tgroup cols="4" colsep="1" rowsep="1" align="left">
+        <colspec colname="c1">
+        <colspec colname="c2">
+        <colspec colname="c3">
+        <colspec colname="c4">
+        <thead>
+          <row>
+            <entry>Name</entry>
+            <entry>Type</entry>
+            <entry>Description</entry>
+            <entry>Default</entry>
+          </row>
+        </thead>
+        <tbody>
+          <row>
+            <entry><replaceable>mem_address</replaceable></entry>
+            <entry>Number</entry>
+            <entry>Address of data to be written to flash.</entry>
+            <entry>Address of last loaded file. If not set by a load
+            operation it must be specified.</entry>
+          </row>
+          <row>
+            <entry><replaceable>length</replaceable></entry>
+            <entry>Number</entry>
+            <entry>Length of data to be written.</entry>
+            <entry>Length of last loaded file.</entry>
+          </row>
+	    <row>
+	      <entry><replaceable>name</replaceable></entry>
+	      <entry>String</entry>
+	      <entry>Name of file to create.</entry>
+	      <entry></entry>
+	    </row>
+        </tbody>
+      </tgroup>
+    </informaltable>
+  </refsect1>
+  <refsect1>
+    <title>Description</title>
+<para>This command is used to write data from memory to a file. If the
+file does not exist it will be created. If it does exist, then it will
+be overwritten with the new contents.</para>
+</refsect1>
+
+  <refsect1>
+    <title>Examples</title>
+<para>Write an area of data to a file
+<screen>
+RedBoot> <userinput>fs write -b 0x0606f000 -l 0x1000 image</userinput>
+RedBoot> <userinput>fs list</userinput>
+212416 d---------  3 size    128 .                                              
+212416 d---------  3 size    128 ..                                             
+211392 ----------  1 size   4096 image                                          
+206784 d---------  2 size     96 tests
+RedBoot>
+</screen>
+    </para>
+  </refsect1>
+</refentry>
+
+
 
 </sect1>
+
+
 <sect1 id="Persistent-State-Flash">
 <title>Persistent State Flash-based Configuration and Control</title>
 <para><indexterm><primary>persistent state flash-based configuration and control
 </primary></indexterm><indexterm><primary>flash-based configuration and control
 </primary></indexterm><indexterm><primary>configuration and control</primary>
Index: include/redboot.h
===================================================================
RCS file: /cvs/ecos/ecos/packages/redboot/current/include/redboot.h,v
retrieving revision 1.36
diff -u -5 -p -r1.36 redboot.h
--- include/redboot.h	9 May 2006 15:52:03 -0000	1.36
+++ include/redboot.h	20 Jul 2006 20:23:15 -0000
@@ -8,10 +8,11 @@
 //####ECOSGPLCOPYRIGHTBEGIN####
 // -------------------------------------------
 // This file is part of eCos, the Embedded Configurable Operating System.
 // Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004 Red Hat, Inc.
 // Copyright (C) 2002, 2003, 2004, 2005 Gary Thomas
+// Copyright (C) 2004, 2005 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
 // Software Foundation; either version 2 or (at your option) any later version.
 //
@@ -249,15 +250,18 @@ struct cmd _cmd_tab_##_f_ CYG_HAL_TABLE_
 extern _cmd_entry(_s_,_h_,_u_,_f_,_subs_,_sube_,_n_)
 #define local_cmd_entry(_s_,_h_,_u_,_f_,_n_)                             \
 static _cmd_entry(_s_,_h_,_u_,_f_,0,0,_n_)
 
 // Initialization functions
-#define RedBoot_INIT_FIRST  0000
-#define RedBoot_INIT_SECOND 0100
+#define RedBoot_INIT_FIRST              0000
+#define RedBoot_INIT_SECOND             0100
 // Specify a 3 digit numeric value for proper prioritizing
 #define RedBoot_INIT_PRIO(_n_) 1##_n_
-#define RedBoot_INIT_LAST  9999
+#define RedBoot_INIT_BEFORE_NET         6900
+#define RedBoot_INIT_NET                7000
+#define RedBoot_INIT_AFTER_NET          7100
+#define RedBoot_INIT_LAST               9999
 typedef void void_fun(void);
 typedef void_fun *void_fun_ptr;
 struct init_tab_entry {
     void_fun_ptr fun;
 } CYG_HAL_TABLE_TYPE;
@@ -310,10 +314,14 @@ externC void init_opts(struct option_inf
                        int arg_type, void *arg, bool *arg_set, char *name);
 externC bool scan_opts(int argc, char *argv[], int first, 
                        struct option_info *opts, int num_opts, 
                        void *def_arg, int def_arg_type, char *def_descr);
 
+externC int redboot_exec( char *command, ... );
+
+externC void err_printf( char *fmt, ... );
+
 #ifdef CYGNUM_HAL_VIRTUAL_VECTOR_AUX_CHANNELS
 #define CYGNUM_HAL_VIRTUAL_VECTOR_NUM_CHANNELS \
   (CYGNUM_HAL_VIRTUAL_VECTOR_COMM_CHANNELS+CYGNUM_HAL_VIRTUAL_VECTOR_AUX_CHANNELS)
 #else
 #define CYGNUM_HAL_VIRTUAL_VECTOR_NUM_CHANNELS \
Index: src/load.c
===================================================================
RCS file: /cvs/ecos/ecos/packages/redboot/current/src/load.c,v
retrieving revision 1.46
diff -u -5 -p -r1.46 load.c
--- src/load.c	25 Feb 2006 14:21:12 -0000	1.46
+++ src/load.c	20 Jul 2006 20:23:17 -0000
@@ -8,10 +8,11 @@
 //####ECOSGPLCOPYRIGHTBEGIN####
 // -------------------------------------------
 // This file is part of eCos, the Embedded Configurable Operating System.
 // Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
 // Copyright (C) 2002, 2003, 2004 Gary Thomas
+// Copyright (C) 2004 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
 // Software Foundation; either version 2 or (at your option) any later version.
 //
@@ -141,11 +142,11 @@ redboot_getc(void)
     if (getc_info.avail < 0) {
       return -1;
     }
     if (getc_info.avail == 0) {
         if (getc_info.verbose) {
-            diag_printf("%c\b", spin[getc_info.tick++]);
+            err_printf("%c\b", spin[getc_info.tick++]);
             if (getc_info.tick >= sizeof(spin)) {
                 getc_info.tick = 0;
             }
         }
         if (getc_info.len < BUF_SIZE) {
@@ -210,11 +211,11 @@ redboot_getc_init(connection_info_t *inf
 {
     int res;
 
     res = (funcs->open)(info, &getc_info.err);    
     if (res < 0) {
-        diag_printf("Can't load '%s': %s\n", info->filename, (funcs->error)(getc_info.err));
+        err_printf("Can't load '%s': %s\n", info->filename, (funcs->error)(getc_info.err));
             return res;
     }
     getc_info.io = funcs;
     getc_info.fun = funcs->read;
     getc_info.avail = 0;
@@ -230,11 +231,11 @@ redboot_getc_init(connection_info_t *inf
         p->in_avail = 0;
         getc_info.raw_fun = getc_info.fun;
         getc_info.fun = _decompress_stream;
         getc_info.err = (*_dc_init)(p);
         if (0 != getc_info.err && p->msg) {
-            diag_printf("open decompression error: %s\n", p->msg);
+            err_printf("open decompression error: %s\n", p->msg);
         }
     }
 #endif
     return 0;
 }
@@ -311,11 +312,11 @@ load_elf_image(getc_t getc, unsigned lon
     unsigned long lowest_address = 0xFFFFFFFF;
     unsigned char *SHORT_DATA = "Short data reading ELF file\n";
 
     // Read the header
     if (_read(getc, (unsigned char *)&ehdr, sizeof(ehdr)) != sizeof(ehdr)) {
-        diag_printf("Can't read ELF header\n");
+        err_printf("Can't read ELF header\n");
         redboot_getc_terminate(true);
         return 0;
     }
     offset += sizeof(ehdr);    
 #if 0 // DEBUG
@@ -323,30 +324,30 @@ load_elf_image(getc_t getc, unsigned lon
                 ehdr.e_type, ehdr.e_machine, ehdr.e_version, ehdr.e_entry, 
                 ehdr.e_phoff, ehdr.e_phentsize, ehdr.e_phnum,
                 ehdr.e_shoff, ehdr.e_shentsize, ehdr.e_shnum);
 #endif
     if (ehdr.e_type != ET_EXEC) {
-        diag_printf("Only absolute ELF images supported\n");
+        err_printf("Only absolute ELF images supported\n");
         redboot_getc_terminate(true);
         return 0;
     }
     if (ehdr.e_phnum > MAX_PHDR) {
-        diag_printf("Too many program headers\n");
+        err_printf("Too many program headers\n");
         redboot_getc_terminate(true);
         return 0;
     }
     while (offset < ehdr.e_phoff) {
         if ((*getc)() < 0) {
-            diag_printf(SHORT_DATA);
+            err_printf(SHORT_DATA);
             redboot_getc_terminate(true);
             return 0;
         }
         offset++;
     }
     for (phx = 0;  phx < ehdr.e_phnum;  phx++) {
         if (_read(getc, (unsigned char *)&phdr[phx], sizeof(phdr[0])) != sizeof(phdr[0])) {
-            diag_printf("Can't read ELF program header\n");
+            err_printf("Can't read ELF program header\n");
             redboot_getc_terminate(true);
             return 0;
         }
 #if 0 // DEBUG
         diag_printf("Program header: type: %d, off: %p, va: %p, pa: %p, len: %d/%d, flags: %d\n",
@@ -385,19 +386,19 @@ load_elf_image(getc_t getc, unsigned lon
                 lowest_address = (unsigned long)addr;
             }
             addr += addr_offset;
             if (offset > phdr[phx].p_offset) {
                 if ((phdr[phx].p_offset + len) < offset) {
-                    diag_printf("Can't load ELF file - program headers out of order\n");
+                    err_printf("Can't load ELF file - program headers out of order\n");
                     redboot_getc_terminate(true);
                     return 0;
                 }
                 addr += offset - phdr[phx].p_offset;
             } else {
                 while (offset < phdr[phx].p_offset) {
                     if ((*getc)() < 0) {
-                        diag_printf(SHORT_DATA);
+                        err_printf(SHORT_DATA);
                         redboot_getc_terminate(true);
                         return 0;
                     }
                     offset++;
                 }
@@ -410,16 +411,16 @@ load_elf_image(getc_t getc, unsigned lon
 #ifdef CYGBLD_REDBOOT_LOAD_INTO_FLASH
                     || (flash_verify_addr(addr) == FLASH_ERR_OK)
 #endif
                     )) {
                     redboot_getc_terminate(true);
-                    diag_printf("*** Abort! Attempt to load ELF data to address: %p which is not valid\n", (void*)addr);
+                    err_printf("*** Abort! Attempt to load ELF data to address: %p which is not valid\n", (void*)addr);
                     return 0;
                 }
 #endif
                 if ((ch = (*getc)()) < 0) {
-                    diag_printf(SHORT_DATA);
+                    err_printf(SHORT_DATA);
                     redboot_getc_terminate(true);
                     return 0;
                 }
                 if (valid_address(addr)) {
                   *addr++ = ch;
@@ -456,11 +457,11 @@ load_elf_image(getc_t getc, unsigned lon
     if (addr_offset) diag_printf("Address offset = %p\n", (void *)addr_offset);
     diag_printf("Entry point: %p, address range: %p-%p\n", 
                 (void*)entry_address, (void *)load_address, (void *)load_address_end);
     return 1;
 #else // CYGSEM_REDBOOT_ELF
-    diag_printf("Loading ELF images not supported\n");
+    err_printf("Loading ELF images not supported\n");
     return 0;
 #endif // CYGSEM_REDBOOT_ELF
 }
 
 
@@ -514,20 +515,20 @@ load_srec_image(getc_t getc, unsigned lo
 
     while ((c = (*getc)()) > 0) {
         // Start of line
         if (c != 'S') {
             redboot_getc_terminate(true);
-            diag_printf("Invalid S-record at offset %p, input: %c\n", 
+            err_printf("Invalid S-record at offset %p, input: %c\n", 
                    (void *)offset, c);
             return 0;
         }
         type = (*getc)();
         offset += 2;
         sum = 0;
         if ((count = _hex2(getc, 1, &sum)) < 0) {
             redboot_getc_terminate(true);
-            diag_printf("Bad S-record count at offset %p\n", (void *)offset);
+            err_printf("Bad S-record count at offset %p\n", (void *)offset);
             return 0;
         }
         offset += 1;
         switch (type) {
         case '0':
@@ -556,11 +557,11 @@ load_srec_image(getc_t getc, unsigned lo
 #endif
                   )) {
 	      // Only if there is no need to stop the download before printing
 	      // output can we ask confirmation questions.
                 redboot_getc_terminate(true);
-		diag_printf("*** Abort! Attempt to load S-record to address: %p, which is not valid\n",(void*)addr);
+		err_printf("*** Abort! Attempt to load S-record to address: %p, which is not valid\n",(void*)addr);
                 return 0;
             }
 #endif
             count -= ((type-'1'+2)+1);
             offset += count;
@@ -580,11 +581,11 @@ load_srec_image(getc_t getc, unsigned lo
             offset += 1;
             sum = sum & 0xFF;
             cksum = (~cksum & 0xFF);
             if (cksum != sum) {
                 redboot_getc_terminate(true);
-                diag_printf("*** Warning! Checksum failure - Addr: %lx, %02lX <> %02lX\n", 
+                err_printf("*** Warning! Checksum failure - Addr: %lx, %02lX <> %02lX\n", 
                        (unsigned long)base_addr, sum, cksum);
                 return 0;
             }
             if ((unsigned long)(addr-addr_offset) > highest_address) {
                 highest_address = (unsigned long)(addr - addr_offset);
@@ -611,11 +612,11 @@ load_srec_image(getc_t getc, unsigned lo
                    (void*)entry_address, (void *)load_address, (void *)load_address_end);
 
             return load_address_end;
         default:
             redboot_getc_terminate(true);
-            diag_printf("Invalid S-record at offset 0x%lx, type: %x\n", 
+            err_printf("Invalid S-record at offset 0x%lx, type: %x\n", 
                    (unsigned long)offset, type);
             return 0;
         }
         while ((c = (*getc)()) != '\n') offset++;
     }
@@ -717,25 +718,25 @@ do_load(int argc, char *argv[])
     }
 #ifdef CYGPKG_REDBOOT_NETWORKING
     if (hostname_set) {
         ip_route_t rt;
         if (!_gethostbyname(hostname, (in_addr_t *)&host)) {
-            diag_printf("Invalid host: %s\n", hostname);
+            err_printf("Invalid host: %s\n", hostname);
             return;
         }
         /* check that the host can be accessed */
         if (__arp_lookup((ip_addr_t *)&host.sin_addr, &rt) < 0) {
-            diag_printf("Unable to reach host %s (%s)\n",
+            err_printf("Unable to reach host %s (%s)\n",
                         hostname, inet_ntoa((in_addr_t *)&host));
             return;
         }
     }
     if (port_set) 
 	    host.sin_port = port;
 #endif
     if (chan >= CYGNUM_HAL_VIRTUAL_VECTOR_NUM_CHANNELS) {
-        diag_printf("Invalid I/O channel: %d\n", chan);
+        err_printf("Invalid I/O channel: %d\n", chan);
         return;
     }
     if (mode_str_set) {
         for (io_tab = __RedBoot_LOAD_TAB__; 
              io_tab != &__RedBoot_LOAD_TAB_END__;  io_tab++) {
@@ -748,19 +749,19 @@ do_load(int argc, char *argv[])
             diag_printf("Invalid 'mode': %s.  Valid modes are:", mode_str);
             for (io_tab = __RedBoot_LOAD_TAB__; 
                  io_tab != &__RedBoot_LOAD_TAB_END__;  io_tab++) {
                 diag_printf(" %s", io_tab->name);
             }
-            diag_printf("\n");
+            err_printf("\n");
         }
         if (!io) {
             return;
         }
         verbose &= io_tab->can_verbose;
         if (io_tab->need_filename && !filename) {
             diag_printf("File name required\n");
-            diag_printf("usage: load %s\n", usage);
+            err_printf("usage: load %s\n", usage);
             return;
         }
     } else {
         char *which = "";
         io_tab = (struct load_io_entry *)NULL;  // Default
@@ -771,11 +772,11 @@ do_load(int argc, char *argv[])
 #elif defined(CYGSEM_REDBOOT_NET_HTTP_DOWNLOAD)
         which = "HTTP";
         io = &http_io;
 #endif
 #endif
-#ifdef CYGPKG_REDBOOT_FILEIO
+#if 0 //def CYGPKG_REDBOOT_FILEIO
         // Make file I/O default if mounted
 	if (fileio_mounted) {
 	    which = "file";
 	    io = &fileio_io;
 	}
@@ -784,11 +785,11 @@ do_load(int argc, char *argv[])
 #ifdef CYGBLD_BUILD_REDBOOT_WITH_XYZMODEM
             which = "Xmodem";
             io = &xyzModem_io;
             verbose = false;
 #else
-            diag_printf("No default protocol!\n");
+            err_printf("No default protocol!\n");
             return;
 #endif
         }
         diag_printf("Using default protocol (%s)\n", which);
     }
@@ -809,11 +810,11 @@ do_load(int argc, char *argv[])
     if (raw && !(base_addr_set 
 #ifdef CYGBLD_REDBOOT_LOAD_INTO_FLASH
                 || flash_addr_set
 #endif
         )) {
-        diag_printf("Raw load requires a memory address\n");
+        err_printf("Raw load requires a memory address\n");
         return;
     }
     info.filename = filename;
     info.chan = chan;
     info.mode = io_tab ? io_tab->mode : 0;
@@ -837,21 +838,21 @@ do_load(int argc, char *argv[])
             if (flash_addr_set && flash_verify_addr(mp) && !spillover_ok) {
                 // Only if there is no need to stop the download
                 // before printing output can we ask confirmation
                 // questions.
                 redboot_getc_terminate(true);
-                diag_printf("*** Abort! RAW data spills over limit of FLASH at %p\n",(void*)mp);
+                err_printf("*** Abort! RAW data spills over limit of FLASH at %p\n",(void*)mp);
                 err = -1;
                 break;
             }
 #endif
             if (base_addr_set && !valid_address(mp) && !spillover_ok) {
                 // Only if there is no need to stop the download
                 // before printing output can we ask confirmation
                 // questions.
                 redboot_getc_terminate(true);
-                diag_printf("*** Abort! RAW data spills over limit of user RAM at %p\n",(void*)mp);
+                err_printf("*** Abort! RAW data spills over limit of user RAM at %p\n",(void*)mp);
                 err = -1;
                 break;
             }
 #endif
 #ifdef CYGBLD_REDBOOT_LOAD_INTO_FLASH
@@ -891,11 +892,11 @@ do_load(int argc, char *argv[])
             } else if ((type[0] == 'S') &&
                        ((type[1] >= '0') && (type[1] <= '9'))) {
 		end = load_srec_image(redboot_getc, base);
             } else {
                 redboot_getc_terminate(true);
-                diag_printf("Unrecognized image type: 0x%lx\n", *(unsigned long *)type);
+                err_printf("Unrecognized image type: 0x%lx\n", *(unsigned long *)type);
             }
         }
     }
 #ifdef CYGBLD_REDBOOT_LOAD_INTO_FLASH
     flash_load_finish();
Index: src/main.c
===================================================================
RCS file: /cvs/ecos/ecos/packages/redboot/current/src/main.c,v
retrieving revision 1.65
diff -u -5 -p -r1.65 main.c
--- src/main.c	9 May 2006 15:52:04 -0000	1.65
+++ src/main.c	20 Jul 2006 20:23:18 -0000
@@ -8,10 +8,11 @@
 //####ECOSGPLCOPYRIGHTBEGIN####
 // -------------------------------------------
 // This file is part of eCos, the Embedded Configurable Operating System.
 // Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 Red Hat, Inc.
 // Copyright (C) 2002, 2003, 2004 Gary Thomas
+// Copyright (C) 2003, 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
 // Software Foundation; either version 2 or (at your option) any later version.
 //
@@ -31,20 +32,17 @@
 // License. However the source code for this file must still be made available
 // in accordance with section (3) of the GNU General Public License.
 //
 // 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, tkoeller
+// Contributors: gthomas, tkoeller, eCosCentric
 // Date:         2000-07-14
 // Purpose:      
 // Description:  
 //              
 // This code is part of RedBoot (tm).
@@ -176,11 +174,12 @@ do_version(int argc, char *argv[])
 
     diag_printf(version);
 #ifdef HAL_PLATFORM_CPU
     diag_printf("Platform: %s (%s) %s\n", HAL_PLATFORM_BOARD, HAL_PLATFORM_CPU, HAL_PLATFORM_EXTRA);
 #endif
-    diag_printf("Copyright (C) 2000, 2001, 2002, 2003, 2004 Red Hat, Inc.\n\n");
+    diag_printf("Copyright (C) 2000, 2001, 2002, 2003, 2004 Red Hat, Inc.\n");
+    diag_printf("Copyright (C) 2003, 2004, 2005, 2006 eCosCentric Limited\n\n");
     diag_printf("RAM: %p-%p, ", (void*)ram_start, (void*)ram_end);
     diag_printf("[%p-%p]", mem_segments[0].start, mem_segments[0].end);
     diag_printf(" available\n");
 #if CYGBLD_REDBOOT_MAX_MEM_SEGMENTS > 1
     for (seg = 1;  seg < CYGBLD_REDBOOT_MAX_MEM_SEGMENTS;  seg++) {
@@ -225,18 +224,17 @@ _mon_write_char(char c, void **param)
 //
 // Handle illegal memory accesses (and other abort conditions)
 //
 static hal_jmp_buf error_jmpbuf;
 #ifdef CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS
-externC 
-#endif
-  void* volatile __mem_fault_handler;
+__externC void* volatile __mem_fault_handler;
 
 static void error_handler(void)
 {
     hal_longjmp(error_jmpbuf, 1);
 }
+#endif
 
 
 //
 // This is the main entry point for RedBoot
 //
@@ -272,11 +270,10 @@ cyg_start(void)
     CYGACC_CALL_IF_SET_CONSOLE_COMM(CYGNUM_HAL_VIRTUAL_VECTOR_DEBUG_CHANNEL);
 #ifdef CYGPKG_REDBOOT_ANY_CONSOLE
     console_selected = false;
 #endif
     console_echo = true;
-    CYGACC_CALL_IF_DELAY_US((cyg_int32)2*100000);
 
     ram_start = (unsigned char *)CYGMEM_REGION_ram;
     ram_end = (unsigned char *)(CYGMEM_REGION_ram+CYGMEM_REGION_ram_SIZE);
 #ifdef HAL_MEM_REAL_REGION_TOP
     {
@@ -420,17 +417,21 @@ cyg_start(void)
                     }
                 } else {
                     while (strlen(command) > 0) {                    
                         if ((cmd = parse(&command, &argc, &argv[0])) != (struct cmd *)0) {
                             // Try to handle aborts - messy because of the stack unwinding...
+#ifdef CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS
                             __mem_fault_handler = error_handler;
+#endif
                             if (hal_setjmp(error_jmpbuf)) {
                                 diag_printf("** command abort - illegal memory access?\n");
                             } else {
                                 (cmd->fun)(argc, argv);
                             }
+#ifdef CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS
                             __mem_fault_handler = 0;
+#endif
                         } else {
                             diag_printf("** Error: Illegal command: \"%s\"\n", argv[0]);
                         }
                     }
                 }
@@ -525,11 +526,13 @@ do_go(int argc, char *argv[])
 #endif
     struct option_info opts[3];
     char line[8];
     hal_virtual_comm_table_t *__chan;
 
+#ifdef CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS
     __mem_fault_handler = 0; // Let GDB handle any faults directly
+#endif
     entry = entry_address;  // Default from last 'load' operation
     init_opts(&opts[0], 'w', true, OPTION_ARG_TYPE_NUM, 
               (void *)&wait_time, (bool *)&wait_time_set, "wait timeout");
     init_opts(&opts[1], 'c', false, OPTION_ARG_TYPE_FLG, 
               (void *)&cache_enabled, (bool *)0, "go with caches enabled");
@@ -545,11 +548,11 @@ do_go(int argc, char *argv[])
     if (!scan_opts(argc, argv, 1, opts, num_options, (void *)&entry, OPTION_ARG_TYPE_NUM, "starting address"))
     {
         return;
     }
     if (entry == (unsigned long)NO_MEMORY) {
-        diag_printf("No entry point known - aborted\n");
+        err_printf("No entry point known - aborted\n");
         return;
     }
     if (wait_time_set) {
         int script_timeout_ms = wait_time * 1000;
 #ifdef CYGSEM_REDBOOT_FLASH_CONFIG
Index: src/parse.c
===================================================================
RCS file: /cvs/ecos/ecos/packages/redboot/current/src/parse.c,v
retrieving revision 1.9
diff -u -5 -p -r1.9 parse.c
--- src/parse.c	30 Sep 2003 21:17:44 -0000	1.9
+++ src/parse.c	20 Jul 2006 20:23:18 -0000
@@ -7,10 +7,11 @@
 //==========================================================================
 //####ECOSGPLCOPYRIGHTBEGIN####
 // -------------------------------------------
 // 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
 // Software Foundation; either version 2 or (at your option) any later version.
 //
@@ -30,20 +31,17 @@
 // License. However the source code for this file must still be made available
 // in accordance with section (3) of the GNU General Public License.
 //
 // 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:  
 //              
 // This code is part of RedBoot (tm).
@@ -191,10 +189,101 @@ cmd_usage(struct cmd *tab, struct cmd *t
     for (cmd = tab;  cmd != tabend;  cmd++) {
         diag_printf("  %s%s %s\n", prefix, cmd->str, cmd->usage);
     }
 }
 
+//
+// 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
 // may have dynamic contents, thus cannot be statically initialized)
 //
Index: src/fs/fileio.c
===================================================================
RCS file: /cvs/ecos/ecos/packages/redboot/current/src/fs/fileio.c,v
retrieving revision 1.6
diff -u -5 -p -r1.6 fileio.c
--- src/fs/fileio.c	6 Jan 2005 09:51:06 -0000	1.6
+++ src/fs/fileio.c	20 Jul 2006 20:23:19 -0000
@@ -8,10 +8,11 @@
 //####ECOSGPLCOPYRIGHTBEGIN####
 // -------------------------------------------
 // This file is part of eCos, the Embedded Configurable Operating System.
 // Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
 // Copyright (C) 2002, 2003, 2004 Gary Thomas
+// 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
 // Software Foundation; either version 2 or (at your option) any later version.
 //
@@ -32,19 +33,18 @@
 // in accordance with section (3) of the GNU General Public License.
 //
 // 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):    dwmw2, msalter
-// Date:         2003-11-27
+// Author(s):    nickg
+// Contributors: dwmw2, msalter
+// Date:         2004-11-21
 // Purpose:      
 // Description:  
 //              
 // This code is part of RedBoot (tm).
 //
@@ -66,154 +66,255 @@
 #ifdef CYGPKG_IO_FLASH
 #include <cyg/io/io.h>
 #include <cyg/io/flash.h>
 #include <cyg/io/config_keys.h>
 #endif
+#include <cyg/io/devtab.h>
 #include <cyg/fileio/fileio.h>
 #include <cyg/infra/cyg_ass.h>         // assertion macros
 
+//==========================================================================
+
+// Define table boundaries
+CYG_HAL_TABLE_BEGIN( __FS_cmds_TAB__, FS_cmds);
+CYG_HAL_TABLE_END( __FS_cmds_TAB_END__, FS_cmds);
+
+extern struct cmd __FS_cmds_TAB__[], __FS_cmds_TAB_END__;
+
+//==========================================================================
+
+static void
+fs_usage(char *why)
+{
+    diag_printf("*** invalid 'fs' command: %s\n", why);
+    cmd_usage(__FS_cmds_TAB__, &__FS_cmds_TAB_END__, "fs ");
+}
+
+
+//==========================================================================
+
+#define MAX_MOUNTS      4
+
+static int mount_count = 0;
+
+static struct
+{
+    char dev_str[PATH_MAX];
+    char mp_str[PATH_MAX];
+    char type_str[PATH_MAX];
+} mounts[MAX_MOUNTS];
+
+//==========================================================================
+
 static void do_mount(int argc, char *argv[]);
 static void do_umount(int argc, char *argv[]);
 
-#ifdef CYGPKG_IO_FLASH_BLOCK_DEVICE
+#ifdef CYGPKG_IO_FLASH_BLOCK_DEVICE_LEGACY
 #define FLASHPART "[-f <partition>] "
 #else
 #define FLASHPART
 #endif
 
-RedBoot_cmd("mount", 
-            "Mount file system",
-	    FLASHPART "[-d <device>] -t fstype",
-            do_mount
-    );
-RedBoot_cmd("umount", 
-            "Unmount file system",
-            "",
-            do_umount
+local_cmd_entry("mount", 
+                "Mount file system",
+                FLASHPART "[-d <device>] -t <fstype> [<mountpoint>]",
+                do_mount,
+                FS_cmds
+    );
+local_cmd_entry("umount", 
+                "Unmount file system",
+                "<mountpoint>",
+                do_umount,
+                FS_cmds
     );
 
-int fileio_mounted = 0;
+//==========================================================================
 
 // Mount disk/filesystem
 static void
 do_mount(int argc, char *argv[])
 {
-    char *part_str, *dev_str, *type_str;
-    bool part_set = false, dev_set = false, type_set = false;
+    char *dev_str = "<undefined>", *type_str, *mp_str;
+    bool dev_set = false, type_set = false;
     struct option_info opts[3];
     int err, num_opts = 2;
+    int i,m=0; /* Set to 0 to silence warning */
+#ifdef CYGPKG_IO_FLASH_BLOCK_DEVICE_LEGACY
+    char *part_str;
+    bool part_set = false;
+#endif
 
     init_opts(&opts[0], 'd', true, OPTION_ARG_TYPE_STR,
               (void *)&dev_str, &dev_set, "device");
     init_opts(&opts[1], 't', true, OPTION_ARG_TYPE_STR,
               (void *)&type_str, &type_set, "fstype");
-#ifdef CYGPKG_IO_FLASH_BLOCK_DEVICE
+#ifdef CYGPKG_IO_FLASH_BLOCK_DEVICE_LEGACY
     init_opts(&opts[2], 'f', true, OPTION_ARG_TYPE_STR,
               (void *)&part_str, &part_set, "partition");
     num_opts++;
 #endif
 
     CYG_ASSERT(num_opts <= NUM_ELEMS(opts), "Too many options");
 
-    if (!scan_opts(argc, argv, 1, opts, num_opts, NULL, 0, NULL))
+    if (!scan_opts(argc, argv, 1, opts, num_opts, &mp_str, OPTION_ARG_TYPE_STR, "mountpoint"))
         return;
 
     if (!type_set) {
-        diag_printf("Must specify file system type\n");
+        err_printf("fs mount: Must specify file system type\n");
         return;
     }
-    if (fileio_mounted) {
-        diag_printf("A file system is already mounted\n");
+
+    if( mp_str == 0 )
+        mp_str = "/";
+
+    if( mount_count >= MAX_MOUNTS )
+    {
+        err_printf("fs mount: Maximum number of mounts exceeded\n");
         return;
     }
-#ifdef CYGPKG_IO_FLASH_BLOCK_DEVICE
+    
+#ifdef CYGPKG_IO_FLASH_BLOCK_DEVICE_LEGACY
     if (part_set) {
         int len;
         cyg_io_handle_t h;
 
         if (dev_set && strcmp(dev_str, CYGDAT_IO_FLASH_BLOCK_DEVICE_NAME_1)) {
-            diag_printf("May only set one of <device> or <partition>\n");
+            err_printf("fs mount: May only set one of <device> or <partition>\n");
             return;
         }
 
         dev_str = CYGDAT_IO_FLASH_BLOCK_DEVICE_NAME_1;
         len = strlen(part_str);
 
         err = cyg_io_lookup(dev_str, &h);
         if (err < 0) {
-            diag_printf("cyg_io_lookup of \"%s\" returned %d\n", err);
+            err_printf("fs mount: cyg_io_lookup of \"%s\" returned %d\n", err);
             return;
         }
         err = cyg_io_set_config(h, CYG_IO_SET_CONFIG_FLASH_FIS_NAME,
                                 part_str, &len);
         if (err < 0) {
-            diag_printf("FIS partition \"%s\" not found\n",
+            diag_printf("fs mount: FIS partition \"%s\" not found\n",
                         part_str);
             return;
         }
     }
 #endif
-    err = mount(dev_str, "/", type_str);
 
-    if (err) {
-        diag_printf("Mount failed %d\n", err);
-    } else {
-//        diag_printf("Mount %s file system succeeded\n", type_str);
-        fileio_mounted = 1;
-#ifdef CYGBLD_REDBOOT_FILEIO_WITH_LS
-        chdir("/");
-#endif        
+    for( i = 0; i < MAX_MOUNTS; i++ )
+    {
+        if( mounts[i].mp_str[0] != '\0' )
+        {
+            if( strcmp(mounts[i].dev_str, dev_str ) == 0 )
+            {
+                err_printf("fs mount: Device %s already mounted\n",dev_str);
+                return;
+            }
+        }
+        else
+            m = i;
+    }
+
+    strcpy( mounts[m].mp_str, mp_str );
+    strcpy( mounts[m].dev_str, dev_str );
+    strcpy( mounts[m].type_str, type_str );
+    
+    err = mount(mounts[m].dev_str, mounts[m].mp_str, mounts[m].type_str);
+
+    if (err)
+    {
+        err_printf("fs mount: mount(%s,%s,%s) failed %d\n", dev_str, mp_str, type_str, errno);
+        mounts[m].mp_str[0] = '\0'; // mount failed so don't let it appear mounted
+    }
+    else
+    {
+        if( mount_count == 0 )
+            chdir( "/" );
+        mount_count++;
     }
 }
 
+//==========================================================================
+
 static void
 do_umount(int argc, char *argv[])
 {
-    if (!fileio_mounted) {
+    char *dir_str;
+    int err;
+    int i;
+    
+     if( mount_count == 0 )
+     {
+         err_printf("fs: No filesystems mounted\n");
+         return;
+     }
+     
+    if (!scan_opts(argc, argv, 1, NULL, 0, &dir_str, OPTION_ARG_TYPE_STR, "mountpoint"))
+        return;
+
+    if( dir_str == 0 )
+        dir_str = "/";
+
+    for( i = 0; i < MAX_MOUNTS; i++ )
+    {
+        if( strcmp(mounts[i].mp_str, dir_str ) == 0 )
+            break;
+    }
+
+    if( i == MAX_MOUNTS )
+    {
+        err_printf("fs unmount: unknown mountpoint %s\n",dir_str);
         return;
     }
-    umount ("/");
-    fileio_mounted = 0;
+    
+    err = umount (dir_str);
+
+    if (err)
+        err_printf("fs umount: unmount failed %d\n", errno);
+    else
+    {
+        mounts[i].mp_str[0] = '\0';
+        mount_count--;
+        if( mount_count == 0 )
+            chdir( "/" );
+    }
+    
 }
 
-#ifdef CYGBLD_REDBOOT_FILEIO_WITH_LS
+//==========================================================================
+
 #include <dirent.h>
 
 static char rwx[8][4] = { "---", "r--", "-w-", "rw-", "--x", "r-x", "-wx", "rwx" }; 
 
 static void 
-do_ls(int argc, char * argv[])
+do_list(int argc, char * argv[])
 {
      char * dir_str;
-     struct option_info opts[1];
-     bool dir_set = false;
      DIR *dirp;
-     char cwd[PATH_MAX];
      char filename[PATH_MAX];
+     char cwd[PATH_MAX];
      struct stat sbuf;
      int err;
-     
-     init_opts(&opts[0], 'd', true, OPTION_ARG_TYPE_STR,
-               (void *)&dir_str, &dir_set, "directory");
-     
-     if (!fileio_mounted) {
-          diag_printf("No filesystem mounted\n");
-          return;
+
+     if( mount_count == 0 )
+     {
+         err_printf("fs: No filesystems mounted\n");
+         return;
      }
      
-     if (!scan_opts(argc, argv, 1, opts, 1, NULL, 0, NULL))
+     if (!scan_opts(argc, argv, 1, NULL, 0, &dir_str, OPTION_ARG_TYPE_STR, "directory"))
           return;
 
-     if (!dir_set) {
-          getcwd(cwd,sizeof(cwd));
-          dir_str = cwd;
+     if( dir_str == 0 )
+     {
+         dir_str = getcwd(cwd, sizeof(cwd));
      }
      
-     diag_printf("directory %s\n",dir_str);
      dirp = opendir(dir_str);
      if (dirp==NULL) {
-          diag_printf("no such directory %s\n",dir_str);
+          err_printf("fs list: no such directory %s\n",dir_str);
           return;
      }
      
      for (;;) {
           struct dirent *entry = readdir(dirp);
@@ -247,31 +348,370 @@ do_ls(int argc, char * argv[])
      
      closedir(dirp);
      return;
 }
 
-RedBoot_cmd("ls", 
-            "list directory contents",
-            "[-d directory]",
-            do_ls
+local_cmd_entry("list", 
+                "list directory contents",
+                "[<directory>]",
+                do_list,
+                FS_cmds
     );
 
-#endif // CYGBLD_REDBOOT_FILEIO_WITH_LS
+
+//==========================================================================
+
+
+static void 
+do_mkdir(int argc, char * argv[])
+{
+    char *dir_str;
+    int err;
+    
+     if( mount_count == 0 )
+     {
+         err_printf("fs: No filesystems mounted\n");
+         return;
+     }
+     
+    if (!scan_opts(argc, argv, 1, NULL, 0, &dir_str, OPTION_ARG_TYPE_STR, "directory") ||
+        dir_str == NULL)
+    {
+        fs_usage("invalid arguments");
+        return;
+    }
+
+    err = mkdir( dir_str, 0 );
+
+    if( err != 0 )
+        err_printf("fs mkdir: failed to create directory %s\n",dir_str);
+}
+
+local_cmd_entry("mkdir", 
+                "create directory",
+                "<directory>",
+                do_mkdir,
+                FS_cmds
+    );
+
+//==========================================================================
+
+static void 
+do_deldir(int argc, char * argv[])
+{
+    char *dir_str;
+    int err;
+    
+     if( mount_count == 0 )
+     {
+         err_printf("fs: No filesystems mounted\n");
+         return;
+     }
+     
+    if (!scan_opts(argc, argv, 1, NULL, 0, &dir_str, OPTION_ARG_TYPE_STR, "directory") ||
+        dir_str == NULL)
+    {
+        fs_usage("invalid arguments");
+        return;
+    }
+
+    err = rmdir( dir_str );
+
+    if( err != 0 )
+        err_printf("fs deldir: failed to remove directory %s\n",dir_str);
+}
+
+local_cmd_entry("deldir", 
+                "delete directory",
+                "<directory>",
+                do_deldir,
+                FS_cmds
+    );
+
+//==========================================================================
+
+static void 
+do_del(int argc, char * argv[])
+{
+    char *name_str = NULL;
+    int err;
+    
+     if( mount_count == 0 )
+     {
+         err_printf("fs: No filesystems mounted\n");
+         return;
+     }
+     
+    if (!scan_opts(argc, argv, 1, NULL, 0, &name_str, OPTION_ARG_TYPE_STR, "file") ||
+        name_str == NULL)
+    {
+        fs_usage("invalid arguments");
+        return;
+    }
+
+    err = unlink( name_str );
+
+    if( err != 0 )
+        err_printf("fs del: failed to delete file %s\n",name_str);
+}
+
+local_cmd_entry("del", 
+                "delete file",
+                "<file>",
+                do_del,
+                FS_cmds
+    );
+
+//==========================================================================
+
+static void 
+do_move(int argc, char * argv[])
+{
+    int err;
+    __externC int rename( const char *oldname, const char *newname );
+    if( mount_count == 0 )
+    {
+        err_printf("fs: No filesystems mounted\n");
+        return;
+    }
+
+    if( argc != 3 )
+        fs_usage("bad arguments to move command\n");
+
+    err = rename( argv[1], argv[2] );
+
+    if( err != 0 )
+        err_printf("fs move: failed to move file %s to %s\n",argv[1],argv[2]);
+}
+
+local_cmd_entry("move", 
+                "move file",
+                "<from> <to>",
+                do_move,
+                FS_cmds
+    );
+
+//==========================================================================
+
+static void 
+do_cd(int argc, char * argv[])
+{
+    char *dir_str;
+    int err;
+    
+     if( mount_count == 0 )
+     {
+         err_printf("fs: No filesystems mounted\n");
+         return;
+     }
+     
+    if (!scan_opts(argc, argv, 1, NULL, 0, &dir_str, OPTION_ARG_TYPE_STR, "directory"))
+        return;
+
+    if( dir_str == NULL )
+        dir_str = "/";
+    
+    err = chdir( dir_str );
+
+    if( err != 0 )
+        err_printf("fs cd: failed to change directory %s\n",dir_str);
+}
+
+local_cmd_entry("cd", 
+                "change directory",
+                "[<directory>]",
+                do_cd,
+                FS_cmds
+    );
+
+//==========================================================================
+
+static void 
+do_write(int argc, char * argv[])
+{
+    char *name_str = NULL;
+    int err;
+    struct option_info opts[2];    
+    CYG_ADDRESS mem_addr = 0;
+    unsigned long length = 0;
+    bool mem_addr_set = false;
+    bool length_set = false;
+    int fd;
+    
+     if( mount_count == 0 )
+     {
+         err_printf("fs: No filesystems mounted\n");
+         return;
+     }
+
+     init_opts(&opts[0], 'b', true, OPTION_ARG_TYPE_NUM, 
+               (void *)&mem_addr, (bool *)&mem_addr_set, "memory base address");
+     init_opts(&opts[1], 'l', true, OPTION_ARG_TYPE_NUM, 
+               (void *)&length, (bool *)&length_set, "image length");
+     
+    if (!scan_opts(argc, argv, 1, opts, 2, &name_str, OPTION_ARG_TYPE_STR, "file name") ||
+        name_str == NULL)
+    {
+        fs_usage("invalid arguments");
+        return;
+    }
+
+//    diag_printf("load_address %08x %08x\n",load_address,load_address_end);
+//    diag_printf("ram %08x %08x\n",ram_start, ram_end);
+//    diag_printf("file name %08x >%s<\n",name_str,name_str);
+    
+    if (!mem_addr_set &&
+        (load_address >= (CYG_ADDRESS)ram_start) &&
+	((load_address_end) < (CYG_ADDRESS)ram_end))
+    {
+	mem_addr = load_address;
+	mem_addr_set = true;
+	if (!length_set)
+        {
+	    length = load_address_end - load_address;
+	    length_set = true;
+            // maybe get length from existing file size if no loaded
+            // image?
+        }
+    }
+    
+    fd = open( name_str, O_WRONLY|O_CREAT|O_TRUNC );
+
+    if( fd < 0 )
+    {
+        err_printf("fs write: Cannot open %s\n", name_str );
+        return;
+    }
+
+//    diag_printf("write %08x %08x\n",mem_addr, length );
+    
+    err = write( fd, (void *)mem_addr, length );
+
+    if( err != length )
+    {
+        err_printf("fs write: failed to write to file %d(%d) %d\n",err,length,errno);
+    }
+
+    err = close( fd );
+
+    if( err != 0 )
+        err_printf("fs write: close failed\n");
+}
+
+local_cmd_entry("write",
+                "write data to file",
+                "-b <mem_base> -l <image_length> <file_name>",
+                do_write,
+                FS_cmds
+    );
+
+//==========================================================================
+
+__externC cyg_fstab_entry cyg_fstab[];
+__externC cyg_fstab_entry cyg_fstab_end;
+__externC cyg_mtab_entry cyg_mtab[];
+__externC cyg_mtab_entry cyg_mtab_end;
+
+static void 
+do_info(int argc, char * argv[])
+{
+    cyg_bool found = false;
+    cyg_fstab_entry *f;
+    cyg_devtab_entry_t *t;
+
+    for( f = &cyg_fstab[0] ; f != &cyg_fstab_end; f++ )
+    {
+        if( !found )
+        {
+            diag_printf("Filesystems available:\n");
+            found = true;
+        }
+        diag_printf("%s\n",f->name);
+    }
+
+    found = false;
+    for (t = &__DEVTAB__[0]; t != &__DEVTAB_END__; t++)
+    {
+        if( (t->status & CYG_DEVTAB_STATUS_BLOCK) == 0 ||
+            (t->status & CYG_DEVTAB_STATUS_AVAIL) == 0 )
+            continue;
+        
+        if( !found )
+        {
+            diag_printf("\nDevices available:\n");
+            found = true;
+        }
+        diag_printf("%s\n",t->name);
+    }
+
+    if( mount_count != 0 )
+    {
+        int i;
+
+        diag_printf("\nMounted filesystems:\n");
+        diag_printf("            Device               Filesystem Mounted on\n");
+
+        for( i = 0; i < MAX_MOUNTS; i++ )
+        {
+            if( mounts[i].mp_str[0] != '\0' )
+                diag_printf("%32s %10s %s\n", mounts[i].dev_str, mounts[i].type_str, mounts[i].mp_str);
+        }
+    }
+}
+
+local_cmd_entry("info", 
+                "filesystem info",
+                "",
+                do_info,
+                FS_cmds
+    );
+
+//==========================================================================
+
+static void
+do_fs(int argc, char *argv[])
+{
+    struct cmd *cmd;
+
+    if (argc < 2) {
+        fs_usage("too few arguments");
+        return;
+    }
+    if ((cmd = cmd_search(__FS_cmds_TAB__, &__FS_cmds_TAB_END__, 
+                          argv[1])) != (struct cmd *)0) {
+        (cmd->fun)(argc-1, argv+1);
+        return;
+    }
+    fs_usage("unrecognized command");
+}
+
+RedBoot_nested_cmd("fs", 
+            "Manage Filesystem files", 
+            "{cmds}",
+            do_fs,
+            __FS_cmds_TAB__, &__FS_cmds_TAB_END__
+    );
+
+
+//==========================================================================
+
 static int fd;
 
 externC int 
 fileio_stream_open(connection_info_t *info, int *err)
 {
     char *filename = info->filename;
 
-    if (!fileio_mounted) {
-        diag_printf("No file system mounted\n");
-        return -1;
-    }
+     if( mount_count == 0 )
+     {
+         diag_printf("fs: No filesystems mounted\n");
+         return -1;
+     }
+    
     fd = open(filename, O_RDONLY);
     if (fd < 0) {
-        diag_printf("Open failed, error %d\n", errno);
+        diag_printf("fs: Open failed, error %d\n", errno);
         return -1;
     }
     return 0;
 }
 
@@ -296,16 +736,19 @@ fileio_stream_close(int *err)
 externC char *
 fileio_error(int err)
 {
     static char myerr[10];
 
-    diag_sprintf(myerr, "error %d\n", err);
+    diag_sprintf(myerr, "error %d", err);
     return myerr;
 }
 
 //
 // RedBoot interface
 //
 GETC_IO_FUNCS(fileio_io, fileio_stream_open, fileio_stream_close,
               0, fileio_stream_read, fileio_error);
 RedBoot_load(file, fileio_io, true, true, 0);
 
+//==========================================================================
+// End of fileio.c
+
Index: src/net/net_io.c
===================================================================
RCS file: /cvs/ecos/ecos/packages/redboot/current/src/net/net_io.c,v
retrieving revision 1.45
diff -u -5 -p -r1.45 net_io.c
--- src/net/net_io.c	24 May 2006 12:24:46 -0000	1.45
+++ src/net/net_io.c	20 Jul 2006 20:23:19 -0000
@@ -592,11 +592,11 @@ RedBoot_idle(net_io_test, RedBoot_IDLE_N
 
 // Define table boundaries
 CYG_HAL_TABLE_BEGIN( __NETDEVTAB__, netdev );
 CYG_HAL_TABLE_END( __NETDEVTAB_END__, netdev );
 
-RedBoot_init(net_init, RedBoot_INIT_LAST);
+RedBoot_init(net_init, RedBoot_INIT_NET);
 
 static void
 show_addrs(void)
 {
     diag_printf("IP: %s", inet_ntoa((in_addr_t *)&__local_ip_addr));

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]