Commit | Line | Data |
---|---|---|
1ccea77e | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
42a0bb3f PM |
2 | /* |
3 | * internal.h - printk internal definitions | |
42a0bb3f PM |
4 | */ |
5 | #include <linux/percpu.h> | |
6 | ||
099f1c84 SS |
7 | #ifdef CONFIG_PRINTK |
8 | ||
8c4e93c3 PM |
9 | #define PRINTK_SAFE_CONTEXT_MASK 0x007ffffff |
10 | #define PRINTK_NMI_DIRECT_CONTEXT_MASK 0x008000000 | |
11 | #define PRINTK_NMI_CONTEXT_MASK 0xff0000000 | |
12 | ||
13 | #define PRINTK_NMI_CONTEXT_OFFSET 0x010000000 | |
099f1c84 | 14 | |
74caba7f | 15 | __printf(4, 0) |
03fc7f9c | 16 | int vprintk_store(int facility, int level, |
74caba7f | 17 | const struct dev_printk_info *dev_info, |
03fc7f9c PM |
18 | const char *fmt, va_list args); |
19 | ||
099f1c84 | 20 | __printf(1, 0) int vprintk_default(const char *fmt, va_list args); |
719f6a70 | 21 | __printf(1, 0) int vprintk_deferred(const char *fmt, va_list args); |
099f1c84 SS |
22 | void __printk_safe_enter(void); |
23 | void __printk_safe_exit(void); | |
24 | ||
ab6f762f SS |
25 | void printk_safe_init(void); |
26 | bool printk_percpu_data_ready(void); | |
27 | ||
099f1c84 SS |
28 | #define printk_safe_enter_irqsave(flags) \ |
29 | do { \ | |
30 | local_irq_save(flags); \ | |
31 | __printk_safe_enter(); \ | |
32 | } while (0) | |
33 | ||
34 | #define printk_safe_exit_irqrestore(flags) \ | |
35 | do { \ | |
36 | __printk_safe_exit(); \ | |
37 | local_irq_restore(flags); \ | |
38 | } while (0) | |
39 | ||
40 | #define printk_safe_enter_irq() \ | |
41 | do { \ | |
42 | local_irq_disable(); \ | |
43 | __printk_safe_enter(); \ | |
44 | } while (0) | |
45 | ||
46 | #define printk_safe_exit_irq() \ | |
47 | do { \ | |
48 | __printk_safe_exit(); \ | |
49 | local_irq_enable(); \ | |
50 | } while (0) | |
51 | ||
03fc7f9c PM |
52 | void defer_console_output(void); |
53 | ||
099f1c84 SS |
54 | #else |
55 | ||
099f1c84 | 56 | /* |
996e9666 | 57 | * In !PRINTK builds we still export console_sem |
099f1c84 SS |
58 | * semaphore and some of console functions (console_unlock()/etc.), so |
59 | * printk-safe must preserve the existing local IRQ guarantees. | |
60 | */ | |
61 | #define printk_safe_enter_irqsave(flags) local_irq_save(flags) | |
62 | #define printk_safe_exit_irqrestore(flags) local_irq_restore(flags) | |
63 | ||
64 | #define printk_safe_enter_irq() local_irq_disable() | |
65 | #define printk_safe_exit_irq() local_irq_enable() | |
66 | ||
ab6f762f SS |
67 | static inline void printk_safe_init(void) { } |
68 | static inline bool printk_percpu_data_ready(void) { return false; } | |
099f1c84 | 69 | #endif /* CONFIG_PRINTK */ |