diff options
-rw-r--r-- | drivers/mtd/ubi/ubi-media.h | 137 |
1 files changed, 137 insertions, 0 deletions
diff --git a/drivers/mtd/ubi/ubi-media.h b/drivers/mtd/ubi/ubi-media.h index 468ffbc0eabd..ac2b24d1783d 100644 --- a/drivers/mtd/ubi/ubi-media.h +++ b/drivers/mtd/ubi/ubi-media.h | |||
@@ -375,4 +375,141 @@ struct ubi_vtbl_record { | |||
375 | __be32 crc; | 375 | __be32 crc; |
376 | } __packed; | 376 | } __packed; |
377 | 377 | ||
378 | /* UBI fastmap on-flash data structures */ | ||
379 | |||
380 | #define UBI_FM_SB_VOLUME_ID (UBI_LAYOUT_VOLUME_ID + 1) | ||
381 | #define UBI_FM_DATA_VOLUME_ID (UBI_LAYOUT_VOLUME_ID + 2) | ||
382 | |||
383 | /* fastmap on-flash data structure format version */ | ||
384 | #define UBI_FM_FMT_VERSION 1 | ||
385 | |||
386 | #define UBI_FM_SB_MAGIC 0x7B11D69F | ||
387 | #define UBI_FM_HDR_MAGIC 0xD4B82EF7 | ||
388 | #define UBI_FM_VHDR_MAGIC 0xFA370ED1 | ||
389 | #define UBI_FM_POOL_MAGIC 0x67AF4D08 | ||
390 | #define UBI_FM_EBA_MAGIC 0xf0c040a8 | ||
391 | |||
392 | /* A fastmap supber block can be located between PEB 0 and | ||
393 | * UBI_FM_MAX_START */ | ||
394 | #define UBI_FM_MAX_START 64 | ||
395 | |||
396 | /* A fastmap can use up to UBI_FM_MAX_BLOCKS PEBs */ | ||
397 | #define UBI_FM_MAX_BLOCKS 32 | ||
398 | |||
399 | /* 5% of the total number of PEBs have to be scanned while attaching | ||
400 | * from a fastmap. | ||
401 | * But the size of this pool is limited to be between UBI_FM_MIN_POOL_SIZE and | ||
402 | * UBI_FM_MAX_POOL_SIZE */ | ||
403 | #define UBI_FM_MIN_POOL_SIZE 8 | ||
404 | #define UBI_FM_MAX_POOL_SIZE 256 | ||
405 | |||
406 | #define UBI_FM_WL_POOL_SIZE 25 | ||
407 | |||
408 | /** | ||
409 | * struct ubi_fm_sb - UBI fastmap super block | ||
410 | * @magic: fastmap super block magic number (%UBI_FM_SB_MAGIC) | ||
411 | * @version: format version of this fastmap | ||
412 | * @data_crc: CRC over the fastmap data | ||
413 | * @used_blocks: number of PEBs used by this fastmap | ||
414 | * @block_loc: an array containing the location of all PEBs of the fastmap | ||
415 | * @block_ec: the erase counter of each used PEB | ||
416 | * @sqnum: highest sequence number value at the time while taking the fastmap | ||
417 | * | ||
418 | */ | ||
419 | struct ubi_fm_sb { | ||
420 | __be32 magic; | ||
421 | __u8 version; | ||
422 | __u8 padding1[3]; | ||
423 | __be32 data_crc; | ||
424 | __be32 used_blocks; | ||
425 | __be32 block_loc[UBI_FM_MAX_BLOCKS]; | ||
426 | __be32 block_ec[UBI_FM_MAX_BLOCKS]; | ||
427 | __be64 sqnum; | ||
428 | __u8 padding2[32]; | ||
429 | } __packed; | ||
430 | |||
431 | /** | ||
432 | * struct ubi_fm_hdr - header of the fastmap data set | ||
433 | * @magic: fastmap header magic number (%UBI_FM_HDR_MAGIC) | ||
434 | * @free_peb_count: number of free PEBs known by this fastmap | ||
435 | * @used_peb_count: number of used PEBs known by this fastmap | ||
436 | * @scrub_peb_count: number of to be scrubbed PEBs known by this fastmap | ||
437 | * @bad_peb_count: number of bad PEBs known by this fastmap | ||
438 | * @erase_peb_count: number of bad PEBs which have to be erased | ||
439 | * @vol_count: number of UBI volumes known by this fastmap | ||
440 | */ | ||
441 | struct ubi_fm_hdr { | ||
442 | __be32 magic; | ||
443 | __be32 free_peb_count; | ||
444 | __be32 used_peb_count; | ||
445 | __be32 scrub_peb_count; | ||
446 | __be32 bad_peb_count; | ||
447 | __be32 erase_peb_count; | ||
448 | __be32 vol_count; | ||
449 | __u8 padding[4]; | ||
450 | } __packed; | ||
451 | |||
452 | /* struct ubi_fm_hdr is followed by two struct ubi_fm_scan_pool */ | ||
453 | |||
454 | /** | ||
455 | * struct ubi_fm_scan_pool - Fastmap pool PEBs to be scanned while attaching | ||
456 | * @magic: pool magic numer (%UBI_FM_POOL_MAGIC) | ||
457 | * @size: current pool size | ||
458 | * @max_size: maximal pool size | ||
459 | * @pebs: an array containing the location of all PEBs in this pool | ||
460 | */ | ||
461 | struct ubi_fm_scan_pool { | ||
462 | __be32 magic; | ||
463 | __be16 size; | ||
464 | __be16 max_size; | ||
465 | __be32 pebs[UBI_FM_MAX_POOL_SIZE]; | ||
466 | __be32 padding[4]; | ||
467 | } __packed; | ||
468 | |||
469 | /* ubi_fm_scan_pool is followed by nfree+nused struct ubi_fm_ec records */ | ||
470 | |||
471 | /** | ||
472 | * struct ubi_fm_ec - stores the erase counter of a PEB | ||
473 | * @pnum: PEB number | ||
474 | * @ec: ec of this PEB | ||
475 | */ | ||
476 | struct ubi_fm_ec { | ||
477 | __be32 pnum; | ||
478 | __be32 ec; | ||
479 | } __packed; | ||
480 | |||
481 | /** | ||
482 | * struct ubi_fm_volhdr - Fastmap volume header | ||
483 | * it identifies the start of an eba table | ||
484 | * @magic: Fastmap volume header magic number (%UBI_FM_VHDR_MAGIC) | ||
485 | * @vol_id: volume id of the fastmapped volume | ||
486 | * @vol_type: type of the fastmapped volume | ||
487 | * @data_pad: data_pad value of the fastmapped volume | ||
488 | * @used_ebs: number of used LEBs within this volume | ||
489 | * @last_eb_bytes: number of bytes used in the last LEB | ||
490 | */ | ||
491 | struct ubi_fm_volhdr { | ||
492 | __be32 magic; | ||
493 | __be32 vol_id; | ||
494 | __u8 vol_type; | ||
495 | __u8 padding1[3]; | ||
496 | __be32 data_pad; | ||
497 | __be32 used_ebs; | ||
498 | __be32 last_eb_bytes; | ||
499 | __u8 padding2[8]; | ||
500 | } __packed; | ||
501 | |||
502 | /* struct ubi_fm_volhdr is followed by one struct ubi_fm_eba records */ | ||
503 | |||
504 | /** | ||
505 | * struct ubi_fm_eba - denotes an association beween a PEB and LEB | ||
506 | * @magic: EBA table magic number | ||
507 | * @reserved_pebs: number of table entries | ||
508 | * @pnum: PEB number of LEB (LEB is the index) | ||
509 | */ | ||
510 | struct ubi_fm_eba { | ||
511 | __be32 magic; | ||
512 | __be32 reserved_pebs; | ||
513 | __be32 pnum[0]; | ||
514 | } __packed; | ||
378 | #endif /* !__UBI_MEDIA_H__ */ | 515 | #endif /* !__UBI_MEDIA_H__ */ |