diff options
author | marcel <marcel@FreeBSD.org> | 2002-12-08 19:46:11 +0000 |
---|---|---|
committer | marcel <marcel@FreeBSD.org> | 2002-12-08 19:46:11 +0000 |
commit | cc1323fd6695c843bdaae5d51a120fbc332f492f (patch) | |
tree | d9f616417e196bd199ba3658ff84acb1f843ea95 /sys | |
parent | b7485df3b01ef657b934b1283b6a40b218b78999 (diff) | |
download | FreeBSD-src-cc1323fd6695c843bdaae5d51a120fbc332f492f.zip FreeBSD-src-cc1323fd6695c843bdaae5d51a120fbc332f492f.tar.gz |
In efi_cons_poll we check if a key is present (pending) by checking
the signaled state of the apropriate event. As a side-effect of
checking the event, it's signaled state is cleared if it was set.
In efi_cons_getchar we used to wait for the apropriate event to be
signaled before reading a character. This however does not work if
we poll before reading the characteri, such as during autoboot. On
a more compliant EFI implementation this resulted in the behaviour
that hitting a key during autoboot would stop the countdown, but
would then wait for a new character to arrive instead of reading
the already pending key that stopped the countdown.
The correct behaviour for efi_cons_getchar is to try to read a key
and if none is pending, to wait for the apropriate event to signal
the arrival of a new key.
Note that with the previous behaviour, the second key would determine
how the autoboot was interrupted. This would indicate that the first
key got lost. This indicates that EFI does not necessarily maintain
a queue of pending keys. FWIW...
Approved by: re (carte blanche)
French corrected by: various people :-)
Diffstat (limited to 'sys')
-rw-r--r-- | sys/boot/efi/libefi/efi_console.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/sys/boot/efi/libefi/efi_console.c b/sys/boot/efi/libefi/efi_console.c index e990e33..254ef0d 100644 --- a/sys/boot/efi/libefi/efi_console.c +++ b/sys/boot/efi/libefi/efi_console.c @@ -69,17 +69,23 @@ int efi_cons_getchar() { EFI_INPUT_KEY key; + EFI_STATUS status; UINTN junk; - BS->WaitForEvent(1, &conin->WaitForKey, &junk); - conin->ReadKeyStroke(conin, &key); - return key.UnicodeChar; + /* Try to read a key stroke. We wait for one if none is pending. */ + status = conin->ReadKeyStroke(conin, &key); + if (status == EFI_NOT_READY) { + BS->WaitForEvent(1, &conin->WaitForKey, &junk); + status = conin->ReadKeyStroke(conin, &key); + } + return (key.UnicodeChar); } int efi_cons_poll() { - return BS->CheckEvent(conin->WaitForKey) == EFI_SUCCESS; + /* This can clear the signaled state. */ + return (BS->CheckEvent(conin->WaitForKey) == EFI_SUCCESS); } struct console efi_console = { |