grub/include/grub/term.h

133 lines
4.2 KiB
C
Raw Normal View History

2002-12-27 08:53:07 +00:00
/*
* GRUB -- GRand Unified Bootloader
shinori K. Okuji <okuji@enbug.org> * genkernsyms.sh: Updated copyright information. * genmk.rb: Likewise. * genmodsrc.sh: Likewise. * gensymlist.sh: Likewise. * boot/i386/pc/boot.S: Likewise. * boot/i386/pc/diskboot.S: Likewise. * disk/i386/pc/biosdisk.c: Likewise. * disk/i386/pc/partition.c: Likewise. * font/manager.c: Likewise. * fs/ext2.c: Likewise. * fs/fat.c: Likewise. * include/pupa/boot.h: Likewise. * include/pupa/device.h: Likewise. * include/pupa/disk.h: Likewise. * include/pupa/dl.h: Likewise. * include/pupa/elf.h: Likewise. * include/pupa/err.h: Likewise. * include/pupa/file.h: Likewise. * include/pupa/font.h: Likewise. * include/pupa/fs.h: Likewise. * include/pupa/kernel.h: Likewise. * include/pupa/loader.h: Likewise. * include/pupa/misc.h: Likewise. * include/pupa/mm.h: Likewise. * include/pupa/net.h: Likewise. * include/pupa/normal.h: Likewise. * include/pupa/rescue.h: Likewise. * include/pupa/setjmp.h: Likewise. * include/pupa/symbol.h: Likewise. * include/pupa/term.h: Likewise. * include/pupa/types.h: Likewise. * include/pupa/i386/setjmp.h: Likewise. * include/pupa/i386/types.h: Likewise. * include/pupa/i386/pc/biosdisk.h: Likewise. * include/pupa/i386/pc/boot.h: Likewise. * include/pupa/i386/pc/console.h: Likewise. * include/pupa/i386/pc/init.h: Likewise. * include/pupa/i386/pc/kernel.h: Likewise. * include/pupa/i386/pc/linux.h: Likewise. * include/pupa/i386/pc/loader.h: Likewise. * include/pupa/i386/pc/memory.h: Likewise. * include/pupa/i386/pc/multiboot.h: Likewise. * include/pupa/i386/pc/partition.h: Likewise. * include/pupa/i386/pc/time.h: Likewise. * include/pupa/i386/pc/vga.h: Likewise. * include/pupa/i386/pc/util/biosdisk.h: Likewise. * include/pupa/util/getroot.h: Likewise. * include/pupa/util/misc.h: Likewise. * include/pupa/util/resolve.h: Likewise. * kern/device.c: Likewise. * kern/disk.c: Likewise. * kern/dl.c: Likewise. * kern/err.c: Likewise. * kern/file.c: Likewise. * kern/fs.c: Likewise. * kern/loader.c: Likewise. * kern/main.c: Likewise. * kern/misc.c: Likewise. * kern/mm.c: Likewise. * kern/rescue.c: Likewise. * kern/term.c: Likewise. * kern/i386/dl.c: Likewise. * kern/i386/pc/init.c: Likewise. * kern/i386/pc/lzo1x.S: Likewise. * kern/i386/pc/startup.S: Likewise. * loader/i386/pc/chainloader.c: Likewise. * loader/i386/pc/linux.c: Likewise. * loader/i386/pc/multiboot.c: Likewise. * normal/cmdline.c: Likewise. * normal/command.c: Likewise. * normal/main.c: Likewise. * normal/menu.c: Likewise. * normal/i386/setjmp.S: Likewise. * term/i386/pc/console.c: Likewise. * term/i386/pc/vga.c: Likewise. * util/console.c: Likewise. * util/genmoddep.c: Likewise. * util/misc.c: Likewise. * util/pupa-emu.c: Likewise. * util/resolve.c: Likewise. * util/unifont2pff.rb: Likewise. * util/i386/pc/biosdisk.c: Likewise. * util/i386/pc/getroot.c: Likewise. * util/i386/pc/pupa-mkimage.c: Likewise. * util/i386/pc/pupa-setup.c: Likewise.
2004-02-24 17:21:53 +00:00
* Copyright (C) 2002,2003 Free Software Foundation, Inc.
2002-12-27 08:53:07 +00:00
*
* GRUB is free software; you can redistribute it and/or modify
2002-12-27 08:53:07 +00:00
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GRUB; if not, write to the Free Software
2002-12-27 08:53:07 +00:00
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef GRUB_TERM_HEADER
#define GRUB_TERM_HEADER 1
2002-12-27 08:53:07 +00:00
#include <grub/err.h>
#include <grub/symbol.h>
#include <grub/types.h>
2002-12-27 08:53:07 +00:00
/* These are used to represent the various color states we use. */
typedef enum
{
/* The color used to display all text that does not use the
user defined colors below. */
GRUB_TERM_COLOR_STANDARD,
2002-12-27 08:53:07 +00:00
/* The user defined colors for normal text. */
GRUB_TERM_COLOR_NORMAL,
2002-12-27 08:53:07 +00:00
/* The user defined colors for highlighted text. */
GRUB_TERM_COLOR_HIGHLIGHT
2002-12-27 08:53:07 +00:00
}
grub_term_color_state;
2002-12-27 08:53:07 +00:00
/* Flags for representing the capabilities of a terminal. */
/* Some notes about the flags:
- These flags are used by higher-level functions but not terminals
themselves.
- If a terminal is dumb, you may assume that only putchar, getkey and
checkkey are called.
- Some fancy features (setcolorstate, setcolor and setcursor) can be set
to NULL. */
/* Set when input characters shouldn't be echoed back. */
#define GRUB_TERM_NO_ECHO (1 << 0)
2002-12-27 08:53:07 +00:00
/* Set when the editing feature should be disabled. */
#define GRUB_TERM_NO_EDIT (1 << 1)
2002-12-27 08:53:07 +00:00
/* Set when the terminal cannot do fancy things. */
#define GRUB_TERM_DUMB (1 << 2)
2002-12-27 08:53:07 +00:00
/* Set when the terminal needs to be initialized. */
#define GRUB_TERM_NEED_INIT (1 << 16)
2002-12-27 08:53:07 +00:00
struct grub_term
2002-12-27 08:53:07 +00:00
{
/* The terminal name. */
const char *name;
2003-09-25 Yoshinori K. Okuji <okuji@enbug.org> I forgot to check in these changes for a long time. This adds incomplete support for VGA console, and this is still very buggy. Also, a lot of consideration is required for I18N, UNICODE, and VGA font issues. Therefore, assume that this is such that "better than nothing". * font/manager.c: New file. * include/pupa/font.h: Likewise. * include/pupa/i386/pc/vga.h: Likewise. * term/i386/pc/vga.c: Likewise. * util/unifont2pff.rb: Likewise. * conf/i386-pc.rmk (kernel_img_HEADERS): Added machine/vga.h. (pkgdata_MODULES): Added vga.mod and font.mod. (vga_mod_SOURCES): New variables. (vga_mod_CFLAGS): Likewise. (font_mod_SOURCES): Likewise. (font_mod_CFLAGS): Likewise. * include/pupa/err.h (PUPA_ERR_BAD_FONT): New constant. * include/pupa/term.h: Include pupa/err.h. (struct pupa_term): Added init and fini. Changed the argument of putchar to pupa_uint32_t. * include/pupa/i386/pc/console.h: Include pupa/symbol.h. (pupa_console_real_putchar): New prototype. (pupa_console_putchar): Removed. (pupa_console_checkkey): Exported. (pupa_console_getkey): Likewise. * kern/misc.c (pupa_vsprintf): Add support for UNICODE characters. * kern/term.c (pupa_term_set_current): Rewritten. (pupa_putchar): Likewise. (pupa_putcode): New function. * kern/i386/pc/startup.S (pupa_console_putchar): Renamed to ... (pupa_console_real_putchar): ... this. (pupa_vga_set_mode): New function. (pupa_vga_get_font): Likewise. * normal/command.c: Include pupa/term.h. (terminal_command): New function. (pupa_command_init): Register the command "terminal". * normal/menu.c (DISP_LEFT): Changed to a UNICODE value. (DISP_UP): Likewise. (DISP_RIGHT): Likewise. (DISP_DOWN): Likewise. (DISP_HLINE): Likewise. (DISP_VLINE): Likewise. (DISP_UL): Likewise. (DISP_UR): Likewise. (DISP_LL): Likewise. (DISP_LR): Likewise. * term/i386/pc/console.c (pupa_console_putchar): New function.
2003-09-25 20:15:53 +00:00
/* Initialize the terminal. */
grub_err_t (*init) (void);
2003-09-25 Yoshinori K. Okuji <okuji@enbug.org> I forgot to check in these changes for a long time. This adds incomplete support for VGA console, and this is still very buggy. Also, a lot of consideration is required for I18N, UNICODE, and VGA font issues. Therefore, assume that this is such that "better than nothing". * font/manager.c: New file. * include/pupa/font.h: Likewise. * include/pupa/i386/pc/vga.h: Likewise. * term/i386/pc/vga.c: Likewise. * util/unifont2pff.rb: Likewise. * conf/i386-pc.rmk (kernel_img_HEADERS): Added machine/vga.h. (pkgdata_MODULES): Added vga.mod and font.mod. (vga_mod_SOURCES): New variables. (vga_mod_CFLAGS): Likewise. (font_mod_SOURCES): Likewise. (font_mod_CFLAGS): Likewise. * include/pupa/err.h (PUPA_ERR_BAD_FONT): New constant. * include/pupa/term.h: Include pupa/err.h. (struct pupa_term): Added init and fini. Changed the argument of putchar to pupa_uint32_t. * include/pupa/i386/pc/console.h: Include pupa/symbol.h. (pupa_console_real_putchar): New prototype. (pupa_console_putchar): Removed. (pupa_console_checkkey): Exported. (pupa_console_getkey): Likewise. * kern/misc.c (pupa_vsprintf): Add support for UNICODE characters. * kern/term.c (pupa_term_set_current): Rewritten. (pupa_putchar): Likewise. (pupa_putcode): New function. * kern/i386/pc/startup.S (pupa_console_putchar): Renamed to ... (pupa_console_real_putchar): ... this. (pupa_vga_set_mode): New function. (pupa_vga_get_font): Likewise. * normal/command.c: Include pupa/term.h. (terminal_command): New function. (pupa_command_init): Register the command "terminal". * normal/menu.c (DISP_LEFT): Changed to a UNICODE value. (DISP_UP): Likewise. (DISP_RIGHT): Likewise. (DISP_DOWN): Likewise. (DISP_HLINE): Likewise. (DISP_VLINE): Likewise. (DISP_UL): Likewise. (DISP_UR): Likewise. (DISP_LL): Likewise. (DISP_LR): Likewise. * term/i386/pc/console.c (pupa_console_putchar): New function.
2003-09-25 20:15:53 +00:00
/* Clean up the terminal. */
grub_err_t (*fini) (void);
2002-12-27 08:53:07 +00:00
2003-09-25 Yoshinori K. Okuji <okuji@enbug.org> I forgot to check in these changes for a long time. This adds incomplete support for VGA console, and this is still very buggy. Also, a lot of consideration is required for I18N, UNICODE, and VGA font issues. Therefore, assume that this is such that "better than nothing". * font/manager.c: New file. * include/pupa/font.h: Likewise. * include/pupa/i386/pc/vga.h: Likewise. * term/i386/pc/vga.c: Likewise. * util/unifont2pff.rb: Likewise. * conf/i386-pc.rmk (kernel_img_HEADERS): Added machine/vga.h. (pkgdata_MODULES): Added vga.mod and font.mod. (vga_mod_SOURCES): New variables. (vga_mod_CFLAGS): Likewise. (font_mod_SOURCES): Likewise. (font_mod_CFLAGS): Likewise. * include/pupa/err.h (PUPA_ERR_BAD_FONT): New constant. * include/pupa/term.h: Include pupa/err.h. (struct pupa_term): Added init and fini. Changed the argument of putchar to pupa_uint32_t. * include/pupa/i386/pc/console.h: Include pupa/symbol.h. (pupa_console_real_putchar): New prototype. (pupa_console_putchar): Removed. (pupa_console_checkkey): Exported. (pupa_console_getkey): Likewise. * kern/misc.c (pupa_vsprintf): Add support for UNICODE characters. * kern/term.c (pupa_term_set_current): Rewritten. (pupa_putchar): Likewise. (pupa_putcode): New function. * kern/i386/pc/startup.S (pupa_console_putchar): Renamed to ... (pupa_console_real_putchar): ... this. (pupa_vga_set_mode): New function. (pupa_vga_get_font): Likewise. * normal/command.c: Include pupa/term.h. (terminal_command): New function. (pupa_command_init): Register the command "terminal". * normal/menu.c (DISP_LEFT): Changed to a UNICODE value. (DISP_UP): Likewise. (DISP_RIGHT): Likewise. (DISP_DOWN): Likewise. (DISP_HLINE): Likewise. (DISP_VLINE): Likewise. (DISP_UL): Likewise. (DISP_UR): Likewise. (DISP_LL): Likewise. (DISP_LR): Likewise. * term/i386/pc/console.c (pupa_console_putchar): New function.
2003-09-25 20:15:53 +00:00
/* Put a character. C is encoded in Unicode. */
void (*putchar) (grub_uint32_t c);
2002-12-27 08:53:07 +00:00
/* Check if any input character is available. */
int (*checkkey) (void);
/* Get a character. */
int (*getkey) (void);
/* Get the cursor position. The return value is ((X << 8) | Y). */
grub_uint16_t (*getxy) (void);
2002-12-27 08:53:07 +00:00
/* Go to the position (X, Y). */
void (*gotoxy) (grub_uint8_t x, grub_uint8_t y);
2002-12-27 08:53:07 +00:00
/* Clear the screen. */
void (*cls) (void);
/* Set the current color to be used */
void (*setcolorstate) (grub_term_color_state state);
2002-12-27 08:53:07 +00:00
/* Set the normal color and the highlight color. The format of each
color is VGA's. */
void (*setcolor) (grub_uint8_t normal_color, grub_uint8_t highlight_color);
2002-12-27 08:53:07 +00:00
/* Turn on/off the cursor. */
void (*setcursor) (int on);
2003-11-17 Marco Gerards <metgerards@student.han.nl> * conf/i386-pc.rmk (sbin_UTILITIES): Added pupa-emu. (pupa_setup_SOURCES): Added util/i386/pc/getroot.c. (pupa_emu_SOURCES): New variable. (pupa_emu_LDFLAGS): Likewise. * include/pupa/fs.h (pupa_ext2_init) [PUPA_UTIL]: New prototype. (pupa_ext2_fini) [PUPA_UTIL]: Likewise. * include/pupa/normal.h (pupa_normal_init) [PUPA_UTIL]: Likewise. (pupa_normal_fini) [PUPA_UTIL]: Likewise. * include/pupa/setjmp.h [PUPA_UTIL]: Include <setjmp.h>. (pupa_jmp_buf): New typedef. (pupa_setjmp) [PUPA_UTIL]: New macro. (pupa_longjmp) [PUPA_UTIL]: Likewise. * include/pupa/term.h (struct pupa_term): New member `refresh'. (pupa_refresh): New prototype. * include/pupa/util/getroot.h: New file. * kern/misc.c (pupa_vsprintf): Refresh the screen after updating it. * kern/rescue.c (pupa_rescue_get_command_line): Likewise. (pupa_rescue_cmd_cat): Likewise. (pupa_rescue_cmd_ls): Likewise. (pupa_rescue_cmd_testload): Likewise. (pupa_rescue_cmd_lsmod): Likewise. * normal/cmdline.c (pupa_cmdline_get): Likewise. * normal/menu.c (run_menu): Likewise. * kern/term.c (pupa_cls): Likewise. (pupa_refresh): New function. * normal/normal.c (pupa_normal_init) [PUPA_UTIL]: New function. (pupa_normal_fini) [PUPA_UTIL]: Likewise. * util/console.c: New file. * util/i386/pc/getroot.c: New file. * util/i386/pc/pupa-setup.c: Include <pupa/util/getroot.h>. (pupa_putchar): New function. (pupa_refresh): Likewise. (xgetcwd): Function moved to ... (strip_extra_slashes): Likewise. (get_prefix): Likewise. * util/i386/pc/getroot.c: ... here. (find_root_device): Function moved and renamed to... * util/i386/pc/getroot.c (pupa_find_root_device): ... here. Changed all callers. * util/i386/pc/pupa-setup.c (guess_root_device): Function moved and renamed to... * util/i386/pc/getroot.c (pupa_guess_root_device): ... here. Changed all callers. * util/misc.c (pupa_memalign): New function. (pupa_mm_init_region): Likewise. (pupa_register_exported_symbols): Likewise. (pupa_putchar): Function removed. * util/pupa-emu.c: New file.
2003-11-17 18:07:09 +00:00
/* Update the screen. */
void (*refresh) (void);
2002-12-27 08:53:07 +00:00
/* The feature flags defined above. */
grub_uint32_t flags;
2002-12-27 08:53:07 +00:00
/* The next terminal. */
struct grub_term *next;
2002-12-27 08:53:07 +00:00
};
typedef struct grub_term *grub_term_t;
2002-12-27 08:53:07 +00:00
void EXPORT_FUNC(grub_term_register) (grub_term_t term);
void EXPORT_FUNC(grub_term_unregister) (grub_term_t term);
void EXPORT_FUNC(grub_term_iterate) (int (*hook) (grub_term_t term));
2002-12-27 08:53:07 +00:00
grub_err_t EXPORT_FUNC(grub_term_set_current) (grub_term_t term);
grub_term_t EXPORT_FUNC(grub_term_get_current) (void);
2002-12-27 08:53:07 +00:00
void EXPORT_FUNC(grub_putchar) (int c);
void EXPORT_FUNC(grub_putcode) (grub_uint32_t code);
int EXPORT_FUNC(grub_getkey) (void);
int EXPORT_FUNC(grub_checkkey) (void);
grub_uint16_t EXPORT_FUNC(grub_getxy) (void);
void EXPORT_FUNC(grub_gotoxy) (grub_uint8_t x, grub_uint8_t y);
void EXPORT_FUNC(grub_cls) (void);
void EXPORT_FUNC(grub_setcolorstate) (grub_term_color_state state);
void EXPORT_FUNC(grub_setcolor) (grub_uint8_t normal_color,
grub_uint8_t highlight_color);
int EXPORT_FUNC(grub_setcursor) (int on);
void EXPORT_FUNC(grub_refresh) (void);
void EXPORT_FUNC(grub_set_more) (int onoff);
2002-12-27 08:53:07 +00:00
/* For convenience. */
#define GRUB_TERM_ASCII_CHAR(c) ((c) & 0xff)
2002-12-27 08:53:07 +00:00
#endif /* ! GRUB_TERM_HEADER */