Blame view
include/linux/printk.h
8.8 KB
968ab1838 include/linux/ker... |
1 2 |
#ifndef __KERNEL_PRINTK__ #define __KERNEL_PRINTK__ |
162a7e750 printk: allocate ... |
3 |
#include <linux/init.h> |
968ab1838 include/linux/ker... |
4 5 |
extern const char linux_banner[]; extern const char linux_proc_banner[]; |
7d1e91aeb include/linux/pri... |
6 7 8 9 10 11 12 13 |
#define KERN_EMERG "<0>" /* system is unusable */ #define KERN_ALERT "<1>" /* action must be taken immediately */ #define KERN_CRIT "<2>" /* critical conditions */ #define KERN_ERR "<3>" /* error conditions */ #define KERN_WARNING "<4>" /* warning conditions */ #define KERN_NOTICE "<5>" /* normal but significant condition */ #define KERN_INFO "<6>" /* informational */ #define KERN_DEBUG "<7>" /* debug-level messages */ |
968ab1838 include/linux/ker... |
14 15 16 17 18 19 20 21 22 |
/* Use the default kernel loglevel */ #define KERN_DEFAULT "<d>" /* * Annotation for a "continued" line of log printout (only done after a * line that had no enclosing ). Only to be used by core/arch code * during early bootup (a continued line is not SMP-safe otherwise). */ |
7d1e91aeb include/linux/pri... |
23 |
#define KERN_CONT "<c>" |
968ab1838 include/linux/ker... |
24 25 26 27 28 29 30 |
extern int console_printk[]; #define console_loglevel (console_printk[0]) #define default_message_loglevel (console_printk[1]) #define minimum_console_loglevel (console_printk[2]) #define default_console_loglevel (console_printk[3]) |
a9747cc3a include/linux/pri... |
31 32 33 34 35 36 37 38 39 40 |
static inline void console_silent(void) { console_loglevel = 0; } static inline void console_verbose(void) { if (console_loglevel) console_loglevel = 15; } |
968ab1838 include/linux/ker... |
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
struct va_format { const char *fmt; va_list *va; }; /* * FW_BUG * Add this to a message where you are sure the firmware is buggy or behaves * really stupid or out of spec. Be aware that the responsible BIOS developer * should be able to fix this issue or at least get a concrete idea of the * problem by reading your message without the need of looking at the kernel * code. * * Use it for definite and high priority BIOS bugs. * * FW_WARN * Use it for not that clear (e.g. could the kernel messed up things already?) * and medium priority BIOS bugs. * * FW_INFO * Use this one if you want to tell the user or vendor about something * suspicious, but generally harmless related to the firmware. * * Use it for information or very low priority BIOS bugs. */ #define FW_BUG "[Firmware Bug]: " #define FW_WARN "[Firmware Warn]: " #define FW_INFO "[Firmware Info]: " /* * HW_ERR * Add this to a message for hardware errors, so that user can report * it to hardware vendor instead of LKML or software vendor. */ #define HW_ERR "[Hardware Error]: " |
5264f2f75 include/linux/pri... |
76 77 78 79 |
/* * Dummy printk for disabled debugging statements to use whilst maintaining * gcc's format and side-effect checking. */ |
b9075fa96 treewide: use __p... |
80 |
static inline __printf(1, 2) |
5264f2f75 include/linux/pri... |
81 82 83 84 |
int no_printk(const char *fmt, ...) { return 0; } |
b9075fa96 treewide: use __p... |
85 |
extern asmlinkage __printf(1, 2) |
5264f2f75 include/linux/pri... |
86 87 88 89 |
void early_printk(const char *fmt, ...); extern int printk_needs_cpu(int cpu); extern void printk_tick(void); |
968ab1838 include/linux/ker... |
90 |
#ifdef CONFIG_PRINTK |
b9075fa96 treewide: use __p... |
91 |
asmlinkage __printf(1, 0) |
5264f2f75 include/linux/pri... |
92 |
int vprintk(const char *fmt, va_list args); |
b9075fa96 treewide: use __p... |
93 |
asmlinkage __printf(1, 2) __cold |
5264f2f75 include/linux/pri... |
94 |
int printk(const char *fmt, ...); |
968ab1838 include/linux/ker... |
95 96 97 98 99 100 101 102 103 104 105 106 107 |
/* * Please don't use printk_ratelimit(), because it shares ratelimiting state * with all other unrelated printk_ratelimit() callsites. Instead use * printk_ratelimited() or plain old __ratelimit(). */ extern int __printk_ratelimit(const char *func); #define printk_ratelimit() __printk_ratelimit(__func__) extern bool printk_timed_ratelimit(unsigned long *caller_jiffies, unsigned int interval_msec); extern int printk_delay_msec; extern int dmesg_restrict; |
455cd5ab3 kptr_restrict for... |
108 |
extern int kptr_restrict; |
968ab1838 include/linux/ker... |
109 |
|
968ab1838 include/linux/ker... |
110 |
void log_buf_kexec_setup(void); |
162a7e750 printk: allocate ... |
111 |
void __init setup_log_buf(int early); |
968ab1838 include/linux/ker... |
112 |
#else |
b9075fa96 treewide: use __p... |
113 |
static inline __printf(1, 0) |
5264f2f75 include/linux/pri... |
114 115 116 117 |
int vprintk(const char *s, va_list args) { return 0; } |
b9075fa96 treewide: use __p... |
118 |
static inline __printf(1, 2) __cold |
5264f2f75 include/linux/pri... |
119 120 121 122 123 124 125 126 127 128 129 130 131 |
int printk(const char *s, ...) { return 0; } static inline int printk_ratelimit(void) { return 0; } static inline bool printk_timed_ratelimit(unsigned long *caller_jiffies, unsigned int interval_msec) { return false; } |
968ab1838 include/linux/ker... |
132 |
|
968ab1838 include/linux/ker... |
133 134 135 |
static inline void log_buf_kexec_setup(void) { } |
162a7e750 printk: allocate ... |
136 137 138 139 |
static inline void setup_log_buf(int early) { } |
968ab1838 include/linux/ker... |
140 |
#endif |
968ab1838 include/linux/ker... |
141 |
extern void dump_stack(void) __cold; |
968ab1838 include/linux/ker... |
142 143 144 145 146 |
#ifndef pr_fmt #define pr_fmt(fmt) fmt #endif #define pr_emerg(fmt, ...) \ |
a3f938bf6 include/linux/pri... |
147 |
printk(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__) |
968ab1838 include/linux/ker... |
148 |
#define pr_alert(fmt, ...) \ |
a3f938bf6 include/linux/pri... |
149 |
printk(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__) |
968ab1838 include/linux/ker... |
150 |
#define pr_crit(fmt, ...) \ |
a3f938bf6 include/linux/pri... |
151 |
printk(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__) |
968ab1838 include/linux/ker... |
152 |
#define pr_err(fmt, ...) \ |
a3f938bf6 include/linux/pri... |
153 |
printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__) |
968ab1838 include/linux/ker... |
154 |
#define pr_warning(fmt, ...) \ |
a3f938bf6 include/linux/pri... |
155 |
printk(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__) |
968ab1838 include/linux/ker... |
156 157 |
#define pr_warn pr_warning #define pr_notice(fmt, ...) \ |
a3f938bf6 include/linux/pri... |
158 |
printk(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__) |
968ab1838 include/linux/ker... |
159 |
#define pr_info(fmt, ...) \ |
a3f938bf6 include/linux/pri... |
160 |
printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__) |
968ab1838 include/linux/ker... |
161 162 163 164 165 166 167 168 169 |
#define pr_cont(fmt, ...) \ printk(KERN_CONT fmt, ##__VA_ARGS__) /* pr_devel() should produce zero code unless DEBUG is defined */ #ifdef DEBUG #define pr_devel(fmt, ...) \ printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) #else #define pr_devel(fmt, ...) \ |
5264f2f75 include/linux/pri... |
170 |
no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) |
968ab1838 include/linux/ker... |
171 172 173 174 175 176 177 178 179 180 181 182 |
#endif /* If you are writing a driver, please use dev_dbg instead */ #if defined(DEBUG) #define pr_debug(fmt, ...) \ printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) #elif defined(CONFIG_DYNAMIC_DEBUG) /* dynamic_pr_debug() uses pr_fmt() internally so we don't need it here */ #define pr_debug(fmt, ...) \ dynamic_pr_debug(fmt, ##__VA_ARGS__) #else #define pr_debug(fmt, ...) \ |
5264f2f75 include/linux/pri... |
183 |
no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) |
968ab1838 include/linux/ker... |
184 185 186 |
#endif /* |
16cb839f1 include/linux/pri... |
187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 |
* Print a one-time message (analogous to WARN_ONCE() et al): */ #ifdef CONFIG_PRINTK #define printk_once(fmt, ...) \ ({ \ static bool __print_once; \ \ if (!__print_once) { \ __print_once = true; \ printk(fmt, ##__VA_ARGS__); \ } \ }) #else #define printk_once(fmt, ...) \ no_printk(fmt, ##__VA_ARGS__) #endif #define pr_emerg_once(fmt, ...) \ printk_once(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__) #define pr_alert_once(fmt, ...) \ printk_once(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__) #define pr_crit_once(fmt, ...) \ printk_once(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__) #define pr_err_once(fmt, ...) \ printk_once(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__) #define pr_warn_once(fmt, ...) \ printk_once(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__) #define pr_notice_once(fmt, ...) \ printk_once(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__) #define pr_info_once(fmt, ...) \ printk_once(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__) #define pr_cont_once(fmt, ...) \ printk_once(KERN_CONT pr_fmt(fmt), ##__VA_ARGS__) /* If you are writing a driver, please use dev_dbg instead */ #if defined(DEBUG) #define pr_debug_once(fmt, ...) \ printk_once(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) #else #define pr_debug_once(fmt, ...) \ no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) #endif /* |
968ab1838 include/linux/ker... |
231 232 233 234 |
* ratelimited messages with local ratelimit_state, * no local ratelimit_state used in the !PRINTK case */ #ifdef CONFIG_PRINTK |
6ec42a56e include/linux/pri... |
235 236 |
#define printk_ratelimited(fmt, ...) \ ({ \ |
968ab1838 include/linux/ker... |
237 238 239 240 241 242 243 244 |
static DEFINE_RATELIMIT_STATE(_rs, \ DEFAULT_RATELIMIT_INTERVAL, \ DEFAULT_RATELIMIT_BURST); \ \ if (__ratelimit(&_rs)) \ printk(fmt, ##__VA_ARGS__); \ }) #else |
6ec42a56e include/linux/pri... |
245 246 |
#define printk_ratelimited(fmt, ...) \ no_printk(fmt, ##__VA_ARGS__) |
968ab1838 include/linux/ker... |
247 |
#endif |
6ec42a56e include/linux/pri... |
248 |
#define pr_emerg_ratelimited(fmt, ...) \ |
968ab1838 include/linux/ker... |
249 |
printk_ratelimited(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__) |
6ec42a56e include/linux/pri... |
250 |
#define pr_alert_ratelimited(fmt, ...) \ |
968ab1838 include/linux/ker... |
251 |
printk_ratelimited(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__) |
6ec42a56e include/linux/pri... |
252 |
#define pr_crit_ratelimited(fmt, ...) \ |
968ab1838 include/linux/ker... |
253 |
printk_ratelimited(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__) |
6ec42a56e include/linux/pri... |
254 |
#define pr_err_ratelimited(fmt, ...) \ |
968ab1838 include/linux/ker... |
255 |
printk_ratelimited(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__) |
6ec42a56e include/linux/pri... |
256 |
#define pr_warn_ratelimited(fmt, ...) \ |
968ab1838 include/linux/ker... |
257 |
printk_ratelimited(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__) |
6ec42a56e include/linux/pri... |
258 |
#define pr_notice_ratelimited(fmt, ...) \ |
968ab1838 include/linux/ker... |
259 |
printk_ratelimited(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__) |
6ec42a56e include/linux/pri... |
260 |
#define pr_info_ratelimited(fmt, ...) \ |
968ab1838 include/linux/ker... |
261 262 263 264 |
printk_ratelimited(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__) /* no pr_cont_ratelimited, don't do that... */ /* If you are writing a driver, please use dev_dbg instead */ #if defined(DEBUG) |
6ec42a56e include/linux/pri... |
265 |
#define pr_debug_ratelimited(fmt, ...) \ |
968ab1838 include/linux/ker... |
266 267 268 |
printk_ratelimited(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) #else #define pr_debug_ratelimited(fmt, ...) \ |
5264f2f75 include/linux/pri... |
269 |
no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) |
968ab1838 include/linux/ker... |
270 |
#endif |
ac83ed687 include/linux/pri... |
271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 |
enum { DUMP_PREFIX_NONE, DUMP_PREFIX_ADDRESS, DUMP_PREFIX_OFFSET }; extern void hex_dump_to_buffer(const void *buf, size_t len, int rowsize, int groupsize, char *linebuf, size_t linebuflen, bool ascii); #ifdef CONFIG_PRINTK extern void print_hex_dump(const char *level, const char *prefix_str, int prefix_type, int rowsize, int groupsize, const void *buf, size_t len, bool ascii); extern void print_hex_dump_bytes(const char *prefix_str, int prefix_type, const void *buf, size_t len); #else static inline void print_hex_dump(const char *level, const char *prefix_str, int prefix_type, int rowsize, int groupsize, const void *buf, size_t len, bool ascii) { } static inline void print_hex_dump_bytes(const char *prefix_str, int prefix_type, const void *buf, size_t len) { } #endif |
968ab1838 include/linux/ker... |
297 |
#endif |