comparison packages/io/flash/current/src/flash.c @ 1722:c4240af0fa28

* removed the functions cyg_flash_get_limits and cyg_flash_get_block_info. Reimplemented the legacy functions that depended on them and flashiodev.c
author asl
date Sat, 21 Aug 2004 13:47:55 +0000
parents 868c3fa9315f
children 0cc13d07a67e
comparison
equal deleted inserted replaced
1721:16115b7a4b8c 1722:c4240af0fa28
207 207
208 return ((((unsigned long)&_stext >= (unsigned long)start) && 208 return ((((unsigned long)&_stext >= (unsigned long)start) &&
209 ((unsigned long)&_stext < (unsigned long)end)) || 209 ((unsigned long)&_stext < (unsigned long)end)) ||
210 (((unsigned long)&_etext >= (unsigned long)start) && 210 (((unsigned long)&_etext >= (unsigned long)start) &&
211 ((unsigned long)&_etext < (unsigned long)end))); 211 ((unsigned long)&_etext < (unsigned long)end)));
212 }
213
214 // Get the start and end address of the first driver
215 __externC int
216 cyg_flash_get_limits(cyg_flashaddr_t *start, cyg_flashaddr_t *end)
217 {
218 if (!init) {
219 return CYG_FLASH_ERR_NOT_INIT;
220 }
221 if (flash_head) {
222 *start = flash_head->start;
223 *end = flash_head->end;
224 return CYG_FLASH_ERR_OK;
225 }
226 return CYG_FLASH_ERR_INVALID;
227 }
228
229 // Get the block size and number of blocks for the first driver. For
230 // devices with boot blocks, consolidate the boot blocks into the
231 // figure.
232 __externC int
233 cyg_flash_get_block_info(size_t *block_size, cyg_uint32 *blocks)
234 {
235 size_t biggest_size=0;
236 cyg_uint32 i;
237
238
239 if (!init) {
240 return CYG_FLASH_ERR_NOT_INIT;
241 }
242 if (!flash_head) return CYG_FLASH_ERR_INVALID;
243
244 // Find the biggest size of blocks
245 for (i=0; i < flash_head->num_block_infos; i++) {
246 if (flash_head->block_info[i].block_size > biggest_size) {
247 biggest_size = flash_head->block_info[i].block_size;
248 }
249 }
250
251 // Calculate the number of biggest size blocks
252 *block_size = biggest_size;
253 *blocks = 0;
254 for (i=0; i < flash_head->num_block_infos; i++) {
255 *blocks += (flash_head->block_info[i].block_size *
256 flash_head->block_info[i].blocks) /
257 biggest_size;
258 }
259 return CYG_FLASH_ERR_OK;
260 } 212 }
261 213
262 // Return information about the Nth driver 214 // Return information about the Nth driver
263 __externC int 215 __externC int
264 cyg_flash_get_info(cyg_uint32 Nth, cyg_flash_info_t * info) 216 cyg_flash_get_info(cyg_uint32 Nth, cyg_flash_info_t * info)