17c478bd9Sstevel@tonic-gate /* term.h - definitions for terminal handling */
27c478bd9Sstevel@tonic-gate /*
37c478bd9Sstevel@tonic-gate  *  GRUB  --  GRand Unified Bootloader
47c478bd9Sstevel@tonic-gate  *  Copyright (C) 2002  Free Software Foundation, Inc.
57c478bd9Sstevel@tonic-gate  *
67c478bd9Sstevel@tonic-gate  *  This program is free software; you can redistribute it and/or modify
77c478bd9Sstevel@tonic-gate  *  it under the terms of the GNU General Public License as published by
87c478bd9Sstevel@tonic-gate  *  the Free Software Foundation; either version 2 of the License, or
97c478bd9Sstevel@tonic-gate  *  (at your option) any later version.
107c478bd9Sstevel@tonic-gate  *
117c478bd9Sstevel@tonic-gate  *  This program is distributed in the hope that it will be useful,
127c478bd9Sstevel@tonic-gate  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
137c478bd9Sstevel@tonic-gate  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
147c478bd9Sstevel@tonic-gate  *  GNU General Public License for more details.
157c478bd9Sstevel@tonic-gate  *
167c478bd9Sstevel@tonic-gate  *  You should have received a copy of the GNU General Public License
177c478bd9Sstevel@tonic-gate  *  along with this program; if not, write to the Free Software
187c478bd9Sstevel@tonic-gate  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
197c478bd9Sstevel@tonic-gate  */
207c478bd9Sstevel@tonic-gate 
217c478bd9Sstevel@tonic-gate #ifndef GRUB_TERM_HEADER
227c478bd9Sstevel@tonic-gate #define GRUB_TERM_HEADER	1
237c478bd9Sstevel@tonic-gate 
247c478bd9Sstevel@tonic-gate /* These are used to represent the various color states we use */
257c478bd9Sstevel@tonic-gate typedef enum
267c478bd9Sstevel@tonic-gate {
277c478bd9Sstevel@tonic-gate   /* represents the color used to display all text that does not use the user
287c478bd9Sstevel@tonic-gate    * defined colors below
297c478bd9Sstevel@tonic-gate    */
307c478bd9Sstevel@tonic-gate   COLOR_STATE_STANDARD,
317c478bd9Sstevel@tonic-gate   /* represents the user defined colors for normal text */
327c478bd9Sstevel@tonic-gate   COLOR_STATE_NORMAL,
337c478bd9Sstevel@tonic-gate   /* represents the user defined colors for highlighted text */
347c478bd9Sstevel@tonic-gate   COLOR_STATE_HIGHLIGHT
357c478bd9Sstevel@tonic-gate } color_state;
367c478bd9Sstevel@tonic-gate 
377c478bd9Sstevel@tonic-gate #ifndef STAGE1_5
387c478bd9Sstevel@tonic-gate 
397c478bd9Sstevel@tonic-gate /* Flags for representing the capabilities of a terminal.  */
407c478bd9Sstevel@tonic-gate /* Some notes about the flags:
417c478bd9Sstevel@tonic-gate    - These flags are used by higher-level functions but not terminals
427c478bd9Sstevel@tonic-gate    themselves.
437c478bd9Sstevel@tonic-gate    - If a terminal is dumb, you may assume that only putchar, getkey and
447c478bd9Sstevel@tonic-gate    checkkey are called.
457c478bd9Sstevel@tonic-gate    - Some fancy features (nocursor, setcolor, and highlight) can be set to
467c478bd9Sstevel@tonic-gate    NULL.  */
477c478bd9Sstevel@tonic-gate 
487c478bd9Sstevel@tonic-gate /* Set when input characters shouldn't be echoed back.  */
497c478bd9Sstevel@tonic-gate #define TERM_NO_ECHO		(1 << 0)
507c478bd9Sstevel@tonic-gate /* Set when the editing feature should be disabled.  */
517c478bd9Sstevel@tonic-gate #define TERM_NO_EDIT		(1 << 1)
527c478bd9Sstevel@tonic-gate /* Set when the terminal cannot do fancy things.  */
537c478bd9Sstevel@tonic-gate #define TERM_DUMB		(1 << 2)
547c478bd9Sstevel@tonic-gate /* Set when the terminal needs to be initialized.  */
557c478bd9Sstevel@tonic-gate #define TERM_NEED_INIT		(1 << 16)
567c478bd9Sstevel@tonic-gate 
577c478bd9Sstevel@tonic-gate struct term_entry
587c478bd9Sstevel@tonic-gate {
597c478bd9Sstevel@tonic-gate   /* The name of a terminal.  */
607c478bd9Sstevel@tonic-gate   const char *name;
617c478bd9Sstevel@tonic-gate   /* The feature flags defined above.  */
627c478bd9Sstevel@tonic-gate   unsigned long flags;
637c478bd9Sstevel@tonic-gate   /* Default for maximum number of lines if not specified */
647c478bd9Sstevel@tonic-gate   unsigned short max_lines;
657c478bd9Sstevel@tonic-gate   /* Put a character.  */
667c478bd9Sstevel@tonic-gate   void (*putchar) (int c);
677c478bd9Sstevel@tonic-gate   /* Check if any input character is available.  */
687c478bd9Sstevel@tonic-gate   int (*checkkey) (void);
697c478bd9Sstevel@tonic-gate   /* Get a character.  */
707c478bd9Sstevel@tonic-gate   int (*getkey) (void);
717c478bd9Sstevel@tonic-gate   /* Get the cursor position. The return value is ((X << 8) | Y).  */
727c478bd9Sstevel@tonic-gate   int (*getxy) (void);
737c478bd9Sstevel@tonic-gate   /* Go to the position (X, Y).  */
747c478bd9Sstevel@tonic-gate   void (*gotoxy) (int x, int y);
757c478bd9Sstevel@tonic-gate   /* Clear the screen.  */
767c478bd9Sstevel@tonic-gate   void (*cls) (void);
777c478bd9Sstevel@tonic-gate   /* Set the current color to be used */
787c478bd9Sstevel@tonic-gate   void (*setcolorstate) (color_state state);
797c478bd9Sstevel@tonic-gate   /* Set the normal color and the highlight color. The format of each
807c478bd9Sstevel@tonic-gate      color is VGA's.  */
817c478bd9Sstevel@tonic-gate   void (*setcolor) (int normal_color, int highlight_color);
827c478bd9Sstevel@tonic-gate   /* Turn on/off the cursor.  */
837c478bd9Sstevel@tonic-gate   int (*setcursor) (int on);
847c478bd9Sstevel@tonic-gate 
857c478bd9Sstevel@tonic-gate   /* function to start a terminal */
867c478bd9Sstevel@tonic-gate   int (*startup) (void);
877c478bd9Sstevel@tonic-gate   /* function to use to shutdown a terminal */
887c478bd9Sstevel@tonic-gate   void (*shutdown) (void);
897c478bd9Sstevel@tonic-gate };
907c478bd9Sstevel@tonic-gate 
917c478bd9Sstevel@tonic-gate /* This lists up available terminals.  */
927c478bd9Sstevel@tonic-gate extern struct term_entry term_table[];
937c478bd9Sstevel@tonic-gate /* This points to the current terminal. This is useful, because only
947c478bd9Sstevel@tonic-gate    a single terminal is enabled normally.  */
957c478bd9Sstevel@tonic-gate extern struct term_entry *current_term;
967c478bd9Sstevel@tonic-gate 
977c478bd9Sstevel@tonic-gate #endif /* ! STAGE1_5 */
987c478bd9Sstevel@tonic-gate 
997c478bd9Sstevel@tonic-gate /* The console stuff.  */
1007c478bd9Sstevel@tonic-gate extern int console_current_color;
1017c478bd9Sstevel@tonic-gate void console_putchar (int c);
1027c478bd9Sstevel@tonic-gate 
1037c478bd9Sstevel@tonic-gate #ifndef STAGE1_5
1047c478bd9Sstevel@tonic-gate int console_checkkey (void);
1057c478bd9Sstevel@tonic-gate int console_getkey (void);
1067c478bd9Sstevel@tonic-gate int console_getxy (void);
1077c478bd9Sstevel@tonic-gate void console_gotoxy (int x, int y);
1087c478bd9Sstevel@tonic-gate void console_cls (void);
1097c478bd9Sstevel@tonic-gate void console_setcolorstate (color_state state);
1107c478bd9Sstevel@tonic-gate void console_setcolor (int normal_color, int highlight_color);
1117c478bd9Sstevel@tonic-gate int console_setcursor (int on);
1127c478bd9Sstevel@tonic-gate #endif
1137c478bd9Sstevel@tonic-gate 
1147c478bd9Sstevel@tonic-gate #ifdef SUPPORT_SERIAL
1157c478bd9Sstevel@tonic-gate void serial_putchar (int c);
1167c478bd9Sstevel@tonic-gate int serial_checkkey (void);
1177c478bd9Sstevel@tonic-gate int serial_getkey (void);
1187c478bd9Sstevel@tonic-gate int serial_getxy (void);
1197c478bd9Sstevel@tonic-gate void serial_gotoxy (int x, int y);
1207c478bd9Sstevel@tonic-gate void serial_cls (void);
1217c478bd9Sstevel@tonic-gate void serial_setcolorstate (color_state state);
122*a5602e1bSKeith M Wesolowski 
123*a5602e1bSKeith M Wesolowski void composite_putchar (int c);
124*a5602e1bSKeith M Wesolowski int composite_checkkey (void);
125*a5602e1bSKeith M Wesolowski int composite_getkey (void);
126*a5602e1bSKeith M Wesolowski int composite_getxy (void);
127*a5602e1bSKeith M Wesolowski void composite_gotoxy (int x, int y);
128*a5602e1bSKeith M Wesolowski void composite_cls (void);
129*a5602e1bSKeith M Wesolowski void composite_setcolorstate (color_state state);
1307c478bd9Sstevel@tonic-gate #endif
1317c478bd9Sstevel@tonic-gate 
1327c478bd9Sstevel@tonic-gate #ifdef SUPPORT_HERCULES
1337c478bd9Sstevel@tonic-gate void hercules_putchar (int c);
1347c478bd9Sstevel@tonic-gate int hercules_getxy (void);
1357c478bd9Sstevel@tonic-gate void hercules_gotoxy (int x, int y);
1367c478bd9Sstevel@tonic-gate void hercules_cls (void);
1377c478bd9Sstevel@tonic-gate void hercules_setcolorstate (color_state state);
1387c478bd9Sstevel@tonic-gate void hercules_setcolor (int normal_color, int highlight_color);
1397c478bd9Sstevel@tonic-gate int hercules_setcursor (int on);
1407c478bd9Sstevel@tonic-gate #endif
1417c478bd9Sstevel@tonic-gate 
1427c478bd9Sstevel@tonic-gate #ifdef SUPPORT_GRAPHICS
1437c478bd9Sstevel@tonic-gate extern int foreground, background, border, graphics_inited;
1447c478bd9Sstevel@tonic-gate 
145a6e28364SSuhasini Peddada void graphics_set_splash(char *splashfile);
1467c478bd9Sstevel@tonic-gate int set_videomode (int mode);
1477c478bd9Sstevel@tonic-gate void graphics_putchar (int c);
1487c478bd9Sstevel@tonic-gate int graphics_getxy(void);
1497c478bd9Sstevel@tonic-gate void graphics_gotoxy(int x, int y);
1507c478bd9Sstevel@tonic-gate void graphics_cls(void);
1517c478bd9Sstevel@tonic-gate void graphics_setcolorstate (color_state state);
1527c478bd9Sstevel@tonic-gate void graphics_setcolor (int normal_color, int highlight_color);
1537c478bd9Sstevel@tonic-gate int graphics_setcursor (int on);
1547c478bd9Sstevel@tonic-gate int graphics_init(void);
1557c478bd9Sstevel@tonic-gate void graphics_end(void);
1567c478bd9Sstevel@tonic-gate 
1577c478bd9Sstevel@tonic-gate int hex(int v);
1587c478bd9Sstevel@tonic-gate void graphics_set_palette(int idx, int red, int green, int blue);
1597c478bd9Sstevel@tonic-gate #endif /* SUPPORT_GRAPHICS */
1607c478bd9Sstevel@tonic-gate 
1617c478bd9Sstevel@tonic-gate #endif /* ! GRUB_TERM_HEADER */
162