ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / include / linux / mtd / inftl.h
1 /*
2  *      inftl.h -- defines to support the Inverse NAND Flash Translation Layer
3  *
4  *      (C) Copyright 2002, Greg Ungerer (gerg@snapgear.com)
5  *
6  *      $Id: inftl.h,v 1.3 2003/05/23 11:35:34 dwmw2 Exp $
7  */
8
9 #ifndef __MTD_INFTL_H__
10 #define __MTD_INFTL_H__
11
12 #include <linux/mtd/blktrans.h>
13 #include <linux/mtd/mtd.h>
14 #include <linux/mtd/nftl.h>
15
16 #define OSAK_VERSION    0x5120
17 #define PERCENTUSED     98
18
19 #define SECTORSIZE      512
20
21 #ifndef INFTL_MAJOR
22 #define INFTL_MAJOR 93 /* FIXME */
23 #endif
24 #define INFTL_PARTN_BITS 4
25
26 /* Block Control Information */
27
28 struct inftl_bci {
29         __u8 ECCsig[6];
30         __u8 Status;
31         __u8 Status1;
32 } __attribute__((packed));
33
34 struct inftl_unithead1 {
35         __u16 virtualUnitNo;
36         __u16 prevUnitNo;
37         __u8 ANAC;
38         __u8 NACs;
39         __u8 parityPerField;
40         __u8 discarded;
41 } __attribute__((packed));
42
43 struct inftl_unithead2 {
44         __u8 parityPerField;
45         __u8 ANAC;
46         __u16 prevUnitNo;
47         __u16 virtualUnitNo;
48         __u8 NACs;
49         __u8 discarded;
50 } __attribute__((packed));
51
52 struct inftl_unittail {
53         __u8 Reserved[4];
54         __u16 EraseMark;
55         __u16 EraseMark1;
56 } __attribute__((packed));
57
58 union inftl_uci {
59         struct inftl_unithead1 a;
60         struct inftl_unithead2 b;
61         struct inftl_unittail c;
62 };
63
64 struct inftl_oob {
65         struct inftl_bci b;
66         union inftl_uci u;
67 };
68
69
70 /* INFTL Media Header */
71
72 struct INFTLPartition {
73         __u32 virtualUnits;
74         __u32 firstUnit;
75         __u32 lastUnit;
76         __u32 flags;
77         __u32 spareUnits;
78         __u32 Reserved0;
79         __u32 Reserved1;
80 } __attribute__((packed));
81
82 struct INFTLMediaHeader {
83         char bootRecordID[8];
84         __u32 NoOfBootImageBlocks;
85         __u32 NoOfBinaryPartitions;
86         __u32 NoOfBDTLPartitions;
87         __u32 BlockMultiplierBits;
88         __u32 FormatFlags;
89         __u32 OsakVersion;
90         __u32 PercentUsed;
91         struct INFTLPartition Partitions[4];
92 } __attribute__((packed));
93
94 /* Partition flag types */
95 #define INFTL_BINARY    0x20000000
96 #define INFTL_BDTL      0x40000000
97 #define INFTL_LAST      0x80000000
98
99
100 #ifdef __KERNEL__
101
102 struct INFTLrecord {
103         struct mtd_blktrans_dev mbd;
104         __u16 MediaUnit, SpareMediaUnit;
105         __u32 EraseSize;
106         struct INFTLMediaHeader MediaHdr;
107         int usecount;
108         unsigned char heads;
109         unsigned char sectors;
110         unsigned short cylinders;
111         __u16 numvunits;
112         __u16 firstEUN;
113         __u16 lastEUN;
114         __u16 numfreeEUNs;
115         __u16 LastFreeEUN;              /* To speed up finding a free EUN */
116         int head,sect,cyl;
117         __u16 *PUtable;                 /* Physical Unit Table  */
118         __u16 *VUtable;                 /* Virtual Unit Table */
119         unsigned int nb_blocks;         /* number of physical blocks */
120         unsigned int nb_boot_blocks;    /* number of blocks used by the bios */
121         struct erase_info instr;
122 };
123
124 int INFTL_mount(struct INFTLrecord *s);
125 int INFTL_formatblock(struct INFTLrecord *s, int block);
126
127 #endif /* __KERNEL__ */
128
129 #endif /* __MTD_INFTL_H__ */