1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26#include <ubi_uboot.h>
27
28#ifdef CONFIG_MTD_UBI_DEBUG_MSG
29
30#include "ubi.h"
31
32
33
34
35
36void ubi_dbg_dump_ec_hdr(const struct ubi_ec_hdr *ec_hdr)
37{
38 dbg_msg("erase counter header dump:");
39 dbg_msg("magic %#08x", be32_to_cpu(ec_hdr->magic));
40 dbg_msg("version %d", (int)ec_hdr->version);
41 dbg_msg("ec %llu", (long long)be64_to_cpu(ec_hdr->ec));
42 dbg_msg("vid_hdr_offset %d", be32_to_cpu(ec_hdr->vid_hdr_offset));
43 dbg_msg("data_offset %d", be32_to_cpu(ec_hdr->data_offset));
44 dbg_msg("hdr_crc %#08x", be32_to_cpu(ec_hdr->hdr_crc));
45 dbg_msg("erase counter header hexdump:");
46 print_hex_dump(KERN_DEBUG, "", DUMP_PREFIX_OFFSET, 32, 1,
47 ec_hdr, UBI_EC_HDR_SIZE, 1);
48}
49
50
51
52
53
54void ubi_dbg_dump_vid_hdr(const struct ubi_vid_hdr *vid_hdr)
55{
56 dbg_msg("volume identifier header dump:");
57 dbg_msg("magic %08x", be32_to_cpu(vid_hdr->magic));
58 dbg_msg("version %d", (int)vid_hdr->version);
59 dbg_msg("vol_type %d", (int)vid_hdr->vol_type);
60 dbg_msg("copy_flag %d", (int)vid_hdr->copy_flag);
61 dbg_msg("compat %d", (int)vid_hdr->compat);
62 dbg_msg("vol_id %d", be32_to_cpu(vid_hdr->vol_id));
63 dbg_msg("lnum %d", be32_to_cpu(vid_hdr->lnum));
64 dbg_msg("leb_ver %u", be32_to_cpu(vid_hdr->leb_ver));
65 dbg_msg("data_size %d", be32_to_cpu(vid_hdr->data_size));
66 dbg_msg("used_ebs %d", be32_to_cpu(vid_hdr->used_ebs));
67 dbg_msg("data_pad %d", be32_to_cpu(vid_hdr->data_pad));
68 dbg_msg("sqnum %llu",
69 (unsigned long long)be64_to_cpu(vid_hdr->sqnum));
70 dbg_msg("hdr_crc %08x", be32_to_cpu(vid_hdr->hdr_crc));
71 dbg_msg("volume identifier header hexdump:");
72}
73
74
75
76
77
78void ubi_dbg_dump_vol_info(const struct ubi_volume *vol)
79{
80 dbg_msg("volume information dump:");
81 dbg_msg("vol_id %d", vol->vol_id);
82 dbg_msg("reserved_pebs %d", vol->reserved_pebs);
83 dbg_msg("alignment %d", vol->alignment);
84 dbg_msg("data_pad %d", vol->data_pad);
85 dbg_msg("vol_type %d", vol->vol_type);
86 dbg_msg("name_len %d", vol->name_len);
87 dbg_msg("usable_leb_size %d", vol->usable_leb_size);
88 dbg_msg("used_ebs %d", vol->used_ebs);
89 dbg_msg("used_bytes %lld", vol->used_bytes);
90 dbg_msg("last_eb_bytes %d", vol->last_eb_bytes);
91 dbg_msg("corrupted %d", vol->corrupted);
92 dbg_msg("upd_marker %d", vol->upd_marker);
93
94 if (vol->name_len <= UBI_VOL_NAME_MAX &&
95 strnlen(vol->name, vol->name_len + 1) == vol->name_len) {
96 dbg_msg("name %s", vol->name);
97 } else {
98 dbg_msg("the 1st 5 characters of the name: %c%c%c%c%c",
99 vol->name[0], vol->name[1], vol->name[2],
100 vol->name[3], vol->name[4]);
101 }
102}
103
104
105
106
107
108
109void ubi_dbg_dump_vtbl_record(const struct ubi_vtbl_record *r, int idx)
110{
111 int name_len = be16_to_cpu(r->name_len);
112
113 dbg_msg("volume table record %d dump:", idx);
114 dbg_msg("reserved_pebs %d", be32_to_cpu(r->reserved_pebs));
115 dbg_msg("alignment %d", be32_to_cpu(r->alignment));
116 dbg_msg("data_pad %d", be32_to_cpu(r->data_pad));
117 dbg_msg("vol_type %d", (int)r->vol_type);
118 dbg_msg("upd_marker %d", (int)r->upd_marker);
119 dbg_msg("name_len %d", name_len);
120
121 if (r->name[0] == '\0') {
122 dbg_msg("name NULL");
123 return;
124 }
125
126 if (name_len <= UBI_VOL_NAME_MAX &&
127 strnlen(&r->name[0], name_len + 1) == name_len) {
128 dbg_msg("name %s", &r->name[0]);
129 } else {
130 dbg_msg("1st 5 characters of the name: %c%c%c%c%c",
131 r->name[0], r->name[1], r->name[2], r->name[3],
132 r->name[4]);
133 }
134 dbg_msg("crc %#08x", be32_to_cpu(r->crc));
135}
136
137
138
139
140
141void ubi_dbg_dump_sv(const struct ubi_scan_volume *sv)
142{
143 dbg_msg("volume scanning information dump:");
144 dbg_msg("vol_id %d", sv->vol_id);
145 dbg_msg("highest_lnum %d", sv->highest_lnum);
146 dbg_msg("leb_count %d", sv->leb_count);
147 dbg_msg("compat %d", sv->compat);
148 dbg_msg("vol_type %d", sv->vol_type);
149 dbg_msg("used_ebs %d", sv->used_ebs);
150 dbg_msg("last_data_size %d", sv->last_data_size);
151 dbg_msg("data_pad %d", sv->data_pad);
152}
153
154
155
156
157
158
159void ubi_dbg_dump_seb(const struct ubi_scan_leb *seb, int type)
160{
161 dbg_msg("eraseblock scanning information dump:");
162 dbg_msg("ec %d", seb->ec);
163 dbg_msg("pnum %d", seb->pnum);
164 if (type == 0) {
165 dbg_msg("lnum %d", seb->lnum);
166 dbg_msg("scrub %d", seb->scrub);
167 dbg_msg("sqnum %llu", seb->sqnum);
168 dbg_msg("leb_ver %u", seb->leb_ver);
169 }
170}
171
172
173
174
175
176void ubi_dbg_dump_mkvol_req(const struct ubi_mkvol_req *req)
177{
178 char nm[17];
179
180 dbg_msg("volume creation request dump:");
181 dbg_msg("vol_id %d", req->vol_id);
182 dbg_msg("alignment %d", req->alignment);
183 dbg_msg("bytes %lld", (long long)req->bytes);
184 dbg_msg("vol_type %d", req->vol_type);
185 dbg_msg("name_len %d", req->name_len);
186
187 memcpy(nm, req->name, 16);
188 nm[16] = 0;
189 dbg_msg("the 1st 16 characters of the name: %s", nm);
190}
191
192#endif
193