This is the mail archive of the ecos-discuss@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]

Re: Reworking eCos flash interfaces...


Hi,

> flash2_redboot_2003_07_15.patch

Ian missed a few bits out which break the fis free command.  Find patch
attached.

2003-07-15 David Vrabel <dvrabel@arcom.com>

	* src/flash.c (fis_free): Only check the start of blocks.
	Previously, each block was divided into 4 which meant it
	erroneously found partially free blocks.
	(fis_find_free): Likewise.  And use cyg_flash_read(..) to read
	flash device.

David Vrabel
--
David Vrabel, Design Engineer

Arcom                         Tel: +44 (0)1223 411200 ext. 3233
Clifton Road                  Fax: +44 (0)1223 403400
Cambridge CB1 7EA             E-mail: dvrabel@arcom.com
UK                            Web: http://www.arcom.com/


________________________________________________________________________ This email has been scanned for all viruses by the MessageLabs Email Security System. For more information on a proactive email security service working around the clock, around the globe, visit http://www.messagelabs.com ________________________________________________________________________
Index: packages/redboot/current/src/flash.c
===================================================================
RCS file: /var/cvs/ecos/packages/redboot/current/src/flash.c,v
retrieving revision 1.5
retrieving revision 1.4
diff -u -B -p -r1.5 -r1.4
--- packages/redboot/current/src/flash.c	15 Jul 2003 13:10:46 -0000	1.5
+++ packages/redboot/current/src/flash.c	19 Jun 2003 15:17:28 -0000	1.4
@@ -527,11 +527,11 @@ fis_free(int argc, char *argv[])
                 if (temp == (unsigned long)0xFFFFFFFF) {
                     break;
                 }
-                area_start += flash_block_size;
+                area_start += flash_block_size / sizeof(CYG_ADDRESS);
             }
             fis_ptr = area_start;
         } else {
-            fis_ptr += flash_block_size;
+            fis_ptr += flash_block_size / sizeof(CYG_ADDRESS);
         }
     }
     if (area_start != fis_ptr) {
@@ -544,17 +544,15 @@ fis_free(int argc, char *argv[])
 static bool
 fis_find_free(CYG_ADDRESS *addr, unsigned long length)
 {
-    unsigned long fis_ptr, fis_end;
-    unsigned long area_start;
-    unsigned long temp;
+    unsigned long *fis_ptr, *fis_end;
+    unsigned long *area_start;
 
     // Do not search the area reserved for pre-RedBoot systems:
-    fis_ptr = CYGNUM_REDBOOT_FLASH_RESERVED_BASE;
-    fis_end = flash_size;
+    fis_ptr = (unsigned long *)(CYGNUM_REDBOOT_FLASH_RESERVED_BASE);
+    fis_end = (unsigned long *)(CYG_ADDRESS)flash_size;
     area_start = fis_ptr;
     while (fis_ptr < fis_end) {
-        cyg_flash_read(flash_info, (CYG_ADDRESS)&temp, fis_ptr, sizeof(unsigned long), NULL);
-        if (temp != (unsigned long)0xFFFFFFFF) {
+        if (*fis_ptr != (unsigned long)0xFFFFFFFF) {
             if (area_start != fis_ptr) {
                 // Assume that this is something
                 if ((fis_ptr-area_start) >= (length/sizeof(unsigned))) {
@@ -565,15 +563,14 @@ fis_find_free(CYG_ADDRESS *addr, unsigne
             // Find next blank block
             area_start = fis_ptr;
             while (area_start < fis_end) {
-                cyg_flash_read(flash_info, (CYG_ADDRESS)&temp, area_start, sizeof(unsigned long), NULL);
-                if (temp == (unsigned long)0xFFFFFFFF) {
+                if (*area_start == (unsigned long)0xFFFFFFFF) {
                     break;
                 }
-                area_start += flash_block_size;
+                area_start += flash_block_size / sizeof(CYG_ADDRESS);
             }
             fis_ptr = area_start;
         } else {
-            fis_ptr += flash_block_size;
+            fis_ptr += flash_block_size / sizeof(CYG_ADDRESS);
         }
     }
     if (area_start != fis_ptr) {


-- 
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss

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