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