Tom Rini | 8b0c8a1 | 2018-05-06 18:27:01 -0400 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL 2.0+ OR BSD-3-Clause */ |
Thomas Gleixner | 820d24d | 2016-07-12 20:28:12 +0200 | [diff] [blame] | 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> |
Thomas Gleixner | 820d24d | 2016-07-12 20:28:12 +0200 | [diff] [blame] | 10 | */ |
| 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 | /* |
| 20 | * Error codes returned by the I/O sub-system. |
| 21 | * |
| 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 |
| 31 | * |
| 32 | * UBI_FASTMAP_ANCHOR: u-boot SPL add on to tell the caller that the fastmap |
| 33 | * anchor block has been found |
| 34 | * |
| 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 |
| 38 | */ |
| 39 | enum { |
| 40 | UBI_IO_FF = 1, |
| 41 | UBI_IO_FF_BITFLIPS, |
| 42 | UBI_IO_BAD_HDR, |
| 43 | UBI_IO_BAD_HDR_EBADMSG, |
| 44 | UBI_IO_BITFLIPS, |
| 45 | UBI_FASTMAP_ANCHOR, |
| 46 | }; |
| 47 | |
| 48 | /* |
| 49 | * UBI volume type constants. |
| 50 | * |
| 51 | * @UBI_DYNAMIC_VOLUME: dynamic volume |
| 52 | * @UBI_STATIC_VOLUME: static volume |
| 53 | */ |
| 54 | enum { |
| 55 | UBI_DYNAMIC_VOLUME = 3, |
| 56 | UBI_STATIC_VOLUME = 4, |
| 57 | }; |
| 58 | |
| 59 | /* |
| 60 | * Return codes of the fastmap sub-system |
| 61 | * |
| 62 | * UBI_NO_FASTMAP: No fastmap super block was found |
| 63 | * UBI_BAD_FASTMAP: A fastmap was found but it's unusable |
| 64 | */ |
| 65 | enum { |
| 66 | UBI_NO_FASTMAP = 1, |
| 67 | UBI_BAD_FASTMAP, |
| 68 | }; |
| 69 | |
| 70 | /** |
| 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 |
| 77 | */ |
| 78 | struct ubi_fastmap_layout { |
| 79 | struct ubi_wl_entry *e[UBI_FM_MAX_BLOCKS]; |
| 80 | int to_be_tortured[UBI_FM_MAX_BLOCKS]; |
| 81 | int used_blocks; |
| 82 | int max_pool_size; |
| 83 | int max_wl_pool_size; |
| 84 | }; |
| 85 | |
| 86 | /** |
| 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 |
| 92 | * |
| 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. |
| 96 | * |
| 97 | */ |
| 98 | struct ubi_fm_pool { |
| 99 | int pebs[UBI_FM_MAX_POOL_SIZE]; |
| 100 | int used; |
| 101 | int size; |
| 102 | int max_size; |
| 103 | }; |
| 104 | |
| 105 | #endif |