This is the mail archive of the ecos-patches@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

V2 flash - fix reads on legacy devices


One of my previous patches broke cyg_flash_read() on legacy devices.
This sorts out the problem, and saves a small amount of code in the
process.

Bart

Index: ChangeLog
===================================================================
RCS file: /cvs/ecos/ecos/packages/io/flash/current/ChangeLog,v
retrieving revision 1.38.2.13
diff -u -r1.38.2.13 ChangeLog
--- ChangeLog	21 Nov 2004 11:20:19 -0000	1.38.2.13
+++ ChangeLog	21 Nov 2004 12:07:38 -0000
@@ -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
Index: src/flash.c
===================================================================
RCS file: /cvs/ecos/ecos/packages/io/flash/current/src/flash.c,v
retrieving revision 1.26.2.9
diff -u -r1.26.2.9 flash.c
--- src/flash.c	21 Nov 2004 11:20:18 -0000	1.26.2.9
+++ src/flash.c	21 Nov 2004 12:08:01 -0000
@@ -618,6 +618,9 @@
 #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
Index: src/legacy_dev.c
===================================================================
RCS file: /cvs/ecos/ecos/packages/io/flash/current/src/Attic/legacy_dev.c,v
retrieving revision 1.1.2.4
diff -u -r1.1.2.4 legacy_dev.c
--- src/legacy_dev.c	6 Oct 2004 10:59:04 -0000	1.1.2.4
+++ src/legacy_dev.c	21 Nov 2004 12:08:25 -0000
@@ -169,6 +169,7 @@
   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 @@
                    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 @@
   _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 @@
                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
 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]