changeset 1764:96ec7e534d98

V2 flash header files clean-up. Eliminate flash_priv.h, moving the functionality into flash_dev.h instead.
author bartv
date Tue, 22 Feb 2005 21:03:43 +0000
parents 42c8ea63b78d
children bfd6d67dba43
files packages/devs/flash/amd/am29xxxxxv2/current/ChangeLog packages/devs/flash/amd/am29xxxxxv2/current/include/am29xxxxx_dev.h packages/devs/flash/amd/am29xxxxxv2/current/src/am29xxxxx.c packages/devs/flash/arm/at91/current/ChangeLog packages/devs/flash/arm/at91/current/src/at91_flash.c packages/devs/flash/arm/ebsa285/current/ChangeLog packages/devs/flash/arm/ebsa285/current/src/ebsa285_flash.c packages/devs/flash/arm/edb7xxx/current/ChangeLog packages/devs/flash/arm/edb7xxx/current/src/edb7xxx_flash.c packages/devs/flash/arm/iq80310/current/ChangeLog packages/devs/flash/arm/iq80310/current/src/iq80310_flash.c packages/devs/flash/arm/sa1100mm/current/ChangeLog packages/devs/flash/arm/sa1100mm/current/src/sa1100mm_flash.c packages/devs/flash/atmel/dataflash/current/ChangeLog packages/devs/flash/atmel/dataflash/current/include/dataflash.h packages/devs/flash/atmel/dataflash/current/src/devs_flash_atmel_dataflash_flash_dev_funs.c packages/devs/flash/intel/strata/current/ChangeLog packages/devs/flash/intel/strata/current/src/strata.c packages/devs/flash/mips/atlas/current/ChangeLog packages/devs/flash/mips/atlas/current/src/atlas_flash.c packages/devs/flash/synth/current/ChangeLog packages/devs/flash/synth/current/src/synth.c packages/devs/flash/synth/current/tests/flash2.c packages/devs/flash/synthv2/current/ChangeLog packages/devs/flash/synthv2/current/include/synth.h packages/devs/flash/synthv2/current/src/synth.c packages/io/flash/current/ChangeLog packages/io/flash/current/include/flash.h packages/io/flash/current/include/flash_dev.h packages/io/flash/current/include/flash_priv.h packages/io/flash/current/src/flash.c packages/io/flash/current/src/flashiodev.c packages/io/flash/current/src/legacy_api.c packages/io/flash/current/src/legacy_dev.c
diffstat 34 files changed, 234 insertions(+), 228 deletions(-) [+]
line wrap: on
line diff
--- a/packages/devs/flash/amd/am29xxxxxv2/current/ChangeLog
+++ b/packages/devs/flash/amd/am29xxxxxv2/current/ChangeLog
@@ -1,3 +1,8 @@
+2004-12-02  Bart Veer  <bartv@ecoscentric.com>
+
+	* src/am29xxxxx.c, include/am29xxxxx_dev.h: <cyg/io/flash_priv.h>
+	no longer exists, use <cyg/io/flash_dev.h> instead.
+
 2004-11-29  Bart Veer  <bartv@ecoscentric.com>
 
 	* include/am29xxxxx_dev.h, src/am29xxxxx.c: eliminate
--- a/packages/devs/flash/amd/am29xxxxxv2/current/include/am29xxxxx_dev.h
+++ b/packages/devs/flash/amd/am29xxxxxv2/current/include/am29xxxxx_dev.h
@@ -50,7 +50,7 @@
 #include <pkgconf/devs_flash_amd_am29xxxxx_v2.h>
 #include <cyg/infra/cyg_type.h>
 #include <cyg/io/flash.h>
-#include <cyg/io/flash_priv.h>
+#include <cyg/io/flash_dev.h>
 
 externC int cyg_am29xxxxx_read_devid_8(     struct cyg_flash_dev*);
 externC int cyg_am29xxxxx_read_devid_16(    struct cyg_flash_dev*);
--- a/packages/devs/flash/amd/am29xxxxxv2/current/src/am29xxxxx.c
+++ b/packages/devs/flash/amd/am29xxxxxv2/current/src/am29xxxxx.c
@@ -50,7 +50,7 @@
 #include <cyg/infra/cyg_ass.h>
 #include <cyg/infra/diag.h>
 #include <cyg/io/flash.h>
-#include <cyg/io/flash_priv.h>
+#include <cyg/io/flash_dev.h>
 #include <cyg/io/am29xxxxx_dev.h>
 #include <cyg/hal/hal_arch.h>
 #include <cyg/hal/hal_cache.h>
@@ -83,7 +83,6 @@
 //  size_t  (*query)(...)
 //  int     (*erase)(...)
 //  int     (*program)(...)
