Mercurial > flash_v2
changeset 1744:f854ed1e81db
Fix reads on legacy devices
| author | bartv |
|---|---|
| date | Sun, 21 Nov 2004 12:09:40 +0000 |
| parents | 0d824ba900cc |
| children | 49e24a462730 |
| files | packages/io/flash/current/ChangeLog packages/io/flash/current/src/flash.c packages/io/flash/current/src/legacy_dev.c |
| diffstat | 3 files changed, 11 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/packages/io/flash/current/ChangeLog +++ b/packages/io/flash/current/ChangeLog @@ -1,5 +1,7 @@ 2004-11-21 Bart Veer <bartv@ecoscentric.com> + * src/legacy_dev.c (legacy_flash_read): only needed if the + underlying legacy driver required indirect reads. * src/flash.c: encapsulate various optional bits of code in macros, to cut down on the #ifdef's in the main code
--- a/packages/io/flash/current/src/flash.c +++ b/packages/io/flash/current/src/flash.c @@ -618,6 +618,9 @@ cyg_flash_read(cyg_flashaddr_t flash_bas #ifndef CYGHWR_IO_FLASH_INDIRECT_READS CYG_FAIL("read function supplied but indirect reads not enabled"); stat = CYG_FLASH_ERR_PROTOCOL; + if (err_address) { + *err_address = addr; + } #else // We have to indirect through the device driver. // The first read may be in the middle of a block. Do the necessary
--- a/packages/io/flash/current/src/legacy_dev.c +++ b/packages/io/flash/current/src/legacy_dev.c @@ -169,6 +169,7 @@ legacy_flash_program(struct cyg_flash_de return (*_flash_program_buf)(base, data, len, block_mask ,block_size); } +#ifdef CYGSEM_IO_FLASH_READ_INDIRECT static int legacy_flash_read (struct cyg_flash_dev *dev, const cyg_flashaddr_t base, @@ -180,7 +181,6 @@ legacy_flash_read (struct cyg_flash_dev const cyg_flashaddr_t base, void* data, const size_t len) { -#ifdef CYGSEM_IO_FLASH_READ_INDIRECT typedef int code_fun(const cyg_flashaddr_t, void *, int, unsigned long, int); code_fun *_flash_read_buf; size_t block_size = dev->block_info[0].block_size; @@ -189,11 +189,12 @@ legacy_flash_read (struct cyg_flash_dev _flash_read_buf = (code_fun*) __anonymizer(&flash_read_buf); return (*_flash_read_buf)(base, data, len, block_mask, block_size); +} + +# define LEGACY_FLASH_READ legacy_flash_read #else - memcpy(data,(void *)base, len); - return CYG_FLASH_ERR_OK; +# define LEGACY_FLASH_READ ((int (*)(struct cyg_flash_dev*, const cyg_flashaddr_t, void*, const size_t))0) #endif -} static int @@ -270,7 +271,7 @@ CYG_FLASH_FUNS(cyg_legacy_funs, legacy_flash_query, legacy_flash_erase_block, legacy_flash_program, - legacy_flash_read, + LEGACY_FLASH_READ, legacy_flash_hwr_map_error, legacy_flash_block_lock, legacy_flash_block_unlock
