Mercurial > flash_v2
diff packages/io/flash/current/include/flash_priv.h @ 1750:fac0499dabd6
Move legacy macros from a public to an internal header file, to
facilitate future clean-ups
| author | bartv |
|---|---|
| date | Mon, 22 Nov 2004 13:25:23 +0000 |
| parents | 80232dbac7fb |
| children | 61fbcc1cb232 |
line wrap: on
line diff
--- a/packages/io/flash/current/include/flash_priv.h +++ b/packages/io/flash/current/include/flash_priv.h @@ -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_init(void); 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_