-//  int     (*hwr_map_error)(...)
 //  int     (*block_lock)(...)
 //  int     (*block_unlock)(...)
 //
@@ -103,10 +102,8 @@
 // No read function need be supplied because the flash memory is
 // always directly accessible to the cpu.
 //
-// The hwr_map_error is a no-op.
-//
 // Erase, program, and the locking functions need real
-// implementations.
+// implementations, although locking is not always available.
 
 // ----------------------------------------------------------------------------
 // The protocol understood by AMD flash chips and compatibles.
--- a/packages/devs/flash/arm/at91/current/ChangeLog
+++ b/packages/devs/flash/arm/at91/current/ChangeLog
@@ -1,3 +1,8 @@
+2004-12-02  Bart Veer  <bartv@ecoscentric.com>
+
+	* src/at91_flash.c: explicitly include <cyg/io/flash_dev.h> rather
+	than just defining _FLASH_PRIVATE_
+
 2004-08-03  Andrew Lunn  <andrew.lunn@ascom.ch>
 
 	* cdl/flash_at91.cdl: Indicate we need the legacy device API.
--- a/packages/devs/flash/arm/at91/current/src/at91_flash.c
+++ b/packages/devs/flash/arm/at91/current/src/at91_flash.c
@@ -55,8 +55,8 @@
 #include <cyg/hal/hal_cache.h>
 #include <cyg/hal/hal_io.h>
 
-#define  _FLASH_PRIVATE_
 #include <cyg/io/flash.h>
+#include <cyg/io/flash_dev.h>
 
 #include "flash.h"
 
--- a/packages/devs/flash/arm/ebsa285/current/ChangeLog
+++ b/packages/devs/flash/arm/ebsa285/current/ChangeLog
@@ -1,3 +1,8 @@
+2004-12-02  Bart Veer  <bartv@ecoscentric.com>
+
+	* src/ebsa285_flash.c: explicitly include <cyg/io/flash_dev.h>
+	rather than just defining _FLASH_PRIVATE_
+
 2004-08-03  Andrew Lunn  <andrew.lunn@ascom.ch>
 
 	* cdl/flash_ebsa285.cdl: Indicate we need the legacy device API.
--- a/packages/devs/flash/arm/ebsa285/current/src/ebsa285_flash.c
+++ b/packages/devs/flash/arm/ebsa285/current/src/ebsa285_flash.c
@@ -54,8 +54,8 @@
 #include <cyg/hal/hal_arch.h>
 #include <cyg/infra/diag.h>
 
-#define  _FLASH_PRIVATE_
 #include <cyg/io/flash.h>
+#include <cyg/io/flash_dev.h>
 
 #include "flash.h"
 
--- a/packages/devs/flash/arm/edb7xxx/current/ChangeLog
+++ b/packages/devs/flash/arm/edb7xxx/current/ChangeLog
@@ -1,3 +1,8 @@
+2004-12-02  Bart Veer  <bartv@ecoscentric.com>
+
+	* src/edb7xxx_flash.c: explicitly include <cyg/io/flash_dev.h>
+	rather than just defining _FLASH_PRIVATE_
+
 2004-08-03  Andrew Lunn  <andrew.lunn@ascom.ch>
 
 	* cdl/flash_edb7xxx.cdl: Indicate we need the legacy device API.
--- a/packages/devs/flash/arm/edb7xxx/current/src/edb7xxx_flash.c
+++ b/packages/devs/flash/arm/edb7xxx/current/src/edb7xxx_flash.c
@@ -53,8 +53,8 @@
 #include <pkgconf/hal.h>
 #include <cyg/hal/hal_arch.h>
 
-#define  _FLASH_PRIVATE_
 #include <cyg/io/flash.h>
+#include <cyg/io/flash_dev.h>
 
 #include "flash.h"
 
--- a/packages/devs/flash/arm/iq80310/current/ChangeLog
+++ b/packages/devs/flash/arm/iq80310/current/ChangeLog
@@ -1,3 +1,8 @@
+2004-12-02  Bart Veer  <bartv@ecoscentric.com>
+
+	* src/iq80310_flash.c: explicitly include <cyg/io/flash_dev.h>
+	rather than just defining _FLASH_PRIVATE_
+
 2004-08-03  Andrew Lunn  <andrew.lunn@ascom.ch>
 
 	* cdl/flash_iq80310.cdl: Indicate we need the legacy device API
--- a/packages/devs/flash/arm/iq80310/current/src/iq80310_flash.c
+++ b/packages/devs/flash/arm/iq80310/current/src/iq80310_flash.c
@@ -54,8 +54,8 @@
 #include <cyg/hal/hal_arch.h>
 #include <cyg/infra/diag.h>
 
