2002-06-12 Yoshinori K. Okuji <okuji@enbug.org>

The terminal handling code is rewritten radically.

	* stage2/console.c: New file.
	* stage2/term.h: Likewise.

	* stage2/Makefile.am (noinst_HEADERS): Added term.h.
	(libgrub_a_SOURCES): Added serial.c.
	(pre_stage2_exec_SOURCES): Added console.c.

	* stage2/asm.S (console_putchar): Rewritten from scratch.
	[!STAGE1_5] (translation_table): New variable.
	[!STAGE1_5] (translate_keycode): New function.
	[!STAGE1_5] (console_getkey): Call translate_keycode.
	[!STAGE1_5] (console_checkkey): Likewise.
	[!STAGE1_5] (nocursor): Renamed to ...
	[!STAGE1_5] (console_nocursor): ... this.
	[!STAGE1_5] (console_set_attrib): Removed.

	* stage2/builtins.c: Include term.h.
	(terminal): Removed.
	(normal_color): Likewise.
	(highlight_color): Likewise.
	(cat_func): Display a question mark when a non-printable
	character was read.
	(terminal_func): Rewritten almost from scratch.

	* stage2/char_io.c: Include term.h.
	[!STAGE1_5] (auto_fill): Removed.
	[!STAGE1_5] (term_table): New variable.
	[!STAGE1_5] (current_term): Likewise.
	[!STAGE1_5] (real_get_cmdline): New function. The code was
	stolen from the previous version of get_cmdline.
	[!STAGE1_5] (get_cmdline): Rewritten from scratch.
	[!STAGE1_5] (translate_keycode): Removed.
	[!STAGE1_5] (getkey): Rewritten from scratch.
	[!STAGE1_5] (checkkey): Likewise.
	(grub_putchar): Likewise.
	[!STAGE1_5] (gotoxy): Likewise.
	[!STAGE1_5] (getxy): Likewise.
	[!STAGE1_5] (cls): Likewise.
	[!STAGE1_5] (nocursor): New function.
	[SUPPORT_SERIAL] (serial_getxy): Removed.
	[SUPPORT_SERIAL] (serial_gotoxy): Likewise.
	[SUPPORT_SERIAL] (serial_cls): Likewise.
	[SUPPORT_SERIAL] (serial_getxy): Likewise.
	[!STAGE1_5] (set_attrib): Likewise.

	* stage2/cmdline.c (init_cmdline): Set COUNT_LINES to -1.

	* stage2/common.c [!STAGE1_5] (err_list): Removed
	ERR_NEED_SERIAL and added ERR_DEV_NEED_INIT.

	* stage2/hercules.c: Rewritten almost from scratch.
	* stage2/hercules.h (herc_putchar): Removed.
	(herc_cls): Likewise.
	(herc_getxy): Likewise.
	(herc_gotoxy): Likewise.
	(herc_set_attrib): Likewise.

	* stage2/serial.c: Rewritten almost from scratch.
	* stage2/serial.h: Likewise.

	* stage2/shared.h [GRUB_UTIL] (DISP_UL): Set to the same value
	as VGA's.
	[GRUB_UTIL] (DISP_UR): Likewise.
	[GRUB_UTIL] (DISP_LL): Likewise.
	[GRUB_UTIL] (DISP_LR): Likewise.
	[GRUB_UTIL] (DISP_HORIZ): Likewise.
	[GRUB_UTIL] (DISP_VERT): Likewise.
	[GRUB_UTIL] (DISP_LEFT): Likewise.
	[GRUB_UTIL] (DISP_RIGHT): Likewise.
	[GRUB_UTIL] (DISP_UP): Likewise.
	[GRUB_UTIL] (DISP_DOWN): Likewise.
	(grub_error_t): Removed ERR_NEED_SERIAL.
	Added ERR_DEV_NEED_INIT.
	(normal_color): Removed.
	(highlight_color): Likewise.
	(console_cls): Removed, because this is declared in term.h.
	(console_getxy): Likewise.
	(console_gotoxy): Likewise.
	(console_putchar): Likewise.
	(console_getkey): Likewise.
	(console_checkkey): Likewise.
	(console_set_attrib): Removed.
	(set_attrib): Likewise.
	[GRUB_UTIL] (nocursor): Declared.
	(auto_fill): Removed.
	(terminal): Likewise.
	(TERMINAL_CONSOLE): Likewise.
	(TERMINAL_SERIAL): Likewise.
	(TERMINAL_HERCULES): Likewise.
	(TERMINAL_DUMB): Likewise.
	(translate_keycode): Likewise.

	* stage2/stage2.c: Include term.h.
	(print_entry): Rewritten from scratch.
	(print_entries): Likewise.
	(print_border): Likewise.
	(set_line): Removed.
	(set_line_normal): Likewise.
	(set_line_highlight): Likewise.

	* grub/Makefile.am (AM_CFLAGS): Added -DSUPPORT_HERCULES=1.

	* grub/asmstub.c: Don't include hercules.h. Include term.h.
	(console_current_color): New variable.
	(console_translate_key): New function.
	(console_checkkey): Rewritten from scratch.
	(console_getkey): Likewise.
	(console_putchar): Likewise.
	(console_set_attrib): Removed.
	(console_highlight): New function.
	(console_setcolor): Likewise.
	(console_nocursor): Likewise.
	(serial_getkey): Removed.
	(serial_checkkey): Likewise.
	(serial_putchar): Likewise.
	(serial_exists): Likewise.
	(serial_get_port): Likewise.
	(serial_init): Likewise.
	(serial_hw_fetch): New function.
	(serial_hw_put): Likewise.
	(serial_hw_delay): Likewise.
	(serial_hw_get_port): Likewise.
	(serial_hw_init): Likewise.
	(set_serial_device): Renamed to ...
	(serial_set_device): ... this.
	(herc_putchar): Renamed to ...
	(hercules_putchar): ... this.
	(herc_cls): Renamed to ...
	(hercules_cls): ... this.
	(herc_getxy): Renamed to ...
	(hercules_getxy): ... this.
	(herc_gotoxy): Renamed to ...
	(hercules_gotoxy): ... this.
	(hercules_highlight): New function.
	(hercules_setcolor): Likewise.
	(hercules_nocursor): Likewise.
	(herc_set_attrib): Removed.

	* grub/main.c: Include term.h.
	(main): If USE_CURSES is false, set CURRENT_TERM->FLAGS to
	TERM_NO_EDIT | TERM_DUMB. TERMINAL is not used any longer.
