This is the mail archive of the ecos-patches@sources.redhat.com 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]

V2 flash - partial clean-up of legacy stuff


This patch moves the cache manipulation macros and the
FLASH_Enable()/Disable() macros from the exported header file
flash_priv.h to a new internal one flash_legacy.h. The relevant macros
are not used by any code outside the generic flash package. In due
course it should be possible to move the macro invocations from the
V2 flash.c file to legacy_dev.c, thus maintaining backwards
compatibility while allowing new drivers to operate cleanly.

Bart

Index: ChangeLog
===================================================================
RCS file: /cvs/ecos/ecos/packages/io/flash/current/ChangeLog,v
retrieving revision 1.38.2.18
diff -u -r1.38.2.18 ChangeLog
--- ChangeLog	22 Nov 2004 12:06:03 -0000	1.38.2.18
+++ ChangeLog	22 Nov 2004 13:13:41 -0000
@@ -1,5 +1,8 @@
 2004-11-22  Bart Veer  <bartv@ecoscentric.com>
 
+	* include/flash_priv, src/flash_legacy.h, src/flash.c,
+	src/legacy_dev.c: move cache stuff andother legacy macros
+	to an internal header.
 	* include/flash.h, include/flash_priv.h, doc/flash.sgml,
 	src/flash.c, src/legacy_dev.c: put const in the right places,
 	and rename cyg_block_info to cyg_flash_block_info
Index: src/flash.c
===================================================================
RCS file: /cvs/ecos/ecos/packages/io/flash/current/src/flash.c,v
retrieving revision 1.26.2.13
diff -u -r1.26.2.13 flash.c
--- src/flash.c	22 Nov 2004 12:05:55 -0000	1.26.2.13
+++ src/flash.c	22 Nov 2004 13:13:48 -0000
@@ -67,6 +67,7 @@
 
 #define  _FLASH_PRIVATE_
 #include <cyg/io/flash.h>
+#include "flash_legacy.h"
 
 // When this flag is set, do not actually jump to the relocated code.
 // This can be used for running the function in place (RAM startup
Index: src/legacy_dev.c
===================================================================
RCS file: /cvs/ecos/ecos/packages/io/flash/current/src/Attic/legacy_dev.c,v
retrieving revision 1.1.2.6
diff -u -r1.1.2.6 legacy_dev.c
--- src/legacy_dev.c	22 Nov 2004 12:05:55 -0000	1.1.2.6
+++ src/legacy_dev.c	22 Nov 2004 13:13:48 -0000
@@ -60,6 +60,7 @@
 
 #define  _FLASH_PRIVATE_
 #include <cyg/io/flash.h>
+#include "flash_legacy.h"
 
 // When this flag is set, do not actually jump to the relocated code.
 // This can be used for running the function in place (RAM startup only),


Index: include/flash_priv.h
===================================================================
RCS file: /cvs/ecos/ecos/packages/io/flash/current/include/Attic/flash_priv.h,v
retrieving revision 1.1.2.4
diff -u -r1.1.2.4 flash_priv.h
--- include/flash_priv.h	22 Nov 2004 12:05:57 -0000	1.1.2.4
+++ include/flash_priv.h	22 Nov 2004 13:13:42 -0000
@@ -1,8 +1,8 @@
 //==========================================================================
 //
-//      flash.h
+//      flash_priv.h
 //
-//      Flash programming - external interfaces
+//      Flash programming - driver internals
 //
 //==========================================================================
 //####ECOSGPLCOPYRIGHTBEGIN####
@@ -143,116 +143,5 @@
 externC int  flash_hwr_map_error(int err);
 externC void flash_dev_query(void *data);
 #endif // CYGHWR_IO_FLASH_DEVICE_LEGACY