-#define  _FLASH_PRIVATE_
 #include <cyg/io/flash.h>
+#include <cyg/io/flash_dev.h>
 
 #include "flash.h"
 
--- a/packages/devs/flash/arm/sa1100mm/current/ChangeLog
+++ b/packages/devs/flash/arm/sa1100mm/current/ChangeLog
@@ -1,3 +1,8 @@
+2004-12-02  Bart Veer  <bartv@ecoscentric.com>
+
+	* src/sa1100mm_flash.c: explicitly include <cyg/io/flash_dev.h>
+	rather than just defining _FLASH_PRIVATE_
+
 2004-08-03  Andrew Lunn  <andrew.lunn@ascom.ch>
 
 	* cdl/flash_sa1100mm.cdl: Indicate we need the legacy device API.
--- a/packages/devs/flash/arm/sa1100mm/current/src/sa1100mm_flash.c
+++ b/packages/devs/flash/arm/sa1100mm/current/src/sa1100mm_flash.c
@@ -53,8 +53,8 @@
 #include <pkgconf/hal.h>
 #include <cyg/hal/hal_arch.h>
 
-#define  _FLASH_PRIVATE_
 #include <cyg/io/flash.h>
+#include <cyg/io/flash_dev.h>
 
 #include "flash.h"
 
--- a/packages/devs/flash/atmel/dataflash/current/ChangeLog
+++ b/packages/devs/flash/atmel/dataflash/current/ChangeLog
@@ -1,3 +1,9 @@
+2004-12-02  Bart Veer  <bartv@ecoscentric.com>
+
+	* include/dataflash.h,
+	src/devs_flash_atmel_dataflash_flash_dev_funs.c: include
+	<cyg/io/flash_dev.h> explicitly rather than using _FLASH_PRIVATE_
+
 2004-11-29  Bart Veer  <bartv@ecoscentric.com>
 
 	(df_flash_hwr_map_error): this is now internal to the driver, no
--- a/packages/devs/flash/atmel/dataflash/current/include/dataflash.h
+++ b/packages/devs/flash/atmel/dataflash/current/include/dataflash.h
@@ -98,8 +98,8 @@ typedef struct cyg_dataflash_device_s
 
 //----------------------------------------------------------------------------
 
-#ifdef _FLASH_PRIVATE_
 #include <cyg/io/flash.h>
+#include <cyg/io/flash_dev.h>
 
 typedef struct cyg_dataflash_flash_dev_priv_s
 {
@@ -128,8 +128,6 @@ externC struct cyg_flash_dev_funs cyg_da
                      cyg_dataflash_priv_ ## name.block_info,                    \
                      & cyg_dataflash_priv_ ## name                              \
         )
-
-#endif // _FLASH_PRIVATE_
     
 //----------------------------------------------------------------------------
 
--- a/packages/devs/flash/atmel/dataflash/current/src/devs_flash_atmel_dataflash_flash_dev_funs.c
+++ b/packages/devs/flash/atmel/dataflash/current/src/devs_flash_atmel_dataflash_flash_dev_funs.c
@@ -56,8 +56,6 @@
 #include <cyg/infra/cyg_type.h>
 #include <cyg/infra/cyg_ass.h>
 #include <cyg/io/spi.h>
-
-#define  _FLASH_PRIVATE_
 #include <cyg/io/dataflash.h>
 
 // -------------------------------------------------------------------------- 
--- a/packages/devs/flash/intel/strata/current/ChangeLog
+++ b/packages/devs/flash/intel/strata/current/ChangeLog
@@ -1,3 +1,7 @@
+2004-12-02  Bart Veer  <bartv@ecoscentric.com>
+
+	* src/strata.c: leave _FLASH_PRIVATE_ to the private strata.h
+
 2005-01-26  Scott Wilkinson <scott@alliantnetworks.com>
 	* src/strata.h:
 	* src/strata.c:
--- a/packages/devs/flash/intel/strata/current/src/strata.c
+++ b/packages/devs/flash/intel/strata/current/src/strata.c
@@ -54,9 +54,7 @@
 #include <pkgconf/hal.h>
 #include <cyg/hal/hal_arch.h>
 
-#define  _FLASH_PRIVATE_
 #include <cyg/io/flash.h>
-
 #include "strata.h"
 
 #define _si(p) ((p[1]<<8)|p[0])
