Closed
Description
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.
let st = unsafe{uefi_services::system_table().as_mut()};
//todo: have a better way, to draw stuff
let mut gop = st.boot_services().locate_protocol::<uefi::proto::console::gop::GraphicsOutput>()?;
//SAFETY:
// FIXME: Cannot satisfy.
// This Application could have been started by another Application.
// If that Application also got the GOP, this is a violation.
let gop = unsafe{&mut *gop.get()};
let i = gop.modes();
the start, and gets set to Some(i.next())).
let i = i.enumerate().map(|(mn,m)|(mn,*m.info())).filter(|(_,m)|m.pixel_format()!=PixelFormat::BltOnly);
I feel like this could be written safer, if uefi allowed getting the Index of Mode.