6ee43b78137cc454b05d342f7445742488212d93
[yaffs2.git] / direct / basic-test / yaffsnewcfg.c
1 /*
2  * YAFFS: Yet Another Flash File System. A NAND-flash specific file system.
3  *
4  * Copyright (C) 2002-2010 Aleph One Ltd.
5  *   for Toby Churchill Ltd and Brightstar Engineering
6  *
7  * Created by Charles Manning <charles@aleph1.co.uk>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License version 2 as
11  * published by the Free Software Foundation.
12  */
13
14 /*
15  * yaffscfg2k.c  The configuration for the "direct" use of yaffs.
16  *
17  * This file is intended to be modified to your requirements.
18  * There is no need to redistribute this file.
19  */
20
21 #include "yaffscfg.h"
22 #include "yaffsfs.h"
23 #include "yaffs_trace.h"
24 #include "yramsim.h"
25
26 unsigned yaffs_traceMask = 
27
28         YAFFS_TRACE_SCAN |  
29         YAFFS_TRACE_GC |
30         YAFFS_TRACE_ERASE | 
31         YAFFS_TRACE_ERROR | 
32         YAFFS_TRACE_TRACING | 
33         YAFFS_TRACE_ALLOCATE | 
34         YAFFS_TRACE_BAD_BLOCKS |
35         YAFFS_TRACE_VERIFY | 
36         
37         0;
38         
39
40 static int yaffsfs_lastError;
41
42 void yaffsfs_SetError(int err)
43 {
44         //Do whatever to set error
45         yaffsfs_lastError = err;
46 }
47
48
49 int yaffsfs_GetLastError(void)
50 {
51         return yaffsfs_lastError;
52 }
53
54 void yaffsfs_Lock(void)
55 {
56 }
57
58 void yaffsfs_Unlock(void)
59 {
60 }
61
62 __u32 yaffsfs_CurrentTime(void)
63 {
64         return 0;
65 }
66
67
68 static int yaffs_kill_alloc = 0;
69 static size_t total_malloced = 0;
70 static size_t malloc_limit = 0 & 6000000;
71
72 void *yaffs_malloc(size_t size)
73 {
74         void * this;
75         if(yaffs_kill_alloc)
76                 return NULL;
77         if(malloc_limit && malloc_limit <(total_malloced + size) )
78                 return NULL;
79
80         this = malloc(size);
81         if(this)
82                 total_malloced += size;
83         return this;
84 }
85
86 void yaffs_free(void *ptr)
87 {
88         free(ptr);
89 }
90
91 void yaffsfs_LocalInitialisation(void)
92 {
93         // Define locking semaphore.
94 }
95
96 // Configuration
97
98
99 int yaffs_StartUp(void)
100 {
101         // Stuff to configure YAFFS
102         // Stuff to initialise anything special (eg lock semaphore).
103         yaffsfs_LocalInitialisation();
104         yramsim_CreateRamSim("yaffs2",1,200,0,0);
105         yramsim_CreateRamSim("p0",0,0x400,1,0xff);
106         yramsim_CreateRamSim("p1",0,0x400,1,0);
107         
108         return 0;
109 }
110
111
112