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

Change the terminal structure a bit, to turn the cursor state
	explicitly. Suggested by Pavel Roskin.

	* stage2/term.h (struct term_entry): Remove the member
	`nocursor' and add `setcursor'.
	[!STAGE1_5] (console_setcursor): New prototype.
	[SUPPORT_HERCULES] (hercules_setcursor): Likewise.
	[!STAGE1_5] (console_nocursor): Removed.
	[SUPPORT_HERCULES] (hercules_nocursor): Likewise.

	* stage2/stage2.c (run_menu): Call setcursor instead of
	nocursor.
	Call setcursor with 1 before starting a boot entry.

	* stage2/shared.h (nocursor): Removed.
	(setcursor): New prototype.

	* stage2/hercules.c (herc_cursor_state): New variable.
	(herc_turn_cursor): Removed.
	(hercules_nocursor): Likewise.
	(hercules_setcursor): New function.

	* stage2/char_io.c (get_cmdline): Turn on the cursor at the
	beginning, and restore it before returning.
	(nocursor): Removed.
	(setcursor): New function.

	* stage2/asm.S (console_cursor_state): New variable.
	(console_cursor_shape): Likewise.
	(console_setcursor): New function.
	(console_nocursor): Removed.

	* grub/asmstub.c (console_setcursor): New function.
	(hercules_setcursor): Likewise.
	(console_nocursor): Removed.
	(hercules_nocursor): Likewise.
This commit is contained in:
okuji 2002-12-03 00:02:53 +00:00
parent 58b292f419
commit c18257ea65
9 changed files with 124 additions and 39 deletions

View file

@ -1,3 +1,42 @@
2002-12-03 Yoshinori K. Okuji <okuji@enbug.org>
Change the terminal structure a bit, to turn the cursor state
explicitly. Suggested by Pavel Roskin.
* stage2/term.h (struct term_entry): Remove the member
`nocursor' and add `setcursor'.
[!STAGE1_5] (console_setcursor): New prototype.
[SUPPORT_HERCULES] (hercules_setcursor): Likewise.
[!STAGE1_5] (console_nocursor): Removed.
[SUPPORT_HERCULES] (hercules_nocursor): Likewise.
* stage2/stage2.c (run_menu): Call setcursor instead of
nocursor.
Call setcursor with 1 before starting a boot entry.
* stage2/shared.h (nocursor): Removed.
(setcursor): New prototype.
* stage2/hercules.c (herc_cursor_state): New variable.
(herc_turn_cursor): Removed.
(hercules_nocursor): Likewise.
(hercules_setcursor): New function.
* stage2/char_io.c (get_cmdline): Turn on the cursor at the
beginning, and restore it before returning.
(nocursor): Removed.
(setcursor): New function.
* stage2/asm.S (console_cursor_state): New variable.
(console_cursor_shape): Likewise.
(console_setcursor): New function.
(console_nocursor): Removed.
* grub/asmstub.c (console_setcursor): New function.
(hercules_setcursor): Likewise.
(console_nocursor): Removed.
(hercules_nocursor): Likewise.
2002-12-03 Yoshinori K. Okuji <okuji@enbug.org>
* docs/grub.texi (terminfo): Fix a misleading English sentence.

View file

@ -743,10 +743,10 @@ console_setcolor (int normal_color, int highlight_color)
/* Nothing to do. */
}
void
console_nocursor (void)
int
console_setcursor (int on)
{
/* Nothing to do. */
return 1;
}
/* Low-level disk I/O. Our stubbed version just returns a file
@ -1266,8 +1266,8 @@ hercules_setcolor (int normal_color, int highlight_color)
console_setcolor (normal_color, highlight_color);
}
void
hercules_nocursor (void)
int
hercules_setcursor (int on)
{
console_nocursor ();
return 1;
}

View file

@ -2169,26 +2169,59 @@ ENTRY(console_cls)
/*
* void console_nocursor (void)
* int console_setcursor (int on)
* BIOS call "INT 10H Function 01h" to set cursor type
* Call with %ah = 0x01
* %ch = cursor starting scanline
* %cl = cursor ending scanline
*/
ENTRY(console_nocursor)
console_cursor_state:
.byte 1
console_cursor_shape:
.word 0
ENTRY(console_setcursor)
push %ebp
push %ebx
/* check if the standard cursor shape has already been saved */
movw console_cursor_shape, %ax
testw %ax, %ax
jne 1f
call EXT_C(prot_to_real)
.code16
movw $0x2000, %cx
movb $0x03, %ah
xorb %bh, %bh
int $0x10
DATA32 call EXT_C(real_to_prot)
.code32
movw %cx, console_cursor_shape
1:
/* set %cx to the designated cursor shape */
movw $0x2000, %cx
movl 0xc(%esp), %ebx
testl %ebx, %ebx
jz 2f
movw console_cursor_shape, %cx
2:
call EXT_C(prot_to_real)
.code16
movb $0x1, %ah
int $0x10
DATA32 call EXT_C(real_to_prot)
.code32
movzbl console_cursor_state, %eax
movb %bl, console_cursor_state
pop %ebx
pop %ebp
ret

View file

