changeset 2980:8d5bed76c596

* cdl/romfs.cdl: Add CYGFUN_FS_ROM_FLASH_BLOCK_DEVICE_LOOKUP option. * support/mk_romfs.c: Fix Win32 build. * src/romfs.c: Add ability to mount a flash block device by name.
author jld
date Mon, 29 Nov 2010 16:29:19 +0000
parents 00ddfb443539
children 3022189df937
files packages/fs/rom/current/ChangeLog packages/fs/rom/current/cdl/romfs.cdl packages/fs/rom/current/src/romfs.c packages/fs/rom/current/support/mk_romfs.c
diffstat 4 files changed, 66 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/packages/fs/rom/current/ChangeLog
+++ b/packages/fs/rom/current/ChangeLog
@@ -1,3 +1,12 @@
+2010-11-29  John Dallaway  <john@dallaway.org.uk>
+
+	* cdl/romfs.cdl: Add CYGFUN_FS_ROM_FLASH_BLOCK_DEVICE_LOOKUP option.
+	* support/mk_romfs.c: Fix Win32 build.
+
+2010-11-13  Alexander Aganichev  <aaganichev@gmail.com>
+
+	* src/romfs.c: Added ability to mount a flash block device by name.
+
 2010-02-28  √ėyvind Harboe  <oyvind.harboe@zylin.com>
 
 	* src/romfs.c: file name comparison was broken for two files
@@ -185,7 +194,7 @@ 2000-10-25  Richard Panton (richard.pant
 // ####GPLCOPYRIGHTBEGIN####                                                
 // -------------------------------------------                              
 // This file is part of eCos, the Embedded Configurable Operating System.   
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004, 2009 Free Software Foundation, Inc.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004, 2009, 2010 Free Software Foundation, Inc.
 //
 // This program is free software; you can redistribute it and/or modify     
 // it under the terms of the GNU General Public License as published by     
--- a/packages/fs/rom/current/cdl/romfs.cdl
+++ b/packages/fs/rom/current/cdl/romfs.cdl
@@ -8,7 +8,7 @@
 ## ####ECOSGPLCOPYRIGHTBEGIN####                                            
 ## -------------------------------------------                              
 ## This file is part of eCos, the Embedded Configurable Operating System.   
-## Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004, 2009 Free Software Foundation, Inc.
+## Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004, 2009, 2010 Free Software Foundation, Inc.
 ##
 ## 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     
@@ -41,7 +41,7 @@
 #
 # Author(s):      nickg
 # Original data:  nickg
-# Contributors:   richard.panton@3glab.com
+# Contributors:   richard.panton@3glab.com, jld
 # Date:           2000-08-01
 #
 #####DESCRIPTIONEND####
@@ -101,6 +101,17 @@ cdl_package CYGPKG_FS_ROM {
             fileio already sets it."
     }
 
+    cdl_option CYGFUN_FS_ROM_FLASH_BLOCK_DEVICE_LOOKUP {
+        display "Lookup flash block device names"
+        flavor bool
+        requires CYGPKG_IO_FLASH
+        requires CYGPKG_IO_FLASH_BLOCK_DEVICE
+        default_value 0
+        description "Enables the location of a ROM filesystem to
+            be specified using a flash block device name such as
+            \"/dev/flash/fis/romfs\" in the call to mount()."
+    }
+
     # ----------------------------------------------------------------
     # Tests
 
--- a/packages/fs/rom/current/src/romfs.c
+++ b/packages/fs/rom/current/src/romfs.c
@@ -136,6 +136,12 @@
 #include <cyg/kernel/kapi.h>
 #include <cyg/infra/diag.h>
 
+#if defined(CYGFUN_FS_ROM_FLASH_BLOCK_DEVICE_LOOKUP)
+#include <cyg/io/io.h>
+#include <cyg/io/config_keys.h>
+#include <cyg/io/flash.h>
+#endif
+
 //==========================================================================
 // Eventually we want to eXecute In Place from the ROM in a protected
 // environment, so we'll need executables to be aligned to a boundary
@@ -593,11 +599,32 @@ static int romfs_mount    ( cyg_fstab_en
     if ( !mte->data ) {
 	// If the image address was not in the MTE data word,
 	if ( mte->devname && mte->devname[0] ) {
-            char *addr;
-            // And there's something in the 'hardware device' field,
-	    // then read the address from there.
-	    sscanf( mte->devname, "%p", &addr );
-            disk = (romfs_disk *) addr;
+	    // If a device name specified, lookup flash block device.
+#if defined(CYGFUN_FS_ROM_FLASH_BLOCK_DEVICE_LOOKUP)
+	    if ( mte->devname[0] == '/' ) {
+		Cyg_ErrNo err;
+		cyg_io_handle_t t;
+		cyg_io_flash_getconfig_devaddr_t d;
+		int len;
+		err = cyg_io_lookup(mte->devname, &t);
+		if (err != ENOERR) {
+		    return -err;
+		}
+		len = sizeof(d);
+		err = cyg_io_get_config(t, CYG_IO_GET_CONFIG_FLASH_DEVADDR, &d, &len);
+		if (err != ENOERR) {
+		    return -err;
+		}
+		disk = (romfs_disk *) d.dev_addr;
+	    } else
+#endif
+	    {
+		char *addr;
+		// And there's something in the 'hardware device' field,
+		// then read the address from there.
+		sscanf( mte->devname, "%p", &addr );
+		disk = (romfs_disk *) addr;
+	    }
         }
     } else {
         disk = (romfs_disk *)mte->data;
--- a/packages/fs/rom/current/support/mk_romfs.c
+++ b/packages/fs/rom/current/support/mk_romfs.c
@@ -8,7 +8,7 @@
 // ####ECOSGPLCOPYRIGHTBEGIN####                                            
 // -------------------------------------------                              
 // This file is part of eCos, the Embedded Configurable Operating System.   
-// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2010 Free Software Foundation, Inc.
 //
 // 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     
@@ -88,6 +88,14 @@
 // Undefine this if the host filesystem does not support lstat()
 #define HAS_LSTAT
 
+// Win32 definitions
+#ifdef _WIN32
+#undef HAS_LSTAT
+#define S_ISLNK(m) (0)
+typedef unsigned int uid_t;
+typedef unsigned int gid_t;
+#endif
+
 //==========================================================================
 
 // Return (n) aligned to the next (b) byte boundary
@@ -270,6 +278,7 @@ static unsigned long ConvertMode( unsign
     if ( posix_mode & S_IRUSR )  result |= 1<<16;
     if ( posix_mode & S_IWUSR )  result |= 1<<17;
     if ( posix_mode & S_IXUSR )  result |= 1<<18;
+#ifndef _WIN32
     if ( posix_mode & S_IRGRP )  result |= 1<<19;
     if ( posix_mode & S_IWGRP )  result |= 1<<20;
     if ( posix_mode & S_IXGRP )  result |= 1<<21;
@@ -278,6 +287,7 @@ static unsigned long ConvertMode( unsign
     if ( posix_mode & S_IXOTH )  result |= 1<<24;
     if ( posix_mode & S_ISUID )  result |= 1<<25;
     if ( posix_mode & S_ISGID )  result |= 1<<26;
+#endif
     return result;
 }