ubi-wrapper.h 2.9 KB

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