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 * \file uffs_badblock.h 34 * \brief bad block management 35 * \author Ricky Zheng 36 */ 37 38 #ifndef _UFFS_BADBLOCK_H_ 39 #define _UFFS_BADBLOCK_H_ 40 41 #include "uffs/uffs_public.h" 42 #include "uffs/uffs_device.h" 43 #include "uffs/uffs_core.h" 44 45 #ifdef __cplusplus 46 extern "C"{ 47 #endif 48 49 50 #define HAVE_BADBLOCK(dev) (dev->bad.block != UFFS_INVALID_BLOCK) 51 52 /** initialize bad block management data structures for uffs device */ 53 void uffs_BadBlockInit(uffs_Device *dev); 54 55 /** processing bad block: erase bad block, 56 mark it as 'bad' and put it to bad block list */ 57 void uffs_BadBlockProcess(uffs_Device *dev, TreeNode *node); 58 59 /** processing bad block: erase bad block, 60 mark it as 'bad' and put it to suspend block list */ 61 void uffs_BadBlockProcessSuspend(uffs_Device *dev, TreeNode *node); 62 63 /** try to recover data from a new discovered bad block */ 64 void uffs_BadBlockRecover(uffs_Device *dev); 65 66 /** put a new block to the bad block waiting list */ 67 void uffs_BadBlockAdd(uffs_Device *dev, int block); 68 69 70 #ifdef __cplusplus 71 } 72 #endif 73 74 75 #endif 76