File: /usr/src/linux/include/linux/mtd/nftl.h

1     
2     /* Defines for NAND Flash Translation Layer  */
3     /* (c) 1999 Machine Vision Holdings, Inc.    */
4     /* Author: David Woodhouse <dwmw2@mvhi.com>  */
5     /* $Id: nftl.h,v 1.10 2000/12/29 00:25:38 dwmw2 Exp $ */
6     
7     #ifndef __MTD_NFTL_H__
8     #define __MTD_NFTL_H__
9     
10     #ifndef __BOOT__
11     #include <linux/mtd/mtd.h>
12     #endif
13     
14     /* Block Control Information */
15     
16     struct nftl_bci {
17     	unsigned char ECCSig[6];
18     	__u8 Status;
19     	__u8 Status1;
20     }__attribute__((packed));
21     
22     /* Unit Control Information */
23     
24     struct nftl_uci0 {
25     	__u16 VirtUnitNum;
26     	__u16 ReplUnitNum;
27     	__u16 SpareVirtUnitNum;
28     	__u16 SpareReplUnitNum;
29     } __attribute__((packed));
30     
31     struct nftl_uci1 {
32     	__u32 WearInfo;
33     	__u16 EraseMark;
34     	__u16 EraseMark1;
35     } __attribute__((packed));
36     
37     struct nftl_uci2 {
38             __u16 FoldMark;
39             __u16 FoldMark1;
40     	__u32 unused;
41     } __attribute__((packed));
42     
43     union nftl_uci {
44     	struct nftl_uci0 a;
45     	struct nftl_uci1 b;
46     	struct nftl_uci2 c;
47     };
48     
49     struct nftl_oob {
50     	struct nftl_bci b;
51     	union nftl_uci u;
52     };
53     
54     /* NFTL Media Header */
55     
56     struct NFTLMediaHeader {
57     	char DataOrgID[6];
58     	__u16 NumEraseUnits;
59     	__u16 FirstPhysicalEUN;
60     	__u32 FormattedSize;
61     	unsigned char UnitSizeFactor;
62     } __attribute__((packed));
63     
64     #define MAX_ERASE_ZONES (8192 - 512)
65     
66     #define ERASE_MARK 0x3c69
67     #define SECTOR_FREE 0xff
68     #define SECTOR_USED 0x55
69     #define SECTOR_IGNORE 0x11
70     #define SECTOR_DELETED 0x00
71     
72     #define FOLD_MARK_IN_PROGRESS 0x5555
73     
74     #define ZONE_GOOD 0xff
75     #define ZONE_BAD_ORIGINAL 0
76     #define ZONE_BAD_MARKED 7
77     
78     #ifdef __KERNEL__
79     
80     /* these info are used in ReplUnitTable */
81     #define BLOCK_NIL          0xffff /* last block of a chain */
82     #define BLOCK_FREE         0xfffe /* free block */
83     #define BLOCK_NOTEXPLORED  0xfffd /* non explored block, only used during mounting */
84     #define BLOCK_RESERVED     0xfffc /* bios block or bad block */
85     
86     struct NFTLrecord {
87     	struct mtd_info *mtd;
88     	struct semaphore mutex;
89     	__u16 MediaUnit, SpareMediaUnit;
90     	__u32 EraseSize;
91     	struct NFTLMediaHeader MediaHdr;
92     	int usecount;
93     	unsigned char heads;
94     	unsigned char sectors;
95     	unsigned short cylinders;
96     	__u16 numvunits;
97     	__u16 lastEUN;                  /* should be suppressed */
98     	__u16 numfreeEUNs;
99     	__u16 LastFreeEUN; 		/* To speed up finding a free EUN */
100     	__u32 long nr_sects;
101     	int head,sect,cyl;
102     	__u16 *EUNtable; 		/* [numvunits]: First EUN for each virtual unit  */
103     	__u16 *ReplUnitTable; 		/* [numEUNs]: ReplUnitNumber for each */
104             unsigned int nb_blocks;		/* number of physical blocks */
105             unsigned int nb_boot_blocks;	/* number of blocks used by the bios */
106             struct erase_info instr;
107     };
108     
109     int NFTL_mount(struct NFTLrecord *s);
110     int NFTL_formatblock(struct NFTLrecord *s, int block);
111     
112     #ifndef NFTL_MAJOR
113     #define NFTL_MAJOR 93
114     #endif
115     
116     #define MAX_NFTLS 16
117     #define MAX_SECTORS_PER_UNIT 32
118     #define NFTL_PARTN_BITS 4
119     
120     #endif /* __KERNEL__ */
121     
122     #endif /* __MTD_NFTL_H__ */
123