blob: 9f3ed2fdb72114286ffe7f3264664615d4c161de [file] [log] [blame]
Thomas Gleixner1ccea772019-05-19 15:51:43 +02001/* SPDX-License-Identifier: GPL-2.0-or-later */
Petr Mladek42a0bb32016-05-20 17:00:33 -07002/*
3 * internal.h - printk internal definitions
Petr Mladek42a0bb32016-05-20 17:00:33 -07004 */
5#include <linux/percpu.h>
6
Sergey Senozhatsky099f1c82016-12-27 23:16:06 +09007#ifdef CONFIG_PRINTK
8
Chris Downa1ad4b82021-06-15 17:52:48 +01009/* Flags for a single printk record. */
10enum printk_info_flags {
11 LOG_NEWLINE = 2, /* text ended with a newline */
12 LOG_CONT = 8, /* text is a fragment of a continuation line */
13};
14
John Ogness74caba72020-09-21 13:24:45 +020615__printf(4, 0)
Petr Mladek03fc7f92018-06-27 16:20:28 +020016int vprintk_store(int facility, int level,
John Ogness74caba72020-09-21 13:24:45 +020617 const struct dev_printk_info *dev_info,
Petr Mladek03fc7f92018-06-27 16:20:28 +020018 const char *fmt, va_list args);
19
Sergey Senozhatsky099f1c82016-12-27 23:16:06 +090020__printf(1, 0) int vprintk_default(const char *fmt, va_list args);
Petr Mladek719f6a72017-04-20 10:52:31 +020021__printf(1, 0) int vprintk_deferred(const char *fmt, va_list args);
Sergey Senozhatsky099f1c82016-12-27 23:16:06 +090022
Sergey Senozhatskyab6f7622020-03-03 20:30:02 +090023bool printk_percpu_data_ready(void);
24
Sergey Senozhatsky099f1c82016-12-27 23:16:06 +090025#define printk_safe_enter_irqsave(flags) \
26 do { \
27 local_irq_save(flags); \
28 __printk_safe_enter(); \
29 } while (0)
30
31#define printk_safe_exit_irqrestore(flags) \
32 do { \
33 __printk_safe_exit(); \
34 local_irq_restore(flags); \
35 } while (0)
36
Petr Mladek03fc7f92018-06-27 16:20:28 +020037void defer_console_output(void);
38
Chris Downf3d75cf2021-06-15 17:52:51 +010039u16 printk_parse_prefix(const char *text, int *level,
40 enum printk_info_flags *flags);
Sergey Senozhatsky099f1c82016-12-27 23:16:06 +090041#else
42
Sergey Senozhatsky099f1c82016-12-27 23:16:06 +090043/*
John Ogness996e9662021-03-03 11:15:26 +010044 * In !PRINTK builds we still export console_sem
Sergey Senozhatsky099f1c82016-12-27 23:16:06 +090045 * semaphore and some of console functions (console_unlock()/etc.), so
46 * printk-safe must preserve the existing local IRQ guarantees.
47 */
48#define printk_safe_enter_irqsave(flags) local_irq_save(flags)
49#define printk_safe_exit_irqrestore(flags) local_irq_restore(flags)
50
Sergey Senozhatskyab6f7622020-03-03 20:30:02 +090051static inline bool printk_percpu_data_ready(void) { return false; }
Sergey Senozhatsky099f1c82016-12-27 23:16:06 +090052#endif /* CONFIG_PRINTK */