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