changeset 1726:d2486ee206e4

* include/flash_strata_v2.inl: Return the end address which is the last valid address, not the first invalid address. Also import Mark Salters changes from the trunk.
author asl
date Tue, 14 Sep 2004 16:02:54 +0000
parents e0ebd07e25f3
children 41dd4286cbbd
files packages/devs/flash/intel/stratav2/current/ChangeLog packages/devs/flash/intel/stratav2/current/include/flash_strata_v2.inl
diffstat 2 files changed, 21 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/packages/devs/flash/intel/stratav2/current/ChangeLog
+++ b/packages/devs/flash/intel/stratav2/current/ChangeLog
@@ -1,3 +1,9 @@
+2004-09-14  Andrew Lunn  <andrew.lunn@ascom.ch>
+
+	* include/flash_strata_v2.inl: Return the end address which is the
+	last valid address, not the first invalid address.
+	Also import Mark Salters changes from the trunk.
+	
 2004-08-21  Andrew Lunn  <andrew.lunn@ascom.ch>
 	
 	* include/flash_strata_v2.inl (flash_unlock_block): 
--- a/packages/devs/flash/intel/stratav2/current/include/flash_strata_v2.inl
+++ b/packages/devs/flash/intel/stratav2/current/include/flash_strata_v2.inl
@@ -70,6 +70,17 @@ extern void diag_dump_buf(void *buf, CYG
 extern int strncmp(const char *s1, const char *s2, size_t len);
 extern void *memcpy( void *, const void *, size_t );
 
+// Platforms may define these for special handling when accessing the
+// query data or write buffer .
+#ifndef CYGHWR_FLASH_READ_QUERY 
+#define CYGHWR_FLASH_READ_QUERY(a) (*(a)) 
+#endif
+#ifndef CYGHWR_FLASH_WRITE_BUF
+#define CYGHWR_FLASH_WRITE_BUF(a,b) (*(a) = *(b))
+#endif
+
+
+
 //----------------------------------------------------------------------------
 // Functions that put the flash device into non-read mode must reside
 // in RAM.
@@ -158,7 +169,7 @@ strata_init (struct cyg_flash_dev *dev)
 #endif // Not CYGOPT_FLASH_IS_BOOTBLOCK
         
         dev->end = dev->start +
-          (num_regions*region_size*CYGNUM_FLASH_INTERLEAVE);
+          (num_regions*region_size*CYGNUM_FLASH_INTERLEAVE) -1;
         priv->buffer_size = buffer_size;
         priv->block_info[0].blocks = num_regions;
         priv->block_info[0].block_size = region_size * CYGNUM_FLASH_INTERLEAVE;
@@ -241,10 +252,10 @@ strata_query_hwr (struct cyg_flash_dev *
 #endif // Not CYGOPT_FLASH_IS_BOOTBLOCK
 
     for (cnt = CNT;  cnt > 0;  cnt--) ;
-    for ( /* i */;  i > 0;  i-- ) {
+    for ( /* i */;  i > 0;  i--, ++ROM ) {
         // It is very deliberate that data is chars NOT flash_t:
         // The info comes out in bytes regardless of device.
-        *data++ = (unsigned char) (*ROM++);
+        *data++ = (unsigned char) CYGHWR_FLASH_READ_QUERY(ROM);
 #ifndef CYGOPT_FLASH_IS_BOOTBLOCK
 # if  8 == CYGNUM_FLASH_WIDTH
 	// strata flash with 'byte-enable' contains the configuration data
@@ -366,7 +377,7 @@ strata_program_buf (struct cyg_flash_dev
 #ifdef CYGHWR_FLASH_WRITE_ELEM
             CYGHWR_FLASH_WRITE_ELEM(addr+i, data+i);
 #else
-            *(addr+i) = *(data+i);
+            CYGHWR_FLASH_WRITE_BUF(addr+i, data+i);
 #endif
         }
         *BA = FLASH_Confirm;