blob: 319ff7e53efbc1f0bd551125bd70951c2a8c83ea [file] [log] [blame]
Linus Torvalds968ab182010-11-15 13:37:37 -08001#ifndef __KERNEL_PRINTK__
2#define __KERNEL_PRINTK__
3
Andrew Morton1b2c2892013-04-29 16:17:19 -07004#include <stdarg.h>
Mike Travis162a7e72011-05-24 17:13:20 -07005#include <linux/init.h>
Joe Perches314ba352012-07-30 14:40:11 -07006#include <linux/kern_levels.h>
Ralf Baechle154c2672013-05-21 10:51:10 +02007#include <linux/linkage.h>
Joe Perchesc28aa1f2014-01-23 15:54:16 -08008#include <linux/cache.h>
Mike Travis162a7e72011-05-24 17:13:20 -07009
Linus Torvalds968ab182010-11-15 13:37:37 -080010extern const char linux_banner[];
11extern const char linux_proc_banner[];
12
Joe Perchesacc8fa412012-07-30 14:40:09 -070013static inline int printk_get_level(const char *buffer)
14{
Joe Perches04d2c8c2012-07-30 14:40:17 -070015 if (buffer[0] == KERN_SOH_ASCII && buffer[1]) {
Joe Perchesacc8fa412012-07-30 14:40:09 -070016 switch (buffer[1]) {
17 case '0' ... '7':
18 case 'd': /* KERN_DEFAULT */
Joe Perchesacc8fa412012-07-30 14:40:09 -070019 return buffer[1];
20 }
21 }
22 return 0;
23}
24
25static inline const char *printk_skip_level(const char *buffer)
26{
Petr Mladek01856982014-04-03 14:48:38 -070027 if (printk_get_level(buffer))
28 return buffer + 2;
29
Joe Perchesacc8fa412012-07-30 14:40:09 -070030 return buffer;
31}
32
Borislav Petkova8fe19e2014-06-04 16:11:46 -070033/* printk's without a loglevel use this.. */
34#define DEFAULT_MESSAGE_LOGLEVEL CONFIG_DEFAULT_MESSAGE_LOGLEVEL
35
36/* We show everything that is MORE important than this.. */
37#define CONSOLE_LOGLEVEL_SILENT 0 /* Mum's the word */
38#define CONSOLE_LOGLEVEL_MIN 1 /* Minimum loglevel we let people use */
39#define CONSOLE_LOGLEVEL_QUIET 4 /* Shhh ..., when booted with "quiet" */
40#define CONSOLE_LOGLEVEL_DEFAULT 7 /* anything MORE serious than KERN_DEBUG */
41#define CONSOLE_LOGLEVEL_DEBUG 10 /* issue debug messages */
42#define CONSOLE_LOGLEVEL_MOTORMOUTH 15 /* You can't shut this one up */
43
Linus Torvalds968ab182010-11-15 13:37:37 -080044extern int console_printk[];
45
46#define console_loglevel (console_printk[0])
47#define default_message_loglevel (console_printk[1])
48#define minimum_console_loglevel (console_printk[2])
49#define default_console_loglevel (console_printk[3])
50
Joe Perchesa9747cc2011-01-12 16:59:43 -080051static inline void console_silent(void)
52{
Borislav Petkova8fe19e2014-06-04 16:11:46 -070053 console_loglevel = CONSOLE_LOGLEVEL_SILENT;
Joe Perchesa9747cc2011-01-12 16:59:43 -080054}
55
56static inline void console_verbose(void)
57{
58 if (console_loglevel)
Borislav Petkova8fe19e2014-06-04 16:11:46 -070059 console_loglevel = CONSOLE_LOGLEVEL_MOTORMOUTH;
Joe Perchesa9747cc2011-01-12 16:59:43 -080060}
61
Linus Torvalds968ab182010-11-15 13:37:37 -080062struct va_format {
63 const char *fmt;
64 va_list *va;
65};
66
67/*
68 * FW_BUG
69 * Add this to a message where you are sure the firmware is buggy or behaves
70 * really stupid or out of spec. Be aware that the responsible BIOS developer
71 * should be able to fix this issue or at least get a concrete idea of the
72 * problem by reading your message without the need of looking at the kernel
73 * code.
74 *
75 * Use it for definite and high priority BIOS bugs.
76 *
77 * FW_WARN
78 * Use it for not that clear (e.g. could the kernel messed up things already?)
79 * and medium priority BIOS bugs.
80 *
81 * FW_INFO
82 * Use this one if you want to tell the user or vendor about something
83 * suspicious, but generally harmless related to the firmware.
84 *
85 * Use it for information or very low priority BIOS bugs.
86 */
87#define FW_BUG "[Firmware Bug]: "
88#define FW_WARN "[Firmware Warn]: "
89#define FW_INFO "[Firmware Info]: "
90
91/*
92 * HW_ERR
93 * Add this to a message for hardware errors, so that user can report
94 * it to hardware vendor instead of LKML or software vendor.
95 */
96#define HW_ERR "[Hardware Error]: "
97
Joe Perches5264f2f2011-01-12 16:59:45 -080098/*
Neil Horman0a9a8bf2013-12-23 08:29:42 -050099 * DEPRECATED
100 * Add this to a message whenever you want to warn user space about the use
101 * of a deprecated aspect of an API so they can stop using it
102 */
103#define DEPRECATED "[Deprecated]: "
104
105/*
Joe Perches5264f2f2011-01-12 16:59:45 -0800106 * Dummy printk for disabled debugging statements to use whilst maintaining
107 * gcc's format and side-effect checking.
108 */
Joe Perchesb9075fa2011-10-31 17:11:33 -0700109static inline __printf(1, 2)
Joe Perches5264f2f2011-01-12 16:59:45 -0800110int no_printk(const char *fmt, ...)
111{
112 return 0;
113}
114
Thomas Gleixnerd0380e62013-04-29 16:17:18 -0700115#ifdef CONFIG_EARLY_PRINTK
Joe Perchesb9075fa2011-10-31 17:11:33 -0700116extern asmlinkage __printf(1, 2)
Joe Perches5264f2f2011-01-12 16:59:45 -0800117void early_printk(const char *fmt, ...);
Thomas Gleixnerd0380e62013-04-29 16:17:18 -0700118void early_vprintk(const char *fmt, va_list ap);
119#else
120static inline __printf(1, 2) __cold
121void early_printk(const char *s, ...) { }
122#endif
Joe Perches5264f2f2011-01-12 16:59:45 -0800123
Linus Torvalds968ab182010-11-15 13:37:37 -0800124#ifdef CONFIG_PRINTK
Kay Sievers7ff95542012-05-03 02:29:13 +0200125asmlinkage __printf(5, 0)
126int vprintk_emit(int facility, int level,
127 const char *dict, size_t dictlen,
128 const char *fmt, va_list args);
129
Joe Perchesb9075fa2011-10-31 17:11:33 -0700130asmlinkage __printf(1, 0)
Joe Perches5264f2f2011-01-12 16:59:45 -0800131int vprintk(const char *fmt, va_list args);
Kay Sievers7ff95542012-05-03 02:29:13 +0200132
133asmlinkage __printf(5, 6) __cold
Simon Kågströmd487d572014-04-03 14:48:44 -0700134int printk_emit(int facility, int level,
135 const char *dict, size_t dictlen,
136 const char *fmt, ...);
Kay Sievers7ff95542012-05-03 02:29:13 +0200137
Joe Perchesb9075fa2011-10-31 17:11:33 -0700138asmlinkage __printf(1, 2) __cold
Joe Perches5264f2f2011-01-12 16:59:45 -0800139int printk(const char *fmt, ...);
Linus Torvalds968ab182010-11-15 13:37:37 -0800140
141/*
John Stultzaac74dc2014-06-04 16:11:40 -0700142 * Special printk facility for scheduler/timekeeping use only, _DO_NOT_USE_ !
Peter Zijlstra3ccf3e82012-02-27 10:47:00 +0100143 */
John Stultzaac74dc2014-06-04 16:11:40 -0700144__printf(1, 2) __cold int printk_deferred(const char *fmt, ...);
Peter Zijlstra3ccf3e82012-02-27 10:47:00 +0100145
146/*
Linus Torvalds968ab182010-11-15 13:37:37 -0800147 * Please don't use printk_ratelimit(), because it shares ratelimiting state
148 * with all other unrelated printk_ratelimit() callsites. Instead use
149 * printk_ratelimited() or plain old __ratelimit().
150 */
151extern int __printk_ratelimit(const char *func);
152#define printk_ratelimit() __printk_ratelimit(__func__)
153extern bool printk_timed_ratelimit(unsigned long *caller_jiffies,
154 unsigned int interval_msec);
155
156extern int printk_delay_msec;
157extern int dmesg_restrict;
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800158extern int kptr_restrict;
Linus Torvalds968ab182010-11-15 13:37:37 -0800159
Frederic Weisbeckerdc72c322013-03-22 15:04:39 -0700160extern void wake_up_klogd(void);
161
Linus Torvalds968ab182010-11-15 13:37:37 -0800162void log_buf_kexec_setup(void);
Mike Travis162a7e72011-05-24 17:13:20 -0700163void __init setup_log_buf(int early);
Tejun Heo98e5e1b2013-04-30 15:27:15 -0700164void dump_stack_set_arch_desc(const char *fmt, ...);
Tejun Heo196779b2013-04-30 15:27:12 -0700165void dump_stack_print_info(const char *log_lvl);
Tejun Heoa43cb952013-04-30 15:27:17 -0700166void show_regs_print_info(const char *log_lvl);
Linus Torvalds968ab182010-11-15 13:37:37 -0800167#else
Joe Perchesb9075fa2011-10-31 17:11:33 -0700168static inline __printf(1, 0)
Joe Perches5264f2f2011-01-12 16:59:45 -0800169int vprintk(const char *s, va_list args)
170{
171 return 0;
172}
Joe Perchesb9075fa2011-10-31 17:11:33 -0700173static inline __printf(1, 2) __cold
Joe Perches5264f2f2011-01-12 16:59:45 -0800174int printk(const char *s, ...)
175{
176 return 0;
177}
Peter Zijlstra3ccf3e82012-02-27 10:47:00 +0100178static inline __printf(1, 2) __cold
John Stultzaac74dc2014-06-04 16:11:40 -0700179int printk_deferred(const char *s, ...)
Peter Zijlstra3ccf3e82012-02-27 10:47:00 +0100180{
181 return 0;
182}
Joe Perches5264f2f2011-01-12 16:59:45 -0800183static inline int printk_ratelimit(void)
184{
185 return 0;
186}
187static inline bool printk_timed_ratelimit(unsigned long *caller_jiffies,
188 unsigned int interval_msec)
189{
190 return false;
191}
Linus Torvalds968ab182010-11-15 13:37:37 -0800192
Frederic Weisbeckerdc72c322013-03-22 15:04:39 -0700193static inline void wake_up_klogd(void)
194{
195}
196
Linus Torvalds968ab182010-11-15 13:37:37 -0800197static inline void log_buf_kexec_setup(void)
198{
199}
Mike Travis162a7e72011-05-24 17:13:20 -0700200
201static inline void setup_log_buf(int early)
202{
203}
Tejun Heo196779b2013-04-30 15:27:12 -0700204
Tejun Heo98e5e1b2013-04-30 15:27:15 -0700205static inline void dump_stack_set_arch_desc(const char *fmt, ...)
206{
207}
208
Tejun Heo196779b2013-04-30 15:27:12 -0700209static inline void dump_stack_print_info(const char *log_lvl)
210{
211}
Tejun Heoa43cb952013-04-30 15:27:17 -0700212
213static inline void show_regs_print_info(const char *log_lvl)
214{
215}
Linus Torvalds968ab182010-11-15 13:37:37 -0800216#endif
217
Andi Kleenb6c035d2013-08-05 15:02:48 -0700218extern asmlinkage void dump_stack(void) __cold;
Linus Torvalds968ab182010-11-15 13:37:37 -0800219
Linus Torvalds968ab182010-11-15 13:37:37 -0800220#ifndef pr_fmt
221#define pr_fmt(fmt) fmt
222#endif
223
Dan Streetman6e099f52014-06-04 16:11:44 -0700224/*
225 * These can be used to print at the various log levels.
226 * All of these will print unconditionally, although note that pr_debug()
227 * and other debug macros are compiled out unless either DEBUG is defined
228 * or CONFIG_DYNAMIC_DEBUG is set.
229 */
Linus Torvalds968ab182010-11-15 13:37:37 -0800230#define pr_emerg(fmt, ...) \
Joe Perchesa3f938b2011-01-12 16:59:48 -0800231 printk(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__)
Linus Torvalds968ab182010-11-15 13:37:37 -0800232#define pr_alert(fmt, ...) \
Joe Perchesa3f938b2011-01-12 16:59:48 -0800233 printk(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__)
Linus Torvalds968ab182010-11-15 13:37:37 -0800234#define pr_crit(fmt, ...) \
Joe Perchesa3f938b2011-01-12 16:59:48 -0800235 printk(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__)
Linus Torvalds968ab182010-11-15 13:37:37 -0800236#define pr_err(fmt, ...) \
Joe Perchesa3f938b2011-01-12 16:59:48 -0800237 printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
Linus Torvalds968ab182010-11-15 13:37:37 -0800238#define pr_warning(fmt, ...) \
Joe Perchesa3f938b2011-01-12 16:59:48 -0800239 printk(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
Linus Torvalds968ab182010-11-15 13:37:37 -0800240#define pr_warn pr_warning
241#define pr_notice(fmt, ...) \
Joe Perchesa3f938b2011-01-12 16:59:48 -0800242 printk(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
Linus Torvalds968ab182010-11-15 13:37:37 -0800243#define pr_info(fmt, ...) \
Joe Perchesa3f938b2011-01-12 16:59:48 -0800244 printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
Linus Torvalds968ab182010-11-15 13:37:37 -0800245#define pr_cont(fmt, ...) \
246 printk(KERN_CONT fmt, ##__VA_ARGS__)
247
248/* pr_devel() should produce zero code unless DEBUG is defined */
249#ifdef DEBUG
250#define pr_devel(fmt, ...) \
251 printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
252#else
253#define pr_devel(fmt, ...) \
Joe Perches5264f2f2011-01-12 16:59:45 -0800254 no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
Linus Torvalds968ab182010-11-15 13:37:37 -0800255#endif
256
Joe Perches29fc2bc2013-10-26 20:41:53 -0700257#include <linux/dynamic_debug.h>
258
Linus Torvalds968ab182010-11-15 13:37:37 -0800259/* If you are writing a driver, please use dev_dbg instead */
Jim Cromieb558c962011-12-19 17:11:18 -0500260#if defined(CONFIG_DYNAMIC_DEBUG)
Linus Torvalds968ab182010-11-15 13:37:37 -0800261/* dynamic_pr_debug() uses pr_fmt() internally so we don't need it here */
262#define pr_debug(fmt, ...) \
263 dynamic_pr_debug(fmt, ##__VA_ARGS__)
Jim Cromieb558c962011-12-19 17:11:18 -0500264#elif defined(DEBUG)
265#define pr_debug(fmt, ...) \
266 printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
Linus Torvalds968ab182010-11-15 13:37:37 -0800267#else
268#define pr_debug(fmt, ...) \
Joe Perches5264f2f2011-01-12 16:59:45 -0800269 no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
Linus Torvalds968ab182010-11-15 13:37:37 -0800270#endif
271
272/*
Joe Perches16cb8392011-01-12 16:59:46 -0800273 * Print a one-time message (analogous to WARN_ONCE() et al):
274 */
275
276#ifdef CONFIG_PRINTK
Joe Perchesc28aa1f2014-01-23 15:54:16 -0800277#define printk_once(fmt, ...) \
278({ \
279 static bool __print_once __read_mostly; \
280 \
281 if (!__print_once) { \
282 __print_once = true; \
283 printk(fmt, ##__VA_ARGS__); \
284 } \
Joe Perches16cb8392011-01-12 16:59:46 -0800285})
John Stultzc2248152014-06-04 16:11:41 -0700286#define printk_deferred_once(fmt, ...) \
287({ \
288 static bool __print_once __read_mostly; \
289 \
290 if (!__print_once) { \
291 __print_once = true; \
292 printk_deferred(fmt, ##__VA_ARGS__); \
293 } \
294})
Joe Perches16cb8392011-01-12 16:59:46 -0800295#else
Joe Perchesc28aa1f2014-01-23 15:54:16 -0800296#define printk_once(fmt, ...) \
Joe Perches16cb8392011-01-12 16:59:46 -0800297 no_printk(fmt, ##__VA_ARGS__)
John Stultzc2248152014-06-04 16:11:41 -0700298#define printk_deferred_once(fmt, ...) \
299 no_printk(fmt, ##__VA_ARGS__)
Joe Perches16cb8392011-01-12 16:59:46 -0800300#endif
301
302#define pr_emerg_once(fmt, ...) \
303 printk_once(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__)
304#define pr_alert_once(fmt, ...) \
305 printk_once(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__)
306#define pr_crit_once(fmt, ...) \
307 printk_once(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__)
308#define pr_err_once(fmt, ...) \
309 printk_once(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
310#define pr_warn_once(fmt, ...) \
311 printk_once(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
312#define pr_notice_once(fmt, ...) \
313 printk_once(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
314#define pr_info_once(fmt, ...) \
315 printk_once(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
316#define pr_cont_once(fmt, ...) \
317 printk_once(KERN_CONT pr_fmt(fmt), ##__VA_ARGS__)
Mikhail Gruzdev36d308d2013-02-21 16:43:10 -0800318
319#if defined(DEBUG)
320#define pr_devel_once(fmt, ...) \
321 printk_once(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
322#else
323#define pr_devel_once(fmt, ...) \
324 no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
325#endif
326
Joe Perches16cb8392011-01-12 16:59:46 -0800327/* If you are writing a driver, please use dev_dbg instead */
328#if defined(DEBUG)
329#define pr_debug_once(fmt, ...) \
330 printk_once(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
331#else
332#define pr_debug_once(fmt, ...) \
333 no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
334#endif
335
336/*
Linus Torvalds968ab182010-11-15 13:37:37 -0800337 * ratelimited messages with local ratelimit_state,
338 * no local ratelimit_state used in the !PRINTK case
339 */
340#ifdef CONFIG_PRINTK
Joe Perches6ec42a562011-01-12 16:59:47 -0800341#define printk_ratelimited(fmt, ...) \
342({ \
Linus Torvalds968ab182010-11-15 13:37:37 -0800343 static DEFINE_RATELIMIT_STATE(_rs, \
344 DEFAULT_RATELIMIT_INTERVAL, \
345 DEFAULT_RATELIMIT_BURST); \
346 \
347 if (__ratelimit(&_rs)) \
348 printk(fmt, ##__VA_ARGS__); \
349})
350#else
Joe Perches6ec42a562011-01-12 16:59:47 -0800351#define printk_ratelimited(fmt, ...) \
352 no_printk(fmt, ##__VA_ARGS__)
Linus Torvalds968ab182010-11-15 13:37:37 -0800353#endif
354
Joe Perches6ec42a562011-01-12 16:59:47 -0800355#define pr_emerg_ratelimited(fmt, ...) \
Linus Torvalds968ab182010-11-15 13:37:37 -0800356 printk_ratelimited(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__)
Joe Perches6ec42a562011-01-12 16:59:47 -0800357#define pr_alert_ratelimited(fmt, ...) \
Linus Torvalds968ab182010-11-15 13:37:37 -0800358 printk_ratelimited(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__)
Joe Perches6ec42a562011-01-12 16:59:47 -0800359#define pr_crit_ratelimited(fmt, ...) \
Linus Torvalds968ab182010-11-15 13:37:37 -0800360 printk_ratelimited(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__)
Joe Perches6ec42a562011-01-12 16:59:47 -0800361#define pr_err_ratelimited(fmt, ...) \
Linus Torvalds968ab182010-11-15 13:37:37 -0800362 printk_ratelimited(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
Joe Perches6ec42a562011-01-12 16:59:47 -0800363#define pr_warn_ratelimited(fmt, ...) \
Linus Torvalds968ab182010-11-15 13:37:37 -0800364 printk_ratelimited(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
Joe Perches6ec42a562011-01-12 16:59:47 -0800365#define pr_notice_ratelimited(fmt, ...) \
Linus Torvalds968ab182010-11-15 13:37:37 -0800366 printk_ratelimited(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
Joe Perches6ec42a562011-01-12 16:59:47 -0800367#define pr_info_ratelimited(fmt, ...) \
Linus Torvalds968ab182010-11-15 13:37:37 -0800368 printk_ratelimited(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
369/* no pr_cont_ratelimited, don't do that... */
Mikhail Gruzdev36d308d2013-02-21 16:43:10 -0800370
371#if defined(DEBUG)
372#define pr_devel_ratelimited(fmt, ...) \
373 printk_ratelimited(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
374#else
375#define pr_devel_ratelimited(fmt, ...) \
376 no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
377#endif
378
Linus Torvalds968ab182010-11-15 13:37:37 -0800379/* If you are writing a driver, please use dev_dbg instead */
Joe Perches29fc2bc2013-10-26 20:41:53 -0700380#if defined(CONFIG_DYNAMIC_DEBUG)
381/* descriptor check is first to prevent flooding with "callbacks suppressed" */
382#define pr_debug_ratelimited(fmt, ...) \
383do { \
384 static DEFINE_RATELIMIT_STATE(_rs, \
385 DEFAULT_RATELIMIT_INTERVAL, \
386 DEFAULT_RATELIMIT_BURST); \
387 DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, fmt); \
388 if (unlikely(descriptor.flags & _DPRINTK_FLAGS_PRINT) && \
389 __ratelimit(&_rs)) \
390 __dynamic_pr_debug(&descriptor, fmt, ##__VA_ARGS__); \
391} while (0)
392#elif defined(DEBUG)
Joe Perches6ec42a562011-01-12 16:59:47 -0800393#define pr_debug_ratelimited(fmt, ...) \
Linus Torvalds968ab182010-11-15 13:37:37 -0800394 printk_ratelimited(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
395#else
396#define pr_debug_ratelimited(fmt, ...) \
Joe Perches5264f2f2011-01-12 16:59:45 -0800397 no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
Linus Torvalds968ab182010-11-15 13:37:37 -0800398#endif
399
Kay Sieverse11fea92012-05-03 02:29:41 +0200400extern const struct file_operations kmsg_fops;
401
Joe Perchesac83ed62011-01-12 16:59:47 -0800402enum {
403 DUMP_PREFIX_NONE,
404 DUMP_PREFIX_ADDRESS,
405 DUMP_PREFIX_OFFSET
406};
407extern void hex_dump_to_buffer(const void *buf, size_t len,
408 int rowsize, int groupsize,
409 char *linebuf, size_t linebuflen, bool ascii);
410#ifdef CONFIG_PRINTK
411extern void print_hex_dump(const char *level, const char *prefix_str,
412 int prefix_type, int rowsize, int groupsize,
413 const void *buf, size_t len, bool ascii);
Vladimir Kondratiev7a555612012-12-05 16:48:27 -0500414#if defined(CONFIG_DYNAMIC_DEBUG)
415#define print_hex_dump_bytes(prefix_str, prefix_type, buf, len) \
416 dynamic_hex_dump(prefix_str, prefix_type, 16, 1, buf, len, true)
417#else
Joe Perchesac83ed62011-01-12 16:59:47 -0800418extern void print_hex_dump_bytes(const char *prefix_str, int prefix_type,
419 const void *buf, size_t len);
Vladimir Kondratiev7a555612012-12-05 16:48:27 -0500420#endif /* defined(CONFIG_DYNAMIC_DEBUG) */
Joe Perchesac83ed62011-01-12 16:59:47 -0800421#else
422static inline void print_hex_dump(const char *level, const char *prefix_str,
423 int prefix_type, int rowsize, int groupsize,
424 const void *buf, size_t len, bool ascii)
425{
426}
427static inline void print_hex_dump_bytes(const char *prefix_str, int prefix_type,
428 const void *buf, size_t len)
429{
430}
431
432#endif
433
Vladimir Kondratiev7a555612012-12-05 16:48:27 -0500434#if defined(CONFIG_DYNAMIC_DEBUG)
435#define print_hex_dump_debug(prefix_str, prefix_type, rowsize, \
436 groupsize, buf, len, ascii) \
437 dynamic_hex_dump(prefix_str, prefix_type, rowsize, \
438 groupsize, buf, len, ascii)
439#else
440#define print_hex_dump_debug(prefix_str, prefix_type, rowsize, \
441 groupsize, buf, len, ascii) \
442 print_hex_dump(KERN_DEBUG, prefix_str, prefix_type, rowsize, \
443 groupsize, buf, len, ascii)
444#endif /* defined(CONFIG_DYNAMIC_DEBUG) */
445
Linus Torvalds968ab182010-11-15 13:37:37 -0800446#endif