*** empty log message ***
authorcharles <charles>
Mon, 22 Nov 2004 03:22:25 +0000 (03:22 +0000)
committercharles <charles>
Mon, 22 Nov 2004 03:22:25 +0000 (03:22 +0000)
13 files changed:
direct/Makefile
direct/dtest.c
direct/yaffs_fileem2k.c
direct/yaffs_ramdisk.c
direct/yaffscfg2k.c
direct/yaffsfs.c
yaffs_guts.c
yaffs_packedtags.h [deleted file]
yaffs_packedtags1.c [moved from yaffs_packedtags.c with 78% similarity]
yaffs_packedtags1.h [new file with mode: 0644]
yaffs_packedtags2.c [new file with mode: 0644]
yaffs_packedtags2.h [new file with mode: 0644]
yportenv.h

index cb83a5f..2d5eed1 100644 (file)
 #
 # NB Warning this Makefile does not include header dependencies.
 #
-# $Id: Makefile,v 1.4 2004-11-16 02:36:15 charles Exp $
+# $Id: Makefile,v 1.5 2004-11-22 03:22:25 charles Exp $
 
 CFLAGS =    -Wall -DCONFIG_YAFFS_DIRECT -DCONFIG_YAFFS_SHORT_NAMES_IN_RAM -DCONFIG_YAFFS_YAFFS2 -g
 #CFLAGS+=   -Wshadow -Wpointer-arith -Wwrite-strings -Wstrict-prototypes -Wmissing-declarations
 #CFLAGS+=   -Wmissing-prototypes -Wredundant-decls -Wnested-externs -Winline
 
 
-DIRECTTESTOBJS = dtest.o yaffscfg2k.o yaffs_ecc.o yaffs_fileem2k.o yaffsfs.o yaffs_guts.o yaffs_packedtags.o yaffs_ramdisk.o yaffs_tagscompat.o
+DIRECTTESTOBJS = dtest.o yaffscfg2k.o yaffs_ecc.o yaffs_fileem2k.o yaffsfs.o yaffs_guts.o yaffs_packedtags1.o yaffs_ramdisk.o yaffs_tagscompat.o yaffs_packedtags2.o
 
 BOOTTESTOBJS = bootldtst.o yboot.o yaffs_fileem.o nand_ecc.o
 
-ALLOBJS =  dtest.o nand_ecc.o yaffscfg.o yaffs_fileem.o yaffsfs.o yaffs_ramdisk.o bootldtst.o yboot.o 
+ALLOBJS =  dtest.o nand_ecc.o yaffscfg.o yaffs_fileem.o yaffsfs.o yaffs_ramdisk.o bootldtst.o yboot.o yaffs_ramem2k.o
 
-SYMLINKS = devextras.h yaffs_ecc.c yaffs_ecc.h yaffs_guts.c yaffs_guts.h yaffsinterface.h yportenv.h yaffs_tagscompat.c yaffs_tagscompat.h yaffs_packedtags.c yaffs_packedtags.h
+SYMLINKS = devextras.h yaffs_ecc.c yaffs_ecc.h yaffs_guts.c yaffs_guts.h yaffsinterface.h yportenv.h yaffs_tagscompat.c yaffs_tagscompat.h \
+          yaffs_packedtags1.c yaffs_packedtags1.h yaffs_packedtags2.c yaffs_packedtags2.h yaffs_ramem2k.c yaffs_nandemul2k.h
 
 #all: directtest2k boottest
 
index 90814f7..53d1e80 100644 (file)
@@ -1318,12 +1318,12 @@ int main(int argc, char *argv[])
        
 
        
-       scan_pattern_test("/boot",40000,10);
+       scan_pattern_test("/ram2k",40000,10);
        //short_scan_test("/flash",40000,200);
        return 0;
        
-       long_test_on_path("/flash");
-       long_test_on_path("/flash");
+       long_test_on_path("/ram2k");
+       long_test_on_path("/ram2k");
        
        // cache_bypass_bug_test();
        
index 069cb19..0a9b9e3 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.1 2004-11-03 08:29:28 charles Exp $";
+const char *yaffs_flashif_c_version = "$Id: yaffs_fileem2k.c,v 1.2 2004-11-22 03:22:25 charles Exp $";
 
 
 #include "yportenv.h"
@@ -30,7 +30,7 @@ const char *yaffs_flashif_c_version = "$Id: yaffs_fileem2k.c,v 1.1 2004-11-03 08
 #include <unistd.h> 
 
 #include "yaffs_fileem2k.h"
