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