--- a/packages/devs/flash/mips/atlas/current/ChangeLog
+++ b/packages/devs/flash/mips/atlas/current/ChangeLog
@@ -1,3 +1,8 @@
+2004-12-02  Bart Veer  <bartv@ecoscentric.com>
+
+	* src/atlas_flash.c: include <cyg/io/flash_dev.h> explicitly
+	rather than defining _FLASH_PRIVATE_
+
 2004-08-03  Andrew Lunn  <andrew.lunn@ascom.ch>
 
 	* cdl/flash_atlas.cdl: Indicate we need the legacy device API
--- a/packages/devs/flash/mips/atlas/current/src/atlas_flash.c
+++ b/packages/devs/flash/mips/atlas/current/src/atlas_flash.c
@@ -54,8 +54,8 @@
 #include <cyg/hal/hal_arch.h>
 #include <cyg/infra/diag.h>
 
-#define  _FLASH_PRIVATE_
 #include <cyg/io/flash.h>
+#include <cyg/io/flash_dev.h>
 
 #include "flash.h"
 
--- a/packages/devs/flash/synth/current/ChangeLog
+++ b/packages/devs/flash/synth/current/ChangeLog
@@ -1,3 +1,9 @@
+2004-12-02  Bart Veer  <bartv@ecoscentric.com>
+
+	* src/synth.c: explicitly include <cyg/io/flash_dev.h> rather than
+	just defining _FLASH_PRIVATE_
+	* tests/flash2.c (cyg_user_start): update as per the v2 testcase
+
 2004-11-22  Bart Veer  <bartv@ecoscentric.com>
 
 	* cdl/flash_synth.cdl: fix testcase definitions
--- a/packages/devs/flash/synth/current/src/synth.c
+++ b/packages/devs/flash/synth/current/src/synth.c
@@ -57,8 +57,8 @@
 #include <errno.h>
 #include <string.h>
 
-#define  _FLASH_PRIVATE_
 #include <cyg/io/flash.h>
+#include <cyg/io/flash_dev.h>
 
 #include "synth.h"
 