-#include "yaffs_packedtags.h"
+#include "yaffs_packedtags2.h"
 
 
 
@@ -141,8 +141,8 @@ int yflash_WriteChunkWithTagsToNAND(yaffs_Device *dev,int chunkInNAND,const __u8
                }
                else
                {
-                       yaffs_PackedTags pt;
-                       yaffs_PackTags(&pt,tags);
+                       yaffs_PackedTags2 pt;
+                       yaffs_PackTags2(&pt,tags);
 
                        written = write(filedisk.handle,&pt,sizeof(pt));
                        if(written != sizeof(pt)) return YAFFS_FAIL;
@@ -158,7 +158,7 @@ int yflash_MarkNANDBlockBad(struct yaffs_DeviceStruct *dev, int blockNo)
 {
        int written;
        
-       yaffs_PackedTags pt;
+       yaffs_PackedTags2 pt;
 
        CheckInit(dev);
        
@@ -222,9 +222,9 @@ int yflash_ReadChunkWithTagsFromNAND(yaffs_Device *dev,int chunkInNAND, __u8 *da
                }
                else
                {
-                       yaffs_PackedTags pt;
+                       yaffs_PackedTags2 pt;
                        nread= read(filedisk.handle,&pt,sizeof(pt));
-                       yaffs_UnpackTags(tags,&pt);
+                       yaffs_UnpackTags2(tags,&pt);
                        if(nread != sizeof(pt)) return YAFFS_FAIL;
                }
        }
index b19d6cb..b19a650 100644 (file)
@@ -16,7 +16,7 @@
 // NB this is not intended for NAND emulation.
 // Use this with dev->useNANDECC enabled, then ECC overheads are not required.
 
-const char *yaffs_ramdisk_c_version = "$Id: yaffs_ramdisk.c,v 1.1 2004-11-03 08:29:28 charles Exp $";
+const char *yaffs_ramdisk_c_version = "$Id: yaffs_ramdisk.c,v 1.2 2004-11-22 03:22:25 charles Exp $";
 
 
 #include "yportenv.h"
@@ -24,7 +24,7 @@ const char *yaffs_ramdisk_c_version = "$Id: yaffs_ramdisk.c,v 1.1 2004-11-03 08:
 #include "yaffs_ramdisk.h"
 #include "yaffs_guts.h"
 #include "devextras.h"
-#include "yaffs_packedtags.h"
+#include "yaffs_packedtags1.h"
 
 
 
@@ -136,9 +136,9 @@ int yramdisk_WriteChunkWithTagsToNAND(yaffs_Device *dev,int chunkInNAND,const __
        
        if(tags)
        {
-               yaffs_PackedTags pt;
+               yaffs_PackedTags1 pt;
                
-               yaffs_PackTags(&pt,tags);
+               yaffs_PackTags1(&pt,tags);
                memcpy(&ramdisk.block[blk]->page[pg].data[512],&pt,sizeof(pt));
        }
 
@@ -167,10 +167,10 @@ int yramdisk_ReadChunkWithTagsFromNAND(yaffs_Device *dev,int chunkInNAND, __u8 *
        
        if(tags)
        {
-               yaffs_PackedTags pt;
+               yaffs_PackedTags1 pt;
                
                memcpy(&pt,&ramdisk.block[blk]->page[pg].data[512],sizeof(pt));
-               yaffs_UnpackTags(tags,&pt);
+               yaffs_UnpackTags1(tags,&pt);
                
        }
 
index 379846b..f51c0c4 100644 (file)
@@ -9,6 +9,7 @@
 #include "yaffscfg.h"
 #include "yaffsfs.h"
 #include "yaffs_fileem2k.h"
+#include "yaffs_nandemul2k.h"
 
 #include <errno.h>
 
@@ -50,16 +51,19 @@ void yaffsfs_LocalInitialisation(void)
 
 #include "yaffs_ramdisk.h"
 #include "yaffs_flashif.h"
+#include "yaffs_nandemul2k.h"
 
 static yaffs_Device ramDev;
 static yaffs_Device bootDev;
 static yaffs_Device flashDev;
+static yaffs_Device ram2kDev;
 
 static yaffsfs_DeviceConfiguration yaffsfs_config[] = {
 
        { "/ram", &ramDev},
        { "/boot", &bootDev},
        { "/flash", &flashDev},
+       { "/ram2k", &ram2kDev},
        {(void *)0,(void *)0}
 };
 
@@ -127,6 +131,28 @@ int yaffs_StartUp(void)
        flashDev.markNANDBlockBad = yflash_MarkNANDBlockBad;
        flashDev.queryNANDBlock = yflash_QueryNANDBlock;
 
+       // /ram2k
+       // Set this puppy up to use
+       // the file emulation space as
+       // 2kpage/64chunk per block/128MB device
+       memset(&ram2kDev,0,sizeof(ram2kDev));
+
+       ram2kDev.nBytesPerChunk = nandemul2k_GetBytesPerChunk();
+       ram2kDev.nChunksPerBlock = nandemul2k_GetChunksPerBlock();
+       ram2kDev.nReservedBlocks = 5;
+       ram2kDev.startBlock = 1; // First block after /boot
+       //ram2kDev.endBlock = 127; // Last block in 16MB
+       ram2kDev.endBlock = nandemul2k_GetNumberOfBlocks() - 1; // Last block in 512MB
+       ram2kDev.isYaffs2 = 1;
+       ram2kDev.nShortOpCaches = 10; // Use caches
+       ram2kDev.genericDevice = (void *) 3;    // Used to identify the device in fstat.
+       ram2kDev.writeChunkWithTagsToNAND = nandemul2k_WriteChunkWithTagsToNAND;
+       ram2kDev.readChunkWithTagsFromNAND = nandemul2k_ReadChunkWithTagsFromNAND;
+       ram2kDev.eraseBlockInNAND = nandemul2k_EraseBlockInNAND;
+       ram2kDev.initialiseNAND = nandemul2k_InitialiseNAND;
+       ram2kDev.markNANDBlockBad = nandemul2k_MarkNANDBlockBad;
+       ram2kDev.queryNANDBlock = nandemul2k_QueryNANDBlock;
+
        yaffs_initialise(yaffsfs_config);
        
        return 0;
index 1c73c99..ba7a6a8 100644 (file)
@@ -25,7 +25,7 @@
 #endif
 
 
-const char *yaffsfs_c_version="$Id: yaffsfs.c,v 1.1 2004-11-03 08:29:28 charles Exp $";
+const char *yaffsfs_c_version="$Id: yaffsfs.c,v 1.2 2004-11-22 03:22:25 charles Exp $";
 
 // configurationList is the list of devices that are supported
 static yaffsfs_DeviceConfiguration *yaffsfs_configurationList;
@@ -180,7 +180,7 @@ static yaffs_Device *yaffsfs_FindDevice(const char *path, char **restOfPath)
                        p++;
                        leftOver++;
                }
-               if(!*p)
+               if(!*p && (!*leftOver || *leftOver == '/'))
                {
                        // Matched prefix
                        *restOfPath = (char *)leftOver;
index e87109b..340c736 100644 (file)
@@ -13,7 +13,7 @@
  */
  //yaffs_guts.c
 
-const char *yaffs_guts_c_version="$Id: yaffs_guts.c,v 1.2 2004-11-16 02:36:15 charles Exp $";
+const char *yaffs_guts_c_version="$Id: yaffs_guts.c,v 1.3 2004-11-22 03:22:25 charles Exp $";
 
 #include "yportenv.h"
 
@@ -201,7 +201,7 @@ int yaffs_EraseBlockInNAND(struct yaffs_DeviceStruct *dev,int blockInNAND)
        return result;
 }
 
-int yaffs_InitialiseNAND(struct yaffs_DeviceStruct *dev)
+static int yaffs_InitialiseNAND(struct yaffs_DeviceStruct *dev)
 {
        return dev->initialiseNAND(dev);
 }
@@ -4524,6 +4524,8 @@ static int yaffs_Scan(yaffs_Device *dev)
        __u8 *chunkData;
 
        yaffs_BlockIndex *blockIndex = NULL;
+
+       T(YAFFS_TRACE_SCAN,(TSTR("yaffs_Scan starts..." TENDSTR)));
        
        chunkData = yaffs_GetTempBuffer(dev,__LINE__);
        
@@ -4947,6 +4949,9 @@ static int yaffs_Scan(yaffs_Device *dev)
        }
        
        yaffs_ReleaseTempBuffer(dev,chunkData,__LINE__);
+
+       T(YAFFS_TRACE_SCAN,(TSTR("yaffs_Scan ends" TENDSTR)));
+
        return YAFFS_OK;
 }
 
