ubi-wrapper.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /*
  2. * The parts taken from the kernel implementation are:
  3. *
  4. * Copyright (c) International Business Machines Corp., 2006
  5. *
  6. * UBISPL specific defines:
  7. *
  8. * Copyright (c) Thomas Gleixner <tglx@linutronix.de>
  9. *
  10. * SPDX-License-Identifier: GPL 2.0+ BSD-3-Clause
  11. */
  12. /*
  13. * Contains various defines copy&pasted from ubi.h and ubi-user.h to make
  14. * the upstream fastboot code happy.
  15. */
  16. #ifndef __UBOOT_UBI_WRAPPER_H
  17. #define __UBOOT_UBI_WRAPPER_H
  18. /*
  19. * Error codes returned by the I/O sub-system.
  20. *
  21. * UBI_IO_FF: the read region of flash contains only 0xFFs
  22. * UBI_IO_FF_BITFLIPS: the same as %UBI_IO_FF, but also also there was a data
  23. * integrity error reported by the MTD driver
  24. * (uncorrectable ECC error in case of NAND)
  25. * UBI_IO_BAD_HDR: the EC or VID header is corrupted (bad magic or CRC)
  26. * UBI_IO_BAD_HDR_EBADMSG: the same as %UBI_IO_BAD_HDR, but also there was a
  27. * data integrity error reported by the MTD driver
  28. * (uncorrectable ECC error in case of NAND)
  29. * UBI_IO_BITFLIPS: bit-flips were detected and corrected
  30. *
  31. * UBI_FASTMAP_ANCHOR: u-boot SPL add on to tell the caller that the fastmap
  32. * anchor block has been found
  33. *
  34. * Note, it is probably better to have bit-flip and ebadmsg as flags which can
  35. * be or'ed with other error code. But this is a big change because there are
  36. * may callers, so it does not worth the risk of introducing a bug
  37. */
  38. enum {
  39. UBI_IO_FF = 1,
  40. UBI_IO_FF_BITFLIPS,
  41. UBI_IO_BAD_HDR,
  42. UBI_IO_BAD_HDR_EBADMSG,
  43. UBI_IO_BITFLIPS,
  44. UBI_FASTMAP_ANCHOR,
  45. };
  46. /*
  47. * UBI volume type constants.
  48. *
  49. * @UBI_DYNAMIC_VOLUME: dynamic volume
  50. * @UBI_STATIC_VOLUME: static volume
  51. */
  52. enum {
  53. UBI_DYNAMIC_VOLUME = 3,
  54. UBI_STATIC_VOLUME = 4,
  55. };
  56. /*
  57. * Return codes of the fastmap sub-system
  58. *
  59. * UBI_NO_FASTMAP: No fastmap super block was found
  60. * UBI_BAD_FASTMAP: A fastmap was found but it's unusable
  61. */
  62. enum {
  63. UBI_NO_FASTMAP = 1,
  64. UBI_BAD_FASTMAP,
  65. };
  66. /**
  67. * struct ubi_fastmap_layout - in-memory fastmap data structure.
  68. * @e: PEBs used by the current fastmap
  69. * @to_be_tortured: if non-zero tortured this PEB
  70. * @used_blocks: number of used PEBs
  71. * @max_pool_size: maximal size of the user pool
  72. * @max_wl_pool_size: maximal size of the pool used by the WL sub-system
  73. */
  74. struct ubi_fastmap_layout {
  75. struct ubi_wl_entry *e[UBI_FM_MAX_BLOCKS];
  76. int to_be_tortured[UBI_FM_MAX_BLOCKS];
  77. int used_blocks;
  78. int max_pool_size;
  79. int max_wl_pool_size;
  80. };
  81. /**
  82. * struct ubi_fm_pool - in-memory fastmap pool
  83. * @pebs: PEBs in this pool
  84. * @used: number of used PEBs
  85. * @size: total number of PEBs in this pool
  86. * @max_size: maximal size of the pool
  87. *
  88. * A pool gets filled with up to max_size.
  89. * If all PEBs within the pool are used a new fastmap will be written
  90. * to the flash and the pool gets refilled with empty PEBs.
  91. *
  92. */
  93. struct ubi_fm_pool {
  94. int pebs[UBI_FM_MAX_POOL_SIZE];
  95. int used;
  96. int size;
  97. int max_size;
  98. };
  99. #endif