# HG changeset patch # User bartv # Date 1101038980 0 # Node ID f854ed1e81db5f6c531f4b1f895d4f8f4b75db39 # Parent 0d824ba900cc600859c27b7fcf51c5676c78f934 Fix reads on legacy devices 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,5 +1,7 @@ 2004-11-21 Bart Veer + * 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 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 @@ -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 diff --git a/packages/io/flash/current/src/legacy_dev.c b/packages/io/flash/current/src/legacy_dev.c --- 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