@ -43,7 +43,7 @@ struct term_entry term_table[] =
console_cls,
console_setcolorstate,
console_setcolor,
console_nocursor
console_setcursor
},
#ifdef SUPPORT_SERIAL
{
@ -73,7 +73,7 @@ struct term_entry term_table[] =
hercules_cls,
hercules_setcolorstate,
hercules_setcolor,
hercules_nocursor
hercules_setcursor
},
#endif /* SUPPORT_HERCULES */
/* This must be the last entry. */
@ -790,6 +790,11 @@ int
get_cmdline (char *prompt, char *cmdline, int maxlen,
int echo_char, int readline)
{
int old_cursor;
int ret;
old_cursor = setcursor (1);
/* Because it is hard to deal with different conditions simultaneously,
less functional cases are handled here. Assume that TERM_NO_ECHO
implies TERM_NO_EDIT. */
@ -811,7 +816,10 @@ get_cmdline (char *prompt, char *cmdline, int maxlen,
{
/* Return immediately if ESC is pressed. */
if (c == 27)
return 1;
{
setcursor (old_cursor);
return 1;
}
/* Printable characters are added into CMDLINE. */
if (c >= ' ' && c <= '~')
@ -829,12 +837,15 @@ get_cmdline (char *prompt, char *cmdline, int maxlen,
if (! (current_term->flags & TERM_NO_ECHO))
grub_putchar ('\n');
setcursor (old_cursor);
return 0;
}
/* Complicated features are left to real_get_cmdline. */
return real_get_cmdline (prompt, cmdline, maxlen, echo_char, readline);
ret = real_get_cmdline (prompt, cmdline, maxlen, echo_char, readline);
setcursor (old_cursor);
return ret;
}
#endif /* STAGE1_5 */
@ -1078,11 +1089,13 @@ cls (void)
current_term->cls ();
}
void
nocursor (void)
int
setcursor (int on)
{
if (current_term->nocursor)
current_term->nocursor ();
if (current_term->setcursor)
return current_term->setcursor (on);
return 1;
}
#endif /* ! STAGE1_5 */

View file

@ -129,7 +129,7 @@ enter_cmdline (char *heap, int forever)
grub_putchar ('\n');
#endif
print_cmdline_message (forever);
while (1)
{
struct builtin *builtin;

View file

@ -33,6 +33,7 @@ static int herc_normal_color = A_NORMAL;
static int herc_highlight_color = A_REVERSE;
static int herc_current_color = A_NORMAL;
static color_state herc_color_state = COLOR_STATE_STANDARD;
static int herc_cursor_state = 1;
/* Write a byte to a port. */
static inline void
@ -57,15 +58,6 @@ herc_set_cursor (void)
outb (0x80, 0);
}
static void
herc_turn_cursor (int state)
{
outb (HERCULES_INDEX_REG, 0x0a);
outb (0x80, 0);
outb (HERCULES_DATA_REG, state ? 0 : (1 << 5));
outb (0x80, 0);
}
void
hercules_putchar (int c)
{
@ -131,7 +123,6 @@ hercules_cls (void)
herc_x = herc_y = 0;
herc_set_cursor ();
herc_turn_cursor (1);
}
int
@ -178,10 +169,18 @@ hercules_setcolor (int normal_color, int highlight_color)
hercules_setcolorstate (herc_color_state);
}
void
hercules_nocursor (void)
int
hercules_setcursor (int on)
{
herc_turn_cursor (0);
int old_state = herc_cursor_state;
outb (HERCULES_INDEX_REG, 0x0a);
outb (0x80, 0);
outb (HERCULES_DATA_REG, on ? 0 : (1 << 5));
outb (0x80, 0);
herc_cursor_state = on;
return old_state;
}
#endif /* SUPPORT_HERCULES */

View file

@ -764,8 +764,8 @@ int currticks (void);
/* Clear the screen. */
void cls (void);
/* Turn off cursor. */
void nocursor (void);
/* Turn on/off cursor. */
int setcursor (int on);
/* Get the current cursor position (where 0,0 is the top left hand
corner of the screen). Returns packed values, (RET >> 8) is x,

View file

@ -292,7 +292,7 @@ restart:
if (show_menu)
{
init_page ();
nocursor ();
setcursor (0);
if (current_term->flags & TERM_DUMB)
print_entries_raw (num_entries, first_entry, menu_entries);
@ -708,6 +708,7 @@ restart:
boot_entry:
cls ();
setcursor (1);
while (1)
{

View file

@ -77,8 +77,8 @@ struct term_entry
/* Set the normal color and the highlight color. The format of each
color is VGA's. */
void (*setcolor) (int normal_color, int highlight_color);
/* Don't show the cursor. */
void (*nocursor) (void);
/* Turn on/off the cursor. */
int (*setcursor) (int on);
};
/* This lists up available terminals. */
@ -101,7 +101,7 @@ void console_gotoxy (int x, int y);
void console_cls (void);
void console_setcolorstate (color_state state);
void console_setcolor (int normal_color, int highlight_color);
void console_nocursor (void);
int console_setcursor (int on);
#endif
#ifdef SUPPORT_SERIAL
@ -121,7 +121,7 @@ void hercules_gotoxy (int x, int y);
void hercules_cls (void);
void hercules_setcolorstate (color_state state);
void hercules_setcolor (int normal_color, int highlight_color);
void hercules_nocursor (void);
int hercules_setcursor (int on);
#endif
#endif /* ! GRUB_TERM_HEADER */