1/* 2 * Copyright © 1999-2010 David Woodhouse <dwmw2@infradead.org> 3 * 4 * This program is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation; either version 2 of the License, or 7 * (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 17 * 18 */ 19 20#ifndef __MTD_NFTL_H__ 21#define __MTD_NFTL_H__ 22 23#include <linux/mtd/mtd.h> 24#include <linux/mtd/blktrans.h> 25 26#include <mtd/nftl-user.h> 27 28/* these info are used in ReplUnitTable */ 29#define BLOCK_NIL 0xffff /* last block of a chain */ 30#define BLOCK_FREE 0xfffe /* free block */ 31#define BLOCK_NOTEXPLORED 0xfffd /* non explored block, only used during mounting */ 32#define BLOCK_RESERVED 0xfffc /* bios block or bad block */ 33 34struct NFTLrecord { 35 struct mtd_blktrans_dev mbd; 36 __u16 MediaUnit, SpareMediaUnit; 37 __u32 EraseSize; 38 struct NFTLMediaHeader MediaHdr; 39 int usecount; 40 unsigned char heads; 41 unsigned char sectors; 42 unsigned short cylinders; 43 __u16 numvunits; 44 __u16 lastEUN; /* should be suppressed */ 45 __u16 numfreeEUNs; 46 __u16 LastFreeEUN; /* To speed up finding a free EUN */ 47 int head,sect,cyl; 48 __u16 *EUNtable; /* [numvunits]: First EUN for each virtual unit */ 49 __u16 *ReplUnitTable; /* [numEUNs]: ReplUnitNumber for each */ 50 unsigned int nb_blocks; /* number of physical blocks */ 51 unsigned int nb_boot_blocks; /* number of blocks used by the bios */ 52 struct erase_info instr; 53 struct nand_ecclayout oobinfo; 54}; 55 56int NFTL_mount(struct NFTLrecord *s); 57int NFTL_formatblock(struct NFTLrecord *s, int block); 58 59int nftl_read_oob(struct mtd_info *mtd, loff_t offs, size_t len, 60 size_t *retlen, uint8_t *buf); 61int nftl_write_oob(struct mtd_info *mtd, loff_t offs, size_t len, 62 size_t *retlen, uint8_t *buf); 63 64#ifndef NFTL_MAJOR 65#define NFTL_MAJOR 93 66#endif 67 68#define MAX_NFTLS 16 69#define MAX_SECTORS_PER_UNIT 64 70#define NFTL_PARTN_BITS 4 71 72#endif /* __MTD_NFTL_H__ */ 73