mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-15 05:26:47 +00:00
std: sys: stdio: uefi: Do not retry on NOT_READY
Since NOT_READY is now used to signal read 0. Remove the loop which would always retry on NOT_READY status. Instead, use the following algorithm: 1. Try reading any pending characters. Return if present. 2. If no pending character, NOT_READY is returned. 3. Wait for key. 4. Return the key or error. Signed-off-by: Ayush Singh <ayush@beagleboard.org>
This commit is contained in:
parent
188cfeccbf
commit
0b47e50344
@ -184,13 +184,17 @@ unsafe fn simple_text_output(
|
||||
fn simple_text_input_read(
|
||||
stdin: *mut r_efi::protocols::simple_text_input::Protocol,
|
||||
) -> io::Result<u16> {
|
||||
loop {
|
||||
match read_key_stroke(stdin) {
|
||||
Ok(x) => return Ok(x.unicode_char),
|
||||
Err(e) if e == r_efi::efi::Status::NOT_READY => wait_stdin(stdin)?,
|
||||
Err(e) => return Err(io::Error::from_raw_os_error(e.as_usize())),
|
||||
}
|
||||
// Try reading any pending keys. Else wait for a new character
|
||||
match read_key_stroke(stdin) {
|
||||
Ok(x) => return Ok(x.unicode_char),
|
||||
Err(e) if e == r_efi::efi::Status::NOT_READY => wait_stdin(stdin)?,
|
||||
Err(e) => return Err(io::Error::from_raw_os_error(e.as_usize())),
|
||||
}
|
||||
|
||||
// Try reading a key after the wait.
|
||||
read_key_stroke(stdin)
|
||||
.map(|x| x.unicode_char)
|
||||
.map_err(|e| io::Error::from_raw_os_error(e.as_usize()))
|
||||
}
|
||||
|
||||
fn wait_stdin(stdin: *mut r_efi::protocols::simple_text_input::Protocol) -> io::Result<()> {
|
||||
|
Loading…
Reference in New Issue
Block a user