comparison packages/io/flash/current/src/flash.c @ 136:a9ac27ec7abc ecos-sw-2000-11-17

Merge from eCos master repository on 2000-11-17-18:24:25-GMT
author jlarmour
date Fri, 17 Nov 2000 23:16:43 +0000
parents 6bd9d475ed4b
children 450e4e1f1e80
comparison
equal deleted inserted replaced
135:3bc2abeae9ff 136:a9ac27ec7abc
49 #include <cyg/hal/hal_cache.h> 49 #include <cyg/hal/hal_cache.h>
50 50
51 #define _FLASH_PRIVATE_ 51 #define _FLASH_PRIVATE_
52 #include <cyg/io/flash.h> 52 #include <cyg/io/flash.h>
53 53
54 // When this flag is set,
55 #undef RAM_FLASH_DEV_DEBUG
56 #if !defined(CYG_HAL_STARTUP_RAM) && defined(RAM_FLASH_DEV_DEBUG)
57 # warning "Can only enable the flash debugging when configured for RAM startup"
58 # undef RAM_FLASH_DEV_DEBUG
59 #endif
60
54 struct flash_info flash_info; 61 struct flash_info flash_info;
55 62
56 int 63 int
57 flash_init(void *work_space, int work_space_size) 64 flash_init(void *work_space, int work_space_size)
58 { 65 {
130 end_addr = (unsigned short *)((unsigned long)addr+len); 137 end_addr = (unsigned short *)((unsigned long)addr+len);
131 138
132 printf("... Erase from %p-%p: ", block, end_addr); 139 printf("... Erase from %p-%p: ", block, end_addr);
133 140
134 while (block < end_addr) { 141 while (block < end_addr) {
142 #ifdef RAM_FLASH_DEV_DEBUG
143 _flash_erase_block = &flash_erase_block;
144 #endif
135 stat = (*_flash_erase_block)(block); 145 stat = (*_flash_erase_block)(block);
136 stat = flash_hwr_map_error(stat); 146 stat = flash_hwr_map_error(stat);
137 if (stat) { 147 if (stat) {
138 *err_addr = (void *)block; 148 *err_addr = (void *)block;
139 break; 149 break;
171 printf("... Program from %p-%p at %p: ", data, ((unsigned long)data)+len, addr); 181 printf("... Program from %p-%p at %p: ", data, ((unsigned long)data)+len, addr);
172 182
173 while (len > 0) { 183 while (len > 0) {
174 size = len; 184 size = len;
175 if (size > flash_info.block_size) size = flash_info.block_size; 185 if (size > flash_info.block_size) size = flash_info.block_size;
186 #ifdef RAM_FLASH_DEV_DEBUG
187 _flash_program_buf = &flash_program_buf;
188 #endif
176 stat = (*_flash_program_buf)(addr, data, size); 189 stat = (*_flash_program_buf)(addr, data, size);
177 stat = flash_hwr_map_error(stat); 190 stat = flash_hwr_map_error(stat);
178 if (stat) { 191 if (stat) {
179 *err_addr = (void *)addr; 192 *err_addr = (void *)addr;
180 break; 193 break;
216 end_addr = (unsigned short *)((unsigned long)addr+len); 229 end_addr = (unsigned short *)((unsigned long)addr+len);
217 230
218 printf("... Lock from %p-%p: ", block, end_addr); 231 printf("... Lock from %p-%p: ", block, end_addr);
219 232
220 while (block < end_addr) { 233 while (block < end_addr) {
234 #ifdef RAM_FLASH_DEV_DEBUG
235 _flash_lock_block = &flash_lock_block;
236 #endif
221 stat = (*_flash_lock_block)(block); 237 stat = (*_flash_lock_block)(block);
222 stat = flash_hwr_map_error(stat); 238 stat = flash_hwr_map_error(stat);
223 if (stat) { 239 if (stat) {
224 *err_addr = (void *)block; 240 *err_addr = (void *)block;
225 break; 241 break;
257 end_addr = (unsigned short *)((unsigned long)addr+len); 273 end_addr = (unsigned short *)((unsigned long)addr+len);
258 274
259 printf("... Unlock from %p-%p: ", block, end_addr); 275 printf("... Unlock from %p-%p: ", block, end_addr);
260 276
261 while (block < end_addr) { 277 while (block < end_addr) {
278 #ifdef RAM_FLASH_DEV_DEBUG
279 _flash_unlock_block = &flash_unlock_block;
280 #endif
262 stat = (*_flash_unlock_block)(block, flash_info.block_size, flash_info.blocks); 281 stat = (*_flash_unlock_block)(block, flash_info.block_size, flash_info.blocks);
263 stat = flash_hwr_map_error(stat); 282 stat = flash_hwr_map_error(stat);
264 if (stat) { 283 if (stat) {
265 *err_addr = (void *)block; 284 *err_addr = (void *)block;
266 break; 285 break;
278 flash_errmsg(int err) 297 flash_errmsg(int err)
279 { 298 {
280 switch (err) { 299 switch (err) {
281 case FLASH_ERR_OK: 300 case FLASH_ERR_OK:
282 return "No error - operation complete"; 301 return "No error - operation complete";
302 case FLASH_ERR_ERASE_SUSPEND:
303 return "Device is in erase suspend state";
304 case FLASH_ERR_PROGRAM_SUSPEND:
305 return "Device is in program suspend state";
283 case FLASH_ERR_INVALID: 306 case FLASH_ERR_INVALID:
284 return "Invalid FLASH address"; 307 return "Invalid FLASH address";
285 case FLASH_ERR_ERASE: 308 case FLASH_ERR_ERASE:
286 return "Error trying to erase"; 309 return "Error trying to erase";
287 case FLASH_ERR_LOCK: 310 case FLASH_ERR_LOCK: