1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 * internal.h - printk internal definitions
5 #include <linux/percpu.h>
7 #if defined(CONFIG_PRINTK) && defined(CONFIG_SYSCTL)
8 void __init printk_sysctl_init(void);
9 int devkmsg_sysctl_set_loglvl(struct ctl_table *table, int write,
10 void *buffer, size_t *lenp, loff_t *ppos);
12 #define printk_sysctl_init() do { } while (0)
17 #ifdef CONFIG_PRINTK_CALLER
18 #define PRINTK_PREFIX_MAX 48
20 #define PRINTK_PREFIX_MAX 32
24 * the maximum size of a formatted record (i.e. with prefix added
25 * per line and dropped messages or in extended message format)
27 #define PRINTK_MESSAGE_MAX 2048
29 /* the maximum size allowed to be reserved for a record */
30 #define PRINTKRB_RECORD_MAX 1024
32 /* Flags for a single printk record. */
33 enum printk_info_flags {
34 LOG_NEWLINE = 2, /* text ended with a newline */
35 LOG_CONT = 8, /* text is a fragment of a continuation line */
39 int vprintk_store(int facility, int level,
40 const struct dev_printk_info *dev_info,
41 const char *fmt, va_list args);
43 __printf(1, 0) int vprintk_default(const char *fmt, va_list args);
44 __printf(1, 0) int vprintk_deferred(const char *fmt, va_list args);
46 bool printk_percpu_data_ready(void);
48 #define printk_safe_enter_irqsave(flags) \
50 local_irq_save(flags); \
51 __printk_safe_enter(); \
54 #define printk_safe_exit_irqrestore(flags) \
56 __printk_safe_exit(); \
57 local_irq_restore(flags); \
60 void defer_console_output(void);
62 u16 printk_parse_prefix(const char *text, int *level,
63 enum printk_info_flags *flags);
66 #define PRINTK_PREFIX_MAX 0
67 #define PRINTK_MESSAGE_MAX 0
68 #define PRINTKRB_RECORD_MAX 0
71 * In !PRINTK builds we still export console_sem
72 * semaphore and some of console functions (console_unlock()/etc.), so
73 * printk-safe must preserve the existing local IRQ guarantees.
75 #define printk_safe_enter_irqsave(flags) local_irq_save(flags)
76 #define printk_safe_exit_irqrestore(flags) local_irq_restore(flags)
78 static inline bool printk_percpu_data_ready(void) { return false; }
79 #endif /* CONFIG_PRINTK */
82 * struct printk_buffers - Buffers to read/format/output printk messages.
83 * @outbuf: After formatting, contains text to output.
84 * @scratchbuf: Used as temporary ringbuffer reading and string-print space.
86 struct printk_buffers {
87 char outbuf[PRINTK_MESSAGE_MAX];
88 char scratchbuf[PRINTKRB_RECORD_MAX];
92 * struct printk_message - Container for a prepared printk message.
93 * @pbufs: printk buffers used to prepare the message.
94 * @outbuf_len: The length of prepared text in @pbufs->outbuf to output. This
95 * does not count the terminator. A value of 0 means there is
96 * nothing to output and this record should be skipped.
97 * @seq: The sequence number of the record used for @pbufs->outbuf.
98 * @dropped: The number of dropped records from reading @seq.
100 struct printk_message {
101 struct printk_buffers *pbufs;
102 unsigned int outbuf_len;
104 unsigned long dropped;
107 bool other_cpu_in_panic(void);