Thomas Gleixner | 1ccea77 | 2019-05-19 15:51:43 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
Petr Mladek | 42a0bb3 | 2016-05-20 17:00:33 -0700 | [diff] [blame] | 2 | /* |
| 3 | * internal.h - printk internal definitions |
Petr Mladek | 42a0bb3 | 2016-05-20 17:00:33 -0700 | [diff] [blame] | 4 | */ |
| 5 | #include <linux/percpu.h> |
| 6 | |
Sergey Senozhatsky | 099f1c8 | 2016-12-27 23:16:06 +0900 | [diff] [blame] | 7 | #ifdef CONFIG_PRINTK |
| 8 | |
Chris Down | a1ad4b8 | 2021-06-15 17:52:48 +0100 | [diff] [blame] | 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 | |
John Ogness | 74caba7 | 2020-09-21 13:24:45 +0206 | [diff] [blame] | 15 | __printf(4, 0) |
Petr Mladek | 03fc7f9 | 2018-06-27 16:20:28 +0200 | [diff] [blame] | 16 | int vprintk_store(int facility, int level, |
John Ogness | 74caba7 | 2020-09-21 13:24:45 +0206 | [diff] [blame] | 17 | const struct dev_printk_info *dev_info, |
Petr Mladek | 03fc7f9 | 2018-06-27 16:20:28 +0200 | [diff] [blame] | 18 | const char *fmt, va_list args); |
| 19 | |
Sergey Senozhatsky | 099f1c8 | 2016-12-27 23:16:06 +0900 | [diff] [blame] | 20 | __printf(1, 0) int vprintk_default(const char *fmt, va_list args); |
Petr Mladek | 719f6a7 | 2017-04-20 10:52:31 +0200 | [diff] [blame] | 21 | __printf(1, 0) int vprintk_deferred(const char *fmt, va_list args); |
Sergey Senozhatsky | 099f1c8 | 2016-12-27 23:16:06 +0900 | [diff] [blame] | 22 | |
Sergey Senozhatsky | ab6f762 | 2020-03-03 20:30:02 +0900 | [diff] [blame] | 23 | bool printk_percpu_data_ready(void); |
| 24 | |
Sergey Senozhatsky | 099f1c8 | 2016-12-27 23:16:06 +0900 | [diff] [blame] | 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 | |
Petr Mladek | 03fc7f9 | 2018-06-27 16:20:28 +0200 | [diff] [blame] | 37 | void defer_console_output(void); |
| 38 | |
Chris Down | f3d75cf | 2021-06-15 17:52:51 +0100 | [diff] [blame] | 39 | u16 printk_parse_prefix(const char *text, int *level, |
| 40 | enum printk_info_flags *flags); |
Sergey Senozhatsky | 099f1c8 | 2016-12-27 23:16:06 +0900 | [diff] [blame] | 41 | #else |
| 42 | |
Sergey Senozhatsky | 099f1c8 | 2016-12-27 23:16:06 +0900 | [diff] [blame] | 43 | /* |
John Ogness | 996e966 | 2021-03-03 11:15:26 +0100 | [diff] [blame] | 44 | * In !PRINTK builds we still export console_sem |
Sergey Senozhatsky | 099f1c8 | 2016-12-27 23:16:06 +0900 | [diff] [blame] | 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 | |
Sergey Senozhatsky | ab6f762 | 2020-03-03 20:30:02 +0900 | [diff] [blame] | 51 | static inline bool printk_percpu_data_ready(void) { return false; } |
Sergey Senozhatsky | 099f1c8 | 2016-12-27 23:16:06 +0900 | [diff] [blame] | 52 | #endif /* CONFIG_PRINTK */ |