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