-
Notifications
You must be signed in to change notification settings - Fork 161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question on how to access to stdin, stdout (and stderr) since 0.32 #1400
Comments
Good question, thanks for pointing that out. I don't have capacity to look into this in the next days, but perhaps @nicholasbishop can work on it? |
Good question indeed, the API here is not making what you want to do as easy as it should be. I think the simplest way forward for now is to manually stash pointers. Here's an example that compiles: #![no_std]
#![no_main]
use uefi::proto::console::text::{Output, Input};
use uefi::{Status, entry, system};
use core::ptr;
pub fn choose(_stdin: &mut Input, _stdout: &mut Output) {
unimplemented!();
}
#[entry]
fn main() -> Status {
let stdin: *mut Input = system::with_stdin(|stdin| ptr::from_mut(stdin));
let stdout: *mut Output = system::with_stdout(|stdout| ptr::from_mut(stdout));
// Safety: in the UEFI spec, section
// EFI_BOOT_SERVICES.UninstallProtocolInterface(), it says that
// console I/O protocols can never be removed. So these pointers are
// always valid, and within this block there is no shared mutable
// reference to stdin or stdout, so Rust's aliasing guarantees are
// maintained.
{
let stdin = unsafe { &mut *stdin };
let stdout = unsafe { &mut *stdout };
choose(stdin, stdout);
}
Status::SUCCESS
} This is not ideal though, we should think about this API some more. |
Can (This also applies to |
How now |
Hi, I'm trying to display a menu. With older versions of uefi-rs, I'd have a function
that accesses
systab.stdin()
andsystab.stdout()
. Since that is now deprecated, how would I change this?The migration document doesn't mention stdin or stdout.
I've thought of this:
but I can't call it with:
as this produces the following error:
Do I have to put the calls to
with_stdin
andwith_stdout
inside the function?The text was updated successfully, but these errors were encountered: