diff packages/io/flash/current/src/flashiodev.c @ 1715:868c3fa9315f

* src/flash.c: Make the flock lock/unlock code compile without warnings. * src/flashiodev.c (flashiodev_lookup): Only initialize the device if we have not already been initialized via cyg_set_config(). This stopped redboots mount -f working. * src/flashiodev.c (flashiodev_lookup): Moved most of the flashiodev_init into this new function. This fixed the ordering issue with redboot startup. When doing a FIS name lookup in flashiodev_init, redboot was not yet nitialised so lookup failed. Moving this into flashiodev_lookup solves this problem. Its now possible for redboot to mount the jffs2 filesystem with -d /dev/flash1.
author asl
date Mon, 16 Aug 2004 08:33:41 +0000
parents 39063f315a19
children c506b95a6346
line wrap: on
line diff
--- a/packages/io/flash/current/src/flashiodev.c
+++ b/packages/io/flash/current/src/flashiodev.c
@@ -73,6 +73,7 @@ struct flashiodev_priv_t{
   cyg_bool        use_offset;
   char *          fis_name;
   cyg_uint32      block_size;
+  cyg_bool        init;
 };
 
 static int dummy_printf( const char *fmt, ... ) {return 0;}
@@ -95,6 +96,10 @@ flashiodev_lookup(struct cyg_devtab_entr
   cyg_uint32 i;
   int stat;
   
+  if (dev->init)
+    return ENOERR;
+  dev->init = 1;
+  
   if (dev->use_fis) {
     CYG_ADDRESS	flash_base;
     unsigned long	size;
@@ -288,6 +293,8 @@ flashiodev_set_config( cyg_io_handle_t h
       for (i=0; i < info.num_block_infos; i++){
         dev->block_size = MAX(dev->block_size, info.block_info[i].block_size);
       }
+      dev->init = 1;
+     
       return ENOERR;
     }
   default:
@@ -298,39 +305,37 @@ flashiodev_set_config( cyg_io_handle_t h
 // get_config/set_config should be added later to provide the other flash
 // operations possible, like erase etc.
 
+#define CYG_FLASHIODEV_DEV(start, end, fis, static, offset, name) \
+   { start, end, fis, static, offset, name, 0, 0 }
+
 #ifdef CYGNUM_IO_FLASH_BLOCK_CFG_FIS_1
-static struct flashiodev_priv_t priv1 = {
+static struct flashiodev_priv_t priv1 = CYG_FLASHIODEV_DEV(
   0,       // start
   0,       // end
   1,       // use_fis
   0,       // use_static
   0,       // use_offset
-  CYGDAT_IO_FLASH_BLOCK_FIS_NAME_1,
-  0        // blocksize
-};
+  CYGDAT_IO_FLASH_BLOCK_FIS_NAME_1);
+#endif
 
-#endif
 #ifdef CYGNUM_IO_FLASH_BLOCK_CFG_STATIC_ABSOLUTE_1 
-static struct flashiodev_priv_t priv1 = {
+static struct flashiodev_priv_t priv1 = CYG_FLASHIODEV_DEV(
   CYGNUM_IO_FLASH_BLOCK_ABSOLUTE_START_1,       // start
   CYGNUM_IO_FLASH_BLOCK_ABSOLUTE_START_1 + CYGNUM_IO_FLASH_BLOCK_ABSOLUTE_LENGTH_1,
   0,       // use_fis
   1,       // use_static
   0,       // use_offset
-  "",      // fis_name
-  0        // blocksize
-};
+  "");     // fis_name
 #endif
+
 #ifdef CYGNUM_IO_FLASH_BLOCK_CFG_STATIC_1
-static struct flashiodev_priv_t priv1 = {
+static struct flashiodev_priv_t priv1 = CYG_FLASHIODEV_DEV(
   CYGNUM_IO_FLASH_BLOCK_OFFSET_1,       // start
   CYGNUM_IO_FLASH_BLOCK_LENGTH_1,       // end 
   0,       // use_fis
   0,       // use_static
   1,       // use_offset
-  "",      // fis_name
-  0        // blocksize
-};
+  "");     // fis_name
 #endif
 
 BLOCK_DEVIO_TABLE( cyg_io_flashdev1_ops,
@@ -350,40 +355,35 @@ BLOCK_DEVTAB_ENTRY( cyg_io_flashdev1,
                     &flashiodev_lookup,
                     &priv1 );
 
-
 #ifdef CYGSEM_IO_FLASH_BLOCK_DEVICE_2 
 #ifdef CYGNUM_IO_FLASH_BLOCK_CFG_FIS_2
-static struct flashiodev_priv_t priv2 = {
+static struct flashiodev_priv_t priv2 = CYG_FLASHIODEV_DEV(
   0,       // start
   0,       // end
   1,       // use_fis
   0,       // use_static
   0,       // use_offset
-  CYGDAT_IO_FLASH_BLOCK_FIS_NAME_2,
-  0        // blocksize
-};
+  CYGDAT_IO_FLASH_BLOCK_FIS_NAME_2);
 #endif
+
 #ifdef CYGNUM_IO_FLASH_BLOCK_CFG_STATIC_ABSOLUTE_2 
-static struct flashiodev_priv_t priv2 = {
+static struct flashiodev_priv_t priv2 = CYG_FLASHIODEV_DEV(
   CYGNUM_IO_FLASH_BLOCK_ABSOLUTE_START_2,       // start
   CYGNUM_IO_FLASH_BLOCK_ABSOLUTE_START_2 + CYGNUM_IO_FLASH_BLOCK_ABSOLUTE_LENGTH_2,
   0,       // use_fis
   1,       // use_static
   0,       // use_offset
-  "",      // fis_name
-  0        // blocksize
-};
+  "");     // fis_name
 #endif
+
 #ifdef CYGNUM_IO_FLASH_BLOCK_CFG_STATIC_2
-static struct flashiodev_priv_t priv2 = {
+static struct flashiodev_priv_t priv2 = CYG_FLASHIODEV_DEV(
   CYGNUM_IO_FLASH_BLOCK_OFFSET_2,       // start
   CYGNUM_IO_FLASH_BLOCK_LENGTH_2,       // end 
   0,       // use_fis
   0,       // use_static
   1,       // use_offset
-  "",      // fis_name
-  0        // blocksize
-};
+  "");     // fis_name
 #endif
 
 BLOCK_DEVTAB_ENTRY( cyg_io_flashdev2,