Fix chunk start problem properly
[yaffs2.git] / direct / ynorsim.c
index 3281a2f374c3b78f05ec82572d974d4f2956e246..f18eac03c3c9f524ea4ce573b3c793f64b9a824d 100644 (file)
@@ -19,7 +19,7 @@
  */
    
 //#define YNORSIM_BIT_CHANGES 15
-#define YNORSIM_BIT_CHANGES 1
+#define YNORSIM_BIT_CHANGES 2
 
 #if 0
 /* Simulate 32MB of flash in 256k byte blocks.
@@ -39,6 +39,8 @@
 
 static __u32 word[YNORSIM_DEV_SIZE_U32];
 
+extern int random_seed;
+extern int simulate_power_failure;
 
 static void NorError(void)
 {
@@ -79,7 +81,8 @@ static void ynorsim_MaybePowerFail(void)
    
    
    remaining_ops--;
-   if(remaining_ops < 1){
+   if(simulate_power_failure &&
+      remaining_ops < 1){
        printf("Simulated power failure after %d operations\n",nops_so_far);
        ynorsim_PowerFail();
   }
@@ -89,9 +92,9 @@ static void ynorsim_Ready(void)
 {
   if(initialised) 
     return;
-  srand(time(NULL));
+  srand(random_seed);
   remaining_ops = 1000000000;
-  remaining_ops = (rand() % 10000) * 3000 * YNORSIM_BIT_CHANGES;
+  remaining_ops = (rand() % 10000) * 4000 * YNORSIM_BIT_CHANGES;
   ynorsim_RestoreImage();
 }