xref: /illumos-gate/usr/src/grub/grub-0.97/stage2/term.h (revision a5602e1bdcf9570fa24684b54cf57a3f22e05ae1)
1 /* term.h - definitions for terminal handling */
2 /*
3  *  GRUB  --  GRand Unified Bootloader
4  *  Copyright (C) 2002  Free Software Foundation, Inc.
5  *
6  *  This program is free software; you can redistribute it and/or modify
7  *  it under the terms of the GNU General Public License as published by
8  *  the Free Software Foundation; either version 2 of the License, or
9  *  (at your option) any later version.
10  *
11  *  This program is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *  GNU General Public License for more details.
15  *
16  *  You should have received a copy of the GNU General Public License
17  *  along with this program; if not, write to the Free Software
18  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19  */
20 
21 #ifndef GRUB_TERM_HEADER
22 #define GRUB_TERM_HEADER	1
23 
24 /* These are used to represent the various color states we use */
25 typedef enum
26 {
27   /* represents the color used to display all text that does not use the user
28    * defined colors below
29    */
30   COLOR_STATE_STANDARD,
31   /* represents the user defined colors for normal text */
32   COLOR_STATE_NORMAL,
33   /* represents the user defined colors for highlighted text */
34   COLOR_STATE_HIGHLIGHT
35 } color_state;
36 
37 #ifndef STAGE1_5
38 
39 /* Flags for representing the capabilities of a terminal.  */
40 /* Some notes about the flags:
41    - These flags are used by higher-level functions but not terminals
42    themselves.
43    - If a terminal is dumb, you may assume that only putchar, getkey and
44    checkkey are called.
45    - Some fancy features (nocursor, setcolor, and highlight) can be set to
46    NULL.  */
47 
48 /* Set when input characters shouldn't be echoed back.  */
49 #define TERM_NO_ECHO		(1 << 0)
50 /* Set when the editing feature should be disabled.  */
51 #define TERM_NO_EDIT		(1 << 1)
52 /* Set when the terminal cannot do fancy things.  */
53 #define TERM_DUMB		(1 << 2)
54 /* Set when the terminal needs to be initialized.  */
55 #define TERM_NEED_INIT		(1 << 16)
56 
57 struct term_entry
58 {
59   /* The name of a terminal.  */
60   const char *name;
61   /* The feature flags defined above.  */
62   unsigned long flags;
63   /* Default for maximum number of lines if not specified */
64   unsigned short max_lines;
65   /* Put a character.  */
66   void (*putchar) (int c);
67   /* Check if any input character is available.  */
68   int (*checkkey) (void);
69   /* Get a character.  */
70   int (*getkey) (void);
71   /* Get the cursor position. The return value is ((X << 8) | Y).  */
72   int (*getxy) (void);
73   /* Go to the position (X, Y).  */
74   void (*gotoxy) (int x, int y);
75   /* Clear the screen.  */
76   void (*cls) (void);
77   /* Set the current color to be used */
78   void (*setcolorstate) (color_state state);
79   /* Set the normal color and the highlight color. The format of each
80      color is VGA's.  */
81   void (*setcolor) (int normal_color, int highlight_color);
82   /* Turn on/off the cursor.  */
83   int (*setcursor) (int on);
84 
85   /* function to start a terminal */
86   int (*startup) (void);
87   /* function to use to shutdown a terminal */
88   void (*shutdown) (void);
89 };
90 
91 /* This lists up available terminals.  */
92 extern struct term_entry term_table[];
93 /* This points to the current terminal. This is useful, because only
94    a single terminal is enabled normally.  */
95 extern struct term_entry *current_term;
96 
97 #endif /* ! STAGE1_5 */
98 
99 /* The console stuff.  */
100 extern int console_current_color;
101 void console_putchar (int c);
102 
103 #ifndef STAGE1_5
104 int console_checkkey (void);
105 int console_getkey (void);
106 int console_getxy (void);
107 void console_gotoxy (int x, int y);
108 void console_cls (void);
109 void console_setcolorstate (color_state state);
110 void console_setcolor (int normal_color, int highlight_color);
111 int console_setcursor (int on);
112 #endif
113 
114 #ifdef SUPPORT_SERIAL
115 void serial_putchar (int c);
116 int serial_checkkey (void);
117 int serial_getkey (void);
118 int serial_getxy (void);
119 void serial_gotoxy (int x, int y);
120 void serial_cls (void);
121 void serial_setcolorstate (color_state state);
122 
123 void composite_putchar (int c);
124 int composite_checkkey (void);
125 int composite_getkey (void);
126 int composite_getxy (void);
127 void composite_gotoxy (int x, int y);
128 void composite_cls (void);
129 void composite_setcolorstate (color_state state);
130 #endif
131 
132 #ifdef SUPPORT_HERCULES
133 void hercules_putchar (int c);
134 int hercules_getxy (void);
135 void hercules_gotoxy (int x, int y);
136 void hercules_cls (void);
137 void hercules_setcolorstate (color_state state);
138 void hercules_setcolor (int normal_color, int highlight_color);
139 int hercules_setcursor (int on);
140 #endif
141 
142 #ifdef SUPPORT_GRAPHICS
143 extern int foreground, background, border, graphics_inited;
144 
145 void graphics_set_splash(char *splashfile);
146 int set_videomode (int mode);
147 void graphics_putchar (int c);
148 int graphics_getxy(void);
149 void graphics_gotoxy(int x, int y);
150 void graphics_cls(void);
151 void graphics_setcolorstate (color_state state);
152 void graphics_setcolor (int normal_color, int highlight_color);
153 int graphics_setcursor (int on);
154 int graphics_init(void);
155 void graphics_end(void);
156 
157 int hex(int v);
158 void graphics_set_palette(int idx, int red, int green, int blue);
159 #endif /* SUPPORT_GRAPHICS */
160 
161 #endif /* ! GRUB_TERM_HEADER */
162