-// 
-// Some FLASH devices may require additional support, e.g. to turn on
-// appropriate voltage drivers, before any operation.
-//
-#ifdef  CYGIMP_FLASH_ENABLE
-#define FLASH_Enable CYGIMP_FLASH_ENABLE
-extern void CYGIMP_FLASH_ENABLE(void *, void *);
-#else
-#define FLASH_Enable(_start_, _end_)
-#endif
-#ifdef  CYGIMP_FLASH_DISABLE
-#define FLASH_Disable CYGIMP_FLASH_DISABLE
-extern void CYGIMP_FLASH_DISABLE(void *, void *);
-#else
-#define FLASH_Disable(_start_, _end_)
-#endif
-
-//
-// Some platforms have a DIP switch or jumper that tells the software that
-// the flash is write protected.
-//
-#ifdef CYGSEM_IO_FLASH_SOFT_WRITE_PROTECT
-externC cyg_bool plf_flash_query_soft_wp(void *addr, int len);
-#endif
-
-//---------------------------------------------------------------------------
-// Execution of flash code must be done inside a
-// HAL_FLASH_CACHES_OFF/HAL_FLASH_CACHES_ON region - disabling the
-// cache on unified cache systems is necessary to prevent burst access
-// to the flash area being programmed. With Harvard style caches, only
-// the data cache needs to be disabled, but the instruction cache is
-// disabled for consistency.
-
-// Targets may provide alternative implementations for these macros in
-// the hal_cache.h (or var/plf) files.
-
-// The first part below is a generic, optimal implementation.  The
-// second part is the old implementation that has been tested to work
-// on some targets - but it is not be suitable for targets that would
-// do burst access to the flash (it does not disable the data cache).
-
-// Both implementations must be called with interrupts disabled.
-
-// NOTE: Do _not_ change any of the below macros without checking that
-//       the changed code still works on _all_ platforms that rely on these
-//       macros. There is no such thing as logical and correct when dealing
-//       with different cache and IO models, so _do not_ mess with this code
-//       unless you test it properly afterwards.
-
-#ifndef HAL_FLASH_CACHES_OFF
-
-// Some drivers have only been tested with the old macros below.
-#ifndef HAL_FLASH_CACHES_OLD_MACROS
-
-#ifdef HAL_CACHE_UNIFIED
-
-// Note: the ucache code has not been tested yet on any target.
-#define HAL_FLASH_CACHES_OFF(_d_, _i_)          \
-    CYG_MACRO_START                             \
-    _i_ = 0; /* avoids warning */               \
-    HAL_UCACHE_IS_ENABLED(_d_);                 \
-    HAL_UCACHE_SYNC();                          \
-    HAL_UCACHE_INVALIDATE_ALL();                \
-    HAL_UCACHE_DISABLE();                       \
-    CYG_MACRO_END
-
-#define HAL_FLASH_CACHES_ON(_d_, _i_)           \
-    CYG_MACRO_START                             \
-    if (_d_) HAL_UCACHE_ENABLE();               \
-    CYG_MACRO_END
-
-#else  // HAL_CACHE_UNIFIED
-
-#define HAL_FLASH_CACHES_OFF(_d_, _i_)          \
-    CYG_MACRO_START                             \
-    _i_ = 0; /* avoids warning */               \
-    HAL_DCACHE_IS_ENABLED(_d_);                 \
-    HAL_DCACHE_SYNC();                          \
-    HAL_DCACHE_INVALIDATE_ALL();                \
-    HAL_DCACHE_DISABLE();                       \
-    HAL_ICACHE_INVALIDATE_ALL();                \
-    CYG_MACRO_END
-
-#define HAL_FLASH_CACHES_ON(_d_, _i_)           \
-    CYG_MACRO_START                             \
-    if (_d_) HAL_DCACHE_ENABLE();               \
-    CYG_MACRO_END
-
-#endif // HAL_CACHE_UNIFIED
-
-#else  // HAL_FLASH_CACHES_OLD_MACROS
-
-// Note: This implementation is broken as it will always enable the i-cache
-//       even if it was not enabled before. It also doesn't work if the
-//       target uses burst access to flash since the d-cache is left enabled.
-//       However, this does not mean you can change this code! Leave it as
-//       is - if you want a different implementation, provide it in the
-//       arch/var/platform cache header file.
-
-#define HAL_FLASH_CACHES_OFF(_d_, _i_)          \
-    _d_ = 0; /* avoids warning */               \
-    _i_ = 0; /* avoids warning */               \
-    HAL_DCACHE_SYNC();                          \
-    HAL_ICACHE_DISABLE();
-
-#define HAL_FLASH_CACHES_ON(_d_, _i_)           \
-    HAL_ICACHE_ENABLE();
-
-#endif  // HAL_FLASH_CACHES_OLD_MACROS
-
-#endif  // HAL_FLASH_CACHES_OFF
 
 #endif  // _IO_FLASH_PRIV_H_
