internal.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * internal.h - printk internal definitions
  4. */
  5. #include <linux/percpu.h>
  6. #if defined(CONFIG_PRINTK) && defined(CONFIG_SYSCTL)
  7. void __init printk_sysctl_init(void);
  8. int devkmsg_sysctl_set_loglvl(struct ctl_table *table, int write,
  9. void *buffer, size_t *lenp, loff_t *ppos);
  10. #else
  11. #define printk_sysctl_init() do { } while (0)
  12. #endif
  13. #ifdef CONFIG_PRINTK
  14. /* Flags for a single printk record. */
  15. enum printk_info_flags {
  16. LOG_NEWLINE = 2, /* text ended with a newline */
  17. LOG_CONT = 8, /* text is a fragment of a continuation line */
  18. };
  19. __printf(4, 0)
  20. int vprintk_store(int facility, int level,
  21. const struct dev_printk_info *dev_info,
  22. const char *fmt, va_list args);
  23. __printf(1, 0) int vprintk_default(const char *fmt, va_list args);
  24. __printf(1, 0) int vprintk_deferred(const char *fmt, va_list args);
  25. bool printk_percpu_data_ready(void);
  26. #define printk_safe_enter_irqsave(flags) \
  27. do { \
  28. local_irq_save(flags); \
  29. __printk_safe_enter(); \
  30. } while (0)
  31. #define printk_safe_exit_irqrestore(flags) \
  32. do { \
  33. __printk_safe_exit(); \
  34. local_irq_restore(flags); \
  35. } while (0)
  36. void defer_console_output(void);
  37. u16 printk_parse_prefix(const char *text, int *level,
  38. enum printk_info_flags *flags);
  39. #else
  40. /*
  41. * In !PRINTK builds we still export console_sem
  42. * semaphore and some of console functions (console_unlock()/etc.), so
  43. * printk-safe must preserve the existing local IRQ guarantees.
  44. */
  45. #define printk_safe_enter_irqsave(flags) local_irq_save(flags)
  46. #define printk_safe_exit_irqrestore(flags) local_irq_restore(flags)
  47. static inline bool printk_percpu_data_ready(void) { return false; }
  48. #endif /* CONFIG_PRINTK */