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