1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
3  * internal.h - printk internal definitions
4  */
5 #include <linux/percpu.h>
6 
7 #ifdef CONFIG_PRINTK
8 
9 /* Flags for a single printk record. */
10 enum 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 
15 __printf(4, 0)
16 int vprintk_store(int facility, int level,
17 		  const struct dev_printk_info *dev_info,
18 		  const char *fmt, va_list args);
19 
20 __printf(1, 0) int vprintk_default(const char *fmt, va_list args);
21 __printf(1, 0) int vprintk_deferred(const char *fmt, va_list args);
22 
23 bool printk_percpu_data_ready(void);
24 
25 #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 
37 void defer_console_output(void);
38 
39 u16 printk_parse_prefix(const char *text, int *level,
40 			enum printk_info_flags *flags);
41 #else
42 
43 /*
44  * In !PRINTK builds we still export console_sem
45  * 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 
printk_percpu_data_ready(void)51 static inline bool printk_percpu_data_ready(void) { return false; }
52 #endif /* CONFIG_PRINTK */
53