@@ -5313,11 +5318,12 @@ int yaffs_GutsInitialise(yaffs_Device *dev)
        int extraBits;
        int nBlocks;
 
+       T(YAFFS_TRACE_ALWAYS,(TSTR("yaffs: yaffs_GutsInitialise()" TENDSTR)));
        // Check stuff that must be set
 
        if(!dev)
        {
-               T(YAFFS_TRACE_ALWAYS,(TSTR("yaffs: Need a device\n" TENDSTR)));
+               T(YAFFS_TRACE_ALWAYS,(TSTR("yaffs: Need a device" TENDSTR)));
                return YAFFS_FAIL;
        }
 
@@ -5332,10 +5338,16 @@ int yaffs_GutsInitialise(yaffs_Device *dev)
                dev->endBlock <= (dev->startBlock + dev->nReservedBlocks + 2) // otherwise it is too small
          )
        {
-               T(YAFFS_TRACE_ALWAYS,(TSTR("yaffs: nand geometry problems\n" TENDSTR)));
+               T(YAFFS_TRACE_ALWAYS,(TSTR("yaffs: NAND geometry problems: chunk size %d, type is yaffs%s " TENDSTR),
+                  dev->nBytesPerChunk, dev->isYaffs2 ? "2" : ""));
                return YAFFS_FAIL;
        }
 
