# HG changeset patch # User asl # Date 1093096075 0 # Node ID c4240af0fa288ecd1f3cd6cee9c16b3fb0d799b5 # Parent 16115b7a4b8cbb5d94195d6d95d7631bfc5421ab * removed the functions cyg_flash_get_limits and cyg_flash_get_block_info. Reimplemented the legacy functions that depended on them and flashiodev.c diff --git a/packages/io/flash/current/ChangeLog b/packages/io/flash/current/ChangeLog --- a/packages/io/flash/current/ChangeLog +++ b/packages/io/flash/current/ChangeLog @@ -1,3 +1,9 @@ +2004-08-21 Andrew Lunn + + * removed the functions cyg_flash_get_limits and + cyg_flash_get_block_info. Reimplemented the legacy functions + that depended on them and flashiodev.c + 2004-08-19 Andrew Lunn * src/flashiodev.c Ordering problem again. If an invalid name is diff --git a/packages/io/flash/current/doc/flash.sgml b/packages/io/flash/current/doc/flash.sgml --- a/packages/io/flash/current/doc/flash.sgml +++ b/packages/io/flash/current/doc/flash.sgml @@ -146,8 +146,6 @@ The following five functions return info __externC int cyg_flash_get_info_addr(cyg_flashaddr_t flash_base, cyg_flash_info_t * info); __externC int cyg_flash_verify_addr(const flashaddr_t address); __externC int cyg_flash_code_overlaps(const flashaddr_t start, const flashaddr_t end); -__externC int cyg_flash_get_block_info(size_t *block_size, cyg_uint32 *blocks); -__externC int cyg_flash_get_limits(flashaddr_t *start, flashaddr_t *end); __extern size_t cyg_flash_block_size(const cyg_flashaddr_t flash_base); typedef struct cyg_block_info @@ -184,16 +182,6 @@ inside the address refion given. Erase a this range are very likely to cause the target to crash and burn horribly. Note the FLASH library does allow you to shoot yourself in the foot in this way. - -To aid with backwards compatibility the following functions have -been retained from the V1 API. However the only operate on the first -FLASH driver. The function cyg_flash_get_block_info() - returns the size and number of blocks for the first -driver. When the device has a mixture of block sizes, the size of the -"normal" block will be returned. Please read the source code to -determine exactly what this means. cyg_flash_get_limits() - returns the lower and upper memory address the first FLASH -occupies. diff --git a/packages/io/flash/current/include/flash.h b/packages/io/flash/current/include/flash.h --- a/packages/io/flash/current/include/flash.h +++ b/packages/io/flash/current/include/flash.h @@ -88,10 +88,6 @@ typedef int cyg_flash_printf(const char __externC int cyg_flash_verify_addr(const cyg_flashaddr_t address); __externC bool cyg_flash_code_overlaps(const cyg_flashaddr_t start, const cyg_flashaddr_t end); -__externC int cyg_flash_get_block_info(size_t *block_size, - cyg_uint32 *blocks); -__externC int cyg_flash_get_limits(cyg_flashaddr_t *start, - cyg_flashaddr_t *end); __externC size_t cyg_flash_block_size(const cyg_flashaddr_t flash_base); __externC int cyg_flash_read(cyg_flashaddr_t flash_base, const void *ram_base, diff --git a/packages/io/flash/current/src/flash.c b/packages/io/flash/current/src/flash.c --- a/packages/io/flash/current/src/flash.c +++ b/packages/io/flash/current/src/flash.c @@ -211,54 +211,6 @@ cyg_flash_verify_addr(const cyg_flashadd ((unsigned long)&_etext < (unsigned long)end))); } -// Get the start and end address of the first driver -__externC int -cyg_flash_get_limits(cyg_flashaddr_t *start, cyg_flashaddr_t *end) -{ - if (!init) { - return CYG_FLASH_ERR_NOT_INIT; - } - if (flash_head) { - *start = flash_head->start; - *end = flash_head->end; - return CYG_FLASH_ERR_OK; - } - return CYG_FLASH_ERR_INVALID; -} - -// Get the block size and number of blocks for the first driver. For -// devices with boot blocks, consolidate the boot blocks into the -// figure. -__externC int -cyg_flash_get_block_info(size_t *block_size, cyg_uint32 *blocks) -{ - size_t biggest_size=0; - cyg_uint32 i; - - - if (!init) { - return CYG_FLASH_ERR_NOT_INIT; - } - if (!flash_head) return CYG_FLASH_ERR_INVALID; - - // Find the biggest size of blocks - for (i=0; i < flash_head->num_block_infos; i++) { - if (flash_head->block_info[i].block_size > biggest_size) { - biggest_size = flash_head->block_info[i].block_size; - } - } - - // Calculate the number of biggest size blocks - *block_size = biggest_size; - *blocks = 0; - for (i=0; i < flash_head->num_block_infos; i++) { - *blocks += (flash_head->block_info[i].block_size * - flash_head->block_info[i].blocks) / - biggest_size; - } - return CYG_FLASH_ERR_OK; -} - // Return information about the Nth driver __externC int cyg_flash_get_info(cyg_uint32 Nth, cyg_flash_info_t * info) diff --git a/packages/io/flash/current/src/flashiodev.c b/packages/io/flash/current/src/flashiodev.c --- a/packages/io/flash/current/src/flashiodev.c +++ b/packages/io/flash/current/src/flashiodev.c @@ -122,9 +122,10 @@ flashiodev_lookup(struct cyg_devtab_entr if (dev->use_offset) { // dev->start the contain the offset to the beginning of the block // dev->end is the length of the block - cyg_flashaddr_t start, end; - cyg_flash_get_limits(&start, &end); - dev->start = dev->start + start; + cyg_flash_info_t info; + + cyg_flash_get_info(0, &info); + dev->start = dev->start + info.start; dev->end = dev->start + dev->end; } if (dev->use_absolute) { diff --git a/packages/io/flash/current/src/legacy_api.c b/packages/io/flash/current/src/legacy_api.c --- a/packages/io/flash/current/src/legacy_api.c +++ b/packages/io/flash/current/src/legacy_api.c @@ -71,14 +71,50 @@ flash_verify_addr(void *target) int flash_get_limits(void *target, void **start, void **end) { - return cyg_flash_get_limits((cyg_flashaddr_t *)start, - (cyg_flashaddr_t *)end); + int err; + cyg_flash_info_t info; + + err = cyg_flash_get_info(0, &info); + if (err != CYG_FLASH_ERR_OK) { + return err; + } + + *start = (void *)info.start; + *end = (void *)info.end; + + return CYG_FLASH_ERR_OK; } + int flash_get_block_info(int *block_size, int *blocks) { - return cyg_flash_get_block_info((size_t *)block_size, blocks); + size_t biggest_size=0; + cyg_uint32 i; + cyg_flash_info_t info; + int err; + + err = cyg_flash_get_info(0, &info); + if (err != CYG_FLASH_ERR_OK) { + return err; + } + + // Find the biggest size of blocks + for (i=0; i < info.num_block_infos; i++) { + if (info.block_info[i].block_size > biggest_size) { + biggest_size = info.block_info[i].block_size; + } + } + + // Calculate the number of biggest size blocks + *block_size = biggest_size; + *blocks = 0; + for (i=0; i < info.num_block_infos; i++) { + *blocks += (info.block_info[i].block_size * + info.block_info[i].blocks) / + biggest_size; + } + return CYG_FLASH_ERR_OK; } int