*** empty log message ***
[yaffs/.git] / direct / yaffscfg.c
1 /*
2  * YAFFS: Yet another FFS. A NAND-flash specific file system.
3  * yaffscfg.c  The configuration for the "direct" use of yaffs.
4  *
5  * This file is intended to be modified to your requirements.
6  * There is no need to redistribute this file.
7  */
8
9 #include "yaffscfg.h"
10 #include "yaffsfs.h"
11 #include <errno.h>
12
13 unsigned yaffs_traceMask = 0xFFFFFFFF;
14
15
16 int yaffs_errno;
17
18 void yaffsfs_SetError(int err)
19 {
20         //Do whatever to set error
21         yaffs_errno = err;
22 }
23
24 void yaffsfs_Lock(void)
25 {
26 }
27
28 void yaffsfs_Unlock(void)
29 {
30 }
31
32 __u32 yaffsfs_CurrentTime(void)
33 {
34         return 0;
35 }
36
37 void yaffsfs_LocalInitialisation(void)
38 {
39         // Define locking semaphore.
40 }
41
42 // Configuration for:
43 // /ram  2MB ramdisk
44 // /boot 2MB boot disk (flash)
45 // /flash 14MB flash disk (flash)
46 // NB Though /boot and /flash occupy the same physical device they
47 // are still disticnt "yaffs_Devices. You may think of these as "partitions"
48 // using non-overlapping areas in the same device.
49 // 
50
51 #include "yaffs_ramdisk.h"
52 #include "yaffs_flashif.h"
53
54 static yaffs_Device ramDev;
55 static yaffs_Device bootDev;
56 static yaffs_Device flashDev;
57
58 static yaffsfs_DeviceConfiguration yaffsfs_config[] = {
59
60         { "/ram", &ramDev},
61         { "/boot", &bootDev},
62         { "/flash", &flashDev},
63         {(void *)0,(void *)0}
64 };
65
66
67 int yaffs_StartUp(void)
68 {
69         // Stuff to configure YAFFS
70         // Stuff to initialise anything special (eg lock semaphore).
71         yaffsfs_LocalInitialisation();
72         
73         // Set up devices
74
75         // /ram
76         ramDev.nBytesPerChunk = YAFFS_BYTES_PER_CHUNK;
77         ramDev.nChunksPerBlock = YAFFS_CHUNKS_PER_BLOCK;
78         ramDev.nReservedBlocks = 2; // Set this smaller for RAM
79         ramDev.startBlock = 0; // Can now use block zero
80         ramDev.endBlock = 127; // Last block in 2MB.    
81         ramDev.useNANDECC = 1;
82         ramDev.nShortOpCaches = 0;      // Disable caching on this device.
83         ramDev.genericDevice = (void *) 0;      // Used to identify the device in fstat.
84         ramDev.writeChunkToNAND = yramdisk_WriteChunkToNAND;
85         ramDev.readChunkFromNAND = yramdisk_ReadChunkFromNAND;
86         ramDev.eraseBlockInNAND = yramdisk_EraseBlockInNAND;
87         ramDev.initialiseNAND = yramdisk_InitialiseNAND;
88
89         // /boot
90         bootDev.nBytesPerChunk = YAFFS_BYTES_PER_CHUNK;
91         bootDev.nChunksPerBlock = YAFFS_CHUNKS_PER_BLOCK;
92         bootDev.nReservedBlocks = 5;
93         bootDev.startBlock = 0; // Can now use block zero
94         bootDev.endBlock = 127; // Last block in 2MB.   
95         bootDev.useNANDECC = 0; // use YAFFS's ECC
96         bootDev.nShortOpCaches = 10; // Use caches
97         bootDev.genericDevice = (void *) 1;     // Used to identify the device in fstat.
98         bootDev.writeChunkToNAND = yflash_WriteChunkToNAND;
99         bootDev.readChunkFromNAND = yflash_ReadChunkFromNAND;
100         bootDev.eraseBlockInNAND = yflash_EraseBlockInNAND;
101         bootDev.initialiseNAND = yflash_InitialiseNAND;
102
103                 // /flash
104         flashDev.nBytesPerChunk = YAFFS_BYTES_PER_CHUNK;
105         flashDev.nChunksPerBlock = YAFFS_CHUNKS_PER_BLOCK;
106         flashDev.nReservedBlocks = 5;
107         flashDev.startBlock = 128; // First block after 2MB
108         flashDev.endBlock = 1023; // Last block in 16MB
109         flashDev.useNANDECC = 0; // use YAFFS's ECC
110         flashDev.nShortOpCaches = 10; // Use caches
111         flashDev.genericDevice = (void *) 2;    // Used to identify the device in fstat.
112         flashDev.writeChunkToNAND = yflash_WriteChunkToNAND;
113         flashDev.readChunkFromNAND = yflash_ReadChunkFromNAND;
114         flashDev.eraseBlockInNAND = yflash_EraseBlockInNAND;
115         flashDev.initialiseNAND = yflash_InitialiseNAND;
116
117         yaffs_initialise(yaffsfs_config);
118         
119         return 0;
120 }
121
122
123
124