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 yaffsfs_SetError(int err)16void yaffsfs_SetError(int err) 17 { 18 //Do whatever to set error 19 errno = err; 20 } 21 yaffsfs_Lock(void)22void yaffsfs_Lock(void) 23 { 24 } 25 yaffsfs_Unlock(void)26void yaffsfs_Unlock(void) 27 { 28 } 29 yaffsfs_CurrentTime(void)30__u32 yaffsfs_CurrentTime(void) 31 { 32 return 0; 33 } 34 yaffsfs_LocalInitialisation(void)35void 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 yaffs_StartUp(void)65int 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 = 512; 75 ramDev.nChunksPerBlock = 32; 76 ramDev.nReservedBlocks = 2; // Set this smaller for RAM 77 ramDev.startBlock = 1; // Can't use block 0 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.writeChunkWithTagsToNAND = yramdisk_WriteChunkWithTagsToNAND; 83 ramDev.readChunkWithTagsFromNAND = yramdisk_ReadChunkWithTagsFromNAND; 84 ramDev.eraseBlockInNAND = yramdisk_EraseBlockInNAND; 85 ramDev.initialiseNAND = yramdisk_InitialiseNAND; 86 87 // /boot 88 bootDev.nBytesPerChunk = 612; 89 bootDev.nChunksPerBlock = 32; 90 bootDev.nReservedBlocks = 5; 91 bootDev.startBlock = 1; // Can't use block 0 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 = 512; 103 flashDev.nChunksPerBlock = 32; 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 123