changeset 1893:8c59bace329e

* src/flash_query.c (flash_query): Fix switching the flash back to array mode, which was broken on MIPS platforms. Always write control codes to offset 0.
author asl
date Tue, 08 Feb 2005 20:14:40 +0000
parents 59626c067d41
children 2f0788800945
files packages/devs/flash/intel/strata/current/ChangeLog packages/devs/flash/intel/strata/current/src/flash_query.c
diffstat 2 files changed, 15 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/packages/devs/flash/intel/strata/current/ChangeLog
+++ b/packages/devs/flash/intel/strata/current/ChangeLog
@@ -1,3 +1,9 @@
+2005-01-14  Thomas Koeller  <thomas.koeller@baslerweb.com>
+
+	* src/flash_query.c (flash_query): Fix switching the flash back to
+	array mode, which was broken on MIPS platforms. Always write
+	control codes to offset 0.
+
 2004-09-02  Mark Salter  <msalter@redhat.com>
 
 	* src/flash_query.c (CYGHWR_FLASH_READ_QUERY): Add platform hook
--- a/packages/devs/flash/intel/strata/current/src/flash_query.c
+++ b/packages/devs/flash/intel/strata/current/src/flash_query.c
@@ -68,7 +68,7 @@ flash_query(unsigned char *data)  __attr
 int
 flash_query(unsigned char *data)
 {
-    volatile flash_t *ROM;
+    volatile flash_t *ROM, *p, dummy;
     int i, cnt;
 
     // Get base address and map addresses to virtual addresses
@@ -85,19 +85,24 @@ flash_query(unsigned char *data)
 #endif // Not CYGOPT_FLASH_IS_BOOTBLOCK
 
     for (cnt = CNT;  cnt > 0;  cnt--) ;
-    for ( /* i */;  i > 0;  i--, ++ROM) {
+    p = ROM;
+    while ( i--) {
         // It is very deliberate that data is chars NOT flash_t:
         // The info comes out in bytes regardless of device.
-        *data++ = (unsigned char) CYGHWR_FLASH_READ_QUERY(ROM);
+        *data++ = (unsigned char) CYGHWR_FLASH_READ_QUERY(p++);
 #ifndef CYGOPT_FLASH_IS_BOOTBLOCK
 # if  8 == CYGNUM_FLASH_WIDTH
 	// strata flash with 'byte-enable' contains the configuration data
 	// at even addresses
-	++ROM;
+        ++p;
 # endif
 #endif
     }
+    // Reset the flash to array mode. The dummy read is required on MIPS
+    // platforms (don't know about others) to force the write out. Should
+    // there be direct HAL support for this kind of operation?
     ROM[0] = FLASH_Reset;
+    dummy = ROM[0];
 
     return 0;
 }