2 * YAFFS: Yet Another Flash File System. A NAND-flash specific file system.
4 * Copyright (C) 2002-2011 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.
28 unsigned yaffs_trace_mask = 0xFFFFFFFF;
31 void yaffsfs_SetError(int err)
33 //Do whatever to set error
37 void yaffsfs_Lock(void)
41 void yaffsfs_Unlock(void)
45 u32 yaffsfs_CurrentTime(void)
50 void *yaffs_malloc(size_t size)
55 void yaffs_free(void *ptr)
60 void yaffsfs_LocalInitialisation(void)
62 // Define locking semaphore.
67 // /boot 2MB boot disk (flash)
68 // /flash 14MB flash disk (flash)
69 // NB Though /boot and /flash occupy the same physical device they
70 // are still disticnt "struct yaffs_devs. You may think of these as "partitions"
71 // using non-overlapping areas in the same device.
74 #include "yaffs_ramdisk.h"
75 #include "yaffs_flashif.h"
77 static struct yaffs_dev ramDev;
78 static struct yaffs_dev bootDev;
79 static struct yaffs_dev flashDev;
81 static yaffsfs_DeviceConfiguration yaffsfs_config[] = {
85 { "/flash", &flashDev},
90 int yaffs_start_up(void)
92 // Stuff to configure YAFFS
93 // Stuff to initialise anything special (eg lock semaphore).
94 yaffsfs_LocalInitialisation();
97 yramsim_CreateSim("yaffs2");
102 ramDev.data_bytes_per_chunk = 512;
103 ramDev.chunks_per_block = 32;
104 ramDev.n_reserved_blocks = 2; // Set this smaller for RAM
105 ramDev.start_block = 1; // Can't use block 0
106 ramDev.end_block = 127; // Last block in 2MB.
107 ramDev.use_nand_ecc = 1;
108 ramDev.n_caches = 0; // Disable caching on this device.
109 ramDev.genericDevice = (void *) 0; // Used to identify the device in fstat.
110 ramDev.write_chunk_tags_fn = yramdisk_wr_chunk;
111 ramDev.read_chunk_tags_fn = yramdisk_rd_chunk;
112 ramDev.erase_fn = yramdisk_erase;
113 ramDev.initialise_flash_fn = yramdisk_initialise;
116 bootDev.data_bytes_per_chunk = 512;
117 bootDev.chunks_per_block = 32;
118 bootDev.n_reserved_blocks = 5;
119 bootDev.start_block = 1; // Can't use block 0
120 bootDev.end_block = 127; // Last block in 2MB.
121 bootDev.use_nand_ecc = 0; // use YAFFS's ECC
122 bootDev.n_caches = 10; // Use caches
123 bootDev.genericDevice = (void *) 1; // Used to identify the device in fstat.
124 bootDev.write_chunk_fn = yflash_WriteChunkToNAND;
125 bootDev.read_chunk_fn = yflash_ReadChunkFromNAND;
126 bootDev.erase_fn = yflash_EraseBlockInNAND;
127 bootDev.initialise_flash_fn = yflash_InitialiseNAND;
130 flashDev.data_bytes_per_chunk = 512;
131 flashDev.chunks_per_block = 32;
132 flashDev.n_reserved_blocks = 5;
133 flashDev.start_block = 128; // First block after 2MB
134 flashDev.end_block = 1023; // Last block in 16MB
135 flashDev.use_nand_ecc = 0; // use YAFFS's ECC
136 flashDev.n_caches = 10; // Use caches
137 flashDev.genericDevice = (void *) 2; // Used to identify the device in fstat.
138 flashDev.write_chunk_fn = yflash_WriteChunkToNAND;
139 flashDev.read_chunk_fn = yflash_ReadChunkFromNAND;
140 flashDev.erase_fn = yflash_EraseBlockInNAND;
141 flashDev.initialise_flash_fn = yflash_InitialiseNAND;
143 yaffs_initialise(yaffsfs_config);