1
2
3
4
5
6
7
8
9#ifndef __UBI_DEBUG_H__
10#define __UBI_DEBUG_H__
11
12void ubi_dump_flash(struct ubi_device *ubi, int pnum, int offset, int len);
13void ubi_dump_ec_hdr(const struct ubi_ec_hdr *ec_hdr);
14void ubi_dump_vid_hdr(const struct ubi_vid_hdr *vid_hdr);
15
16#ifndef __UBOOT__
17#include <linux/random.h>
18#endif
19
20#define ubi_assert(expr) do { \
21 if (unlikely(!(expr))) { \
22 pr_crit("UBI assert failed in %s at %u (pid %d)\n", \
23 __func__, __LINE__, current->pid); \
24 dump_stack(); \
25 } \
26} while (0)
27
28#define ubi_dbg_print_hex_dump(l, ps, pt, r, g, b, len, a) \
29 print_hex_dump(l, ps, pt, r, g, b, len, a)
30
31#define ubi_dbg_msg(type, fmt, ...) \
32 pr_debug("UBI DBG " type " (pid %d): " fmt "\n", current->pid, \
33 ##__VA_ARGS__)
34
35
36#define dbg_gen(fmt, ...) ubi_dbg_msg("gen", fmt, ##__VA_ARGS__)
37
38#define dbg_eba(fmt, ...) ubi_dbg_msg("eba", fmt, ##__VA_ARGS__)
39
40#define dbg_wl(fmt, ...) ubi_dbg_msg("wl", fmt, ##__VA_ARGS__)
41
42#define dbg_io(fmt, ...) ubi_dbg_msg("io", fmt, ##__VA_ARGS__)
43
44#define dbg_bld(fmt, ...) ubi_dbg_msg("bld", fmt, ##__VA_ARGS__)
45
46void ubi_dump_vol_info(const struct ubi_volume *vol);
47void ubi_dump_vtbl_record(const struct ubi_vtbl_record *r, int idx);
48void ubi_dump_av(const struct ubi_ainf_volume *av);
49void ubi_dump_aeb(const struct ubi_ainf_peb *aeb, int type);
50void ubi_dump_mkvol_req(const struct ubi_mkvol_req *req);
51int ubi_self_check_all_ff(struct ubi_device *ubi, int pnum, int offset,
52 int len);
53int ubi_debugfs_init(void);
54void ubi_debugfs_exit(void);
55int ubi_debugfs_init_dev(struct ubi_device *ubi);
56void ubi_debugfs_exit_dev(struct ubi_device *ubi);
57
58
59
60
61
62
63
64
65static inline int ubi_dbg_is_bgt_disabled(const struct ubi_device *ubi)
66{
67 return ubi->dbg.disable_bgt;
68}
69
70
71
72
73
74
75
76static inline int ubi_dbg_is_bitflip(const struct ubi_device *ubi)
77{
78 if (ubi->dbg.emulate_bitflips)
79 return !(prandom_u32() % 200);
80 return 0;
81}
82
83
84
85
86
87
88
89
90static inline int ubi_dbg_is_write_failure(const struct ubi_device *ubi)
91{
92 if (ubi->dbg.emulate_io_failures)
93 return !(prandom_u32() % 500);
94 return 0;
95}
96
97
98
99
100
101
102
103
104static inline int ubi_dbg_is_erase_failure(const struct ubi_device *ubi)
105{
106 if (ubi->dbg.emulate_io_failures)
107 return !(prandom_u32() % 400);
108 return 0;
109}
110
111static inline int ubi_dbg_chk_io(const struct ubi_device *ubi)
112{
113 return ubi->dbg.chk_io;
114}
115
116static inline int ubi_dbg_chk_gen(const struct ubi_device *ubi)
117{
118 return ubi->dbg.chk_gen;
119}
120
121static inline int ubi_dbg_chk_fastmap(const struct ubi_device *ubi)
122{
123 return ubi->dbg.chk_fastmap;
124}
125
126static inline void ubi_enable_dbg_chk_fastmap(struct ubi_device *ubi)
127{
128 ubi->dbg.chk_fastmap = 1;
129}
130
131int ubi_dbg_power_cut(struct ubi_device *ubi, int caller);
132#endif
133