Commit | Line | Data |
---|---|---|
968ab183 LT |
1 | #ifndef __KERNEL_PRINTK__ |
2 | #define __KERNEL_PRINTK__ | |
3 | ||
1b2c289b | 4 | #include <stdarg.h> |
162a7e75 | 5 | #include <linux/init.h> |
314ba352 | 6 | #include <linux/kern_levels.h> |
154c2670 | 7 | #include <linux/linkage.h> |
c28aa1f0 | 8 | #include <linux/cache.h> |
162a7e75 | 9 | |
968ab183 LT |
10 | extern const char linux_banner[]; |
11 | extern const char linux_proc_banner[]; | |
12 | ||
acc8fa41 JP |
13 | static inline int printk_get_level(const char *buffer) |
14 | { | |
04d2c8c8 | 15 | if (buffer[0] == KERN_SOH_ASCII && buffer[1]) { |
acc8fa41 JP |
16 | switch (buffer[1]) { |
17 | case '0' ... '7': | |
18 | case 'd': /* KERN_DEFAULT */ | |
acc8fa41 JP |
19 | return buffer[1]; |
20 | } | |
21 | } | |
22 | return 0; | |
23 | } | |
24 | ||
25 | static inline const char *printk_skip_level(const char *buffer) | |
26 | { | |
0185698c PM |
27 | if (printk_get_level(buffer)) |
28 | return buffer + 2; | |
29 | ||
acc8fa41 JP |
30 | return buffer; |
31 | } | |
32 | ||
d43ff430 TH |
33 | #define CONSOLE_EXT_LOG_MAX 8192 |
34 | ||
a8fe19eb | 35 | /* printk's without a loglevel use this.. */ |
42a9dc0b | 36 | #define MESSAGE_LOGLEVEL_DEFAULT CONFIG_MESSAGE_LOGLEVEL_DEFAULT |
a8fe19eb BP |
37 | |
38 | /* We show everything that is MORE important than this.. */ | |
39 | #define CONSOLE_LOGLEVEL_SILENT 0 /* Mum's the word */ | |
40 | #define CONSOLE_LOGLEVEL_MIN 1 /* Minimum loglevel we let people use */ | |
41 | #define CONSOLE_LOGLEVEL_QUIET 4 /* Shhh ..., when booted with "quiet" */ | |
42 | #define CONSOLE_LOGLEVEL_DEFAULT 7 /* anything MORE serious than KERN_DEBUG */ | |
43 | #define CONSOLE_LOGLEVEL_DEBUG 10 /* issue debug messages */ | |
44 | #define CONSOLE_LOGLEVEL_MOTORMOUTH 15 /* You can't shut this one up */ | |
45 | ||
968ab183 LT |
46 | extern int console_printk[]; |
47 | ||
48 | #define console_loglevel (console_printk[0]) | |
49 | #define default_message_loglevel (console_printk[1]) | |
50 | #define minimum_console_loglevel (console_printk[2]) | |
51 | #define default_console_loglevel (console_printk[3]) | |
52 | ||
a9747cc3 JP |
53 | static inline void console_silent(void) |
54 | { | |
a8fe19eb | 55 | console_loglevel = CONSOLE_LOGLEVEL_SILENT; |
a9747cc3 JP |
56 | } |
57 | ||
58 | static inline void console_verbose(void) | |
59 | { | |
60 | if (console_loglevel) | |
a8fe19eb | 61 | console_loglevel = CONSOLE_LOGLEVEL_MOTORMOUTH; |
a9747cc3 JP |
62 | } |
63 | ||
750afe7b BP |
64 | /* strlen("ratelimit") + 1 */ |
65 | #define DEVKMSG_STR_MAX_SIZE 10 | |
66 | extern char devkmsg_log_str[]; | |
67 | struct ctl_table; | |
68 | ||
968ab183 LT |
69 | struct va_format { |
70 | const char *fmt; | |
71 | va_list *va; | |
72 | }; | |
73 | ||
74 | /* | |
75 | * FW_BUG | |
76 | * Add this to a message where you are sure the firmware is buggy or behaves | |
77 | * really stupid or out of spec. Be aware that the responsible BIOS developer | |
78 | * should be able to fix this issue or at least get a concrete idea of the | |
79 | * problem by reading your message without the need of looking at the kernel | |
80 | * code. | |
81 | * | |
82 | * Use it for definite and high priority BIOS bugs. | |
83 | * | |
84 | * FW_WARN | |
85 | * Use it for not that clear (e.g. could the kernel messed up things already?) | |
86 | * and medium priority BIOS bugs. | |
87 | * | |
88 | * FW_INFO | |
89 | * Use this one if you want to tell the user or vendor about something | |
90 | * suspicious, but generally harmless related to the firmware. | |
91 | * | |
92 | * Use it for information or very low priority BIOS bugs. | |
93 | */ | |
94 | #define FW_BUG "[Firmware Bug]: " | |
95 | #define FW_WARN "[Firmware Warn]: " | |
96 | #define FW_INFO "[Firmware Info]: " | |
97 | ||
98 | /* | |
99 | * HW_ERR | |
100 | * Add this to a message for hardware errors, so that user can report | |
101 | * it to hardware vendor instead of LKML or software vendor. | |
102 | */ | |
103 | #define HW_ERR "[Hardware Error]: " | |
104 | ||
0a9a8bfd NH |
105 | /* |
106 | * DEPRECATED | |
107 | * Add this to a message whenever you want to warn user space about the use | |
108 | * of a deprecated aspect of an API so they can stop using it | |
109 | */ | |
110 | #define DEPRECATED "[Deprecated]: " | |
111 | ||
5264f2f7 JP |
112 | /* |
113 | * Dummy printk for disabled debugging statements to use whilst maintaining | |
fe22cd9b | 114 | * gcc's format checking. |
5264f2f7 | 115 | */ |
069f0cd0 BP |
116 | #define no_printk(fmt, ...) \ |
117 | ({ \ | |
118 | do { \ | |
119 | if (0) \ | |
120 | printk(fmt, ##__VA_ARGS__); \ | |
121 | } while (0); \ | |
122 | 0; \ | |
123 | }) | |
5264f2f7 | 124 | |
d0380e6c | 125 | #ifdef CONFIG_EARLY_PRINTK |
b9075fa9 | 126 | extern asmlinkage __printf(1, 2) |
5264f2f7 | 127 | void early_printk(const char *fmt, ...); |
d0380e6c TG |
128 | #else |
129 | static inline __printf(1, 2) __cold | |
130 | void early_printk(const char *s, ...) { } | |
131 | #endif | |
5264f2f7 | 132 | |
42a0bb3f PM |
133 | #ifdef CONFIG_PRINTK_NMI |
134 | extern void printk_nmi_init(void); | |
135 | extern void printk_nmi_enter(void); | |
136 | extern void printk_nmi_exit(void); | |
137 | extern void printk_nmi_flush(void); | |
cf9b1106 | 138 | extern void printk_nmi_flush_on_panic(void); |
42a0bb3f PM |
139 | #else |
140 | static inline void printk_nmi_init(void) { } | |
141 | static inline void printk_nmi_enter(void) { } | |
142 | static inline void printk_nmi_exit(void) { } | |
143 | static inline void printk_nmi_flush(void) { } | |
cf9b1106 | 144 | static inline void printk_nmi_flush_on_panic(void) { } |
42a0bb3f | 145 | #endif /* PRINTK_NMI */ |
04b74b27 | 146 | |
968ab183 | 147 | #ifdef CONFIG_PRINTK |
7ff9554b KS |
148 | asmlinkage __printf(5, 0) |
149 | int vprintk_emit(int facility, int level, | |
150 | const char *dict, size_t dictlen, | |
151 | const char *fmt, va_list args); | |
152 | ||
b9075fa9 | 153 | asmlinkage __printf(1, 0) |
5264f2f7 | 154 | int vprintk(const char *fmt, va_list args); |
7ff9554b KS |
155 | |
156 | asmlinkage __printf(5, 6) __cold | |
d487d575 SK |
157 | int printk_emit(int facility, int level, |
158 | const char *dict, size_t dictlen, | |
159 | const char *fmt, ...); | |
7ff9554b | 160 | |
b9075fa9 | 161 | asmlinkage __printf(1, 2) __cold |
5264f2f7 | 162 | int printk(const char *fmt, ...); |
968ab183 | 163 | |
3ccf3e83 | 164 | /* |
aac74dc4 | 165 | * Special printk facility for scheduler/timekeeping use only, _DO_NOT_USE_ ! |
3ccf3e83 | 166 | */ |
aac74dc4 | 167 | __printf(1, 2) __cold int printk_deferred(const char *fmt, ...); |
3ccf3e83 | 168 | |
968ab183 LT |
169 | /* |
170 | * Please don't use printk_ratelimit(), because it shares ratelimiting state | |
171 | * with all other unrelated printk_ratelimit() callsites. Instead use | |
172 | * printk_ratelimited() or plain old __ratelimit(). | |
173 | */ | |
174 | extern int __printk_ratelimit(const char *func); | |
175 | #define printk_ratelimit() __printk_ratelimit(__func__) | |
176 | extern bool printk_timed_ratelimit(unsigned long *caller_jiffies, | |
177 | unsigned int interval_msec); | |
178 | ||
179 | extern int printk_delay_msec; | |
180 | extern int dmesg_restrict; | |
455cd5ab | 181 | extern int kptr_restrict; |
968ab183 | 182 | |
750afe7b BP |
183 | extern int |
184 | devkmsg_sysctl_set_loglvl(struct ctl_table *table, int write, void __user *buf, | |
185 | size_t *lenp, loff_t *ppos); | |
186 | ||
dc72c32e FW |
187 | extern void wake_up_klogd(void); |
188 | ||
07261edb PK |
189 | char *log_buf_addr_get(void); |
190 | u32 log_buf_len_get(void); | |
968ab183 | 191 | void log_buf_kexec_setup(void); |
162a7e75 | 192 | void __init setup_log_buf(int early); |
8db14860 | 193 | __printf(1, 2) void dump_stack_set_arch_desc(const char *fmt, ...); |
196779b9 | 194 | void dump_stack_print_info(const char *log_lvl); |
a43cb95d | 195 | void show_regs_print_info(const char *log_lvl); |
968ab183 | 196 | #else |
b9075fa9 | 197 | static inline __printf(1, 0) |
5264f2f7 JP |
198 | int vprintk(const char *s, va_list args) |
199 | { | |
200 | return 0; | |
201 | } | |
b9075fa9 | 202 | static inline __printf(1, 2) __cold |
5264f2f7 JP |
203 | int printk(const char *s, ...) |
204 | { | |
205 | return 0; | |
206 | } | |
3ccf3e83 | 207 | static inline __printf(1, 2) __cold |
aac74dc4 | 208 | int printk_deferred(const char *s, ...) |
3ccf3e83 PZ |
209 | { |
210 | return 0; | |
211 | } | |
5264f2f7 JP |
212 | static inline int printk_ratelimit(void) |
213 | { | |
214 | return 0; | |
215 | } | |
216 | static inline bool printk_timed_ratelimit(unsigned long *caller_jiffies, | |
217 | unsigned int interval_msec) | |
218 | { | |
219 | return false; | |
220 | } | |
968ab183 | 221 | |
dc72c32e FW |
222 | static inline void wake_up_klogd(void) |
223 | { | |
224 | } | |
225 | ||
07261edb PK |
226 | static inline char *log_buf_addr_get(void) |
227 | { | |
228 | return NULL; | |
229 | } | |
230 | ||
231 | static inline u32 log_buf_len_get(void) | |
232 | { | |
233 | return 0; | |
234 | } | |
235 | ||
968ab183 LT |
236 | static inline void log_buf_kexec_setup(void) |
237 | { | |
238 | } | |
162a7e75 MT |
239 | |
240 | static inline void setup_log_buf(int early) | |
241 | { | |
242 | } | |
196779b9 | 243 | |
8db14860 | 244 | static inline __printf(1, 2) void dump_stack_set_arch_desc(const char *fmt, ...) |
98e5e1bf TH |
245 | { |
246 | } | |
247 | ||
196779b9 TH |
248 | static inline void dump_stack_print_info(const char *log_lvl) |
249 | { | |
250 | } | |
a43cb95d TH |
251 | |
252 | static inline void show_regs_print_info(const char *log_lvl) | |
253 | { | |
254 | } | |
968ab183 LT |
255 | #endif |
256 | ||
b6c035d0 | 257 | extern asmlinkage void dump_stack(void) __cold; |
968ab183 | 258 | |
968ab183 LT |
259 | #ifndef pr_fmt |
260 | #define pr_fmt(fmt) fmt | |
261 | #endif | |
262 | ||
6e099f55 DS |
263 | /* |
264 | * These can be used to print at the various log levels. | |
265 | * All of these will print unconditionally, although note that pr_debug() | |
266 | * and other debug macros are compiled out unless either DEBUG is defined | |
267 | * or CONFIG_DYNAMIC_DEBUG is set. | |
268 | */ | |
a0cba217 LT |
269 | #define pr_emerg(fmt, ...) \ |
270 | printk(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__) | |
271 | #define pr_alert(fmt, ...) \ | |
272 | printk(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__) | |
273 | #define pr_crit(fmt, ...) \ | |
274 | printk(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__) | |
275 | #define pr_err(fmt, ...) \ | |
276 | printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__) | |
277 | #define pr_warning(fmt, ...) \ | |
278 | printk(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__) | |
279 | #define pr_warn pr_warning | |
280 | #define pr_notice(fmt, ...) \ | |
281 | printk(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__) | |
282 | #define pr_info(fmt, ...) \ | |
283 | printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__) | |
7b1460ec SR |
284 | /* |
285 | * Like KERN_CONT, pr_cont() should only be used when continuing | |
286 | * a line with no newline ('\n') enclosed. Otherwise it defaults | |
287 | * back to KERN_DEFAULT. | |
288 | */ | |
968ab183 LT |
289 | #define pr_cont(fmt, ...) \ |
290 | printk(KERN_CONT fmt, ##__VA_ARGS__) | |
291 | ||
292 | /* pr_devel() should produce zero code unless DEBUG is defined */ | |
293 | #ifdef DEBUG | |
294 | #define pr_devel(fmt, ...) \ | |
295 | printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) | |
296 | #else | |
297 | #define pr_devel(fmt, ...) \ | |
5264f2f7 | 298 | no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) |
968ab183 LT |
299 | #endif |
300 | ||
29fc2bc7 | 301 | |
968ab183 | 302 | /* If you are writing a driver, please use dev_dbg instead */ |
b558c96f | 303 | #if defined(CONFIG_DYNAMIC_DEBUG) |
9d5059c9 LB |
304 | #include <linux/dynamic_debug.h> |
305 | ||
968ab183 LT |
306 | /* dynamic_pr_debug() uses pr_fmt() internally so we don't need it here */ |
307 | #define pr_debug(fmt, ...) \ | |
308 | dynamic_pr_debug(fmt, ##__VA_ARGS__) | |
b558c96f JC |
309 | #elif defined(DEBUG) |
310 | #define pr_debug(fmt, ...) \ | |
311 | printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) | |
968ab183 LT |
312 | #else |
313 | #define pr_debug(fmt, ...) \ | |
5264f2f7 | 314 | no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) |
968ab183 LT |
315 | #endif |
316 | ||
16cb839f JP |
317 | /* |
318 | * Print a one-time message (analogous to WARN_ONCE() et al): | |
319 | */ | |
320 | ||
321 | #ifdef CONFIG_PRINTK | |
c28aa1f0 JP |
322 | #define printk_once(fmt, ...) \ |
323 | ({ \ | |
324 | static bool __print_once __read_mostly; \ | |
069f0cd0 | 325 | bool __ret_print_once = !__print_once; \ |
c28aa1f0 JP |
326 | \ |
327 | if (!__print_once) { \ | |
328 | __print_once = true; \ | |
329 | printk(fmt, ##__VA_ARGS__); \ | |
330 | } \ | |
069f0cd0 | 331 | unlikely(__ret_print_once); \ |
16cb839f | 332 | }) |
c224815d JS |
333 | #define printk_deferred_once(fmt, ...) \ |
334 | ({ \ | |
335 | static bool __print_once __read_mostly; \ | |
069f0cd0 | 336 | bool __ret_print_once = !__print_once; \ |
c224815d JS |
337 | \ |
338 | if (!__print_once) { \ | |
339 | __print_once = true; \ | |
340 | printk_deferred(fmt, ##__VA_ARGS__); \ | |
341 | } \ | |
069f0cd0 | 342 | unlikely(__ret_print_once); \ |
c224815d | 343 | }) |
16cb839f | 344 | #else |
c28aa1f0 | 345 | #define printk_once(fmt, ...) \ |
16cb839f | 346 | no_printk(fmt, ##__VA_ARGS__) |
c224815d JS |
347 | #define printk_deferred_once(fmt, ...) \ |
348 | no_printk(fmt, ##__VA_ARGS__) | |
16cb839f JP |
349 | #endif |
350 | ||
351 | #define pr_emerg_once(fmt, ...) \ | |
352 | printk_once(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__) | |
353 | #define pr_alert_once(fmt, ...) \ | |
354 | printk_once(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__) | |
355 | #define pr_crit_once(fmt, ...) \ | |
356 | printk_once(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__) | |
357 | #define pr_err_once(fmt, ...) \ | |
358 | printk_once(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__) | |
359 | #define pr_warn_once(fmt, ...) \ | |
360 | printk_once(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__) | |
361 | #define pr_notice_once(fmt, ...) \ | |
362 | printk_once(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__) | |
363 | #define pr_info_once(fmt, ...) \ | |
364 | printk_once(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__) | |
365 | #define pr_cont_once(fmt, ...) \ | |
366 | printk_once(KERN_CONT pr_fmt(fmt), ##__VA_ARGS__) | |
36d308d8 MG |
367 | |
368 | #if defined(DEBUG) | |
369 | #define pr_devel_once(fmt, ...) \ | |
370 | printk_once(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) | |
371 | #else | |
372 | #define pr_devel_once(fmt, ...) \ | |
373 | no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) | |
374 | #endif | |
375 | ||
16cb839f JP |
376 | /* If you are writing a driver, please use dev_dbg instead */ |
377 | #if defined(DEBUG) | |
378 | #define pr_debug_once(fmt, ...) \ | |
379 | printk_once(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) | |
380 | #else | |
381 | #define pr_debug_once(fmt, ...) \ | |
382 | no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) | |
383 | #endif | |
384 | ||
968ab183 LT |
385 | /* |
386 | * ratelimited messages with local ratelimit_state, | |
387 | * no local ratelimit_state used in the !PRINTK case | |
388 | */ | |
389 | #ifdef CONFIG_PRINTK | |
6ec42a56 JP |
390 | #define printk_ratelimited(fmt, ...) \ |
391 | ({ \ | |
968ab183 LT |
392 | static DEFINE_RATELIMIT_STATE(_rs, \ |
393 | DEFAULT_RATELIMIT_INTERVAL, \ | |
394 | DEFAULT_RATELIMIT_BURST); \ | |
395 | \ | |
396 | if (__ratelimit(&_rs)) \ | |
397 | printk(fmt, ##__VA_ARGS__); \ | |
398 | }) | |
399 | #else | |
6ec42a56 JP |
400 | #define printk_ratelimited(fmt, ...) \ |
401 | no_printk(fmt, ##__VA_ARGS__) | |
968ab183 LT |
402 | #endif |
403 | ||
6ec42a56 | 404 | #define pr_emerg_ratelimited(fmt, ...) \ |
968ab183 | 405 | printk_ratelimited(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__) |
6ec42a56 | 406 | #define pr_alert_ratelimited(fmt, ...) \ |
968ab183 | 407 | printk_ratelimited(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__) |
6ec42a56 | 408 | #define pr_crit_ratelimited(fmt, ...) \ |
968ab183 | 409 | printk_ratelimited(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__) |
6ec42a56 | 410 | #define pr_err_ratelimited(fmt, ...) \ |
968ab183 | 411 | printk_ratelimited(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__) |
6ec42a56 | 412 | #define pr_warn_ratelimited(fmt, ...) \ |
968ab183 | 413 | printk_ratelimited(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__) |
6ec42a56 | 414 | #define pr_notice_ratelimited(fmt, ...) \ |
968ab183 | 415 | printk_ratelimited(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__) |
6ec42a56 | 416 | #define pr_info_ratelimited(fmt, ...) \ |
968ab183 LT |
417 | printk_ratelimited(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__) |
418 | /* no pr_cont_ratelimited, don't do that... */ | |
36d308d8 MG |
419 | |
420 | #if defined(DEBUG) | |
421 | #define pr_devel_ratelimited(fmt, ...) \ | |
422 | printk_ratelimited(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) | |
423 | #else | |
424 | #define pr_devel_ratelimited(fmt, ...) \ | |
425 | no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) | |
426 | #endif | |
427 | ||
968ab183 | 428 | /* If you are writing a driver, please use dev_dbg instead */ |
29fc2bc7 JP |
429 | #if defined(CONFIG_DYNAMIC_DEBUG) |
430 | /* descriptor check is first to prevent flooding with "callbacks suppressed" */ | |
431 | #define pr_debug_ratelimited(fmt, ...) \ | |
432 | do { \ | |
433 | static DEFINE_RATELIMIT_STATE(_rs, \ | |
434 | DEFAULT_RATELIMIT_INTERVAL, \ | |
435 | DEFAULT_RATELIMIT_BURST); \ | |
515a9adc | 436 | DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, pr_fmt(fmt)); \ |
29fc2bc7 JP |
437 | if (unlikely(descriptor.flags & _DPRINTK_FLAGS_PRINT) && \ |
438 | __ratelimit(&_rs)) \ | |
515a9adc | 439 | __dynamic_pr_debug(&descriptor, pr_fmt(fmt), ##__VA_ARGS__); \ |
29fc2bc7 JP |
440 | } while (0) |
441 | #elif defined(DEBUG) | |
6ec42a56 | 442 | #define pr_debug_ratelimited(fmt, ...) \ |
968ab183 LT |
443 | printk_ratelimited(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) |
444 | #else | |
445 | #define pr_debug_ratelimited(fmt, ...) \ | |
5264f2f7 | 446 | no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) |
968ab183 LT |
447 | #endif |
448 | ||
e11fea92 KS |
449 | extern const struct file_operations kmsg_fops; |
450 | ||
ac83ed68 JP |
451 | enum { |
452 | DUMP_PREFIX_NONE, | |
453 | DUMP_PREFIX_ADDRESS, | |
454 | DUMP_PREFIX_OFFSET | |
455 | }; | |
114fc1af AS |
456 | extern int hex_dump_to_buffer(const void *buf, size_t len, int rowsize, |
457 | int groupsize, char *linebuf, size_t linebuflen, | |
458 | bool ascii); | |
ac83ed68 JP |
459 | #ifdef CONFIG_PRINTK |
460 | extern void print_hex_dump(const char *level, const char *prefix_str, | |
461 | int prefix_type, int rowsize, int groupsize, | |
462 | const void *buf, size_t len, bool ascii); | |
7a555613 VK |
463 | #if defined(CONFIG_DYNAMIC_DEBUG) |
464 | #define print_hex_dump_bytes(prefix_str, prefix_type, buf, len) \ | |
465 | dynamic_hex_dump(prefix_str, prefix_type, 16, 1, buf, len, true) | |
466 | #else | |
ac83ed68 JP |
467 | extern void print_hex_dump_bytes(const char *prefix_str, int prefix_type, |
468 | const void *buf, size_t len); | |
7a555613 | 469 | #endif /* defined(CONFIG_DYNAMIC_DEBUG) */ |
ac83ed68 JP |
470 | #else |
471 | static inline void print_hex_dump(const char *level, const char *prefix_str, | |
472 | int prefix_type, int rowsize, int groupsize, | |
473 | const void *buf, size_t len, bool ascii) | |
474 | { | |
475 | } | |
476 | static inline void print_hex_dump_bytes(const char *prefix_str, int prefix_type, | |
477 | const void *buf, size_t len) | |
478 | { | |
479 | } | |
480 | ||
481 | #endif | |
482 | ||
7a555613 VK |
483 | #if defined(CONFIG_DYNAMIC_DEBUG) |
484 | #define print_hex_dump_debug(prefix_str, prefix_type, rowsize, \ | |
485 | groupsize, buf, len, ascii) \ | |
486 | dynamic_hex_dump(prefix_str, prefix_type, rowsize, \ | |
487 | groupsize, buf, len, ascii) | |
cdf17449 | 488 | #elif defined(DEBUG) |
7a555613 VK |
489 | #define print_hex_dump_debug(prefix_str, prefix_type, rowsize, \ |
490 | groupsize, buf, len, ascii) \ | |
491 | print_hex_dump(KERN_DEBUG, prefix_str, prefix_type, rowsize, \ | |
492 | groupsize, buf, len, ascii) | |
cdf17449 LW |
493 | #else |
494 | static inline void print_hex_dump_debug(const char *prefix_str, int prefix_type, | |
495 | int rowsize, int groupsize, | |
496 | const void *buf, size_t len, bool ascii) | |
497 | { | |
498 | } | |
499 | #endif | |
7a555613 | 500 | |
968ab183 | 501 | #endif |