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