More driver cleanup
[yaffs2.git] / direct / test-framework / yaffscfg.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  * yaffscfg.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 "yaffsfs.h"
23 #include <errno.h>
24
25
26 #include "yramsim.h"
27
28 unsigned yaffs_trace_mask = 0xFFFFFFFF;
29
30
31 void yaffsfs_SetError(int err)
32 {
33         //Do whatever to set error
34         errno = err;
35 }
36
37 void yaffsfs_Lock(void)
38 {
39 }
40
41 void yaffsfs_Unlock(void)
42 {
43 }
44
45 u32 yaffsfs_CurrentTime(void)
46 {
47         return 0;
48 }
49
50 void *yaffs_malloc(size_t size)
51 {
52         return malloc(size);
53 }
54
55 void yaffs_free(void *ptr)
56 {
57         free(ptr);
58 }
59
60 void yaffsfs_LocalInitialisation(void)
61 {
62         // Define locking semaphore.
63 }
64
65 // Configuration for:
66 // /ram  2MB ramdisk
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.
72 // 
73
74 #include "yaffs_ramdisk.h"
75 #include "yaffs_flashif.h"
76
77 static struct yaffs_dev ramDev;
78 static struct yaffs_dev bootDev;
79 static struct yaffs_dev flashDev;
80
81 static yaffsfs_DeviceConfiguration yaffsfs_config[] = {
82
83         { "/ram", &ramDev},
84         { "/boot", &bootDev},
85         { "/flash", &flashDev},
86         {(void *)0,(void *)0}
87 };
88
89
90 int yaffs_start_up(void)
91 {
92         // Stuff to configure YAFFS
93         // Stuff to initialise anything special (eg lock semaphore).
94         yaffsfs_LocalInitialisation();
95         
96 #if 1
97         yramsim_CreateSim("yaffs2");
98 #else
99         // Set up devices
100
101         // /ram
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;
114
115         // /boot
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;
128
129                 // /flash
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;
142
143         yaffs_initialise(yaffsfs_config);
144 #endif
145         
146         return 0;
147 }
148
149
150
151