+       if(yaffs_InitialiseNAND(dev) != YAFFS_OK)
+       {
+               T(YAFFS_TRACE_ALWAYS,(TSTR("yaffs: InitialiseNAND failed" TENDSTR)));
+               return YAFFS_FAIL;
+       }
 
        // Got the right mix of functions?
        //
@@ -5442,7 +5454,6 @@ int yaffs_GutsInitialise(yaffs_Device *dev)
        
 
        
-       
        yaffs_InitialiseBlocks(dev,nBlocks);
        
        yaffs_InitialiseTnodes(dev);
@@ -5502,7 +5513,7 @@ int yaffs_GutsInitialise(yaffs_Device *dev)
 
        dev->nRetiredBlocks = 0;
 
-       
+       T(YAFFS_TRACE_ALWAYS,(TSTR("yaffs: yaffs_GutsInitialise() done.\n" TENDSTR)));
        return YAFFS_OK;
                
 }
diff --git a/yaffs_packedtags.h b/yaffs_packedtags.h
deleted file mode 100644 (file)
index d0790d5..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-
-#ifndef __YAFFS_PACKEDTAGS_H__
-#define __YAFFS_PACKEDTAGS_H__
-
-#include "yaffs_guts.h"
-
-typedef struct
-{   
-       unsigned chunkId:20;
-    unsigned serialNumber:2;
-    unsigned byteCount:10;
-    unsigned objectId:18;
-    unsigned ecc:12;
-    unsigned deleted:1;
-    unsigned unusedStuff:1;
-    unsigned shouldBeFF;
-
-} yaffs_PackedTags;
-
-void yaffs_PackTags(yaffs_PackedTags *pt, yaffs_ExtendedTags *t);
-void yaffs_UnpackTags(yaffs_ExtendedTags *t, yaffs_PackedTags *pt);
-#endif
-
-
similarity index 78%
rename from yaffs_packedtags.c
rename to yaffs_packedtags1.c
index d290ac9..018eacf 100644 (file)
@@ -1,7 +1,7 @@
-#include "yaffs_packedtags.h"
+#include "yaffs_packedtags1.h"
 #include "yportenv.h"
 
-void yaffs_PackTags(yaffs_PackedTags *pt, yaffs_ExtendedTags *t)
+void yaffs_PackTags1(yaffs_PackedTags1 *pt, yaffs_ExtendedTags *t)
 {
        pt->chunkId = t->chunkId;
        pt->serialNumber = t->serialNumber;
@@ -14,11 +14,11 @@ void yaffs_PackTags(yaffs_PackedTags *pt, yaffs_ExtendedTags *t)
        
 }
 
