drivers: power: report battery voltage in AOSP compatible format
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / drivers / mtd / ubi / ubi-media.h
CommitLineData
801c135c
AB
1/*
2 * Copyright (c) International Business Machines Corp., 2006
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
12 * the 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 * Authors: Artem Bityutskiy (Битюцкий Артём)
19 * Thomas Gleixner
20 * Frank Haverkamp
21 * Oliver Lohmann
22 * Andreas Arnez
23 */
24
25/*
26 * This file defines the layout of UBI headers and all the other UBI on-flash
92a74f1c 27 * data structures.
801c135c
AB
28 */
29
92a74f1c
AB
30#ifndef __UBI_MEDIA_H__
31#define __UBI_MEDIA_H__
801c135c 32
6fa3eb70
S
33#ifdef CONFIG_MTK_MLC_NAND_SUPPORT
34#define CONFIG_BLB 1
35#endif
36
801c135c
AB
37#include <asm/byteorder.h>
38
39/* The version of UBI images supported by this implementation */
40#define UBI_VERSION 1
41
42/* The highest erase counter value supported by this implementation */
43#define UBI_MAX_ERASECOUNTER 0x7FFFFFFF
44
45/* The initial CRC32 value used when calculating CRC checksums */
46#define UBI_CRC32_INIT 0xFFFFFFFFU
47
48/* Erase counter header magic number (ASCII "UBI#") */
49#define UBI_EC_HDR_MAGIC 0x55424923
50/* Volume identifier header magic number (ASCII "UBI!") */
51#define UBI_VID_HDR_MAGIC 0x55424921
52
53/*
54 * Volume type constants used in the volume identifier header.
55 *
56 * @UBI_VID_DYNAMIC: dynamic volume
57 * @UBI_VID_STATIC: static volume
58 */
59enum {
60 UBI_VID_DYNAMIC = 1,
61 UBI_VID_STATIC = 2
62};
63
4ccf8cff
AB
64/*
65 * Volume flags used in the volume table record.
66 *
67 * @UBI_VTBL_AUTORESIZE_FLG: auto-resize this volume
68 *
69 * %UBI_VTBL_AUTORESIZE_FLG flag can be set only for one volume in the volume
70 * table. UBI automatically re-sizes the volume which has this flag and makes
71 * the volume to be of largest possible size. This means that if after the
72 * initialization UBI finds out that there are available physical eraseblocks
73 * present on the device, it automatically appends all of them to the volume
74 * (the physical eraseblocks reserved for bad eraseblocks handling and other
75 * reserved physical eraseblocks are not taken). So, if there is a volume with
76 * the %UBI_VTBL_AUTORESIZE_FLG flag set, the amount of available logical
77 * eraseblocks will be zero after UBI is loaded, because all of them will be
78 * reserved for this volume. Note, the %UBI_VTBL_AUTORESIZE_FLG bit is cleared
79 * after the volume had been initialized.
80 *
81 * The auto-resize feature is useful for device production purposes. For
82 * example, different NAND flash chips may have different amount of initial bad
83 * eraseblocks, depending of particular chip instance. Manufacturers of NAND
84 * chips usually guarantee that the amount of initial bad eraseblocks does not
85 * exceed certain percent, e.g. 2%. When one creates an UBI image which will be
86 * flashed to the end devices in production, he does not know the exact amount
87 * of good physical eraseblocks the NAND chip on the device will have, but this
88 * number is required to calculate the volume sized and put them to the volume
89 * table of the UBI image. In this case, one of the volumes (e.g., the one
90 * which will store the root file system) is marked as "auto-resizable", and
91 * UBI will adjust its size on the first boot if needed.
92 *
93 * Note, first UBI reserves some amount of physical eraseblocks for bad
94 * eraseblock handling, and then re-sizes the volume, not vice-versa. This
95 * means that the pool of reserved physical eraseblocks will always be present.
96 */
97enum {
98 UBI_VTBL_AUTORESIZE_FLG = 0x01,
99};
100
801c135c
AB
101/*
102 * Compatibility constants used by internal volumes.
103 *
104 * @UBI_COMPAT_DELETE: delete this internal volume before anything is written
85c6e6e2 105 * to the flash
801c135c
AB
106 * @UBI_COMPAT_RO: attach this device in read-only mode
107 * @UBI_COMPAT_PRESERVE: preserve this internal volume - do not touch its
85c6e6e2
AB
108 * physical eraseblocks, don't allow the wear-leveling
109 * sub-system to move them
801c135c
AB
110 * @UBI_COMPAT_REJECT: reject this UBI image
111 */
112enum {
113 UBI_COMPAT_DELETE = 1,
114 UBI_COMPAT_RO = 2,
115 UBI_COMPAT_PRESERVE = 4,
116 UBI_COMPAT_REJECT = 5
117};
118
801c135c
AB
119/* Sizes of UBI headers */
120#define UBI_EC_HDR_SIZE sizeof(struct ubi_ec_hdr)
121#define UBI_VID_HDR_SIZE sizeof(struct ubi_vid_hdr)
122
123/* Sizes of UBI headers without the ending CRC */
3261ebd7
CH
124#define UBI_EC_HDR_SIZE_CRC (UBI_EC_HDR_SIZE - sizeof(__be32))
125#define UBI_VID_HDR_SIZE_CRC (UBI_VID_HDR_SIZE - sizeof(__be32))
801c135c
AB
126
127/**
128 * struct ubi_ec_hdr - UBI erase counter header.
129 * @magic: erase counter header magic number (%UBI_EC_HDR_MAGIC)
130 * @version: version of UBI implementation which is supposed to accept this
85c6e6e2 131 * UBI image
801c135c
AB
132 * @padding1: reserved for future, zeroes
133 * @ec: the erase counter
134 * @vid_hdr_offset: where the VID header starts
135 * @data_offset: where the user data start
0c6c7fa1 136 * @image_seq: image sequence number
801c135c
AB
137 * @padding2: reserved for future, zeroes
138 * @hdr_crc: erase counter header CRC checksum
139 *
140 * The erase counter header takes 64 bytes and has a plenty of unused space for
141 * future usage. The unused fields are zeroed. The @version field is used to
142 * indicate the version of UBI implementation which is supposed to be able to
025dfdaf 143 * work with this UBI image. If @version is greater than the current UBI
801c135c
AB
144 * version, the image is rejected. This may be useful in future if something
145 * is changed radically. This field is duplicated in the volume identifier
146 * header.
147 *
148 * The @vid_hdr_offset and @data_offset fields contain the offset of the the
149 * volume identifier header and user data, relative to the beginning of the
150 * physical eraseblock. These values have to be the same for all physical
151 * eraseblocks.
0c6c7fa1
AH
152 *
153 * The @image_seq field is used to validate a UBI image that has been prepared
154 * for a UBI device. The @image_seq value can be any value, but it must be the
155 * same on all eraseblocks. UBI will ensure that all new erase counter headers
fbd0107f 156 * also contain this value, and will check the value when attaching the flash.
0c6c7fa1
AH
157 * One way to make use of @image_seq is to increase its value by one every time
158 * an image is flashed over an existing image, then, if the flashing does not
fbd0107f 159 * complete, UBI will detect the error when attaching the media.
801c135c
AB
160 */
161struct ubi_ec_hdr {
3261ebd7
CH
162 __be32 magic;
163 __u8 version;
164 __u8 padding1[3];
165 __be64 ec; /* Warning: the current limit is 31-bit anyway! */
166 __be32 vid_hdr_offset;
167 __be32 data_offset;
0c6c7fa1
AH
168 __be32 image_seq;
169 __u8 padding2[32];
3261ebd7 170 __be32 hdr_crc;
3627924a 171} __packed;
801c135c
AB
172
173/**
174 * struct ubi_vid_hdr - on-flash UBI volume identifier header.
175 * @magic: volume identifier header magic number (%UBI_VID_HDR_MAGIC)
176 * @version: UBI implementation version which is supposed to accept this UBI
85c6e6e2 177 * image (%UBI_VERSION)
801c135c
AB
178 * @vol_type: volume type (%UBI_VID_DYNAMIC or %UBI_VID_STATIC)
179 * @copy_flag: if this logical eraseblock was copied from another physical
85c6e6e2 180 * eraseblock (for wear-leveling reasons)
801c135c 181 * @compat: compatibility of this volume (%0, %UBI_COMPAT_DELETE,
85c6e6e2 182 * %UBI_COMPAT_IGNORE, %UBI_COMPAT_PRESERVE, or %UBI_COMPAT_REJECT)
801c135c
AB
183 * @vol_id: ID of this volume
184 * @lnum: logical eraseblock number
9869cd80 185 * @padding1: reserved for future, zeroes
801c135c
AB
186 * @data_size: how many bytes of data this logical eraseblock contains
187 * @used_ebs: total number of used logical eraseblocks in this volume
188 * @data_pad: how many bytes at the end of this physical eraseblock are not
85c6e6e2 189 * used
801c135c 190 * @data_crc: CRC checksum of the data stored in this logical eraseblock
801c135c 191 * @padding2: reserved for future, zeroes
9869cd80
AB
192 * @sqnum: sequence number
193 * @padding3: reserved for future, zeroes
801c135c
AB
194 * @hdr_crc: volume identifier header CRC checksum
195 *
196 * The @sqnum is the value of the global sequence counter at the time when this
197 * VID header was created. The global sequence counter is incremented each time
198 * UBI writes a new VID header to the flash, i.e. when it maps a logical
199 * eraseblock to a new physical eraseblock. The global sequence counter is an
200 * unsigned 64-bit integer and we assume it never overflows. The @sqnum
201 * (sequence number) is used to distinguish between older and newer versions of
202 * logical eraseblocks.
203 *
025dfdaf 204 * There are 2 situations when there may be more than one physical eraseblock
801c135c
AB
205 * corresponding to the same logical eraseblock, i.e., having the same @vol_id
206 * and @lnum values in the volume identifier header. Suppose we have a logical
207 * eraseblock L and it is mapped to the physical eraseblock P.
208 *
209 * 1. Because UBI may erase physical eraseblocks asynchronously, the following
210 * situation is possible: L is asynchronously erased, so P is scheduled for
211 * erasure, then L is written to,i.e. mapped to another physical eraseblock P1,
212 * so P1 is written to, then an unclean reboot happens. Result - there are 2
213 * physical eraseblocks P and P1 corresponding to the same logical eraseblock
214 * L. But P1 has greater sequence number, so UBI picks P1 when it attaches the
215 * flash.
216 *
217 * 2. From time to time UBI moves logical eraseblocks to other physical
218 * eraseblocks for wear-leveling reasons. If, for example, UBI moves L from P
219 * to P1, and an unclean reboot happens before P is physically erased, there
220 * are two physical eraseblocks P and P1 corresponding to L and UBI has to
221 * select one of them when the flash is attached. The @sqnum field says which
222 * PEB is the original (obviously P will have lower @sqnum) and the copy. But
223 * it is not enough to select the physical eraseblock with the higher sequence
224 * number, because the unclean reboot could have happen in the middle of the
225 * copying process, so the data in P is corrupted. It is also not enough to
226 * just select the physical eraseblock with lower sequence number, because the
227 * data there may be old (consider a case if more data was added to P1 after
228 * the copying). Moreover, the unclean reboot may happen when the erasure of P
229 * was just started, so it result in unstable P, which is "mostly" OK, but
230 * still has unstable bits.
231 *
232 * UBI uses the @copy_flag field to indicate that this logical eraseblock is a
233 * copy. UBI also calculates data CRC when the data is moved and stores it at
234 * the @data_crc field of the copy (P1). So when UBI needs to pick one physical
235 * eraseblock of two (P or P1), the @copy_flag of the newer one (P1) is
236 * examined. If it is cleared, the situation* is simple and the newer one is
237 * picked. If it is set, the data CRC of the copy (P1) is examined. If the CRC
238 * checksum is correct, this physical eraseblock is selected (P1). Otherwise
239 * the older one (P) is selected.
240 *
801c135c
AB
241 * There are 2 sorts of volumes in UBI: user volumes and internal volumes.
242 * Internal volumes are not seen from outside and are used for various internal
243 * UBI purposes. In this implementation there is only one internal volume - the
244 * layout volume. Internal volumes are the main mechanism of UBI extensions.
245 * For example, in future one may introduce a journal internal volume. Internal
246 * volumes have their own reserved range of IDs.
247 *
248 * The @compat field is only used for internal volumes and contains the "degree
249 * of their compatibility". It is always zero for user volumes. This field
250 * provides a mechanism to introduce UBI extensions and to be still compatible
251 * with older UBI binaries. For example, if someone introduced a journal in
252 * future, he would probably use %UBI_COMPAT_DELETE compatibility for the
253 * journal volume. And in this case, older UBI binaries, which know nothing
254 * about the journal volume, would just delete this volume and work perfectly
255 * fine. This is similar to what Ext2fs does when it is fed by an Ext3fs image
256 * - it just ignores the Ext3fs journal.
257 *
258 * The @data_crc field contains the CRC checksum of the contents of the logical
259 * eraseblock if this is a static volume. In case of dynamic volumes, it does
260 * not contain the CRC checksum as a rule. The only exception is when the
85c6e6e2
AB
261 * data of the physical eraseblock was moved by the wear-leveling sub-system,
262 * then the wear-leveling sub-system calculates the data CRC and stores it in
263 * the @data_crc field. And of course, the @copy_flag is %in this case.
801c135c
AB
264 *
265 * The @data_size field is used only for static volumes because UBI has to know
266 * how many bytes of data are stored in this eraseblock. For dynamic volumes,
267 * this field usually contains zero. The only exception is when the data of the
268 * physical eraseblock was moved to another physical eraseblock for
269 * wear-leveling reasons. In this case, UBI calculates CRC checksum of the
270 * contents and uses both @data_crc and @data_size fields. In this case, the
271 * @data_size field contains data size.
272 *
273 * The @used_ebs field is used only for static volumes and indicates how many
274 * eraseblocks the data of the volume takes. For dynamic volumes this field is
275 * not used and always contains zero.
276 *
277 * The @data_pad is calculated when volumes are created using the alignment
278 * parameter. So, effectively, the @data_pad field reduces the size of logical
279 * eraseblocks of this volume. This is very handy when one uses block-oriented
280 * software (say, cramfs) on top of the UBI volume.
281 */
282struct ubi_vid_hdr {
3261ebd7
CH
283 __be32 magic;
284 __u8 version;
285 __u8 vol_type;
286 __u8 copy_flag;
287 __u8 compat;
288 __be32 vol_id;
289 __be32 lnum;
9869cd80 290 __u8 padding1[4];
3261ebd7
CH
291 __be32 data_size;
292 __be32 used_ebs;
293 __be32 data_pad;
294 __be32 data_crc;
9869cd80 295 __u8 padding2[4];
3261ebd7 296 __be64 sqnum;
9869cd80 297 __u8 padding3[12];
3261ebd7 298 __be32 hdr_crc;
3627924a 299} __packed;
801c135c
AB
300
301/* Internal UBI volumes count */
6fa3eb70
S
302#ifdef CONFIG_BLB
303#define UBI_INT_VOL_COUNT 2
304#else
801c135c 305#define UBI_INT_VOL_COUNT 1
6fa3eb70 306#endif
801c135c
AB
307
308/*
5cc09420
JR
309 * Starting ID of internal volumes: 0x7fffefff.
310 * There is reserved room for 4096 internal volumes.
801c135c
AB
311 */
312#define UBI_INTERNAL_VOL_START (0x7FFFFFFF - 4096)
313
314/* The layout volume contains the volume table */
315
91f2d53c
AB
316#define UBI_LAYOUT_VOLUME_ID UBI_INTERNAL_VOL_START
317#define UBI_LAYOUT_VOLUME_TYPE UBI_VID_DYNAMIC
318#define UBI_LAYOUT_VOLUME_ALIGN 1
801c135c
AB
319#define UBI_LAYOUT_VOLUME_EBS 2
320#define UBI_LAYOUT_VOLUME_NAME "layout volume"
321#define UBI_LAYOUT_VOLUME_COMPAT UBI_COMPAT_REJECT
322
6fa3eb70
S
323/* The backup volume contains LSB page backup */
324#ifdef CONFIG_BLB
325#define UBI_BACKUP_VOLUME_ID (UBI_LAYOUT_VOLUME_ID+1)
326#define UBI_BACKUP_VOLUME_TYPE UBI_VID_DYNAMIC
327#define UBI_BACKUP_VOLUME_ALIGN 1
328#define UBI_BACKUP_VOLUME_EBS 2
329#define UBI_BACKUP_VOLUME_NAME "backup volume"
330#define UBI_BACKUP_VOLUME_COMPAT 0//UBI_COMPAT_REJECT
331#endif
332
801c135c
AB
333/* The maximum number of volumes per one UBI device */
334#define UBI_MAX_VOLUMES 128
335
336/* The maximum volume name length */
337#define UBI_VOL_NAME_MAX 127
338
339/* Size of the volume table record */
340#define UBI_VTBL_RECORD_SIZE sizeof(struct ubi_vtbl_record)
341
342/* Size of the volume table record without the ending CRC */
3261ebd7 343#define UBI_VTBL_RECORD_SIZE_CRC (UBI_VTBL_RECORD_SIZE - sizeof(__be32))
801c135c
AB
344
345/**
346 * struct ubi_vtbl_record - a record in the volume table.
347 * @reserved_pebs: how many physical eraseblocks are reserved for this volume
348 * @alignment: volume alignment
349 * @data_pad: how many bytes are unused at the end of the each physical
350 * eraseblock to satisfy the requested alignment
351 * @vol_type: volume type (%UBI_DYNAMIC_VOLUME or %UBI_STATIC_VOLUME)
352 * @upd_marker: if volume update was started but not finished
353 * @name_len: volume name length
354 * @name: the volume name
4ccf8cff
AB
355 * @flags: volume flags (%UBI_VTBL_AUTORESIZE_FLG)
356 * @padding: reserved, zeroes
801c135c
AB
357 * @crc: a CRC32 checksum of the record
358 *
359 * The volume table records are stored in the volume table, which is stored in
360 * the layout volume. The layout volume consists of 2 logical eraseblock, each
361 * of which contains a copy of the volume table (i.e., the volume table is
362 * duplicated). The volume table is an array of &struct ubi_vtbl_record
363 * objects indexed by the volume ID.
364 *
365 * If the size of the logical eraseblock is large enough to fit
366 * %UBI_MAX_VOLUMES records, the volume table contains %UBI_MAX_VOLUMES
367 * records. Otherwise, it contains as many records as it can fit (i.e., size of
368 * logical eraseblock divided by sizeof(struct ubi_vtbl_record)).
369 *
370 * The @upd_marker flag is used to implement volume update. It is set to %1
371 * before update and set to %0 after the update. So if the update operation was
372 * interrupted, UBI knows that the volume is corrupted.
373 *
374 * The @alignment field is specified when the volume is created and cannot be
375 * later changed. It may be useful, for example, when a block-oriented file
376 * system works on top of UBI. The @data_pad field is calculated using the
377 * logical eraseblock size and @alignment. The alignment must be multiple to the
378 * minimal flash I/O unit. If @alignment is 1, all the available space of
379 * the physical eraseblocks is used.
380 *
381 * Empty records contain all zeroes and the CRC checksum of those zeroes.
382 */
383struct ubi_vtbl_record {
3261ebd7
CH
384 __be32 reserved_pebs;
385 __be32 alignment;
386 __be32 data_pad;
387 __u8 vol_type;
388 __u8 upd_marker;
389 __be16 name_len;
390 __u8 name[UBI_VOL_NAME_MAX+1];
4ccf8cff
AB
391 __u8 flags;
392 __u8 padding[23];
3261ebd7 393 __be32 crc;
3627924a 394} __packed;
801c135c 395
6fa3eb70
S
396#ifdef CONFIG_BLB
397struct ubi_blb_spare {
398 __be16 pnum;
399 __be16 lnum;
400 __be16 num;
401 __be16 page;
402 __be32 vol_id;
403 __be64 sqnum;
404 __be32 crc;
405} __attribute__ ((packed));
406#endif
407
1c865749
RW
408/* UBI fastmap on-flash data structures */
409
6fa3eb70
S
410#define UBI_FM_SB_VOLUME_ID (UBI_LAYOUT_VOLUME_ID + 2)
411#define UBI_FM_DATA_VOLUME_ID (UBI_LAYOUT_VOLUME_ID + 3)
1c865749
RW
412
413/* fastmap on-flash data structure format version */
414#define UBI_FM_FMT_VERSION 1
415
416#define UBI_FM_SB_MAGIC 0x7B11D69F
417#define UBI_FM_HDR_MAGIC 0xD4B82EF7
418#define UBI_FM_VHDR_MAGIC 0xFA370ED1
419#define UBI_FM_POOL_MAGIC 0x67AF4D08
420#define UBI_FM_EBA_MAGIC 0xf0c040a8
421
422/* A fastmap supber block can be located between PEB 0 and
423 * UBI_FM_MAX_START */
424#define UBI_FM_MAX_START 64
425
426/* A fastmap can use up to UBI_FM_MAX_BLOCKS PEBs */
427#define UBI_FM_MAX_BLOCKS 32
428
429/* 5% of the total number of PEBs have to be scanned while attaching
430 * from a fastmap.
431 * But the size of this pool is limited to be between UBI_FM_MIN_POOL_SIZE and
432 * UBI_FM_MAX_POOL_SIZE */
433#define UBI_FM_MIN_POOL_SIZE 8
434#define UBI_FM_MAX_POOL_SIZE 256
435
436#define UBI_FM_WL_POOL_SIZE 25
437
438/**
439 * struct ubi_fm_sb - UBI fastmap super block
440 * @magic: fastmap super block magic number (%UBI_FM_SB_MAGIC)
441 * @version: format version of this fastmap
442 * @data_crc: CRC over the fastmap data
443 * @used_blocks: number of PEBs used by this fastmap
444 * @block_loc: an array containing the location of all PEBs of the fastmap
445 * @block_ec: the erase counter of each used PEB
446 * @sqnum: highest sequence number value at the time while taking the fastmap
447 *
448 */
449struct ubi_fm_sb {
450 __be32 magic;
451 __u8 version;
452 __u8 padding1[3];
453 __be32 data_crc;
454 __be32 used_blocks;
455 __be32 block_loc[UBI_FM_MAX_BLOCKS];
456 __be32 block_ec[UBI_FM_MAX_BLOCKS];
457 __be64 sqnum;
458 __u8 padding2[32];
459} __packed;
460
461/**
462 * struct ubi_fm_hdr - header of the fastmap data set
463 * @magic: fastmap header magic number (%UBI_FM_HDR_MAGIC)
464 * @free_peb_count: number of free PEBs known by this fastmap
465 * @used_peb_count: number of used PEBs known by this fastmap
466 * @scrub_peb_count: number of to be scrubbed PEBs known by this fastmap
467 * @bad_peb_count: number of bad PEBs known by this fastmap
468 * @erase_peb_count: number of bad PEBs which have to be erased
469 * @vol_count: number of UBI volumes known by this fastmap
470 */
471struct ubi_fm_hdr {
472 __be32 magic;
473 __be32 free_peb_count;
474 __be32 used_peb_count;
475 __be32 scrub_peb_count;
476 __be32 bad_peb_count;
477 __be32 erase_peb_count;
478 __be32 vol_count;
479 __u8 padding[4];
480} __packed;
481
482/* struct ubi_fm_hdr is followed by two struct ubi_fm_scan_pool */
483
484/**
485 * struct ubi_fm_scan_pool - Fastmap pool PEBs to be scanned while attaching
486 * @magic: pool magic numer (%UBI_FM_POOL_MAGIC)
487 * @size: current pool size
488 * @max_size: maximal pool size
489 * @pebs: an array containing the location of all PEBs in this pool
490 */
491struct ubi_fm_scan_pool {
492 __be32 magic;
493 __be16 size;
494 __be16 max_size;
495 __be32 pebs[UBI_FM_MAX_POOL_SIZE];
496 __be32 padding[4];
497} __packed;
498
499/* ubi_fm_scan_pool is followed by nfree+nused struct ubi_fm_ec records */
500
501/**
502 * struct ubi_fm_ec - stores the erase counter of a PEB
503 * @pnum: PEB number
504 * @ec: ec of this PEB
505 */
506struct ubi_fm_ec {
507 __be32 pnum;
508 __be32 ec;
509} __packed;
510
511/**
512 * struct ubi_fm_volhdr - Fastmap volume header
513 * it identifies the start of an eba table
514 * @magic: Fastmap volume header magic number (%UBI_FM_VHDR_MAGIC)
515 * @vol_id: volume id of the fastmapped volume
516 * @vol_type: type of the fastmapped volume
517 * @data_pad: data_pad value of the fastmapped volume
518 * @used_ebs: number of used LEBs within this volume
519 * @last_eb_bytes: number of bytes used in the last LEB
520 */
521struct ubi_fm_volhdr {
522 __be32 magic;
523 __be32 vol_id;
524 __u8 vol_type;
525 __u8 padding1[3];
526 __be32 data_pad;
527 __be32 used_ebs;
528 __be32 last_eb_bytes;
529 __u8 padding2[8];
530} __packed;
531
532/* struct ubi_fm_volhdr is followed by one struct ubi_fm_eba records */
533
534/**
535 * struct ubi_fm_eba - denotes an association beween a PEB and LEB
536 * @magic: EBA table magic number
537 * @reserved_pebs: number of table entries
538 * @pnum: PEB number of LEB (LEB is the index)
539 */
540struct ubi_fm_eba {
541 __be32 magic;
542 __be32 reserved_pebs;
543 __be32 pnum[0];
544} __packed;
92a74f1c 545#endif /* !__UBI_MEDIA_H__ */