Tweaks to retirement handling
[yaffs2.git] / direct / yaffs_fileem2k.c
index dcb3e5fc7e85a73c1f6b28473f2987bb9a3e9723..59d0c8efa12e3d51b1faf283bb6cdb8dcbec6ca2 100644 (file)
@@ -15,7 +15,7 @@
 // This provides a YAFFS nand emulation on a file for emulating 2kB pages.
 // THis is only intended as test code to test persistence etc.
 
-const char *yaffs_flashif_c_version = "$Id: yaffs_fileem2k.c,v 1.6 2006-10-03 10:13:03 charles Exp $";
+const char *yaffs_flashif_c_version = "$Id: yaffs_fileem2k.c,v 1.7 2006-10-13 08:52:49 charles Exp $";
 
 
 #include "yportenv.h"
@@ -204,6 +204,9 @@ int yaffs_CheckAllFF(const __u8 *ptr, int n)
 }
 
 
+static int fail300 = 1;
+static int fail320 = 1;
+
 int yflash_ReadChunkWithTagsFromNAND(yaffs_Device *dev,int chunkInNAND, __u8 *data, yaffs_ExtendedTags *tags)
 {
        int nread;
@@ -249,6 +252,19 @@ int yflash_ReadChunkWithTagsFromNAND(yaffs_Device *dev,int chunkInNAND, __u8 *da
                        yaffs_PackedTags2 pt;
                        nread= read(h,&pt,sizeof(pt));
                        yaffs_UnpackTags2(tags,&pt);
+                       if((chunkInNAND >> 6) == 300) {
+                           if(fail300 && tags->eccResult == YAFFS_ECC_RESULT_NO_ERROR){
+                              tags->eccResult = YAFFS_ECC_RESULT_FIXED;
+                              fail300 = 0;
+                           }
+                           
+                       }
+                       if((chunkInNAND >> 6) == 320) {
+                           if(fail320 && tags->eccResult == YAFFS_ECC_RESULT_NO_ERROR){
+                              tags->eccResult = YAFFS_ECC_RESULT_FIXED;
+                              fail320 = 0;
+                           }
+                       }
                        if(nread != sizeof(pt)) return YAFFS_FAIL;
                }
        }
@@ -288,6 +304,9 @@ int yflash_EraseBlockInNAND(yaffs_Device *dev, int blockNumber)
                
        CheckInit();
        
+       if(blockNumber == 320)
+               fail320 = 1;
+       
        if(blockNumber < 0 || blockNumber >= filedisk.nBlocks)
        {
                T(YAFFS_TRACE_ALWAYS,("Attempt to erase non-existant block %d\n",blockNumber));