Home | History | Annotate | Download | only in stage2
      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   /* Put a character.  */
     64   void (*putchar) (int c);
     65   /* Check if any input character is available.  */
     66   int (*checkkey) (void);
     67   /* Get a character.  */
     68   int (*getkey) (void);
     69   /* Get the cursor position. The return value is ((X << 8) | Y).  */
     70   int (*getxy) (void);
     71   /* Go to the position (X, Y).  */
     72   void (*gotoxy) (int x, int y);
     73   /* Clear the screen.  */
     74   void (*cls) (void);
     75   /* Set the current color to be used */
     76   void (*setcolorstate) (color_state state);
     77   /* Set the normal color and the highlight color. The format of each
     78      color is VGA's.  */
     79   void (*setcolor) (int normal_color, int highlight_color);
     80   /* Turn on/off the cursor.  */
     81   int (*setcursor) (int on);
     82 };
     83 
     84 /* This lists up available terminals.  */
     85 extern struct term_entry term_table[];
     86 /* This points to the current terminal. This is useful, because only
     87    a single terminal is enabled normally.  */
     88 extern struct term_entry *current_term;
     89 
     90 #endif /* ! STAGE1_5 */
     91 
     92 /* The console stuff.  */
     93 extern int console_current_color;
     94 void console_putchar (int c);
     95 
     96 #ifndef STAGE1_5
     97 int console_checkkey (void);
     98 int console_getkey (void);
     99 int console_getxy (void);
    100 void console_gotoxy (int x, int y);
    101 void console_cls (void);
    102 void console_setcolorstate (color_state state);
    103 void console_setcolor (int normal_color, int highlight_color);
    104 int console_setcursor (int on);
    105 #endif
    106 
    107 #ifdef SUPPORT_SERIAL
    108 void serial_putchar (int c);
    109 int serial_checkkey (void);
    110 int serial_getkey (void);
    111 int serial_getxy (void);
    112 void serial_gotoxy (int x, int y);
    113 void serial_cls (void);
    114 void serial_setcolorstate (color_state state);
    115 #endif
    116 
    117 #ifdef SUPPORT_HERCULES
    118 void hercules_putchar (int c);
    119 int hercules_getxy (void);
    120 void hercules_gotoxy (int x, int y);
    121 void hercules_cls (void);
    122 void hercules_setcolorstate (color_state state);
    123 void hercules_setcolor (int normal_color, int highlight_color);
    124 int hercules_setcursor (int on);
    125 #endif
    126 
    127 #endif /* ! GRUB_TERM_HEADER */
    128