1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
use uefi::prelude::*;
use uefi::proto::console::gop::*;
pub struct GOP<'boot>(&'boot mut GraphicsOutput<'boot>);
impl<'boot> GOP<'boot> {
pub fn new(st: &SystemTable<Boot>) -> Result<GOP<'boot>, uefi::Error> {
let res = st.boot_services().locate_protocol::<GraphicsOutput>();
match res {
Ok(protocol) => {
return Ok(unsafe { GOP(&mut *protocol.get()) })
},
Err(e) => {return Err(e)}
}
}
pub fn get_modes(&'boot self) -> impl ExactSizeIterator<Item = Mode> + 'boot {
self.0.modes()
}
pub fn set_mode(&mut self, mode: &Mode) -> Result<(), uefi::Error> {
self.0.set_mode(mode)
}
pub fn set_highest_resolution(&mut self) -> Result<(), uefi::Error> {
let mut last_mode;
let res = self.0.query_mode(0);
match res {
Ok(mode) => {last_mode = mode;},
Err(e) => {return Err(e)}
}
for mode in self.0.modes() {
last_mode = mode;
}
self.0.set_mode(&last_mode)
}
pub fn get_resolution(&self) -> (usize, usize) {
self.0.current_mode_info().resolution()
}
pub fn fill_box(&mut self,
x: usize, y: usize,
dx: usize, dy: usize,
r: u8, g: u8, b: u8)
-> Result<(), uefi::Error> {
let blt_op = BltOp::VideoFill {
color: BltPixel::new(r, g, b),
dest: (x, y),
dims: (dx, dy)
};
self.0.blt(blt_op)
}
}
|