2 * YAFFS: Yet Another Flash File System. A NAND-flash specific file system.
4 * Copyright (C) 2002-2010 Aleph One Ltd.
5 * for Toby Churchill Ltd and Brightstar Engineering
7 * Created by Charles Manning <charles@aleph1.co.uk>
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.
15 * yaffscfg.c The configuration for the "direct" use of yaffs.
17 * This file is intended to be modified to your requirements.
18 * There is no need to redistribute this file.
25 unsigned yaffs_traceMask = 0xFFFFFFFF;
28 void yaffsfs_SetError(int err)
30 //Do whatever to set error
34 void yaffsfs_Lock(void)
38 void yaffsfs_Unlock(void)
42 __u32 yaffsfs_CurrentTime(void)
47 void *yaffs_malloc(size_t size)
52 void yaffs_free(void *ptr)
57 void yaffsfs_LocalInitialisation(void)
59 // Define locking semaphore.
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.
71 #include "yaffs_ramdisk.h"
72 #include "yaffs_flashif.h"
74 static yaffs_Device ramDev;
75 static yaffs_Device bootDev;
76 static yaffs_Device flashDev;
78 static yaffsfs_DeviceConfiguration yaffsfs_config[] = {
82 { "/flash", &flashDev},
87 int yaffs_StartUp(void)
89 // Stuff to configure YAFFS
90 // Stuff to initialise anything special (eg lock semaphore).
91 yaffsfs_LocalInitialisation();
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;
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;
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;
137 yaffs_initialise(yaffsfs_config);