1 /* 2 This file is part of UFFS, the Ultra-low-cost Flash File System. 3 4 Copyright (C) 2005-2009 Ricky Zheng <[email protected]> 5 6 UFFS is free software; you can redistribute it and/or modify it under 7 the GNU Library General Public License as published by the Free Software 8 Foundation; either version 2 of the License, or (at your option) any 9 later version. 10 11 UFFS is distributed in the hope that it will be useful, but WITHOUT 12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 or GNU Library General Public License, as applicable, for more details. 15 16 You should have received a copy of the GNU General Public License 17 and GNU Library General Public License along with UFFS; if not, write 18 to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 19 Boston, MA 02110-1301, USA. 20 21 As a special exception, if other files instantiate templates or use 22 macros or inline functions from this file, or you compile this file 23 and link it with other works to produce a work based on this file, 24 this file does not by itself cause the resulting work to be covered 25 by the GNU General Public License. However the source code for this 26 file must still be made available in accordance with section (3) of 27 the GNU General Public License v2. 28 29 This exception does not invalidate any other reasons why a work based 30 on this file might be covered by the GNU General Public License. 31 */ 32 33 /** 34 * \file uffs_fileem.h 35 * \brief Emulate NAND flash with host file. 36 * \author Ricky Zheng 37 */ 38 39 #ifndef _UFFS_FILEEM_H_ 40 #define _UFFS_FILEEM_H_ 41 42 #include "uffs/uffs_device.h" 43 44 #define UFFS_FEMU_FILE_NAME "uffsemfile.bin" 45 46 #define UFFS_FEMU_MAX_BLOCKS (1024 * 16) // maximum 16K blocks 47 48 #define UFFS_FEMU_ENABLE_INJECTION // enable bad block & ecc error injection 49 50 extern struct uffs_FlashOpsSt g_femu_ops_ecc_soft; // for software ECC or no ECC. 51 extern struct uffs_FlashOpsSt g_femu_ops_ecc_hw; // for hardware ECC 52 extern struct uffs_FlashOpsSt g_femu_ops_ecc_hw_auto; // for auto hardware ECC 53 54 #define PAGE_DATA_WRITE_COUNT_LIMIT 1 55 #define PAGE_SPARE_WRITE_COUNT_LIMIT 1 56 57 typedef struct uffs_FileEmuSt { 58 int initCount; 59 FILE *fp; 60 FILE *dump_fp; 61 u8 *em_monitor_page; // page write monitor 62 u8 * em_monitor_spare; // spare write monitor 63 u32 *em_monitor_block; // block erease monitor 64 const char *emu_filename; 65 #ifdef UFFS_FEMU_ENABLE_INJECTION 66 struct uffs_FlashOpsSt ops_orig; 67 UBOOL wrap_inited; 68 #endif 69 } uffs_FileEmu; 70 71 /* file emulator device init/release entry */ 72 URET femu_InitDevice(uffs_Device *dev); 73 URET femu_ReleaseDevice(uffs_Device *dev); 74 75 struct uffs_StorageAttrSt * femu_GetStorage(void); 76 struct uffs_FileEmuSt * femu_GetPrivate(void); 77 78 #ifdef UFFS_FEMU_ENABLE_INJECTION 79 void femu_setup_wrapper_functions(uffs_Device *dev); 80 #endif 81 82 /* internal used functions, shared by all ecc option implementations */ 83 int femu_InitFlash(uffs_Device *dev); 84 int femu_ReleaseFlash(uffs_Device *dev); 85 int femu_EraseBlock(uffs_Device *dev, u32 blockNumber); 86 87 #endif 88 89