/src/u-boot/drivers/mtd/ubi/debug.h
Line | Count | Source |
1 | | /* SPDX-License-Identifier: GPL-2.0+ */ |
2 | | /* |
3 | | * Copyright (c) International Business Machines Corp., 2006 |
4 | | * |
5 | | * Author: Artem Bityutskiy (Битюцкий Артём) |
6 | | */ |
7 | | |
8 | | #ifndef __UBI_DEBUG_H__ |
9 | | #define __UBI_DEBUG_H__ |
10 | | |
11 | | void ubi_dump_flash(struct ubi_device *ubi, int pnum, int offset, int len); |
12 | | void ubi_dump_ec_hdr(const struct ubi_ec_hdr *ec_hdr); |
13 | | void ubi_dump_vid_hdr(const struct ubi_vid_hdr *vid_hdr); |
14 | | |
15 | | #ifndef __UBOOT__ |
16 | | #include <linux/random.h> |
17 | | #endif |
18 | | |
19 | | #include <hexdump.h> |
20 | | #include <linux/printk.h> |
21 | | |
22 | | #ifndef __UBOOT__ |
23 | | #define ubi_assert(expr) do { \ |
24 | | if (unlikely(!(expr))) { \ |
25 | | pr_crit("UBI assert failed in %s at %u (pid %d)\n", \ |
26 | | __func__, __LINE__, current->pid); \ |
27 | | dump_stack(); \ |
28 | | } \ |
29 | | } while (0) |
30 | | #else |
31 | | #include <log.h> |
32 | | #define ubi_assert(expr) assert(expr) |
33 | | #endif |
34 | | |
35 | | #define ubi_dbg_print_hex_dump(ps, pt, r, g, b, len, a) \ |
36 | | print_hex_dump(ps, pt, r, g, b, len, a) |
37 | | |
38 | | #define ubi_dbg_msg(type, fmt, ...) \ |
39 | | pr_debug("UBI DBG " type " (pid %d): " fmt "\n", current->pid, \ |
40 | | ##__VA_ARGS__) |
41 | | |
42 | | /* General debugging messages */ |
43 | | #define dbg_gen(fmt, ...) ubi_dbg_msg("gen", fmt, ##__VA_ARGS__) |
44 | | /* Messages from the eraseblock association sub-system */ |
45 | | #define dbg_eba(fmt, ...) ubi_dbg_msg("eba", fmt, ##__VA_ARGS__) |
46 | | /* Messages from the wear-leveling sub-system */ |
47 | | #define dbg_wl(fmt, ...) ubi_dbg_msg("wl", fmt, ##__VA_ARGS__) |
48 | | /* Messages from the input/output sub-system */ |
49 | | #define dbg_io(fmt, ...) ubi_dbg_msg("io", fmt, ##__VA_ARGS__) |
50 | | /* Initialization and build messages */ |
51 | | #define dbg_bld(fmt, ...) ubi_dbg_msg("bld", fmt, ##__VA_ARGS__) |
52 | | |
53 | | void ubi_dump_vol_info(const struct ubi_volume *vol); |
54 | | void ubi_dump_vtbl_record(const struct ubi_vtbl_record *r, int idx); |
55 | | void ubi_dump_av(const struct ubi_ainf_volume *av); |
56 | | void ubi_dump_aeb(const struct ubi_ainf_peb *aeb, int type); |
57 | | void ubi_dump_mkvol_req(const struct ubi_mkvol_req *req); |
58 | | int ubi_self_check_all_ff(struct ubi_device *ubi, int pnum, int offset, |
59 | | int len); |
60 | | int ubi_debugfs_init(void); |
61 | | void ubi_debugfs_exit(void); |
62 | | int ubi_debugfs_init_dev(struct ubi_device *ubi); |
63 | | void ubi_debugfs_exit_dev(struct ubi_device *ubi); |
64 | | |
65 | | /** |
66 | | * ubi_dbg_is_bgt_disabled - if the background thread is disabled. |
67 | | * @ubi: UBI device description object |
68 | | * |
69 | | * Returns non-zero if the UBI background thread is disabled for testing |
70 | | * purposes. |
71 | | */ |
72 | | static inline int ubi_dbg_is_bgt_disabled(const struct ubi_device *ubi) |
73 | 0 | { |
74 | 0 | return ubi->dbg.disable_bgt; |
75 | 0 | } Unexecuted instantiation: mtdcore.c:ubi_dbg_is_bgt_disabled Unexecuted instantiation: mtdpart.c:ubi_dbg_is_bgt_disabled Unexecuted instantiation: rbtree.c:ubi_dbg_is_bgt_disabled Unexecuted instantiation: bch.c:ubi_dbg_is_bgt_disabled |
76 | | |
77 | | /** |
78 | | * ubi_dbg_is_bitflip - if it is time to emulate a bit-flip. |
79 | | * @ubi: UBI device description object |
80 | | * |
81 | | * Returns non-zero if a bit-flip should be emulated, otherwise returns zero. |
82 | | */ |
83 | | static inline int ubi_dbg_is_bitflip(const struct ubi_device *ubi) |
84 | 0 | { |
85 | 0 | if (ubi->dbg.emulate_bitflips) |
86 | 0 | return !(prandom_u32() % 200); |
87 | 0 | return 0; |
88 | 0 | } Unexecuted instantiation: mtdcore.c:ubi_dbg_is_bitflip Unexecuted instantiation: mtdpart.c:ubi_dbg_is_bitflip Unexecuted instantiation: rbtree.c:ubi_dbg_is_bitflip Unexecuted instantiation: bch.c:ubi_dbg_is_bitflip |
89 | | |
90 | | /** |
91 | | * ubi_dbg_is_write_failure - if it is time to emulate a write failure. |
92 | | * @ubi: UBI device description object |
93 | | * |
94 | | * Returns non-zero if a write failure should be emulated, otherwise returns |
95 | | * zero. |
96 | | */ |
97 | | static inline int ubi_dbg_is_write_failure(const struct ubi_device *ubi) |
98 | 0 | { |
99 | 0 | if (ubi->dbg.emulate_io_failures) |
100 | 0 | return !(prandom_u32() % 500); |
101 | 0 | return 0; |
102 | 0 | } Unexecuted instantiation: mtdcore.c:ubi_dbg_is_write_failure Unexecuted instantiation: mtdpart.c:ubi_dbg_is_write_failure Unexecuted instantiation: rbtree.c:ubi_dbg_is_write_failure Unexecuted instantiation: bch.c:ubi_dbg_is_write_failure |
103 | | |
104 | | /** |
105 | | * ubi_dbg_is_erase_failure - if its time to emulate an erase failure. |
106 | | * @ubi: UBI device description object |
107 | | * |
108 | | * Returns non-zero if an erase failure should be emulated, otherwise returns |
109 | | * zero. |
110 | | */ |
111 | | static inline int ubi_dbg_is_erase_failure(const struct ubi_device *ubi) |
112 | 0 | { |
113 | 0 | if (ubi->dbg.emulate_io_failures) |
114 | 0 | return !(prandom_u32() % 400); |
115 | 0 | return 0; |
116 | 0 | } Unexecuted instantiation: mtdcore.c:ubi_dbg_is_erase_failure Unexecuted instantiation: mtdpart.c:ubi_dbg_is_erase_failure Unexecuted instantiation: rbtree.c:ubi_dbg_is_erase_failure Unexecuted instantiation: bch.c:ubi_dbg_is_erase_failure |
117 | | |
118 | | static inline int ubi_dbg_chk_io(const struct ubi_device *ubi) |
119 | 0 | { |
120 | 0 | return ubi->dbg.chk_io; |
121 | 0 | } Unexecuted instantiation: mtdcore.c:ubi_dbg_chk_io Unexecuted instantiation: mtdpart.c:ubi_dbg_chk_io Unexecuted instantiation: rbtree.c:ubi_dbg_chk_io Unexecuted instantiation: bch.c:ubi_dbg_chk_io |
122 | | |
123 | | static inline int ubi_dbg_chk_gen(const struct ubi_device *ubi) |
124 | 0 | { |
125 | 0 | return ubi->dbg.chk_gen; |
126 | 0 | } Unexecuted instantiation: mtdcore.c:ubi_dbg_chk_gen Unexecuted instantiation: mtdpart.c:ubi_dbg_chk_gen Unexecuted instantiation: rbtree.c:ubi_dbg_chk_gen Unexecuted instantiation: bch.c:ubi_dbg_chk_gen |
127 | | |
128 | | static inline int ubi_dbg_chk_fastmap(const struct ubi_device *ubi) |
129 | 0 | { |
130 | 0 | return ubi->dbg.chk_fastmap; |
131 | 0 | } Unexecuted instantiation: mtdcore.c:ubi_dbg_chk_fastmap Unexecuted instantiation: mtdpart.c:ubi_dbg_chk_fastmap Unexecuted instantiation: rbtree.c:ubi_dbg_chk_fastmap Unexecuted instantiation: bch.c:ubi_dbg_chk_fastmap |
132 | | |
133 | | static inline void ubi_enable_dbg_chk_fastmap(struct ubi_device *ubi) |
134 | 0 | { |
135 | 0 | ubi->dbg.chk_fastmap = 1; |
136 | 0 | } Unexecuted instantiation: mtdcore.c:ubi_enable_dbg_chk_fastmap Unexecuted instantiation: mtdpart.c:ubi_enable_dbg_chk_fastmap Unexecuted instantiation: rbtree.c:ubi_enable_dbg_chk_fastmap Unexecuted instantiation: bch.c:ubi_enable_dbg_chk_fastmap |
137 | | |
138 | | int ubi_dbg_power_cut(struct ubi_device *ubi, int caller); |
139 | | #endif /* !__UBI_DEBUG_H__ */ |