Change test to 32MB
[yaffs2.git] / direct / yaffscfg.c
1 /*
2  * YAFFS: Yet Another Flash File System. A NAND-flash specific file system.
3  *
4  * Copyright (C) 2002-2007 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  * yaffscfg.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 <errno.h>
24
25 unsigned yaffs_traceMask = 0xFFFFFFFF;
26
27
28 void yaffsfs_SetError(int err)
29 {
30         //Do whatever to set error
31         errno = err;
32 }
33
34 void yaffsfs_Lock(void)
35 {
36 }
37
38 void yaffsfs_Unlock(void)
39 {
40 }
41
42 __u32 yaffsfs_CurrentTime(void)
43 {
44         return 0;
45 }
46
47 void *yaffs_malloc(size_t size)
48 {
49         return malloc(size);
50 }
51
52 void yaffs_free(void *ptr)
53 {
54         free(ptr);
55 }
56
57 void yaffsfs_LocalInitialisation(void)
58 {
59         // Define locking semaphore.
60 }
61
62 // Configuration for:
63 // /ram  2MB ramdisk
64 // /boot 2MB boot disk (flash)
65 // /flash 14MB flash disk (flash)
66 // NB Though /boot and /flash occupy the same physical device they
67 // are still disticnt "yaffs_Devices. You may think of these as "partitions"
68 // using non-overlapping areas in the same device.
69 // 
70
71 #include "yaffs_ramdisk.h"
72 #include "yaffs_flashif.h"
73
74 static yaffs_Device ramDev;
75 static yaffs_Device bootDev;
76 static yaffs_Device flashDev;
77
78 static yaffsfs_DeviceConfiguration yaffsfs_config[] = {
79
80         { "/ram", &ramDev},
81         { "/boot", &bootDev},
82         { "/flash", &flashDev},
83         {(void *)0,(void *)0}
84 };
85
86
87 int yaffs_StartUp(void)
88 {
89         // Stuff to configure YAFFS
90         // Stuff to initialise anything special (eg lock semaphore).
91         yaffsfs_LocalInitialisation();
92         
93         // Set up devices
94
95         // /ram
96         ramDev.nDataBytesPerChunk = 512;
97         ramDev.nChunksPerBlock = 32;
98         ramDev.nReservedBlocks = 2; // Set this smaller for RAM
99         ramDev.startBlock = 1; // Can't use block 0
100         ramDev.endBlock = 127; // Last block in 2MB.    
101         ramDev.useNANDECC = 1;
102         ramDev.nShortOpCaches = 0;      // Disable caching on this device.
103         ramDev.genericDevice = (void *) 0;      // Used to identify the device in fstat.
104         ramDev.writeChunkWithTagsToNAND = yramdisk_WriteChunkWithTagsToNAND;
105         ramDev.readChunkWithTagsFromNAND = yramdisk_ReadChunkWithTagsFromNAND;
106         ramDev.eraseBlockInNAND = yramdisk_EraseBlockInNAND;
107         ramDev.initialiseNAND = yramdisk_InitialiseNAND;
108
109         // /boot
110         bootDev.nDataBytesPerChunk = 512;
111         bootDev.nChunksPerBlock = 32;
112         bootDev.nReservedBlocks = 5;
113         bootDev.startBlock = 1; // Can't use block 0
114         bootDev.endBlock = 127; // Last block in 2MB.   
115         bootDev.useNANDECC = 0; // use YAFFS's ECC
116         bootDev.nShortOpCaches = 10; // Use caches
117         bootDev.genericDevice = (void *) 1;     // Used to identify the device in fstat.
118         bootDev.writeChunkToNAND = yflash_WriteChunkToNAND;
119         bootDev.readChunkFromNAND = yflash_ReadChunkFromNAND;
120         bootDev.eraseBlockInNAND = yflash_EraseBlockInNAND;
121         bootDev.initialiseNAND = yflash_InitialiseNAND;
122
123                 // /flash
124         flashDev.nDataBytesPerChunk =  512;
125         flashDev.nChunksPerBlock = 32;
126         flashDev.nReservedBlocks = 5;
127         flashDev.startBlock = 128; // First block after 2MB
128         flashDev.endBlock = 1023; // Last block in 16MB
129         flashDev.useNANDECC = 0; // use YAFFS's ECC
130         flashDev.nShortOpCaches = 10; // Use caches
131         flashDev.genericDevice = (void *) 2;    // Used to identify the device in fstat.
132         flashDev.writeChunkToNAND = yflash_WriteChunkToNAND;
133         flashDev.readChunkFromNAND = yflash_ReadChunkFromNAND;
134         flashDev.eraseBlockInNAND = yflash_EraseBlockInNAND;
135         flashDev.initialiseNAND = yflash_InitialiseNAND;
136
137         yaffs_initialise(yaffsfs_config);
138         
139         return 0;
140 }
141
142
143
144