Set up u-boot glue code and patching scripts.
[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-2011 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         static int start_up_called = 0;
62
63         if(start_up_called)
64                 return;
65         start_up_called = 1;
66
67         // Stuff to configure YAFFS
68         // Stuff to initialise anything special (eg lock semaphore).
69         yaffsfs_OSInitialisation();
70
71         // Set up devices
72         // /ram1   ram, yaffs1
73         memset(&ram1Dev,0,sizeof(ram1Dev));
74         ram1Dev.param.name = "ram1";
75         ram1Dev.param.total_bytes_per_chunk = 512;
76         ram1Dev.param.chunks_per_block = 32;
77         ram1Dev.param.n_reserved_blocks = 2; // Set this smaller for RAM
78         ram1Dev.param.start_block = 0; // Can use block 0
79         ram1Dev.param.end_block = 127; // Last block in 2MB.
80         //ram1Dev.param.use_nand_ecc = 1;
81         ram1Dev.param.n_caches = 0;     // Disable caching on this device.
82         ram1Dev.driver_context = (void *) 0;    // Used to identify the device in fstat.
83         ram1Dev.param.write_chunk_tags_fn = yramdisk_wr_chunk;
84         ram1Dev.param.read_chunk_tags_fn = yramdisk_rd_chunk;
85         ram1Dev.param.erase_fn = yramdisk_erase;
86         ram1Dev.param.initialise_flash_fn = yramdisk_initialise;
87
88         yaffs_add_device(&ram1Dev);
89
90         // /M18-1 yaffs1 on M18 nor sim
91         memset(&m18_1Dev,0,sizeof(m18_1Dev));
92         m18_1Dev.param.name = "M18-1";
93         m18_1Dev.param.total_bytes_per_chunk = 1024;
94         m18_1Dev.param.chunks_per_block =248;
95         m18_1Dev.param.n_reserved_blocks = 2;
96         m18_1Dev.param.start_block = 0; // Can use block 0
97         m18_1Dev.param.end_block = 31; // Last block
98         m18_1Dev.param.use_nand_ecc = 0; // use YAFFS's ECC
99         m18_1Dev.param.n_caches = 10; // Use caches
100         m18_1Dev.driver_context = (void *) 1;   // Used to identify the device in fstat.
101         m18_1Dev.param.write_chunk_fn = ynorif1_WriteChunkToNAND;
102         m18_1Dev.param.read_chunk_fn = ynorif1_ReadChunkFromNAND;
103         m18_1Dev.param.erase_fn = ynorif1_EraseBlockInNAND;
104         m18_1Dev.param.initialise_flash_fn = ynorif1_InitialiseNAND;
105         m18_1Dev.param.deinitialise_flash_fn = ynorif1_Deinitialise_flash_fn;
106
107 //      m18_1Dev.param.disable_soft_del = 1;
108
109         yaffs_add_device(&m18_1Dev);
110
111         // /yaffs2  yaffs2 file emulation
112         // 2kpage/64chunk per block
113         //
114         memset(&flashDev,0,sizeof(flashDev));
115         flashDev.param.name = "yaffs2";
116         flashDev.param.total_bytes_per_chunk = 2048;
117         flashDev.param.chunks_per_block = 64;
118         flashDev.param.n_reserved_blocks = 5;
119         flashDev.param.inband_tags = 0;
120         flashDev.param.start_block = 0;
121         flashDev.param.end_block = yflash2_GetNumberOfBlocks()-1;
122         flashDev.param.is_yaffs2 = 1;
123         flashDev.param.use_nand_ecc=1;
124         flashDev.param.wide_tnodes_disabled=0;
125         flashDev.param.refresh_period = 1000;
126         flashDev.param.n_caches = 10; // Use caches
127         flashDev.driver_context = (void *) 2;   // Used to identify the device in fstat.
128         flashDev.param.write_chunk_tags_fn = yflash2_WriteChunkWithTagsToNAND;
129         flashDev.param.read_chunk_tags_fn = yflash2_ReadChunkWithTagsFromNAND;
130         flashDev.param.erase_fn = yflash2_EraseBlockInNAND;
131         flashDev.param.initialise_flash_fn = yflash2_InitialiseNAND;
132         flashDev.param.bad_block_fn = yflash2_MarkNANDBlockBad;
133         flashDev.param.query_block_fn = yflash2_QueryNANDBlock;
134         flashDev.param.enable_xattr = 1;
135
136         yaffs_add_device(&flashDev);
137
138 // todo yaffs_initialise(yaffsfs_config);
139
140         return 0;
141 }
142
143
144