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 #include "yaffs_nandsim_file.h"
16 #include "yaffs_nand_drv.h"
17 #include "nandsim_file.h"
18 #include "nand_chip.h"
19 #include "yaffs_guts.h"
23 struct yaffs_dev *yaffs_nandsim_install_drv(const char *dev_name,
24 const char *backing_file_name,
27 struct yaffs_dev *dev;
28 char *name_copy = NULL;
29 struct yaffs_param *param;
30 struct nand_chip *chip = NULL;
34 dev = malloc(sizeof(struct yaffs_dev));
35 name_copy = strdup(dev_name);
37 if(!dev || !name_copy)
40 memset(dev, 0, sizeof(*dev));
41 chip = nandsim_file_init(backing_file_name, n_blocks, 64, 2048, 64, 0);
47 param->name = name_copy;
49 param->total_bytes_per_chunk = chip->data_bytes_per_page;
50 param->chunks_per_block = chip->pages_per_block;
51 param->n_reserved_blocks = 5;
52 param->start_block = 0; // First block
53 param->end_block = n_blocks - 1; // Last block
55 param->use_nand_ecc = 1;
57 param->stored_endian = 2;
59 if(yaffs_nand_install_drv(dev, chip) != YAFFS_OK)
62 /* The yaffs device has been configured, install it into yaffs */
63 yaffs_add_device(dev);