Macroify GRUB_TERM_NO_KEY and use grub_checkkey in grub_getkey

This commit is contained in:
Vladimir 'phcoder' Serbinenko 2010-08-23 12:53:42 +02:00
parent df2174dded
commit 9518e2a12b
7 changed files with 39 additions and 47 deletions

View file

@ -1226,6 +1226,9 @@ notpending:
.code16
DATA32 call real_to_prot
.code32
#if GRUB_TERM_NO_KEY != -1
#error Fix this asm code
#endif
decl %eax
jmp 2b

View file

@ -78,43 +78,14 @@ grub_xputs_dumb (const char *str)
void (*grub_xputs) (const char *str) = grub_xputs_dumb;
static int pending_key = -1;
int
grub_getkey (void)
{
grub_term_input_t term;
grub_refresh ();
if (pending_key != -1)
{
pending_key = -1;
return pending_key;
}
while (1)
{
if (grub_term_poll_usb)
grub_term_poll_usb ();
FOR_ACTIVE_TERM_INPUTS(term)
{
int key = term->getkey (term);
if (key != -1)
return key;
}
grub_cpu_idle ();
}
}
static int pending_key = GRUB_TERM_NO_KEY;
int
grub_checkkey (void)
{
grub_term_input_t term;
if (pending_key != -1)
if (pending_key != GRUB_TERM_NO_KEY)
return pending_key;
if (grub_term_poll_usb)
@ -123,13 +94,28 @@ grub_checkkey (void)
FOR_ACTIVE_TERM_INPUTS(term)
{
pending_key = term->getkey (term);
if (pending_key != -1)
if (pending_key != GRUB_TERM_NO_KEY)
return pending_key;
}
return -1;
}
int
grub_getkey (void)
{
grub_refresh ();
while (pending_key != GRUB_TERM_NO_KEY)
{
grub_cpu_idle ();
grub_checkkey ();
}
pending_key = GRUB_TERM_NO_KEY;
return pending_key;
}
void
grub_refresh (void)
{