Rev 5270 | Rev 6102 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
5270 | serge | 1 | #ifndef __KERNEL_PRINTK__ |
2 | #define __KERNEL_PRINTK__ |
||
3 | |||
4 | #include |
||
5 | #include |
||
6 | #include |
||
7 | |||
8 | extern const char linux_banner[]; |
||
9 | extern const char linux_proc_banner[]; |
||
10 | |||
11 | extern char *log_buf_addr_get(void); |
||
12 | extern u32 log_buf_len_get(void); |
||
13 | |||
14 | /* printk's without a loglevel use this.. */ |
||
15 | #define MESSAGE_LOGLEVEL_DEFAULT CONFIG_MESSAGE_LOGLEVEL_DEFAULT |
||
16 | |||
17 | /* We show everything that is MORE important than this.. */ |
||
18 | #define CONSOLE_LOGLEVEL_SILENT 0 /* Mum's the word */ |
||
19 | #define CONSOLE_LOGLEVEL_MIN 1 /* Minimum loglevel we let people use */ |
||
20 | #define CONSOLE_LOGLEVEL_QUIET 4 /* Shhh ..., when booted with "quiet" */ |
||
21 | #define CONSOLE_LOGLEVEL_DEFAULT 7 /* anything MORE serious than KERN_DEBUG */ |
||
22 | #define CONSOLE_LOGLEVEL_DEBUG 10 /* issue debug messages */ |
||
23 | #define CONSOLE_LOGLEVEL_MOTORMOUTH 15 /* You can't shut this one up */ |
||
24 | |||
25 | struct va_format { |
||
26 | const char *fmt; |
||
27 | va_list *va; |
||
28 | }; |
||
29 | |||
30 | /* |
||
31 | * FW_BUG |
||
32 | * Add this to a message where you are sure the firmware is buggy or behaves |
||
33 | * really stupid or out of spec. Be aware that the responsible BIOS developer |
||
34 | * should be able to fix this issue or at least get a concrete idea of the |
||
35 | * problem by reading your message without the need of looking at the kernel |
||
36 | * code. |
||
37 | * |
||
38 | * Use it for definite and high priority BIOS bugs. |
||
39 | * |
||
40 | * FW_WARN |
||
41 | * Use it for not that clear (e.g. could the kernel messed up things already?) |
||
42 | * and medium priority BIOS bugs. |
||
43 | * |
||
44 | * FW_INFO |
||
45 | * Use this one if you want to tell the user or vendor about something |
||
46 | * suspicious, but generally harmless related to the firmware. |
||
47 | * |
||
48 | * Use it for information or very low priority BIOS bugs. |
||
49 | */ |
||
50 | #define FW_BUG "[Firmware Bug]: " |
||
51 | #define FW_WARN "[Firmware Warn]: " |
||
52 | #define FW_INFO "[Firmware Info]: " |
||
53 | |||
54 | /* |
||
55 | * HW_ERR |
||
56 | * Add this to a message for hardware errors, so that user can report |
||
57 | * it to hardware vendor instead of LKML or software vendor. |
||
58 | */ |
||
59 | #define HW_ERR "[Hardware Error]: " |
||
60 | |||
61 | /* |
||
62 | * DEPRECATED |
||
63 | * Add this to a message whenever you want to warn user space about the use |
||
64 | * of a deprecated aspect of an API so they can stop using it |
||
65 | */ |
||
66 | #define DEPRECATED "[Deprecated]: " |
||
67 | |||
6082 | serge | 68 | /* |
69 | * Dummy printk for disabled debugging statements to use whilst maintaining |
||
70 | * gcc's format and side-effect checking. |
||
71 | */ |
||
5270 | serge | 72 | static inline __printf(1, 2) |
73 | int no_printk(const char *fmt, ...) |
||
74 | { |
||
75 | return 0; |
||
76 | } |
||
77 | |||
78 | __printf(1, 2) int dbgprintf(const char *fmt, ...); |
||
79 | |||
80 | #define printk(fmt, arg...) dbgprintf(fmt , ##arg) |
||
81 | |||
82 | #ifndef pr_fmt |
||
83 | #define pr_fmt(fmt) fmt |
||
84 | #endif |
||
85 | |||
86 | #define pr_debug(fmt, ...) \ |
||
87 | printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) |
||
88 | |||
89 | /* |
||
90 | * These can be used to print at the various log levels. |
||
91 | * All of these will print unconditionally, although note that pr_debug() |
||
92 | * and other debug macros are compiled out unless either DEBUG is defined |
||
93 | * or CONFIG_DYNAMIC_DEBUG is set. |
||
94 | */ |
||
95 | #define pr_emerg(fmt, ...) \ |
||
96 | printk(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__) |
||
97 | #define pr_alert(fmt, ...) \ |
||
98 | printk(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__) |
||
99 | #define pr_crit(fmt, ...) \ |
||
100 | printk(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__) |
||
101 | #define pr_err(fmt, ...) \ |
||
102 | printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__) |
||
103 | #define pr_warning(fmt, ...) \ |
||
104 | printk(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__) |
||
105 | #define pr_warn pr_warning |
||
106 | #define pr_notice(fmt, ...) \ |
||
107 | printk(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__) |
||
108 | #define pr_info(fmt, ...) \ |
||
109 | printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__) |
||
6082 | serge | 110 | /* |
111 | * Like KERN_CONT, pr_cont() should only be used when continuing |
||
112 | * a line with no newline ('\n') enclosed. Otherwise it defaults |
||
113 | * back to KERN_DEFAULT. |
||
114 | */ |
||
5270 | serge | 115 | #define pr_cont(fmt, ...) \ |
116 | printk(KERN_CONT fmt, ##__VA_ARGS__) |
||
117 | |||
118 | /* pr_devel() should produce zero code unless DEBUG is defined */ |
||
119 | #ifdef DEBUG |
||
120 | #define pr_devel(fmt, ...) \ |
||
121 | printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) |
||
122 | #else |
||
123 | #define pr_devel(fmt, ...) \ |
||
124 | no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) |
||
125 | #endif |
||
126 | |||
127 | /* |
||
128 | * Print a one-time message (analogous to WARN_ONCE() et al): |
||
129 | */ |
||
130 | |||
131 | #ifdef CONFIG_PRINTK |
||
132 | #define printk_once(fmt, ...) \ |
||
133 | ({ \ |
||
134 | static bool __print_once __read_mostly; \ |
||
135 | \ |
||
136 | if (!__print_once) { \ |
||
137 | __print_once = true; \ |
||
138 | printk(fmt, ##__VA_ARGS__); \ |
||
139 | } \ |
||
140 | }) |
||
141 | #define printk_deferred_once(fmt, ...) \ |
||
142 | ({ \ |
||
143 | static bool __print_once __read_mostly; \ |
||
144 | \ |
||
145 | if (!__print_once) { \ |
||
146 | __print_once = true; \ |
||
147 | printk_deferred(fmt, ##__VA_ARGS__); \ |
||
148 | } \ |
||
149 | }) |
||
150 | #else |
||
151 | #define printk_once(fmt, ...) \ |
||
152 | no_printk(fmt, ##__VA_ARGS__) |
||
153 | #define printk_deferred_once(fmt, ...) \ |
||
154 | no_printk(fmt, ##__VA_ARGS__) |
||
155 | #endif |
||
156 | |||
157 | #define pr_emerg_once(fmt, ...) \ |
||
158 | printk_once(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__) |
||
159 | #define pr_alert_once(fmt, ...) \ |
||
160 | printk_once(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__) |
||
161 | #define pr_crit_once(fmt, ...) \ |
||
162 | printk_once(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__) |
||
163 | #define pr_err_once(fmt, ...) \ |
||
164 | printk_once(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__) |
||
165 | #define pr_warn_once(fmt, ...) \ |
||
166 | printk_once(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__) |
||
167 | #define pr_notice_once(fmt, ...) \ |
||
168 | printk_once(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__) |
||
169 | #define pr_info_once(fmt, ...) \ |
||
170 | printk_once(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__) |
||
171 | #define pr_cont_once(fmt, ...) \ |
||
172 | printk_once(KERN_CONT pr_fmt(fmt), ##__VA_ARGS__) |
||
173 | |||
174 | #if defined(DEBUG) |
||
175 | #define pr_devel_once(fmt, ...) \ |
||
176 | printk_once(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) |
||
177 | #else |
||
178 | #define pr_devel_once(fmt, ...) \ |
||
179 | no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) |
||
180 | #endif |
||
181 | |||
182 | /* If you are writing a driver, please use dev_dbg instead */ |
||
183 | #if defined(DEBUG) |
||
184 | #define pr_debug_once(fmt, ...) \ |
||
185 | printk_once(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) |
||
186 | #else |
||
187 | #define pr_debug_once(fmt, ...) \ |
||
188 | no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) |
||
189 | #endif |
||
190 | |||
191 | /* |
||
192 | * ratelimited messages with local ratelimit_state, |
||
193 | * no local ratelimit_state used in the !PRINTK case |
||
194 | */ |
||
195 | #ifdef CONFIG_PRINTK |
||
196 | #define printk_ratelimited(fmt, ...) \ |
||
197 | ({ \ |
||
198 | static DEFINE_RATELIMIT_STATE(_rs, \ |
||
199 | DEFAULT_RATELIMIT_INTERVAL, \ |
||
200 | DEFAULT_RATELIMIT_BURST); \ |
||
201 | \ |
||
202 | if (__ratelimit(&_rs)) \ |
||
203 | printk(fmt, ##__VA_ARGS__); \ |
||
204 | }) |
||
205 | #else |
||
206 | #define printk_ratelimited(fmt, ...) \ |
||
207 | no_printk(fmt, ##__VA_ARGS__) |
||
208 | #endif |
||
209 | |||
210 | #define pr_emerg_ratelimited(fmt, ...) \ |
||
211 | printk_ratelimited(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__) |
||
212 | #define pr_alert_ratelimited(fmt, ...) \ |
||
213 | printk_ratelimited(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__) |
||
214 | #define pr_crit_ratelimited(fmt, ...) \ |
||
215 | printk_ratelimited(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__) |
||
216 | #define pr_err_ratelimited(fmt, ...) \ |
||
217 | printk_ratelimited(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__) |
||
218 | #define pr_warn_ratelimited(fmt, ...) \ |
||
219 | printk_ratelimited(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__) |
||
220 | #define pr_notice_ratelimited(fmt, ...) \ |
||
221 | printk_ratelimited(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__) |
||
222 | #define pr_info_ratelimited(fmt, ...) \ |
||
223 | printk_ratelimited(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__) |
||
224 | /* no pr_cont_ratelimited, don't do that... */ |
||
225 | |||
226 | #if defined(DEBUG) |
||
227 | #define pr_devel_ratelimited(fmt, ...) \ |
||
228 | printk_ratelimited(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) |
||
229 | #else |
||
230 | #define pr_devel_ratelimited(fmt, ...) \ |
||
231 | no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) |
||
232 | #endif |
||
233 | |||
234 | /* If you are writing a driver, please use dev_dbg instead */ |
||
235 | #if defined(CONFIG_DYNAMIC_DEBUG) |
||
236 | /* descriptor check is first to prevent flooding with "callbacks suppressed" */ |
||
237 | #define pr_debug_ratelimited(fmt, ...) \ |
||
238 | do { \ |
||
239 | static DEFINE_RATELIMIT_STATE(_rs, \ |
||
240 | DEFAULT_RATELIMIT_INTERVAL, \ |
||
241 | DEFAULT_RATELIMIT_BURST); \ |
||
242 | DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, fmt); \ |
||
243 | if (unlikely(descriptor.flags & _DPRINTK_FLAGS_PRINT) && \ |
||
244 | __ratelimit(&_rs)) \ |
||
245 | __dynamic_pr_debug(&descriptor, fmt, ##__VA_ARGS__); \ |
||
246 | } while (0) |
||
247 | #elif defined(DEBUG) |
||
248 | #define pr_debug_ratelimited(fmt, ...) \ |
||
249 | printk_ratelimited(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) |
||
250 | #else |
||
251 | #define pr_debug_ratelimited(fmt, ...) \ |
||
252 | no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) |
||
253 | #endif |
||
254 | |||
255 | extern const struct file_operations kmsg_fops; |
||
256 | |||
257 | enum { |
||
258 | DUMP_PREFIX_NONE, |
||
259 | DUMP_PREFIX_ADDRESS, |
||
260 | DUMP_PREFIX_OFFSET |
||
261 | }; |
||
6082 | serge | 262 | extern int hex_dump_to_buffer(const void *buf, size_t len, int rowsize, |
263 | int groupsize, char *linebuf, size_t linebuflen, |
||
264 | bool ascii); |
||
5270 | serge | 265 | |
266 | extern void print_hex_dump(const char *level, const char *prefix_str, |
||
267 | int prefix_type, int rowsize, int groupsize, |
||
268 | const void *buf, size_t len, bool ascii); |
||
269 | extern void print_hex_dump_bytes(const char *prefix_str, int prefix_type, |
||
270 | const void *buf, size_t len); |
||
271 | |||
272 | |||
273 | #endif |