Index: src/flash_legacy.h
===================================================================
RCS file: src/flash_legacy.h
diff -N src/flash_legacy.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ src/flash_legacy.h	22 Nov 2004 13:13:48 -0000
@@ -0,0 +1,170 @@
+//==========================================================================
+//
+//      flash_legacy.h
+//
+//      Flash programming - some internal implementation details.
+//
+//==========================================================================
+//####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// 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
+// 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####
+//
+//==========================================================================
+
+#include <pkgconf/system.h>
+#include <pkgconf/io_flash.h>
+#include <cyg/infra/cyg_type.h>
+#include <cyg/hal/hal_arch.h>
+#include <cyg/hal/hal_cache.h>
+
+
+// Some FLASH devices may require additional support, e.g. to turn on
+// appropriate voltage drivers, before any operation.
+#ifdef  CYGIMP_FLASH_ENABLE
+# define FLASH_Enable CYGIMP_FLASH_ENABLE
+extern void CYGIMP_FLASH_ENABLE(void *, void *);
+#else
+# define FLASH_Enable(_start_, _end_) CYG_EMPTY_STATEMENT
+#endif
+#ifdef  CYGIMP_FLASH_DISABLE
+# define FLASH_Disable CYGIMP_FLASH_DISABLE
+extern void CYGIMP_FLASH_DISABLE(void *, void *);
+#else
+# define FLASH_Disable(_start_, _end_) CYG_EMPTY_STATEMENT
+#endif
+
+//
+// Some platforms have a DIP switch or jumper that tells the software that
+// the flash is write protected.
+//
+#ifdef CYGSEM_IO_FLASH_SOFT_WRITE_PROTECT
+externC cyg_bool plf_flash_query_soft_wp(void *addr, int len);
+#endif
+
+//---------------------------------------------------------------------------
+// Execution of flash code must be done inside a
+// HAL_FLASH_CACHES_OFF/HAL_FLASH_CACHES_ON region - disabling the
+// cache on unified cache systems is necessary to prevent burst access
+// to the flash area being programmed. With Harvard style caches, only
+// the data cache needs to be disabled, but the instruction cache is
+// disabled for consistency.
+
+// Targets may provide alternative implementations for these macros in
+// the hal_cache.h (or var/plf) files.
+
+// The first part below is a generic, optimal implementation.  The
+// second part is the old implementation that has been tested to work
+// on some targets - but it is not be suitable for targets that would
+// do burst access to the flash (it does not disable the data cache).
+
+// Both implementations must be called with interrupts disabled.
+
+// NOTE: Do _not_ change any of the below macros without checking that
+//       the changed code still works on _all_ platforms that rely on these
+//       macros. There is no such thing as logical and correct when dealing
+//       with different cache and IO models, so _do not_ mess with this code
+//       unless you test it properly afterwards.
+
+#ifndef HAL_FLASH_CACHES_OFF
+
+// Some drivers have only been tested with the old macros below.
+#ifndef HAL_FLASH_CACHES_OLD_MACROS
+
+#ifdef HAL_CACHE_UNIFIED
+
+// Note: the ucache code has not been tested yet on any target.
+#define HAL_FLASH_CACHES_OFF(_d_, _i_)          \
+    CYG_MACRO_START                             \
+    _i_ = 0; /* avoids warning */               \
+    HAL_UCACHE_IS_ENABLED(_d_);                 \
+    HAL_UCACHE_SYNC();                          \
+    HAL_UCACHE_INVALIDATE_ALL();                \
+    HAL_UCACHE_DISABLE();                       \
+    CYG_MACRO_END
+
+#define HAL_FLASH_CACHES_ON(_d_, _i_)           \
+    CYG_MACRO_START                             \
+    if (_d_) HAL_UCACHE_ENABLE();               \
+    CYG_MACRO_END
+
+#else  // HAL_CACHE_UNIFIED
+
+#define HAL_FLASH_CACHES_OFF(_d_, _i_)          \
+    CYG_MACRO_START                             \
+    _i_ = 0; /* avoids warning */               \
+    HAL_DCACHE_IS_ENABLED(_d_);                 \
+    HAL_DCACHE_SYNC();                          \
+    HAL_DCACHE_INVALIDATE_ALL();                \
+    HAL_DCACHE_DISABLE();                       \
+    HAL_ICACHE_INVALIDATE_ALL();                \
+    CYG_MACRO_END
+
+#define HAL_FLASH_CACHES_ON(_d_, _i_)           \
+    CYG_MACRO_START                             \
+    if (_d_) HAL_DCACHE_ENABLE();               \
+    CYG_MACRO_END
+
+#endif // HAL_CACHE_UNIFIED
+
+#else  // HAL_FLASH_CACHES_OLD_MACROS
+
+// Note: This implementation is broken as it will always enable the i-cache
+//       even if it was not enabled before. It also doesn't work if the
+//       target uses burst access to flash since the d-cache is left enabled.
+//       However, this does not mean you can change this code! Leave it as
+//       is - if you want a different implementation, provide it in the
+//       arch/var/platform cache header file.
+
+#define HAL_FLASH_CACHES_OFF(_d_, _i_)          \
+    _d_ = 0; /* avoids warning */               \
+    _i_ = 0; /* avoids warning */               \
+    HAL_DCACHE_SYNC();                          \
+    HAL_ICACHE_DISABLE();
+
+#define HAL_FLASH_CACHES_ON(_d_, _i_)           \
+    HAL_ICACHE_ENABLE();
+
+#endif  // HAL_FLASH_CACHES_OLD_MACROS
+
+#endif  // HAL_FLASH_CACHES_OFF


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