comparison packages/io/flash/current/include/flash.h @ 154:e2d866e32dac

Merge from eCos master repository on 2001-02-26-23:18:05-GMT
author jlarmour
date Tue, 27 Feb 2001 01:21:45 +0000
parents 6b5f480c6929
children b939e9cada46
comparison
equal deleted inserted replaced
153:5e8f3b328bb3 154:e2d866e32dac
75 #define FLASH_ERR_NOT_INIT 0x07 // FLASH info not yet initialized 75 #define FLASH_ERR_NOT_INIT 0x07 // FLASH info not yet initialized
76 #define FLASH_ERR_HWR 0x08 // Hardware (configuration?) problem 76 #define FLASH_ERR_HWR 0x08 // Hardware (configuration?) problem
77 #define FLASH_ERR_ERASE_SUSPEND 0x09 // Device is in erase suspend mode 77 #define FLASH_ERR_ERASE_SUSPEND 0x09 // Device is in erase suspend mode
78 #define FLASH_ERR_PROGRAM_SUSPEND 0x0a // Device is in in program suspend mode 78 #define FLASH_ERR_PROGRAM_SUSPEND 0x0a // Device is in in program suspend mode
79 #define FLASH_ERR_DRV_VERIFY 0x0b // Driver failed to verify data 79 #define FLASH_ERR_DRV_VERIFY 0x0b // Driver failed to verify data
80 #define FLASH_ERR_DRV_TIMEOUT 0x0c // Driver timed out waiting for device
81 #define FLASH_ERR_DRV_WRONG_PART 0x0d // Driver does not support device
80 82
81 #ifdef _FLASH_PRIVATE_ 83 #ifdef _FLASH_PRIVATE_
82 84
83 struct flash_info { 85 struct flash_info {
84 void *work_space; 86 void *work_space;
88 unsigned long block_mask; 90 unsigned long block_mask;
89 void *start, *end; // Address range 91 void *start, *end; // Address range
90 int init; 92 int init;
91 }; 93 };
92 94
93 extern struct flash_info flash_info; 95 externC struct flash_info flash_info;
94 extern int flash_hwr_init(void); 96 externC int flash_hwr_init(void);
95 extern int flash_hwr_map_error(int err); 97 externC int flash_hwr_map_error(int err);
96 98
97 99
98 //--------------------------------------------------------------------------- 100 //---------------------------------------------------------------------------
99 //Execution of relocated code must be done inside a 101 // Execution of flash code must be done inside a
100 //HAL_FLASH_CACHES_OFF/HAL_FLASH_CACHES_ON region - disabling the 102 // HAL_FLASH_CACHES_OFF/HAL_FLASH_CACHES_ON region - disabling the
101 //cache on unified cache systems is necessary to prevent burst access 103 // cache on unified cache systems is necessary to prevent burst access
102 //to the flash area being programmed. With Harvard style caches, only 104 // to the flash area being programmed. With Harvard style caches, only
103 //the data cache needs to be disabled, but the instruction cache must 105 // the data cache needs to be disabled, but the instruction cache is
104 //still be invalidated to ensure the relocated code is properly 106 // disabled for consistency.
105 //fetched from memory.
106 107
107 // Targets may provide alternative implementations for these macros in 108 // Targets may provide alternative implementations for these macros in
108 // the hal_cache.h (or var/plf) files. 109 // the hal_cache.h (or var/plf) files.
109 110
110 // The first part below is the optimal implementation, but it does not 111 // The first part below is a generic, optimal implementation. The
111 // always work. The second part is a more safe implementation that has 112 // second part is the old implementation that has been tested to work
112 // been tested to work on some targets - it may not be suitable for 113 // on some targets - but it is not be suitable for targets that would
113 // targets that would do burst access to the flash (data cache needs 114 // do burst access to the flash (it does not disable the data cache).
114 // disabling as well).
115 115
116 // NOTE: Do _not_ change any of the below macros without checking that 116 // NOTE: Do _not_ change any of the below macros without checking that
117 // the changed code still works on _all_ platforms that rely on these 117 // the changed code still works on _all_ platforms that rely on these
118 // macros. There is no such thing as logical and correct when dealing 118 // macros. There is no such thing as logical and correct when dealing
119 // with different cache and IO models, so _do not_ mess with this code 119 // with different cache and IO models, so _do not_ mess with this code
120 // unless you test it properly afterwards. 120 // unless you test it properly afterwards.
121 121
122 #ifndef HAL_FLASH_CACHES_OFF 122 #ifndef HAL_FLASH_CACHES_OFF
123 123
124 #ifdef HAL_FLASH_CACHES_WANT_OPTIMAL // Optimal implementation 124 // Some drivers have only been tested with the old macros below.
125 #ifndef HAL_FLASH_CACHES_OLD_MACROS
125 126
126 #ifdef HAL_CACHE_UNIFIED 127 #ifdef HAL_CACHE_UNIFIED
127 128
128 // Note: the ucache code has not been tested yet on any target. 129 // Note: the ucache code has not been tested yet on any target.
129 #define HAL_FLASH_CACHES_OFF(_d_, _i_) \ 130 #define HAL_FLASH_CACHES_OFF(_d_, _i_) \
157 if (_d_) HAL_DCACHE_ENABLE(); \ 158 if (_d_) HAL_DCACHE_ENABLE(); \
158 CYG_MACRO_END 159 CYG_MACRO_END
159 160
160 #endif // HAL_CACHE_UNIFIED 161 #endif // HAL_CACHE_UNIFIED
161 162
162 #else // HAL_FLASH_CACHES_WANT_OPTIMAL 163 #else // HAL_FLASH_CACHES_OLD_MACROS
163 164
164 // Note: This implementation is broken as it will always enable the i-cache 165 // Note: This implementation is broken as it will always enable the i-cache
165 // even if it was not enabled before. It also doesn't work if the 166 // even if it was not enabled before. It also doesn't work if the
166 // target uses burst access to flash since the d-cache is left enabled. 167 // target uses burst access to flash since the d-cache is left enabled.
167 // However, this does not mean you can change this code! Leave it as 168 // However, this does not mean you can change this code! Leave it as
175 HAL_ICACHE_DISABLE(); 176 HAL_ICACHE_DISABLE();
176 177
177 #define HAL_FLASH_CACHES_ON(_d_, _i_) \ 178 #define HAL_FLASH_CACHES_ON(_d_, _i_) \
178 HAL_ICACHE_ENABLE(); 179 HAL_ICACHE_ENABLE();
179 180
180 #endif // HAL_FLASH_CACHES_WANT_OPTIMAL 181 #endif // HAL_FLASH_CACHES_OLD_MACROS
181 182
182 #endif // HAL_FLASH_CACHES_OFF 183 #endif // HAL_FLASH_CACHES_OFF
183 184
184 #endif // _FLASH_PRIVATE_ 185 #endif // _FLASH_PRIVATE_
185 186