2 * Copyright (c) 2015-2019 François Tigeot <ftigeot@wolfpond.org>
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice unmodified, this list of conditions, and the following
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 #ifndef _LINUX_PRINTK_H_
28 #define _LINUX_PRINTK_H_
30 #include <sys/stdarg.h>
31 #include <linux/init.h>
32 #include <linux/cache.h>
34 #include <sys/types.h>
35 #include <sys/systm.h>
42 #define printk(...) kprintf(__VA_ARGS__)
45 #define KERN_EMERG "<0>"
46 #define KERN_ALERT "<1>"
47 #define KERN_CRIT "<2>"
48 #define KERN_ERR "<3>"
49 #define KERN_WARNING "<4>"
50 #define KERN_NOTICE "<5>"
51 #define KERN_INFO "<6>"
52 #define KERN_DEBUG "<7>"
55 #define pr_fmt(fmt) fmt
58 #define pr_emerg(fmt, ...) \
59 printk(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__)
60 #define pr_alert(fmt, ...) \
61 printk(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__)
62 #define pr_crit(fmt, ...) \
63 printk(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__)
64 #define pr_err(fmt, ...) \
65 printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
66 #define pr_warning(fmt, ...) \
67 printk(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
68 #define pr_warn pr_warning
69 #define pr_notice(fmt, ...) \
70 printk(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
71 #define pr_info(fmt, ...) \
72 printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
73 #define pr_cont(fmt, ...) \
74 printk(KERN_CONT fmt, ##__VA_ARGS__)
76 /* pr_devel() should produce zero code unless DEBUG is defined */
78 #define pr_devel(fmt, ...) \
79 printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
81 #define pr_devel(fmt, ...) \
82 ({ if (0) printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); 0; })
85 #define pr_debug(fmt, ...) \
86 printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
89 * Print a one-time message (analogous to WARN_ONCE() et al):
91 #define printk_once(x...) \
93 static bool __print_once; \
95 if (!__print_once) { \
96 __print_once = true; \
101 #define pr_info_once(fmt, ...) do { \
102 static bool __printed_once; \
104 if (!__printed_once) { \
105 __printed_once = true; \
106 kprintf(fmt, ##__VA_ARGS__); \
117 print_hex_dump(const char *level, const char *prefix_str, int prefix_type,
118 int rowsize, int groupsize, const void *buf, size_t len, bool ascii)
123 if (prefix_type != DUMP_PREFIX_OFFSET)
124 flags |= HD_OMIT_COUNT;
126 flags |= HD_OMIT_CHARS;
128 hexdump(buf, len, prefix_str, flags);
131 #endif /* _LINUX_PRINTK_H_ */