yaffs direct: Modify lseek value checking
[yaffs2.git] / direct / basic-test / ynorsim.c
index 0c691a6a58c4418ee377ed4e8d76f16dbce535a0..39651011f175638eb35e768015b92537ade6530b 100644 (file)
@@ -1,4 +1,15 @@
-
+/*
+ * YAFFS: Yet Another Flash File System. A NAND-flash specific file system.
+ *
+ * Copyright (C) 2002-2010 Aleph One Ltd.
+ *   for Toby Churchill Ltd and Brightstar Engineering
+ *
+ * Created by Charles Manning <charles@aleph1.co.uk>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
 
 #include "ynorsim.h"
 
@@ -37,7 +48,7 @@
 #define YNORSIM_DEV_SIZE_U32   (8*1024 * 1024/4)
 #endif
 
-static __u32 word[YNORSIM_DEV_SIZE_U32];
+static u32 word[YNORSIM_DEV_SIZE_U32];
 
 extern int random_seed;
 extern int simulate_power_failure;
@@ -48,14 +59,14 @@ static void NorError(void)
   while(1){}
 }
 
-static void ynorsim_SaveImage(void)
+static void ynorsim_save_image(void)
 {
   int h = open(YNORSIM_FNAME, O_RDWR | O_CREAT | O_TRUNC, S_IREAD | S_IWRITE);
   write(h,word,sizeof(word));
   close(h);
 }
 
-static void ynorsim_RestoreImage(void)
+static void ynorsim_restore_image(void)
 {
   int h = open(YNORSIM_FNAME, O_RDONLY, S_IREAD | S_IWRITE);
   memset(word,0xFF,sizeof(word));
@@ -64,9 +75,9 @@ static void ynorsim_RestoreImage(void)
 }
 
 
-static void ynorsim_PowerFail(void)
+static void ynorsim_power_fail(void)
 {
-  ynorsim_SaveImage();
+  ynorsim_save_image();
   exit(1);
 }
 
@@ -76,7 +87,7 @@ static int nops_so_far;
 
 int ops_multiplier = 500;
 
-static void ynorsim_MaybePowerFail(void)
+static void ynorsim_maybe_power_fail(void)
 {
 
    nops_so_far++;
@@ -86,21 +97,21 @@ static void ynorsim_MaybePowerFail(void)
    if(simulate_power_failure &&
       remaining_ops < 1){
        printf("Simulated power failure after %d operations\n",nops_so_far);
-       ynorsim_PowerFail();
+       ynorsim_power_fail();
   }
 }
 
-static void ynorsim_Ready(void)
+static void ynorsim_ready(void)
 {
   if(initialised) 
     return;
   srand(random_seed);
   remaining_ops = 1000000000;
   remaining_ops = (rand() % 10000) * ops_multiplier * YNORSIM_BIT_CHANGES;
-  ynorsim_RestoreImage();
+  ynorsim_restore_image();
 }
 
-void ynorsim_Read32(__u32 *addr,__u32 *buf, int nwords)
+void ynorsim_rd32(u32 *addr,u32 *buf, int nwords)
 { 
    while(nwords > 0){
      *buf = *addr;
@@ -110,10 +121,10 @@ void ynorsim_Read32(__u32 *addr,__u32 *buf, int nwords)
    }
 }
 
-void ynorsim_WriteOneWord32(__u32 *addr,__u32 val)
+void ynorsim_wr_one_word32(u32 *addr,u32 val)
 {
-  __u32 tmp;
-  __u32 m;
+  u32 tmp;
+  u32 m;
   int i;
 
   tmp = *addr;
@@ -128,43 +139,43 @@ void ynorsim_WriteOneWord32(__u32 *addr,__u32 val)
     if(!(m & val)){
       tmp &= ~m;
       *addr = tmp;
-      ynorsim_MaybePowerFail();
+      ynorsim_maybe_power_fail();
     }
        
   }
   
   *addr = tmp & val;
-  ynorsim_MaybePowerFail();
+  ynorsim_maybe_power_fail();
 }
 
-void ynorsim_Write32(__u32 *addr, __u32 *buf, int nwords)
+void ynorsim_wr32(u32 *addr, u32 *buf, int nwords)
 {
   while(nwords >0){
-    ynorsim_WriteOneWord32(addr,*buf);
+    ynorsim_wr_one_word32(addr,*buf);
     addr++;
     buf++;
     nwords--;
   }
 }
 
-void ynorsim_EraseBlock(__u32 *addr)
+void ynorsim_erase(u32 *addr)
 {
   /* Todo... bit flipping */
   memset(addr,0xFF,YNORSIM_BLOCK_SIZE_U32 * 4);
 }
 
-void ynorsim_Initialise(void)
+void ynorsim_initialise(void)
 {
-  ynorsim_Ready();
+  ynorsim_ready();
 }
 
-void ynorsim_Shutdown(void)
+void ynorsim_shutdown(void)
 {
-  ynorsim_SaveImage();
+  ynorsim_save_image();
   initialised=0;
 }
 
-__u32 *ynorsim_GetBase(void)
+u32 *ynorsim_get_base(void)
 {
   return word;
 }