mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-05 11:48:30 +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(
|
fn simple_text_input_read(
|
||||||
stdin: *mut r_efi::protocols::simple_text_input::Protocol,
|
stdin: *mut r_efi::protocols::simple_text_input::Protocol,
|
||||||
) -> io::Result<u16> {
|
) -> io::Result<u16> {
|
||||||
loop {
|
// Try reading any pending keys. Else wait for a new character
|
||||||
match read_key_stroke(stdin) {
|
match read_key_stroke(stdin) {
|
||||||
Ok(x) => return Ok(x.unicode_char),
|
Ok(x) => return Ok(x.unicode_char),
|
||||||
Err(e) if e == r_efi::efi::Status::NOT_READY => wait_stdin(stdin)?,
|
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())),
|
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<()> {
|
fn wait_stdin(stdin: *mut r_efi::protocols::simple_text_input::Protocol) -> io::Result<()> {
|
||||||
|
Loading…
Reference in New Issue
Block a user