console.h 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  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_font_copy)(struct vc_data *vc, int con);
  60. int (*con_resize)(struct vc_data *vc, unsigned int width,
  61. unsigned int height, unsigned int user);
  62. void (*con_set_palette)(struct vc_data *vc,
  63. const unsigned char *table);
  64. void (*con_scrolldelta)(struct vc_data *vc, int lines);
  65. int (*con_set_origin)(struct vc_data *vc);
  66. void (*con_save_screen)(struct vc_data *vc);
  67. u8 (*con_build_attr)(struct vc_data *vc, u8 color,
  68. enum vc_intensity intensity,
  69. bool blink, bool underline, bool reverse, bool italic);
  70. void (*con_invert_region)(struct vc_data *vc, u16 *p, int count);
  71. u16 *(*con_screen_pos)(const struct vc_data *vc, int offset);
  72. unsigned long (*con_getxy)(struct vc_data *vc, unsigned long position,
  73. int *px, int *py);
  74. /*
  75. * Flush the video console driver's scrollback buffer
  76. */
  77. void (*con_flush_scrollback)(struct vc_data *vc);
  78. /*
  79. * Prepare the console for the debugger. This includes, but is not
  80. * limited to, unblanking the console, loading an appropriate
  81. * palette, and allowing debugger generated output.
  82. */
  83. int (*con_debug_enter)(struct vc_data *vc);
  84. /*
  85. * Restore the console to its pre-debug state as closely as possible.
  86. */
  87. int (*con_debug_leave)(struct vc_data *vc);
  88. };
  89. extern const struct consw *conswitchp;
  90. extern const struct consw dummy_con; /* dummy console buffer */
  91. extern const struct consw vga_con; /* VGA text console */
  92. extern const struct consw newport_con; /* SGI Newport console */
  93. int con_is_bound(const struct consw *csw);
  94. int do_unregister_con_driver(const struct consw *csw);
  95. int do_take_over_console(const struct consw *sw, int first, int last, int deflt);
  96. void give_up_console(const struct consw *sw);
  97. #ifdef CONFIG_HW_CONSOLE
  98. int con_debug_enter(struct vc_data *vc);
  99. int con_debug_leave(void);
  100. #else
  101. static inline int con_debug_enter(struct vc_data *vc)
  102. {
  103. return 0;
  104. }
  105. static inline int con_debug_leave(void)
  106. {
  107. return 0;
  108. }
  109. #endif
  110. /* cursor */
  111. #define CM_DRAW (1)
  112. #define CM_ERASE (2)
  113. #define CM_MOVE (3)
  114. /*
  115. * The interface for a console, or any other device that wants to capture
  116. * console messages (printer driver?)
  117. *
  118. * If a console driver is marked CON_BOOT then it will be auto-unregistered
  119. * when the first real console is registered. This is for early-printk drivers.
  120. */
  121. #define CON_PRINTBUFFER (1)
  122. #define CON_CONSDEV (2) /* Preferred console, /dev/console */
  123. #define CON_ENABLED (4)
  124. #define CON_BOOT (8)
  125. #define CON_ANYTIME (16) /* Safe to call when cpu is offline */
  126. #define CON_BRL (32) /* Used for a braille device */
  127. #define CON_EXTENDED (64) /* Use the extended output format a la /dev/kmsg */
  128. struct console {
  129. char name[16];
  130. void (*write)(struct console *, const char *, unsigned);
  131. int (*read)(struct console *, char *, unsigned);
  132. struct tty_driver *(*device)(struct console *, int *);
  133. void (*unblank)(void);
  134. int (*setup)(struct console *, char *);
  135. int (*exit)(struct console *);
  136. int (*match)(struct console *, char *name, int idx, char *options);
  137. short flags;
  138. short index;
  139. int cflag;
  140. void *data;
  141. struct console *next;
  142. };
  143. /*
  144. * for_each_console() allows you to iterate on each console
  145. */
  146. #define for_each_console(con) \
  147. for (con = console_drivers; con != NULL; con = con->next)
  148. extern int console_set_on_cmdline;
  149. extern struct console *early_console;
  150. enum con_flush_mode {
  151. CONSOLE_FLUSH_PENDING,
  152. CONSOLE_REPLAY_ALL,
  153. };
  154. extern int add_preferred_console(char *name, int idx, char *options);
  155. extern void register_console(struct console *);
  156. extern int unregister_console(struct console *);
  157. extern struct console *console_drivers;
  158. extern void console_lock(void);
  159. extern int console_trylock(void);
  160. extern void console_unlock(void);
  161. extern void console_conditional_schedule(void);
  162. extern void console_unblank(void);
  163. extern void console_flush_on_panic(enum con_flush_mode mode);
  164. extern struct tty_driver *console_device(int *);
  165. extern void console_stop(struct console *);
  166. extern void console_start(struct console *);
  167. extern int is_console_locked(void);
  168. extern int braille_register_console(struct console *, int index,
  169. char *console_options, char *braille_options);
  170. extern int braille_unregister_console(struct console *);
  171. #ifdef CONFIG_TTY
  172. extern void console_sysfs_notify(void);
  173. #else
  174. static inline void console_sysfs_notify(void)
  175. { }
  176. #endif
  177. extern bool console_suspend_enabled;
  178. /* Suspend and resume console messages over PM events */
  179. extern void suspend_console(void);
  180. extern void resume_console(void);
  181. int mda_console_init(void);
  182. void vcs_make_sysfs(int index);
  183. void vcs_remove_sysfs(int index);
  184. /* Some debug stub to catch some of the obvious races in the VT code */
  185. #define WARN_CONSOLE_UNLOCKED() \
  186. WARN_ON(!atomic_read(&ignore_console_lock_warning) && \
  187. !is_console_locked() && !oops_in_progress)
  188. /*
  189. * Increment ignore_console_lock_warning if you need to quiet
  190. * WARN_CONSOLE_UNLOCKED() for debugging purposes.
  191. */
  192. extern atomic_t ignore_console_lock_warning;
  193. /* VESA Blanking Levels */
  194. #define VESA_NO_BLANKING 0
  195. #define VESA_VSYNC_SUSPEND 1
  196. #define VESA_HSYNC_SUSPEND 2
  197. #define VESA_POWERDOWN 3
  198. #ifdef CONFIG_VGA_CONSOLE
  199. extern bool vgacon_text_force(void);
  200. #else
  201. static inline bool vgacon_text_force(void) { return false; }
  202. #endif
  203. extern void console_init(void);
  204. /* For deferred console takeover */
  205. void dummycon_register_output_notifier(struct notifier_block *nb);
  206. void dummycon_unregister_output_notifier(struct notifier_block *nb);
  207. #endif /* _LINUX_CONSOLE_H */