Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  *  linux/include/linux/console.h
0003  *
0004  *  Copyright (C) 1993        Hamish Macdonald
0005  *
0006  * This file is subject to the terms and conditions of the GNU General Public
0007  * License.  See the file COPYING in the main directory of this archive
0008  * for more details.
0009  *
0010  * Changed:
0011  * 10-Mar-94: Arno Griffioen: Conversion for vt100 emulator port from PC LINUX
0012  */
0013 
0014 #ifndef _LINUX_CONSOLE_H_
0015 #define _LINUX_CONSOLE_H_ 1
0016 
0017 #include <linux/atomic.h>
0018 #include <linux/types.h>
0019 
0020 struct vc_data;
0021 struct console_font_op;
0022 struct console_font;
0023 struct module;
0024 struct tty_struct;
0025 struct notifier_block;
0026 
0027 enum con_scroll {
0028     SM_UP,
0029     SM_DOWN,
0030 };
0031 
0032 enum vc_intensity;
0033 
0034 /**
0035  * struct consw - callbacks for consoles
0036  *
0037  * @con_scroll: move lines from @top to @bottom in direction @dir by @lines.
0038  *      Return true if no generic handling should be done.
0039  *      Invoked by csi_M and printing to the console.
0040  * @con_set_palette: sets the palette of the console to @table (optional)
0041  * @con_scrolldelta: the contents of the console should be scrolled by @lines.
0042  *           Invoked by user. (optional)
0043  */
0044 struct consw {
0045     struct module *owner;
0046     const char *(*con_startup)(void);
0047     void    (*con_init)(struct vc_data *vc, int init);
0048     void    (*con_deinit)(struct vc_data *vc);
0049     void    (*con_clear)(struct vc_data *vc, int sy, int sx, int height,
0050             int width);
0051     void    (*con_putc)(struct vc_data *vc, int c, int ypos, int xpos);
0052     void    (*con_putcs)(struct vc_data *vc, const unsigned short *s,
0053             int count, int ypos, int xpos);
0054     void    (*con_cursor)(struct vc_data *vc, int mode);
0055     bool    (*con_scroll)(struct vc_data *vc, unsigned int top,
0056             unsigned int bottom, enum con_scroll dir,
0057             unsigned int lines);
0058     int (*con_switch)(struct vc_data *vc);
0059     int (*con_blank)(struct vc_data *vc, int blank, int mode_switch);
0060     int (*con_font_set)(struct vc_data *vc, struct console_font *font,
0061             unsigned int flags);
0062     int (*con_font_get)(struct vc_data *vc, struct console_font *font);
0063     int (*con_font_default)(struct vc_data *vc,
0064             struct console_font *font, char *name);
0065     int     (*con_resize)(struct vc_data *vc, unsigned int width,
0066             unsigned int height, unsigned int user);
0067     void    (*con_set_palette)(struct vc_data *vc,
0068             const unsigned char *table);
0069     void    (*con_scrolldelta)(struct vc_data *vc, int lines);
0070     int (*con_set_origin)(struct vc_data *vc);
0071     void    (*con_save_screen)(struct vc_data *vc);
0072     u8  (*con_build_attr)(struct vc_data *vc, u8 color,
0073             enum vc_intensity intensity,
0074             bool blink, bool underline, bool reverse, bool italic);
0075     void    (*con_invert_region)(struct vc_data *vc, u16 *p, int count);
0076     u16    *(*con_screen_pos)(const struct vc_data *vc, int offset);
0077     unsigned long (*con_getxy)(struct vc_data *vc, unsigned long position,
0078             int *px, int *py);
0079     /*
0080      * Flush the video console driver's scrollback buffer
0081      */
0082     void    (*con_flush_scrollback)(struct vc_data *vc);
0083     /*
0084      * Prepare the console for the debugger.  This includes, but is not
0085      * limited to, unblanking the console, loading an appropriate
0086      * palette, and allowing debugger generated output.
0087      */
0088     int (*con_debug_enter)(struct vc_data *vc);
0089     /*
0090      * Restore the console to its pre-debug state as closely as possible.
0091      */
0092     int (*con_debug_leave)(struct vc_data *vc);
0093 };
0094 
0095 extern const struct consw *conswitchp;
0096 
0097 extern const struct consw dummy_con;    /* dummy console buffer */
0098 extern const struct consw vga_con;  /* VGA text console */
0099 extern const struct consw newport_con;  /* SGI Newport console  */
0100 
0101 int con_is_bound(const struct consw *csw);
0102 int do_unregister_con_driver(const struct consw *csw);
0103 int do_take_over_console(const struct consw *sw, int first, int last, int deflt);
0104 void give_up_console(const struct consw *sw);
0105 #ifdef CONFIG_HW_CONSOLE
0106 int con_debug_enter(struct vc_data *vc);
0107 int con_debug_leave(void);
0108 #else
0109 static inline int con_debug_enter(struct vc_data *vc)
0110 {
0111     return 0;
0112 }
0113 static inline int con_debug_leave(void)
0114 {
0115     return 0;
0116 }
0117 #endif
0118 
0119 /* cursor */
0120 #define CM_DRAW     (1)
0121 #define CM_ERASE    (2)
0122 #define CM_MOVE     (3)
0123 
0124 /*
0125  * The interface for a console, or any other device that wants to capture
0126  * console messages (printer driver?)
0127  *
0128  * If a console driver is marked CON_BOOT then it will be auto-unregistered
0129  * when the first real console is registered.  This is for early-printk drivers.
0130  */
0131 
0132 #define CON_PRINTBUFFER (1)
0133 #define CON_CONSDEV (2) /* Preferred console, /dev/console */
0134 #define CON_ENABLED (4)
0135 #define CON_BOOT    (8)
0136 #define CON_ANYTIME (16) /* Safe to call when cpu is offline */
0137 #define CON_BRL     (32) /* Used for a braille device */
0138 #define CON_EXTENDED    (64) /* Use the extended output format a la /dev/kmsg */
0139 
0140 struct console {
0141     char    name[16];
0142     void    (*write)(struct console *, const char *, unsigned);
0143     int (*read)(struct console *, char *, unsigned);
0144     struct tty_driver *(*device)(struct console *, int *);
0145     void    (*unblank)(void);
0146     int (*setup)(struct console *, char *);
0147     int (*exit)(struct console *);
0148     int (*match)(struct console *, char *name, int idx, char *options);
0149     short   flags;
0150     short   index;
0151     int cflag;
0152     uint    ispeed;
0153     uint    ospeed;
0154     u64 seq;
0155     unsigned long dropped;
0156     void    *data;
0157     struct   console *next;
0158 };
0159 
0160 /*
0161  * for_each_console() allows you to iterate on each console
0162  */
0163 #define for_each_console(con) \
0164     for (con = console_drivers; con != NULL; con = con->next)
0165 
0166 extern int console_set_on_cmdline;
0167 extern struct console *early_console;
0168 
0169 enum con_flush_mode {
0170     CONSOLE_FLUSH_PENDING,
0171     CONSOLE_REPLAY_ALL,
0172 };
0173 
0174 extern int add_preferred_console(char *name, int idx, char *options);
0175 extern void register_console(struct console *);
0176 extern int unregister_console(struct console *);
0177 extern struct console *console_drivers;
0178 extern void console_lock(void);
0179 extern int console_trylock(void);
0180 extern void console_unlock(void);
0181 extern void console_conditional_schedule(void);
0182 extern void console_unblank(void);
0183 extern void console_flush_on_panic(enum con_flush_mode mode);
0184 extern struct tty_driver *console_device(int *);
0185 extern void console_stop(struct console *);
0186 extern void console_start(struct console *);
0187 extern int is_console_locked(void);
0188 extern int braille_register_console(struct console *, int index,
0189         char *console_options, char *braille_options);
0190 extern int braille_unregister_console(struct console *);
0191 #ifdef CONFIG_TTY
0192 extern void console_sysfs_notify(void);
0193 #else
0194 static inline void console_sysfs_notify(void)
0195 { }
0196 #endif
0197 extern bool console_suspend_enabled;
0198 
0199 /* Suspend and resume console messages over PM events */
0200 extern void suspend_console(void);
0201 extern void resume_console(void);
0202 
0203 int mda_console_init(void);
0204 
0205 void vcs_make_sysfs(int index);
0206 void vcs_remove_sysfs(int index);
0207 
0208 /* Some debug stub to catch some of the obvious races in the VT code */
0209 #define WARN_CONSOLE_UNLOCKED()                     \
0210     WARN_ON(!atomic_read(&ignore_console_lock_warning) &&       \
0211         !is_console_locked() && !oops_in_progress)
0212 /*
0213  * Increment ignore_console_lock_warning if you need to quiet
0214  * WARN_CONSOLE_UNLOCKED() for debugging purposes.
0215  */
0216 extern atomic_t ignore_console_lock_warning;
0217 
0218 /* VESA Blanking Levels */
0219 #define VESA_NO_BLANKING        0
0220 #define VESA_VSYNC_SUSPEND      1
0221 #define VESA_HSYNC_SUSPEND      2
0222 #define VESA_POWERDOWN          3
0223 
0224 extern void console_init(void);
0225 
0226 /* For deferred console takeover */
0227 void dummycon_register_output_notifier(struct notifier_block *nb);
0228 void dummycon_unregister_output_notifier(struct notifier_block *nb);
0229 
0230 #endif /* _LINUX_CONSOLE_H */