Skip to content

Commit 3514708

Browse files
authored
Merge pull request #1344 from nicholasbishop/bishop-gop-bs
uefi: Drop BootServices arg from GraphicsOutput::modes
2 parents b5d1f7b + 09e2809 commit 3514708

File tree

3 files changed

+13
-12
lines changed

3 files changed

+13
-12
lines changed

uefi-test-runner/src/proto/console/gop.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ pub unsafe fn test(bt: &BootServices) {
2222
)
2323
.expect("failed to open Graphics Output Protocol");
2424

25-
set_graphics_mode(gop, bt);
25+
set_graphics_mode(gop);
2626
fill_color(gop);
2727
draw_fb(gop);
2828

@@ -33,10 +33,10 @@ pub unsafe fn test(bt: &BootServices) {
3333
}
3434

3535
// Set a larger graphics mode.
36-
fn set_graphics_mode(gop: &mut GraphicsOutput, bs: &BootServices) {
36+
fn set_graphics_mode(gop: &mut GraphicsOutput) {
3737
// We know for sure QEMU has a 1024x768 mode.
3838
let mode = gop
39-
.modes(bs)
39+
.modes()
4040
.find(|mode| {
4141
let info = mode.info();
4242
info.resolution() == (1024, 768)

uefi/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ how to integrate the `uefi` crate into them.
1010
## Changed
1111
- **Breaking:** The conversion functions between device paths and text no longer
1212
take a `BootServices` argument. The global system table is used instead.
13+
- **Breaking:** `GraphicsOutput::modes` no longer takes a `BootServices`
14+
argument. The global system table is used instead.
1315

1416

1517
# uefi - 0.31.0 (2024-08-21)

uefi/src/proto/console/gop.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,13 @@
5050
//! You will have to implement your own double buffering if you want to
5151
//! avoid tearing with animations.
5252
53-
use crate::prelude::BootServices;
5453
use crate::proto::unsafe_protocol;
5554
use crate::util::usize_from_u32;
56-
use crate::{Result, StatusExt};
55+
use crate::{boot, Result, StatusExt};
5756
use core::fmt::{Debug, Formatter};
5857
use core::marker::PhantomData;
59-
use core::{mem, ptr};
58+
use core::mem;
59+
use core::ptr::{self, NonNull};
6060
use uefi_raw::protocol::console::{
6161
GraphicsOutputBltOperation, GraphicsOutputModeInformation, GraphicsOutputProtocol,
6262
GraphicsOutputProtocolMode,
@@ -76,7 +76,7 @@ pub struct GraphicsOutput(GraphicsOutputProtocol);
7676
impl GraphicsOutput {
7777
/// Returns information for an available graphics mode that the graphics
7878
/// device and the set of active video output devices supports.
79-
fn query_mode(&self, index: u32, bs: &BootServices) -> Result<Mode> {
79+
fn query_mode(&self, index: u32) -> Result<Mode> {
8080
let mut info_sz = 0;
8181
let mut info_heap_ptr = ptr::null();
8282
// query_mode allocates a buffer and stores the heap ptr in the provided
@@ -90,7 +90,8 @@ impl GraphicsOutput {
9090

9191
// User has no benefit from propagating this error. If this
9292
// fails, it is an error of the UEFI implementation.
93-
unsafe { bs.free_pool(info_heap_ptr) }.expect("buffer should be deallocatable");
93+
unsafe { boot::free_pool(NonNull::new(info_heap_ptr).unwrap()) }
94+
.expect("buffer should be deallocatable");
9495

9596
Mode {
9697
index,
@@ -102,10 +103,9 @@ impl GraphicsOutput {
102103

103104
/// Returns a [`ModeIter`].
104105
#[must_use]
105-
pub const fn modes<'a>(&'a self, bs: &'a BootServices) -> ModeIter {
106+
pub const fn modes(&self) -> ModeIter {
106107
ModeIter {
107108
gop: self,
108-
bs,
109109
current: 0,
110110
max: self.mode().max_mode,
111111
}
@@ -410,7 +410,6 @@ impl ModeInfo {
410410
/// Iterator for [`Mode`]s of the [`GraphicsOutput`] protocol.
411411
pub struct ModeIter<'gop> {
412412
gop: &'gop GraphicsOutput,
413-
bs: &'gop BootServices,
414413
current: u32,
415414
max: u32,
416415
}
@@ -421,7 +420,7 @@ impl<'gop> Iterator for ModeIter<'gop> {
421420
fn next(&mut self) -> Option<Self::Item> {
422421
let index = self.current;
423422
if index < self.max {
424-
let m = self.gop.query_mode(index, self.bs);
423+
let m = self.gop.query_mode(index);
425424
self.current += 1;
426425

427426
m.ok().or_else(|| self.next())

0 commit comments

Comments
 (0)