yaffs Expanding the the test direct/timothy_tests/threading
[yaffs2.git] / direct / basic-test / yaffscfg2k.c
1 /*
2  * YAFFS: Yet Another Flash File System. A NAND-flash specific file system.
3  *
4  * Copyright (C) 2002-2010 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  * yaffscfg2k.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 "yaffs_guts.h"
23 #include "yaffsfs.h"
24 #include "yaffs_fileem2k.h"
25 #include "yaffs_nandemul2k.h"
26 #include "yaffs_norif1.h"
27 #include "yaffs_trace.h"
28 #include "yaffs_osglue.h"
29
30
31 #include <errno.h>
32
33 unsigned yaffs_trace_mask = 
34
35         YAFFS_TRACE_SCAN |  
36         YAFFS_TRACE_GC |
37         YAFFS_TRACE_ERASE | 
38         YAFFS_TRACE_ERROR | 
39         YAFFS_TRACE_TRACING | 
40         YAFFS_TRACE_ALLOCATE | 
41         YAFFS_TRACE_BAD_BLOCKS |
42         YAFFS_TRACE_VERIFY | 
43         
44         0;
45         
46
47
48 // Configuration
49
50 #include "yaffs_ramdisk.h"
51 #include "yaffs_flashif.h"
52 #include "yaffs_flashif2.h"
53 #include "yaffs_nandemul2k.h"
54
55 struct yaffs_dev ram1Dev;
56 struct yaffs_dev flashDev;
57 struct yaffs_dev m18_1Dev;
58
59 int yaffs_start_up(void)
60 {
61         // Stuff to configure YAFFS
62         // Stuff to initialise anything special (eg lock semaphore).
63         yaffsfs_OSInitialisation();
64         
65         // Set up devices
66         // /ram1   ram, yaffs1
67         memset(&ram1Dev,0,sizeof(ram1Dev));
68         ram1Dev.param.name = "ram1";
69         ram1Dev.param.total_bytes_per_chunk = 512;
70         ram1Dev.param.chunks_per_block = 32;
71         ram1Dev.param.n_reserved_blocks = 2; // Set this smaller for RAM
72         ram1Dev.param.start_block = 0; // Can use block 0
73         ram1Dev.param.end_block = 127; // Last block in 2MB.    
74         //ram1Dev.param.use_nand_ecc = 1;
75         ram1Dev.param.n_caches = 0;     // Disable caching on this device.
76         ram1Dev.driver_context = (void *) 0;    // Used to identify the device in fstat.
77         ram1Dev.param.write_chunk_tags_fn = yramdisk_wr_chunk;
78         ram1Dev.param.read_chunk_tags_fn = yramdisk_rd_chunk;
79         ram1Dev.param.erase_fn = yramdisk_erase;
80         ram1Dev.param.initialise_flash_fn = yramdisk_initialise;
81         
82         yaffs_add_device(&ram1Dev);
83
84         // /M18-1 yaffs1 on M18 nor sim
85         memset(&m18_1Dev,0,sizeof(m18_1Dev));
86         m18_1Dev.param.name = "M18-1";
87         m18_1Dev.param.total_bytes_per_chunk = 1024;
88         m18_1Dev.param.chunks_per_block =248;
89         m18_1Dev.param.n_reserved_blocks = 2;
90         m18_1Dev.param.start_block = 0; // Can use block 0
91         m18_1Dev.param.end_block = 31; // Last block
92         m18_1Dev.param.use_nand_ecc = 0; // use YAFFS's ECC
93         m18_1Dev.param.n_caches = 10; // Use caches
94         m18_1Dev.driver_context = (void *) 1;   // Used to identify the device in fstat.
95         m18_1Dev.param.write_chunk_fn = ynorif1_WriteChunkToNAND;
96         m18_1Dev.param.read_chunk_fn = ynorif1_ReadChunkFromNAND;
97         m18_1Dev.param.erase_fn = ynorif1_EraseBlockInNAND;
98         m18_1Dev.param.initialise_flash_fn = ynorif1_InitialiseNAND;
99         m18_1Dev.param.deinitialise_flash_fn = ynorif1_Deinitialise_flash_fn;
100
101 //      m18_1Dev.param.disable_soft_del = 1;
102
103         yaffs_add_device(&m18_1Dev);
104
105         // /yaffs2  yaffs2 file emulation
106         // 2kpage/64chunk per block
107         //
108         memset(&flashDev,0,sizeof(flashDev));
109         flashDev.param.name = "yaffs2";
110         flashDev.param.total_bytes_per_chunk = 2048;
111         flashDev.param.chunks_per_block = 64;
112         flashDev.param.n_reserved_blocks = 5;
113         flashDev.param.inband_tags = 0;
114         flashDev.param.start_block = 0;
115         flashDev.param.end_block = yflash2_GetNumberOfBlocks()-1;
116         flashDev.param.is_yaffs2 = 1;
117         flashDev.param.use_nand_ecc=1;
118         flashDev.param.wide_tnodes_disabled=0;
119         flashDev.param.refresh_period = 1000;
120         flashDev.param.n_caches = 10; // Use caches
121         flashDev.driver_context = (void *) 2;   // Used to identify the device in fstat.
122         flashDev.param.write_chunk_tags_fn = yflash2_WriteChunkWithTagsToNAND;
123         flashDev.param.read_chunk_tags_fn = yflash2_ReadChunkWithTagsFromNAND;
124         flashDev.param.erase_fn = yflash2_EraseBlockInNAND;
125         flashDev.param.initialise_flash_fn = yflash2_InitialiseNAND;
126         flashDev.param.bad_block_fn = yflash2_MarkNANDBlockBad;
127         flashDev.param.query_block_fn = yflash2_QueryNANDBlock;
128         flashDev.param.enable_xattr = 1;
129
130         yaffs_add_device(&flashDev);
131
132 // todo yaffs_initialise(yaffsfs_config);
133         
134         return 0;
135 }
136
137
138