-
-
Notifications
You must be signed in to change notification settings - Fork 170
Add a method, to get Index on uefi::proto::console::gop::Mode #458
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
Comments
Alternatively you could allow us to know how many modes there are. AFAIK Currently only queriably by doing: let i = gop.modes();
let max_modes=i.size_hint().0; |
Here's how you can do this with the existing API: use uefi::proto::console::gop::{GraphicsOutput, PixelFormat};
use uefi::table::boot::{BootServices, OpenProtocolAttributes, OpenProtocolParams, SearchType};
use uefi::{Handle, Identify, Result};
pub fn gop_test(image: Handle, bt: &BootServices) -> Result {
let gop_handle = *bt
.locate_handle_buffer(SearchType::ByProtocol(&GraphicsOutput::GUID))?
.handles()
.first()
.expect("no GOP handle found");
let gop = bt.open_protocol::<GraphicsOutput>(
OpenProtocolParams {
handle: gop_handle,
agent: image,
controller: None,
},
OpenProtocolAttributes::Exclusive,
)?;
// SAFETY: the protocol was opened in exclusive mode so nothing else
// can use it.
let gop = unsafe { &mut *gop.interface.get() };
let mode = gop
.modes()
.find(|mode| mode.info().pixel_format() != PixelFormat::BltOnly)
.expect("no valid mode found");
gop.set_mode(&mode)?;
Ok(())
} (Adapted from https://github.com/rust-osdev/uefi-rs/blob/main/uefi-test-runner/src/proto/console/gop.rs) |
Oops. I completely forgot to look at set_mode. Any reason why Mode is non-Copy, non-Clone and most of all non-debug? |
I am currently writing my own kernel.
I use the GOP to get a framebuffer.
I look through all, and grab the one, that has the best properties.
The annoying part is, that I CAN iterate over all Modes and grab their respective ModeInfo.
It is just, that there is no good way to know which mode I have the info of.
That means it is impossible for me to modeset, because I don't know which index ModeInfo is from.
My current approach is the following. It doesn't feel very clean, but I don't think, that I can come up with a better approach.
I feel like this could be written safer, if uefi allowed getting the Index of Mode.
The text was updated successfully, but these errors were encountered: