*** empty log message ***
[yaffs2.git] / direct / yaffscfg2k.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 "yaffs_fileem2k.h"
12
13 #include <errno.h>
14
15 unsigned yaffs_traceMask = 0xFFFFFFFF;
16
17
18 void yaffsfs_SetError(int err)
19 {
20         //Do whatever to set error
21         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         // /ram
75         memset(&ramDev,0,sizeof(ramDev));
76         ramDev.nBytesPerChunk = 512;
77         ramDev.nChunksPerBlock = 32;
78         ramDev.nReservedBlocks = 2; // Set this smaller for RAM
79         ramDev.startBlock = 1; // Can't use block 0
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.writeChunkWithTagsToNAND = yramdisk_WriteChunkWithTagsToNAND;
85         ramDev.readChunkWithTagsFromNAND = yramdisk_ReadChunkWithTagsFromNAND;
86         ramDev.eraseBlockInNAND = yramdisk_EraseBlockInNAND;
87         ramDev.initialiseNAND = yramdisk_InitialiseNAND;
88
89         // /boot
90         memset(&bootDev,0,sizeof(bootDev));
91         bootDev.nBytesPerChunk = 512;
92         bootDev.nChunksPerBlock = 32;
93         bootDev.nReservedBlocks = 5;
94         bootDev.startBlock = 1; // Can't use block 0
95         bootDev.endBlock = 63; // Last block
96         //bootDev.useNANDECC = 0; // use YAFFS's ECC
97         bootDev.nShortOpCaches = 10; // Use caches
98         bootDev.genericDevice = (void *) 1;     // Used to identify the device in fstat.
99         bootDev.writeChunkWithTagsToNAND = yflash_WriteChunkWithTagsToNAND;
100         bootDev.readChunkWithTagsFromNAND = yflash_ReadChunkWithTagsFromNAND;
101         bootDev.eraseBlockInNAND = yflash_EraseBlockInNAND;
102         bootDev.initialiseNAND = yflash_InitialiseNAND;
103         bootDev.markNANDBlockBad = yflash_MarkNANDBlockBad;
104         bootDev.queryNANDBlock = yflash_QueryNANDBlock;
105
106
107
108         // /flash
109         // Set this puppy up to use
110         // the file emulation space as
111         // 2kpage/64chunk per block/128MB device
112         memset(&flashDev,0,sizeof(flashDev));
113
114         flashDev.nBytesPerChunk = 2048;
115         flashDev.nChunksPerBlock = 64;
116         flashDev.nReservedBlocks = 5;
117         flashDev.startBlock = 64; // First block after /boot
118         //flashDev.endBlock = 127; // Last block in 16MB
119         flashDev.endBlock = (512 * 1024 * 1024)/(flashDev.nBytesPerChunk * flashDev.nChunksPerBlock) - 1; // Last block in 512MB
120         flashDev.isYaffs2 = 1;
121         flashDev.nShortOpCaches = 10; // Use caches
122         flashDev.genericDevice = (void *) 2;    // Used to identify the device in fstat.
123         flashDev.writeChunkWithTagsToNAND = yflash_WriteChunkWithTagsToNAND;
124         flashDev.readChunkWithTagsFromNAND = yflash_ReadChunkWithTagsFromNAND;
125         flashDev.eraseBlockInNAND = yflash_EraseBlockInNAND;
126         flashDev.initialiseNAND = yflash_InitialiseNAND;
127         flashDev.markNANDBlockBad = yflash_MarkNANDBlockBad;
128         flashDev.queryNANDBlock = yflash_QueryNANDBlock;
129
130         yaffs_initialise(yaffsfs_config);
131         
132         return 0;
133 }
134
135
136
137