rust-osdev / uefi-rs

Rusty wrapper for the Unified Extensible Firmware Interface (UEFI). This crate makes it easy to develop Rust software that leverages safe, convenient, and performant abstractions for UEFI functionality.
https://rust-osdev.com/uefi-book
Mozilla Public License 2.0
1.29k stars 156 forks source link

Trouble with user input and boot services at the same time #838

Open DecrepitHuman opened 1 year ago

DecrepitHuman commented 1 year ago

I've written a display driver using embedded_graphics and the GraphicsOutput protocol. I'm using that to display geometry & text to the screen, and need to get keyboard input at the same time. I cannot do this at the moment because of the mutable borrow at SystemTable<Boot>::stdin() and the immutable borrow at SystemTable<Boot>::boot_services() that is used for the display driver. I can break these rules by casting the struct to a pointer and then de-referencing it to obtain a new "owned" instance but this is most definitely a ugly solution and I'm not 100% if this will cause problems (more specifically, I don't know if this will interfere with the ::boot_services() call).

nicholasbishop commented 1 year ago

This is indeed an area that is inconvenient as things currently stand. I think probably the easiest workaround for now is to use https://docs.rs/uefi/latest/uefi/table/struct.SystemTable.html#method.unsafe_clone to make a copy of the table and access stdin() via that copy.

sky5454 commented 4 months ago

see exam https://github.com/slint-ui/slint/tree/master/examples/uefi-demo

phip1611 commented 4 months ago

By the way, this is going to be closed by #905