This commit is contained in:
okuji committed 2002-06-11 16:36:54 +00:00
1 parent 9ab2360b15
commit 2369202e83
22 files changed
+1626 -1502

No files matched your search

+11 -66
View File
@@ -334,29 +334,16 @@ extern char *grub_scratch_mem;
#define ACS_DARROW 'v'
/* Special graphics characters for IBM displays. */
#ifdef GRUB_UTIL
# define DISP_UL ACS_ULCORNER
# define DISP_UR ACS_URCORNER
# define DISP_LL ACS_LLCORNER
# define DISP_LR ACS_LRCORNER
# define DISP_HORIZ ACS_HLINE
# define DISP_VERT ACS_VLINE
# define DISP_LEFT ACS_LARROW
# define DISP_RIGHT ACS_RARROW
# define DISP_UP ACS_UARROW
# define DISP_DOWN ACS_DARROW
#else /* ! GRUB_UTIL */
# define DISP_UL 218
# define DISP_UR 191
# define DISP_LL 192
# define DISP_LR 217
# define DISP_HORIZ 196
# define DISP_VERT 179
# define DISP_LEFT 0x1b
# define DISP_RIGHT 0x1a
# define DISP_UP 0x18
# define DISP_DOWN 0x19
#endif /* ! GRUB_UTIL */
#define DISP_UL 218
#define DISP_UR 191
#define DISP_LL 192
#define DISP_LR 217
#define DISP_HORIZ 196
#define DISP_VERT 179
#define DISP_LEFT 0x1b
#define DISP_RIGHT 0x1a
#define DISP_UP 0x18
#define DISP_DOWN 0x19
/* Remap some libc-API-compatible function names so that we prevent
circularararity. */
@@ -546,7 +533,7 @@ typedef enum
ERR_BAD_ARGUMENT,
ERR_UNALIGNED,
ERR_PRIVILEGED,
ERR_NEED_SERIAL,
ERR_DEV_NEED_INIT,
ERR_NO_DISK_SPACE,
ERR_NUMBER_OVERFLOW,
@@ -628,8 +615,6 @@ extern void (*disk_read_func) (int, int, int);
#ifndef STAGE1_5
/* The flag for debug mode. */
extern int debug;
/* Color settings */
extern int normal_color, highlight_color;
#endif /* STAGE1_5 */
extern unsigned long current_drive;
@@ -781,56 +766,29 @@ int currticks (void);
/* Clear the screen. */
void cls (void);
/* The console part of cls. */
void console_cls (void);
#ifndef GRUB_UTIL
/* Turn off cursor. */
void nocursor (void);
#endif
/* Get the current cursor position (where 0,0 is the top left hand
corner of the screen). Returns packed values, (RET >> 8) is x,
(RET & 0xff) is y. */
int getxy (void);
/* The console part of getxy. */
int console_getxy (void);
/* Set the cursor position. */
void gotoxy (int x, int y);
/* The console part of gotoxy. */
void console_gotoxy (int x, int y);
/* Displays an ASCII character. IBM displays will translate some
characters to special graphical ones (see the DISP_* constants). */
void grub_putchar (int c);
/* The console part of grub_putchar. */
void console_putchar (int c);
/* Wait for a keypress, and return its packed BIOS/ASCII key code.
Use ASCII_CHAR(ret) to extract the ASCII code. */
int getkey (void);
/* The console part of getkey. */
int console_getkey (void);
/* Like GETKEY, but doesn't block, and returns -1 if no keystroke is
available. */
int checkkey (void);
/* The console part of checkkey. */
int console_checkkey (void);
/* Sets text mode character attribute at the cursor position. See A_*
constants defined above. */
void set_attrib (int attr);
/* The console part of set_attrib. */
void console_set_attrib (int attr);
/* Low-level disk I/O */
int get_diskinfo (int drive, struct geometry *geometry);
int biosdisk (int subfunc, int drive, struct geometry *geometry,
@@ -883,18 +841,6 @@ extern kernel_t kernel_type;
extern int show_menu;
extern int grub_timeout;
/* Control the auto fill mode. */
extern int auto_fill;
/* This variable specifies which console should be used. */
extern int terminal;
#define TERMINAL_CONSOLE (1 << 0) /* keyboard and screen */
#define TERMINAL_SERIAL (1 << 1) /* serial console */
#define TERMINAL_HERCULES (1 << 2) /* hercules */
#define TERMINAL_DUMB (1 << 16) /* dumb terminal */
void init_builtins (void);
void init_config (void);
char *skip_to (int after_equal, char *cmdline);
@@ -951,7 +897,6 @@ int nul_terminate (char *str);
int get_based_digit (int c, int base);
int safe_parse_maxint (char **str_ptr, int *myint_ptr);
int memcheck (int start, int len);
int translate_keycode (int c);
#ifndef NO_DECOMPRESSION
/* Compression support. */