xref: /linux-6.15/include/linux/mtd/ftl.h (revision 3854be77)
11da177e4SLinus Torvalds /*
21da177e4SLinus Torvalds  * Derived from (and probably identical to):
31da177e4SLinus Torvalds  * ftl.h 1.7 1999/10/25 20:23:17
41da177e4SLinus Torvalds  *
51da177e4SLinus Torvalds  * The contents of this file are subject to the Mozilla Public License
61da177e4SLinus Torvalds  * Version 1.1 (the "License"); you may not use this file except in
71da177e4SLinus Torvalds  * compliance with the License. You may obtain a copy of the License
81da177e4SLinus Torvalds  * at http://www.mozilla.org/MPL/
91da177e4SLinus Torvalds  *
101da177e4SLinus Torvalds  * Software distributed under the License is distributed on an "AS IS"
111da177e4SLinus Torvalds  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
121da177e4SLinus Torvalds  * the License for the specific language governing rights and
131da177e4SLinus Torvalds  * limitations under the License.
141da177e4SLinus Torvalds  *
151da177e4SLinus Torvalds  * The initial developer of the original code is David A. Hinds
161da177e4SLinus Torvalds  * <[email protected]>.  Portions created by David A. Hinds
171da177e4SLinus Torvalds  * are Copyright (C) 1999 David A. Hinds.  All Rights Reserved.
181da177e4SLinus Torvalds  *
191da177e4SLinus Torvalds  * Alternatively, the contents of this file may be used under the
201da177e4SLinus Torvalds  * terms of the GNU General Public License version 2 (the "GPL"), in
211da177e4SLinus Torvalds  * which case the provisions of the GPL are applicable instead of the
221da177e4SLinus Torvalds  * above.  If you wish to allow the use of your version of this file
231da177e4SLinus Torvalds  * only under the terms of the GPL and not to allow others to use
241da177e4SLinus Torvalds  * your version of this file under the MPL, indicate your decision by
251da177e4SLinus Torvalds  * deleting the provisions above and replace them with the notice and
261da177e4SLinus Torvalds  * other provisions required by the GPL.  If you do not delete the
271da177e4SLinus Torvalds  * provisions above, a recipient may use your version of this file
281da177e4SLinus Torvalds  * under either the MPL or the GPL.
291da177e4SLinus Torvalds  */
301da177e4SLinus Torvalds 
311da177e4SLinus Torvalds #ifndef _LINUX_FTL_H
321da177e4SLinus Torvalds #define _LINUX_FTL_H
331da177e4SLinus Torvalds 
341da177e4SLinus Torvalds typedef struct erase_unit_header_t {
35*3854be77SDavid Woodhouse     uint8_t	LinkTargetTuple[5];
36*3854be77SDavid Woodhouse     uint8_t	DataOrgTuple[10];
37*3854be77SDavid Woodhouse     uint8_t	NumTransferUnits;
38*3854be77SDavid Woodhouse     uint32_t	EraseCount;
39*3854be77SDavid Woodhouse     uint16_t	LogicalEUN;
40*3854be77SDavid Woodhouse     uint8_t	BlockSize;
41*3854be77SDavid Woodhouse     uint8_t	EraseUnitSize;
42*3854be77SDavid Woodhouse     uint16_t	FirstPhysicalEUN;
43*3854be77SDavid Woodhouse     uint16_t	NumEraseUnits;
44*3854be77SDavid Woodhouse     uint32_t	FormattedSize;
45*3854be77SDavid Woodhouse     uint32_t	FirstVMAddress;
46*3854be77SDavid Woodhouse     uint16_t	NumVMPages;
47*3854be77SDavid Woodhouse     uint8_t	Flags;
48*3854be77SDavid Woodhouse     uint8_t	Code;
49*3854be77SDavid Woodhouse     uint32_t	SerialNumber;
50*3854be77SDavid Woodhouse     uint32_t	AltEUHOffset;
51*3854be77SDavid Woodhouse     uint32_t	BAMOffset;
52*3854be77SDavid Woodhouse     uint8_t	Reserved[12];
53*3854be77SDavid Woodhouse     uint8_t	EndTuple[2];
541da177e4SLinus Torvalds } erase_unit_header_t;
551da177e4SLinus Torvalds 
561da177e4SLinus Torvalds /* Flags in erase_unit_header_t */
571da177e4SLinus Torvalds #define HIDDEN_AREA		0x01
581da177e4SLinus Torvalds #define REVERSE_POLARITY	0x02
591da177e4SLinus Torvalds #define DOUBLE_BAI		0x04
601da177e4SLinus Torvalds 
611da177e4SLinus Torvalds /* Definitions for block allocation information */
621da177e4SLinus Torvalds 
631da177e4SLinus Torvalds #define BLOCK_FREE(b)		((b) == 0xffffffff)
641da177e4SLinus Torvalds #define BLOCK_DELETED(b)	(((b) == 0) || ((b) == 0xfffffffe))
651da177e4SLinus Torvalds 
661da177e4SLinus Torvalds #define BLOCK_TYPE(b)		((b) & 0x7f)
671da177e4SLinus Torvalds #define BLOCK_ADDRESS(b)	((b) & ~0x7f)
681da177e4SLinus Torvalds #define BLOCK_NUMBER(b)		((b) >> 9)
691da177e4SLinus Torvalds #define BLOCK_CONTROL		0x30
701da177e4SLinus Torvalds #define BLOCK_DATA		0x40
711da177e4SLinus Torvalds #define BLOCK_REPLACEMENT	0x60
721da177e4SLinus Torvalds #define BLOCK_BAD		0x70
731da177e4SLinus Torvalds 
741da177e4SLinus Torvalds #endif /* _LINUX_FTL_H */
75