console.h 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. /*
  2. * linux/include/linux/console.h
  3. *
  4. * Copyright (C) 1993 Hamish Macdonald
  5. *
  6. * This file is subject to the terms and conditions of the GNU General Public
  7. * License. See the file COPYING in the main directory of this archive
  8. * for more details.
  9. *
  10. * Changed:
  11. * 10-Mar-94: Arno Griffioen: Conversion for vt100 emulator port from PC LINUX
  12. */
  13. #ifndef _LINUX_CONSOLE_H_
  14. #define _LINUX_CONSOLE_H_ 1
  15. #include <linux/atomic.h>
  16. #include <linux/types.h>
  17. struct vc_data;
  18. struct console_font_op;
  19. struct console_font;
  20. struct module;
  21. struct tty_struct;
  22. struct notifier_block;
  23. enum con_scroll {
  24. SM_UP,
  25. SM_DOWN,
  26. };
  27. enum vc_intensity;
  28. /**
  29. * struct consw - callbacks for consoles
  30. *
  31. * @con_scroll: move lines from @top to @bottom in direction @dir by @lines.
  32. * Return true if no generic handling should be done.
  33. * Invoked by csi_M and printing to the console.
  34. * @con_set_palette: sets the palette of the console to @table (optional)
  35. * @con_scrolldelta: the contents of the console should be scrolled by @lines.
  36. * Invoked by user. (optional)
  37. */
  38. struct consw {
  39. struct module *owner;
  40. const char *(*con_startup)(void);
  41. void (*con_init)(struct vc_data *vc, int init);
  42. void (*con_deinit)(struct vc_data *vc);
  43. void (*con_clear)(struct vc_data *vc, int sy, int sx, int height,
  44. int width);
  45. void (*con_putc)(struct vc_data *vc, int c, int ypos, int xpos);
  46. void (*con_putcs)(struct vc_data *vc, const unsigned short *s,
  47. int count, int ypos, int xpos);
  48. void (*con_cursor)(struct vc_data *vc, int mode);
  49. bool (*con_scroll)(struct vc_data *vc, unsigned int top,
  50. unsigned int bottom, enum con_scroll dir,
  51. unsigned int lines);
  52. int (*con_switch)(struct vc_data *vc);
  53. int (*con_blank)(struct vc_data *vc, int blank, int mode_switch);
  54. int (*con_font_set)(struct vc_data *vc, struct console_font *font,
  55. unsigned int flags);
  56. int (*con_font_get)(struct vc_data *vc, struct console_font *font);
  57. int (*con_font_default)(struct vc_data *vc,
  58. struct console_font *font, char *name);
  59. int (*con_resize)(struct vc_data *vc, unsigned int width,
  60. unsigned int height, unsigned int user);
  61. void (*con_set_palette)(struct vc_data *vc,
  62. const unsigned char *table);
  63. void (*con_scrolldelta)(struct vc_data *vc, int lines);
  64. int (*con_set_origin)(struct vc_data *vc);
  65. void (*con_save_screen)(struct vc_data *vc);
  66. u8 (*con_build_attr)(struct vc_data *vc, u8 color,
  67. enum vc_intensity intensity,
  68. bool blink, bool underline, bool reverse, bool italic);
  69. void (*con_invert_region)(struct vc_data *vc, u16 *p, int count);
  70. u16 *(*con_screen_pos)(const struct vc_data *vc, int offset);
  71. unsigned long (*con_getxy)(struct vc_data *vc, unsigned long position,
  72. int *px, int *py);
  73. /*
  74. * Flush the video console driver's scrollback buffer
  75. */
  76. void (*con_flush_scrollback)(struct vc_data *vc);
  77. /*
  78. * Prepare the console for the debugger. This includes, but is not
  79. * limited to, unblanking the console, loading an appropriate
  80. * palette, and allowing debugger generated output.
  81. */
  82. int (*con_debug_enter)(struct vc_data *vc);
  83. /*
  84. * Restore the console to its pre-debug state as closely as possible.
  85. */
  86. int (*con_debug_leave)(struct vc_data *vc);
  87. };
  88. extern const struct consw *conswitchp;
  89. extern const struct consw dummy_con; /* dummy console buffer */
  90. extern const struct consw vga_con; /* VGA text console */
  91. extern const struct consw newport_con; /* SGI Newport console */
  92. int con_is_bound(const struct consw *csw);
  93. int do_unregister_con_driver(const struct consw *csw);
  94. int do_take_over_console(const struct consw *sw, int first, int last, int deflt);
  95. void give_up_console(const struct consw *sw);
  96. #ifdef CONFIG_HW_CONSOLE
  97. int con_debug_enter(struct vc_data *vc);
  98. int con_debug_leave(void);
  99. #else
  100. static inline int con_debug_enter(struct vc_data *vc)
  101. {
  102. return 0;
  103. }
  104. static inline int con_debug_leave(void)
  105. {
  106. return 0;
  107. }
  108. #endif
  109. /* cursor */
  110. #define CM_DRAW (1)
  111. #define CM_ERASE (2)
  112. #define CM_MOVE (3)
  113. /*
  114. * The interface for a console, or any other device that wants to capture
  115. * console messages (printer driver?)
  116. *
  117. * If a console driver is marked CON_BOOT then it will be auto-unregistered
  118. * when the first real console is registered. This is for early-printk drivers.
  119. */
  120. #define CON_PRINTBUFFER (1)
  121. #define CON_CONSDEV (2) /* Preferred console, /dev/console */
  122. #define CON_ENABLED (4)
  123. #define CON_BOOT (8)
  124. #define CON_ANYTIME (16) /* Safe to call when cpu is offline */
  125. #define CON_BRL (32) /* Used for a braille device */
  126. #define CON_EXTENDED (64) /* Use the extended output format a la /dev/kmsg */
  127. struct console {
  128. char name[16];
  129. void (*write)(struct console *, const char *, unsigned);
  130. int (*read)(struct console *, char *, unsigned);
  131. struct tty_driver *(*device)(struct console *, int *);
  132. void (*unblank)(void);
  133. int (*setup)(struct console *, char *);
  134. int (*exit)(struct console *);
  135. int (*match)(struct console *, char *name, int idx, char *options);
  136. short flags;
  137. short index;
  138. int cflag;
  139. uint ispeed;
  140. uint ospeed;
  141. u64 seq;
  142. unsigned long dropped;
  143. void *data;
  144. struct console *next;
  145. };
  146. /*
  147. * for_each_console() allows you to iterate on each console
  148. */
  149. #define for_each_console(con) \
  150. for (con = console_drivers; con != NULL; con = con->next)
  151. extern int console_set_on_cmdline;
  152. extern struct console *early_console;
  153. enum con_flush_mode {
  154. CONSOLE_FLUSH_PENDING,
  155. CONSOLE_REPLAY_ALL,
  156. };
  157. extern int add_preferred_console(char *name, int idx, char *options);
  158. extern void register_console(struct console *);
  159. extern int unregister_console(struct console *);
  160. extern struct console *console_drivers;
  161. extern void console_lock(void);
  162. extern int console_trylock(void);
  163. extern void console_unlock(void);
  164. extern void console_conditional_schedule(void);
  165. extern void console_unblank(void);
  166. extern void console_flush_on_panic(enum con_flush_mode mode);
  167. extern struct tty_driver *console_device(int *);
  168. extern void console_stop(struct console *);
  169. extern void console_start(struct console *);
  170. extern int is_console_locked(void);
  171. extern int braille_register_console(struct console *, int index,
  172. char *console_options, char *braille_options);
  173. extern int braille_unregister_console(struct console *);
  174. #ifdef CONFIG_TTY
  175. extern void console_sysfs_notify(void);
  176. #else
  177. static inline void console_sysfs_notify(void)
  178. { }
  179. #endif
  180. extern bool console_suspend_enabled;
  181. /* Suspend and resume console messages over PM events */
  182. extern void suspend_console(void);
  183. extern void resume_console(void);
  184. int mda_console_init(void);
  185. void vcs_make_sysfs(int index);
  186. void vcs_remove_sysfs(int index);
  187. /* Some debug stub to catch some of the obvious races in the VT code */
  188. #define WARN_CONSOLE_UNLOCKED() \
  189. WARN_ON(!atomic_read(&ignore_console_lock_warning) && \
  190. !is_console_locked() && !oops_in_progress)
  191. /*
  192. * Increment ignore_console_lock_warning if you need to quiet
  193. * WARN_CONSOLE_UNLOCKED() for debugging purposes.
  194. */
  195. extern atomic_t ignore_console_lock_warning;
  196. /* VESA Blanking Levels */
  197. #define VESA_NO_BLANKING 0
  198. #define VESA_VSYNC_SUSPEND 1
  199. #define VESA_HSYNC_SUSPEND 2
  200. #define VESA_POWERDOWN 3
  201. extern void console_init(void);
  202. /* For deferred console takeover */
  203. void dummycon_register_output_notifier(struct notifier_block *nb);
  204. void dummycon_unregister_output_notifier(struct notifier_block *nb);
  205. #endif /* _LINUX_CONSOLE_H */