yaffs direct: Prevent yaffs_start_up being called twice.
[yaffs2.git] / direct / basic-test / yaffscfg2k.c
index b05952f1998dd9d8636dca67a99f15367ebd60fd..b857479940e83e4eb9b0b65c107898543082e9bf 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * YAFFS: Yet Another Flash File System. A NAND-flash specific file system.
  *
- * Copyright (C) 2002-2010 Aleph One Ltd.
+ * Copyright (C) 2002-2011 Aleph One Ltd.
  *   for Toby Churchill Ltd and Brightstar Engineering
  *
  * Created by Charles Manning <charles@aleph1.co.uk>
 #include "yaffs_nandemul2k.h"
 #include "yaffs_norif1.h"
 #include "yaffs_trace.h"
+#include "yaffs_osglue.h"
 
 
 #include <errno.h>
 
-unsigned yaffs_trace_mask = 
+unsigned yaffs_trace_mask =
 
-       YAFFS_TRACE_SCAN |  
+       YAFFS_TRACE_SCAN |
        YAFFS_TRACE_GC |
-       YAFFS_TRACE_ERASE | 
-       YAFFS_TRACE_ERROR | 
-       YAFFS_TRACE_TRACING | 
-       YAFFS_TRACE_ALLOCATE | 
+       YAFFS_TRACE_ERASE |
+       YAFFS_TRACE_ERROR |
+       YAFFS_TRACE_TRACING |
+       YAFFS_TRACE_ALLOCATE |
        YAFFS_TRACE_BAD_BLOCKS |
-       YAFFS_TRACE_VERIFY | 
-       
-       0;
-        
-
-static int yaffsfs_lastError;
-
-void yaffsfs_SetError(int err)
-{
-       //Do whatever to set error
-       yaffsfs_lastError = err;
-}
-
-
-int yaffsfs_GetLastError(void)
-{
-       return yaffsfs_lastError;
-}
+       YAFFS_TRACE_VERIFY |
 
-void yaffsfs_Lock(void)
-{
-}
-
-void yaffsfs_Unlock(void)
-{
-}
-
-u32 yaffsfs_CurrentTime(void)
-{
-       return 0;
-}
-
-
-static int yaffs_kill_alloc = 0;
-static size_t total_malloced = 0;
-static size_t malloc_limit = 0 & 6000000;
-
-void *yaffs_malloc(size_t size)
-{
-       void * this;
-       if(yaffs_kill_alloc)
-               return NULL;
-       if(malloc_limit && malloc_limit <(total_malloced + size) )
-               return NULL;
-
-       this = malloc(size);
-       if(this)
-               total_malloced += size;
-       return this;
-}
+       0;
 
-void yaffs_free(void *ptr)
-{
-       free(ptr);
-}
 
-void yaffsfs_LocalInitialisation(void)
-{
-       // Define locking semaphore.
-}
 
 // Configuration
 
@@ -106,16 +52,22 @@ void yaffsfs_LocalInitialisation(void)
 #include "yaffs_flashif2.h"
 #include "yaffs_nandemul2k.h"
 
-struct yaffs_dev_s ram1Dev;
-struct yaffs_dev_s flashDev;
-struct yaffs_dev_s m18_1Dev;
+struct yaffs_dev ram1Dev;
+struct yaffs_dev flashDev;
+struct yaffs_dev m18_1Dev;
 
 int yaffs_start_up(void)
 {
+       static int start_up_called = 0;
+
+       if(start_up_called)
+               return;
+       start_up_called = 1;
+
        // Stuff to configure YAFFS
        // Stuff to initialise anything special (eg lock semaphore).
-       yaffsfs_LocalInitialisation();
-       
+       yaffsfs_OSInitialisation();
+
        // Set up devices
        // /ram1   ram, yaffs1
        memset(&ram1Dev,0,sizeof(ram1Dev));
@@ -124,7 +76,7 @@ int yaffs_start_up(void)
        ram1Dev.param.chunks_per_block = 32;
        ram1Dev.param.n_reserved_blocks = 2; // Set this smaller for RAM
        ram1Dev.param.start_block = 0; // Can use block 0
-       ram1Dev.param.end_block = 127; // Last block in 2MB.    
+       ram1Dev.param.end_block = 127; // Last block in 2MB.
        //ram1Dev.param.use_nand_ecc = 1;
        ram1Dev.param.n_caches = 0;     // Disable caching on this device.
        ram1Dev.driver_context = (void *) 0;    // Used to identify the device in fstat.
@@ -132,7 +84,7 @@ int yaffs_start_up(void)
        ram1Dev.param.read_chunk_tags_fn = yramdisk_rd_chunk;
        ram1Dev.param.erase_fn = yramdisk_erase;
        ram1Dev.param.initialise_flash_fn = yramdisk_initialise;
-       
+
        yaffs_add_device(&ram1Dev);
 
        // /M18-1 yaffs1 on M18 nor sim
@@ -184,7 +136,7 @@ int yaffs_start_up(void)
        yaffs_add_device(&flashDev);
 
 // todo        yaffs_initialise(yaffsfs_config);
-       
+
        return 0;
 }