-void yaffs_UnpackTags(yaffs_ExtendedTags *t, yaffs_PackedTags *pt)
+void yaffs_UnpackTags1(yaffs_ExtendedTags *t, yaffs_PackedTags1 *pt)
 {
        static const __u8 allFF[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,0xff, 0xff, 0xff, 0xff};
        
-       if(memcmp(allFF,pt,sizeof(yaffs_PackedTags)))
+       if(memcmp(allFF,pt,sizeof(yaffs_PackedTags1)))
        {
                t->blockBad = 0;
                if(pt->shouldBeFF != 0xFFFFFFFF)
diff --git a/yaffs_packedtags1.h b/yaffs_packedtags1.h
new file mode 100644 (file)
index 0000000..5f67668
--- /dev/null
@@ -0,0 +1,28 @@
+// This is used to pack YAFFS1 tags, not YAFFS2 tags.
+
+#ifndef __YAFFS_PACKEDTAGS1_H__
+#define __YAFFS_PACKEDTAGS1_H__
+
+
+#include "yaffs_guts.h"
+
+typedef struct
+{   
+    unsigned chunkId:20;
+    unsigned serialNumber:2;
+    unsigned byteCount:10;
+    unsigned objectId:18;
+    unsigned ecc:12;
+    unsigned deleted:1;
+    unsigned unusedStuff:1;
+    unsigned shouldBeFF;
+
+} yaffs_PackedTags1;
+
+
+
+void yaffs_PackTags1(yaffs_PackedTags1 *pt, yaffs_ExtendedTags *t);
+void yaffs_UnpackTags1(yaffs_ExtendedTags *t, yaffs_PackedTags1 *pt);
+#endif
+
+
diff --git a/yaffs_packedtags2.c b/yaffs_packedtags2.c
new file mode 100644 (file)
index 0000000..f734882
--- /dev/null
@@ -0,0 +1,42 @@
+#include "yaffs_packedtags2.h"
+#include "yportenv.h"
+
+
+
+void yaffs_PackTags2(yaffs_PackedTags2 *pt, yaffs_ExtendedTags *t)
+{
+       pt->t.chunkId = t->chunkId;
+       pt->t.sequenceNumber = t->sequenceNumber;
+       pt->t.byteCount = t->byteCount;
+       pt->t.objectId = t->objectId;
+       
+       yaffs_ECCCalculateOther((unsigned char *)&pt->t,sizeof(yaffs_PackedTags2TagsPart),&pt->ecc);
+       
+}
+
+void yaffs_UnpackTags2(yaffs_ExtendedTags *t, yaffs_PackedTags2 *pt)
+{
+
+       
+       if(pt->t.sequenceNumber == 0xFFFFFFFF)
+       {
+               memset(t,0,sizeof(yaffs_ExtendedTags));
+               
+       }
+       else
+       {
+               // Page is in use
+               yaffs_ECCOther ecc;
+               yaffs_ECCCalculateOther((unsigned char *)&pt->t,sizeof(yaffs_PackedTags2TagsPart),&ecc);
+               t->eccResult = yaffs_ECCCorrectOther((unsigned char *)&pt->t,sizeof(yaffs_PackedTags2TagsPart),&pt->ecc,&ecc);
+               t->blockBad = 0;
+               t->chunkUsed = 1;
+               t->objectId = pt->t.objectId;
+               t->chunkId =  pt->t.chunkId;
+               t->byteCount = pt->t.byteCount;
+               t->chunkDeleted = 0;
+               t->serialNumber = 0;
+               t->sequenceNumber = pt->t.sequenceNumber;
+       }
+}
+
diff --git a/yaffs_packedtags2.h b/yaffs_packedtags2.h
new file mode 100644 (file)
index 0000000..659e2f6
--- /dev/null
@@ -0,0 +1,31 @@
+// This is used to pack YAFFS2 tags, not YAFFS1tags.
+
+#ifndef __YAFFS_PACKEDTAGS2_H__
+#define __YAFFS_PACKEDTAGS2_H__
+
+
+#include "yaffs_guts.h"
+#include "yaffs_ecc.h"
+
+typedef struct
+{   
+    unsigned sequenceNumber;
+    unsigned chunkId;
+    unsigned objectId;
+    unsigned byteCount;
+    unsigned nandTagsEcc;
+    
+} yaffs_PackedTags2TagsPart;
+
+typedef struct
+{
+    yaffs_PackedTags2TagsPart t;
+    yaffs_ECCOther ecc;
+} yaffs_PackedTags2;
+
+
+void yaffs_PackTags2(yaffs_PackedTags2 *pt, yaffs_ExtendedTags *t);
+void yaffs_UnpackTags2(yaffs_ExtendedTags *t, yaffs_PackedTags2 *pt);
+#endif
+
+
index 77c5b05..a1a2074 100644 (file)
@@ -15,7 +15,7 @@
  *
  * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.
  *
- * $Id: yportenv.h,v 1.3 2004-11-16 02:36:15 charles Exp $
+ * $Id: yportenv.h,v 1.4 2004-11-22 03:22:25 charles Exp $
  *
  */
  
@@ -71,7 +71,7 @@
 #define yaffs_strcmp(a,b) strcmp(a,b)
 
 #define TENDSTR "\n"
-#define TSTR(x) KERN_DEBUG x
+#define TSTR(x) KERN_WARNING x
 #define TOUT(p) printk p