--- a/packages/devs/flash/synth/current/tests/flash2.c
+++ b/packages/devs/flash/synth/current/tests/flash2.c
@@ -80,9 +80,9 @@ void cyg_user_start(void)
 void cyg_user_start(void)
 {
     int ret;
-    cyg_flashaddr_t flash_start, flash_end;
+    cyg_flashaddr_t flash_start=0, flash_end=0;
     cyg_flash_info_t info;
-    int block_size, blocks;
+    int block_size=0, blocks=0;
     cyg_flashaddr_t prog_start;
     unsigned char * ptr;
     cyg_uint32 i=0;
@@ -94,25 +94,17 @@ void cyg_user_start(void)
   
     CYG_TEST_PASS_FAIL((ret == CYG_FLASH_ERR_OK),"flash_init");
 
-    ret = cyg_flash_get_limits(&flash_start,&flash_end);
-    CYG_TEST_PASS_FAIL((ret == CYG_FLASH_ERR_OK),"flash_get_limits");
-    diag_printf("INFO: flash_start=%p, flash_end=%p\n", 
-                flash_start, flash_end);
-    
-    ret = cyg_flash_get_block_info(&block_size, &blocks);
-    CYG_TEST_PASS_FAIL((ret == CYG_FLASH_ERR_OK),"flash_get_block_info");
-    CYG_TEST_PASS_FAIL((block_size == CYGNUM_FLASH_SYNTH_BLOCKSIZE),
-                      "correct block size");
-    CYG_TEST_PASS_FAIL((blocks == CYGNUM_FLASH_SYNTH_NUMBLOCKS),
-                      "correct number of blocks");
-    
-    diag_printf("INFO: block_size=0x%x, blocks=%d\n", block_size, blocks);
-    
     do {
       ret = cyg_flash_get_info(i, &info);
       if (ret == CYG_FLASH_ERR_OK) {
         diag_printf("INFO: Nth=%d, start=%p, end=%p\n",
                     i, info.start, info.end);
+        if (i == 0) {
+          flash_start = info.start;
+          flash_end = info.end;
+          block_size = info.block_info[0].block_size;
+          blocks = info.block_info[0].blocks;
+        }
         for (j=0;j < info.num_block_infos; j++) {
           diag_printf("INFO:\t block_size %d, blocks %d\n",
                       info.block_info[j].block_size,
--- a/packages/devs/flash/synthv2/current/ChangeLog
+++ b/packages/devs/flash/synthv2/current/ChangeLog
@@ -1,3 +1,8 @@
+2004-12-02  Bart Veer  <bartv@ecoscentric.com>
+
+	* include/synth.h, src/synth.c: explicitly include
+	<cyg/io/flash_dev.h> rather than just defining _FLASH_PRIVATE_
+
 2004-11-29  Bart Veer  <bartv@ecoscentric.com>
 
 	* src/synth.c: eliminate hwr_map_error() support, no longer needed
--- a/packages/devs/flash/synthv2/current/include/synth.h
+++ b/packages/devs/flash/synthv2/current/include/synth.h
@@ -52,7 +52,8 @@
 //
 //==========================================================================
 
-#include <cyg/io/flash_priv.h>
+#include <cyg/io/flash.h>
+#include <cyg/io/flash_dev.h>
 
 // Structure of data private to each flash device
 struct cyg_flash_synth_priv 
--- a/packages/devs/flash/synthv2/current/src/synth.c
+++ b/packages/devs/flash/synthv2/current/src/synth.c
@@ -56,8 +56,8 @@
 #include <cyg/infra/cyg_ass.h>
 #include <string.h>
 
-#define  _FLASH_PRIVATE_
 #include <cyg/io/flash.h>
+#include <cyg/io/flash_dev.h>
 #include <cyg/flash/synth.h>
 
 #ifndef MIN
--- a/packages/io/flash/current/ChangeLog
+++ b/packages/io/flash/current/ChangeLog
@@ -1,3 +1,15 @@
+2004-12-02  Bart Veer  <bartv@ecoscentric.com>
+
+	* include/flash_dev.h: now provides everything needed by flash
+	device drivers.
+
+	* include/flash_priv.h: removed, subsumed by flash_dev.h
+	
+	* include/flash.h, src/flash.c, src/flashiodev.c,
+	  src/legacy_api.c, src/legacy_dev.c:
+	Replace implicit #include's of <cyg/io/flash_priv.h> with explicit
+	#include's of <cyg/io/flash_dev.h>
+
 2004-11-29  Bart Veer  <bartv@ecoscentric.com>
 	
 	* include/flash_priv.h, src/flash.c, src/legacy_dev.c: remove
--- a/packages/io/flash/current/include/flash.h
+++ b/packages/io/flash/current/include/flash.h
@@ -189,8 +189,4 @@ typedef struct {
 } cyg_io_flash_getconfig_blocksize_t;
 #endif
 
-#ifdef _FLASH_PRIVATE_
-#include <cyg/io/flash_priv.h>
-#endif
-
 #endif  // _IO_FLASH_H_
--- a/packages/io/flash/current/include/flash_dev.h
+++ b/packages/io/flash/current/include/flash_dev.h
@@ -10,6 +10,9 @@
 //####ECOSGPLCOPYRIGHTBEGIN####
 // -------------------------------------------
 // This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 2004 eCosCentric Ltd.
+// Copyright (C) 2004 Andrew Lunn
+// Copyright (C) 2003 Gary Thomas
 // Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
 //
 // eCos is free software; you can redistribute it and/or modify it under
@@ -42,6 +45,144 @@
 //==========================================================================
 //#####DESCRIPTIONBEGIN####
 //
+// Author(s):    gthomas
+// Contributors: gthomas, Andrew Lunn, bartv
+// Date:         2000-07-14
+// Purpose:      
+// Description:  
+//              
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+
+#include <pkgconf/system.h>
+#include <pkgconf/io_flash.h>
+#include <cyg/infra/cyg_type.h>
+#include <cyg/io/flash.h>
+#include <cyg/hal/hal_cache.h>
+#include <cyg/hal/hal_tables.h>
+
+// Forward reference of the device structure
+struct cyg_flash_dev;
+
+// Structure of pointers to functions in the device driver
+struct cyg_flash_dev_funs {
+  int     (*flash_init) (struct cyg_flash_dev *dev);
+  size_t  (*flash_query) (struct cyg_flash_dev *dev,
+                          void * data, size_t len);
+  int     (*flash_erase_block) (struct cyg_flash_dev *dev, 
+                                cyg_flashaddr_t block_base);
+  int     (*flash_program) (struct cyg_flash_dev *dev, 
+                            cyg_flashaddr_t base, 
+                            const void* data, size_t len);
+  int     (*flash_read) (struct cyg_flash_dev *dev, 
+                         const cyg_flashaddr_t base, 
+                         void* data, size_t len);
+#ifdef CYGHWR_IO_FLASH_BLOCK_LOCKING    
+  int     (*flash_block_lock) (struct cyg_flash_dev *dev, 
+                               const cyg_flashaddr_t block_base);
+  int     (*flash_block_unlock) (struct cyg_flash_dev *dev, 
+                                 const cyg_flashaddr_t block_base);
+#endif    
+};
+
+// Dummy functions for some of the above operations, if a device does
+// not support e.g. locking.
+externC int     cyg_flash_devfn_init_nop(struct cyg_flash_dev*);
+externC size_t  cyg_flash_devfn_query_nop(struct cyg_flash_dev*, void*, const size_t);
+externC int     cyg_flash_devfn_lock_nop(struct cyg_flash_dev*, const cyg_flashaddr_t);
+externC int     cyg_flash_devfn_unlock_nop(struct cyg_flash_dev*, const cyg_flashaddr_t);
+
+// Facilitate function calls between flash-resident code and .2ram
+// functions.
+externC void*   cyg_flash_anonymizer(void*);
+
+// Structure each device places in the HAL table
+struct cyg_flash_dev {
+  const struct cyg_flash_dev_funs *funs;            // Function pointers
+  cyg_uint32                      flags;            // Device characteristics
+  cyg_flashaddr_t                 start;            // First address
+  cyg_flashaddr_t                 end;              // Last address
+  cyg_uint32                      num_block_infos;  // Number of entries
+  const cyg_flash_block_info_t    *block_info;      // Info about one block size
+
+  const void                      *priv;            // Devices private data
+
+  // The following are only written to by the FLASH IO layer.
+  cyg_flash_printf                *pf;              // Pointer to diagnostic printf
+  bool                            init;             // Device has been initialised
+#ifdef CYGPKG_KERNEL
+  cyg_mutex_t                     mutex;            // Mutex for thread safeness
+#endif
+#if (CYGHWR_IO_FLASH_DEVICE > 1)    
+  struct cyg_flash_dev            *next;            // Pointer to next device
+#endif    
+} CYG_HAL_TABLE_TYPE;
+
+// Macros for instantiating the above structures.
+#ifdef CYGHWR_IO_FLASH_BLOCK_LOCKING
+# define CYG_FLASH_FUNS(_funs_, _init_, _query_ , _erase_, _prog_ , _read_, _lock_, _unlock_) \
+struct cyg_flash_dev_funs _funs_ =      \
+{										\
+	.flash_init             = _init_,   \
+	.flash_query            = _query_,  \
+	.flash_erase_block      = _erase_,  \
+	.flash_program          = _prog_,   \
+	.flash_read             = _read_,   \
+	.flash_block_lock       = _lock_,   \
+	.flash_block_unlock     = _unlock_  \
+}
+#else
+# define CYG_FLASH_FUNS(_funs_, _init_, _query_ , _erase_, _prog_ , _read_, _lock_, _unlock_) \
+struct cyg_flash_dev_funs _funs_ =      \
+{										\
+	.flash_init             = _init_,   \
+	.flash_query            = _query_,  \
+	.flash_erase_block      = _erase_,  \
+	.flash_program          = _prog_,   \
+	.flash_read             = _read_    \
+}
+#endif
+
+// We assume HAL tables are placed into RAM.
+#define CYG_FLASH_DRIVER(_name_, _funs_, _flags_, _start_, _end_, _num_block_infos_, _block_info_, _priv_)  \
+struct cyg_flash_dev _name_ CYG_HAL_TABLE_ENTRY(cyg_flashdev) = \
+{                                                               \
+    .funs               = _funs_,                               \
+    .flags              = _flags_,                              \
+    .start              = _start_,                              \
+    .end                = _end_,                                \
+    .num_block_infos    = _num_block_infos_,                    \
+    .block_info         = _block_info_,                         \
+    .priv               = _priv_                                \
+}
+
+// Additional support for legacy device drivers.
+#ifdef CYGHWR_IO_FLASH_DEVICE_LEGACY
+struct flash_info {
+  int	block_size;	  // Assuming fixed size "blocks"
+  int	blocks;		  // Number of blocks
+  int	buffer_size;  // Size of write buffer (only defined for some devices)
+  unsigned long block_mask;
+  void *start, *end;  // Address range
+  int	init;
+  cyg_flash_printf *pf;
+};
+
+externC struct flash_info flash_info;
+externC int	 flash_hwr_init(void);
+externC int	 flash_hwr_map_error(int err);
+externC void flash_dev_query(void *data);
+#endif // CYGHWR_IO_FLASH_DEVICE_LEGACY
+
+// ----------------------------------------------------------------------------
+// This section provides utility macros used by some flash drivers, especially
+// the legacy ones. Such flash drivers need to #define _FLASH_PRIVATE before
+// including this file.
+
+#ifdef _FLASH_PRIVATE_
+
+//==========================================================================
 // Author(s):    hmt
 // Contributors: hmt, jskov, Jose Pascual <josepascual@almudi.com>
 // Date:         2001-02-22
@@ -53,16 +194,8 @@
 //               The FLASH_P2V macro can be used to fix up non-linear
 //               mappings of flash blocks (defaults to a linear 
 //               implementation).
-//              
-//####DESCRIPTIONEND####
-//
 //==========================================================================
 
-#ifdef _FLASH_PRIVATE_
-#include <cyg/infra/cyg_type.h>
-
-// ------------------------------------------------------------------------
-//
 // No mapping on this target - but these casts would be needed if some
 // manipulation did occur.  An example of this might be:
 // // First 4K page of flash at physical address zero is
@@ -165,3 +298,4 @@ typedef cyg_uint64 flash_data_t;
 #endif // CYGONCE_IO_FLASH_FLASH_DEV_H
 //----------------------------------------------------------------------------
 // end of flash_dev.h
+
deleted file mode 100644
--- a/packages/io/flash/current/include/flash_priv.h
+++ /dev/null
@@ -1,173 +0,0 @@
-//==========================================================================
-//
-//      flash_priv.h
-//
-//      Flash programming - driver internals
-//
-//==========================================================================
-//####ECOSGPLCOPYRIGHTBEGIN####
-// -------------------------------------------
-// This file is part of eCos, the Embedded Configurable Operating System.
-// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
-// Copyright (C) 2003 Gary Thomas
-// copyright (C) 2004 Andrew Lunn
-//
-// 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.
-//
-// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
-// WARRANTY; without even the implied warranty of MERCHANTABILITY or
-// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-// for more details.
-//
-// You should have received a copy of the GNU General Public License along
-// with eCos; if not, write to the Free Software Foundation, Inc.,
-// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
-//
-// As a special exception, if other files instantiate templates or use macros
-// or inline functions from this file, or you compile this file and link it
-// with other works to produce a work based on this file, this file does not
-// by itself cause the resulting work to be covered by the GNU General Public
-// 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, Andrew Lunn
-// Date:         2000-07-14
-// Purpose:      
-// Description:  
-//              
-//####DESCRIPTIONEND####
-//
-//==========================================================================
-#ifndef _IO_FLASH_PRIV_H_
-#define _IO_FLASH_PRIV_H_
-
-#include <pkgconf/system.h>
-#include <pkgconf/io_flash.h>
-#include <cyg/hal/hal_cache.h>
-#include <cyg/hal/hal_tables.h>
-
-// Forward reference of the device structure
-struct cyg_flash_dev;
-
-// Structure of pointers to functions in the device driver
-struct cyg_flash_dev_funs {
-  int     (*flash_init) (struct cyg_flash_dev *dev);
-  size_t  (*flash_query) (struct cyg_flash_dev *dev,
-                          void * data, size_t len);
-  int     (*flash_erase_block) (struct cyg_flash_dev *dev, 
-                                cyg_flashaddr_t block_base);
-  int     (*flash_program) (struct cyg_flash_dev *dev, 
-                            cyg_flashaddr_t base, 
-                            const void* data, size_t len);
-  int     (*flash_read) (struct cyg_flash_dev *dev, 
-                         const cyg_flashaddr_t base, 
-                         void* data, size_t len);
-#ifdef CYGHWR_IO_FLASH_BLOCK_LOCKING    
-  int     (*flash_block_lock) (struct cyg_flash_dev *dev, 
-                               const cyg_flashaddr_t block_base);
-  int     (*flash_block_unlock) (struct cyg_flash_dev *dev, 
-                                 const cyg_flashaddr_t block_base);
-#endif    
-};
-
-// Dummy functions for some of the above operations, if a device does
-// not support e.g. locking.
-externC int     cyg_flash_devfn_init_nop(struct cyg_flash_dev*);
-externC size_t  cyg_flash_devfn_query_nop(struct cyg_flash_dev*, void*, const size_t);
-externC int     cyg_flash_devfn_lock_nop(struct cyg_flash_dev*, const cyg_flashaddr_t);
-externC int     cyg_flash_devfn_unlock_nop(struct cyg_flash_dev*, const cyg_flashaddr_t);
-
-// Facilitate function calls between flash-resident code and .2ram
-// functions.
-externC void*   cyg_flash_anonymizer(void*);
-
-// Structure each device places in the HAL table
-struct cyg_flash_dev {
-  const struct cyg_flash_dev_funs *funs;            // Function pointers
-  cyg_uint32                      flags;            // Device characteristics
-  cyg_flashaddr_t                 start;            // First address
-  cyg_flashaddr_t                 end;              // Last address
-  cyg_uint32                      num_block_infos;  // Number of entries
-  const cyg_flash_block_info_t    *block_info;      // Info about one block size
-
-  const void                      *priv;            // Devices private data
-
-  // The following are only written to by the FLASH IO layer.
-  cyg_flash_printf                *pf;              // Pointer to diagnostic printf
-  bool                            init;             // Device has been initialised
-#ifdef CYGPKG_KERNEL
-  cyg_mutex_t                     mutex;            // Mutex for thread safeness
-#endif
-#if (CYGHWR_IO_FLASH_DEVICE > 1)    
-  struct cyg_flash_dev            *next;            // Pointer to next device
-#endif    
-} CYG_HAL_TABLE_TYPE;
-
-#ifdef CYGHWR_IO_FLASH_BLOCK_LOCKING
-# define CYG_FLASH_FUNS(_funs_, _init_, _query_ , _erase_, _prog_ , _read_, _lock_, _unlock_) \
-struct cyg_flash_dev_funs _funs_ =      \
-{										\
-	.flash_init             = _init_,   \
-	.flash_query            = _query_,  \
-	.flash_erase_block      = _erase_,  \
-	.flash_program          = _prog_,   \
-	.flash_read             = _read_,   \
-	.flash_block_lock       = _lock_,   \
-	.flash_block_unlock     = _unlock_  \
-}
-#else
-# define CYG_FLASH_FUNS(_funs_, _init_, _query_ , _erase_, _prog_ , _read_, _lock_, _unlock_) \
-struct cyg_flash_dev_funs _funs_ =      \
-{										\
-	.flash_init             = _init_,   \
-	.flash_query            = _query_,  \
-	.flash_erase_block      = _erase_,  \
-	.flash_program          = _prog_,   \
-	.flash_read             = _read_    \
-}
-#endif
-
-// We assume HAL tables are placed into RAM.
-#define CYG_FLASH_DRIVER(_name_, _funs_, _flags_, _start_, _end_, _num_block_infos_, _block_info_, _priv_)  \
-struct cyg_flash_dev _name_ CYG_HAL_TABLE_ENTRY(cyg_flashdev) = \
-{                                                               \
-    .funs               = _funs_,                               \
-    .flags              = _flags_,                              \
-    .start              = _start_,                              \
-    .end                = _end_,                                \
-    .num_block_infos    = _num_block_infos_,                    \
-    .block_info         = _block_info_,                         \
-    .priv               = _priv_                                \
-}
-
-#ifdef CYGHWR_IO_FLASH_DEVICE_LEGACY
-struct flash_info {
-  int	block_size;	  // Assuming fixed size "blocks"
-  int	blocks;		  // Number of blocks
-  int	buffer_size;  // Size of write buffer (only defined for some devices)
-  unsigned long block_mask;
-  void *start, *end;  // Address range
-  int	init;
-  cyg_flash_printf *pf;
-};
-
-externC struct flash_info flash_info;
-externC int	 flash_hwr_init(void);
-externC int	 flash_hwr_map_error(int err);
-externC void flash_dev_query(void *data);
-#endif // CYGHWR_IO_FLASH_DEVICE_LEGACY
-
-#endif  // _IO_FLASH_PRIV_H_
--- a/packages/io/flash/current/src/flash.c
+++ b/packages/io/flash/current/src/flash.c
@@ -65,8 +65,8 @@
 #include <cyg/infra/cyg_ass.h>
 #include <string.h>
 
-#define  _FLASH_PRIVATE_
 #include <cyg/io/flash.h>
+#include <cyg/io/flash_dev.h>
 #include "flash_legacy.h"
 
 // When this flag is set, do not actually jump to the relocated code.
--- a/packages/io/flash/current/src/flashiodev.c
+++ b/packages/io/flash/current/src/flashiodev.c
@@ -51,9 +51,7 @@
 //
 //==========================================================================
 
-#define _FLASH_PRIVATE_
 #include <pkgconf/io_flash.h>
-
 #include <errno.h>
 #include <cyg/infra/cyg_type.h>
 #include <cyg/io/devtab.h>
--- a/packages/io/flash/current/src/legacy_api.c
+++ b/packages/io/flash/current/src/legacy_api.c
@@ -53,7 +53,6 @@
 #include <pkgconf/system.h>
 #include <pkgconf/io_flash.h>
 
-#define  _FLASH_PRIVATE_
 #include <cyg/io/flash.h>
 
 int
--- a/packages/io/flash/current/src/legacy_dev.c
+++ b/packages/io/flash/current/src/legacy_dev.c
@@ -58,8 +58,8 @@
 #include <cyg/hal/hal_cache.h>
 #include <string.h>
 
-#define  _FLASH_PRIVATE_
 #include <cyg/io/flash.h>
+#include <cyg/io/flash_dev.h>
 #include "flash_legacy.h"
 
 // When this flag is set, do not actually jump to the relocated code.