380a7270aa5b6d0b0597d986ad470be9f55f368e
[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 yaffsfs_LocalInitialisation(void)
48 {
49         // Define locking semaphore.
50 }
51
52 // Configuration for:
53 // /ram  2MB ramdisk
54 // /boot 2MB boot disk (flash)
55 // /flash 14MB flash disk (flash)
56 // NB Though /boot and /flash occupy the same physical device they
57 // are still disticnt "yaffs_Devices. You may think of these as "partitions"
58 // using non-overlapping areas in the same device.
59 // 
60
61 #include "yaffs_ramdisk.h"
62 #include "yaffs_flashif.h"
63
64 static yaffs_Device ramDev;
65 static yaffs_Device bootDev;
66 static yaffs_Device flashDev;
67
68 static yaffsfs_DeviceConfiguration yaffsfs_config[] = {
69
70         { "/ram", &ramDev},
71         { "/boot", &bootDev},
72         { "/flash", &flashDev},
73         {(void *)0,(void *)0}
74 };
75
76
77 int yaffs_StartUp(void)
78 {
79         // Stuff to configure YAFFS
80         // Stuff to initialise anything special (eg lock semaphore).
81         yaffsfs_LocalInitialisation();
82         
83         // Set up devices
84
85         // /ram
86         ramDev.nBytesPerChunk = 512;
87         ramDev.nChunksPerBlock = 32;
88         ramDev.nReservedBlocks = 2; // Set this smaller for RAM
89         ramDev.startBlock = 1; // Can't use block 0
90         ramDev.endBlock = 127; // Last block in 2MB.    
91         ramDev.useNANDECC = 1;
92         ramDev.nShortOpCaches = 0;      // Disable caching on this device.
93         ramDev.genericDevice = (void *) 0;      // Used to identify the device in fstat.
94         ramDev.writeChunkWithTagsToNAND = yramdisk_WriteChunkWithTagsToNAND;
95         ramDev.readChunkWithTagsFromNAND = yramdisk_ReadChunkWithTagsFromNAND;
96         ramDev.eraseBlockInNAND = yramdisk_EraseBlockInNAND;
97         ramDev.initialiseNAND = yramdisk_InitialiseNAND;
98
99         // /boot
100         bootDev.nBytesPerChunk = 612;
101         bootDev.nChunksPerBlock = 32;
102         bootDev.nReservedBlocks = 5;
103         bootDev.startBlock = 1; // Can't use block 0
104         bootDev.endBlock = 127; // Last block in 2MB.   
105         bootDev.useNANDECC = 0; // use YAFFS's ECC
106         bootDev.nShortOpCaches = 10; // Use caches
107         bootDev.genericDevice = (void *) 1;     // Used to identify the device in fstat.
108         bootDev.writeChunkToNAND = yflash_WriteChunkToNAND;
109         bootDev.readChunkFromNAND = yflash_ReadChunkFromNAND;
110         bootDev.eraseBlockInNAND = yflash_EraseBlockInNAND;
111         bootDev.initialiseNAND = yflash_InitialiseNAND;
112
113                 // /flash
114         flashDev.nBytesPerChunk =  512;
115         flashDev.nChunksPerBlock = 32;
116         flashDev.nReservedBlocks = 5;
117         flashDev.startBlock = 128; // First block after 2MB
118         flashDev.endBlock = 1023; // Last block in 16MB
119         flashDev.useNANDECC = 0; // use YAFFS's ECC
120         flashDev.nShortOpCaches = 10; // Use caches
121         flashDev.genericDevice = (void *) 2;    // Used to identify the device in fstat.
122         flashDev.writeChunkToNAND = yflash_WriteChunkToNAND;
123         flashDev.readChunkFromNAND = yflash_ReadChunkFromNAND;
124         flashDev.eraseBlockInNAND = yflash_EraseBlockInNAND;
125         flashDev.initialiseNAND = yflash_InitialiseNAND;
126
127         yaffs_initialise(yaffsfs_config);
128         
129         return 0;
130 }
131
132
133
134