Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit cf005f5

Browse files
Merge pull request #689 from nicholasbishop/output-drop-lifetime
uefi: Drop `'boot` lifetime from Output protocol
2 parents 4dd7b7b + 48e8f25 commit cf005f5

File tree

5 files changed

+25
-20
lines changed

5 files changed

+25
-20
lines changed

‎CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
- `HandleBuffer` and `ProtocolsPerHandle` now implement `Deref`. The
2121
`HandleBuffer::handles` and `ProtocolsPerHandle::protocols` methods have been
2222
deprecated.
23+
- Removed `'boot` lifetime from the `Output` protocol.
2324

2425
## uefi-macros - [Unreleased]
2526

‎uefi-test-runner/src/proto/mod.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,8 @@ pub fn test(image: Handle, st: &mut SystemTable<Boot>) {
3333
}
3434

3535
fn find_protocol(bt: &BootServices) {
36-
type SearchedProtocol<'boot> = proto::console::text::Output<'boot>;
37-
3836
let handles = bt
39-
.find_handles::<SearchedProtocol>()
37+
.find_handles::<proto::console::text::Output>()
4038
.expect("Failed to retrieve list of handles");
4139

4240
assert!(

‎uefi/src/logger.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use core::ptr::NonNull;
2323
/// `disable` method before exiting UEFI boot services in order to prevent
2424
/// undefined behaviour from inadvertent logging.
2525
pub struct Logger {
26-
writer: Option<NonNull<Output<'static>>>,
26+
writer: Option<NonNull<Output>>,
2727
}
2828

2929
impl Logger {

‎uefi/src/proto/console/text/output.rs

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use core::fmt::{Debug, Formatter};
2222
/// [`BootServices`]: crate::table::boot::BootServices#accessing-protocols
2323
#[repr(C)]
2424
#[unsafe_protocol("387477c2-69c7-11d2-8e39-00a0c969723b")]
25-
pub struct Output<'boot> {
25+
pub struct Output {
2626
reset: extern "efiapi" fn(this: &Output, extended: bool) -> Status,
2727
output_string: unsafe extern "efiapi" fn(this: &Output, string: *const Char16) -> Status,
2828
test_string: unsafe extern "efiapi" fn(this: &Output, string: *const Char16) -> Status,
@@ -37,10 +37,10 @@ pub struct Output<'boot> {
3737
clear_screen: extern "efiapi" fn(this: &mut Output) -> Status,
3838
set_cursor_position: extern "efiapi" fn(this: &mut Output, column: usize, row: usize) -> Status,
3939
enable_cursor: extern "efiapi" fn(this: &mut Output, visible: bool) -> Status,
40-
data: &'boot OutputData,
40+
data: *const OutputData,
4141
}
4242

43-
impl<'boot> Output<'boot> {
43+
impl Output {
4444
/// Resets and clears the text output device hardware.
4545
pub fn reset(&mut self, extended: bool) -> Result {
4646
(self.reset)(self, extended).into()
@@ -85,8 +85,8 @@ impl<'boot> Output<'boot> {
8585

8686
/// Returns an iterator of all supported text modes.
8787
// TODO: Bring back impl Trait once the story around bounds improves
88-
pub fn modes<'out>(&'outmut self) -> OutputModeIter<'out,'boot> {
89-
let max = self.data.max_mode as usize;
88+
pub fn modes(&mut self) -> OutputModeIter<'_> {
89+
let max = self.data().max_mode as usize;
9090
OutputModeIter {
9191
output: self,
9292
current: 0,
@@ -111,7 +111,7 @@ impl<'boot> Output<'boot> {
111111

112112
/// Returns the current text mode.
113113
pub fn current_mode(&self) -> Result<Option<OutputMode>> {
114-
match self.data.mode {
114+
match self.data().mode {
115115
-1 => Ok(None),
116116
n if n >= 0 => {
117117
let index = n as usize;
@@ -130,7 +130,7 @@ impl<'boot> Output<'boot> {
130130
/// Returns whether the cursor is currently shown or not.
131131
#[must_use]
132132
pub const fn cursor_visible(&self) -> bool {
133-
self.data.cursor_visible
133+
self.data().cursor_visible
134134
}
135135

136136
/// Make the cursor visible or invisible.
@@ -144,8 +144,8 @@ impl<'boot> Output<'boot> {
144144
/// Returns the column and row of the cursor.
145145
#[must_use]
146146
pub const fn cursor_position(&self) -> (usize, usize) {
147-
let column = self.data.cursor_column;
148-
let row = self.data.cursor_row;
147+
let column = self.data().cursor_column;
148+
let row = self.data().cursor_row;
149149
(column as usize, row as usize)
150150
}
151151

@@ -169,9 +169,15 @@ impl<'boot> Output<'boot> {
169169
let attr = ((bgc & 0x7) << 4) | (fgc & 0xF);
170170
(self.set_attribute)(self, attr).into()
171171
}
172+
173+
/// Get a reference to `OutputData`. The lifetime of the reference is tied
174+
/// to `self`.
175+
const fn data(&self) -> &OutputData {
176+
unsafe { &*self.data }
177+
}
172178
}
173179

174-
impl<'boot> fmt::Write for Output<'boot> {
180+
impl fmt::Write for Output {
175181
fn write_str(&mut self, s: &str) -> fmt::Result {
176182
// Allocate a small buffer on the stack.
177183
const BUF_SIZE: usize = 128;
@@ -222,7 +228,7 @@ impl<'boot> fmt::Write for Output<'boot> {
222228
}
223229
}
224230

225-
impl<'boot> Debug for Output<'boot> {
231+
impl Debug for Output {
226232
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
227233
f.debug_struct("Output")
228234
.field("reset (fn ptr)", &(self.reset as *const u64))
@@ -282,13 +288,13 @@ impl OutputMode {
282288
}
283289

284290
/// An iterator of the text modes (possibly) supported by a device.
285-
pub struct OutputModeIter<'out,'boot:'out> {
286-
output: &'out mut Output<'boot>,
291+
pub struct OutputModeIter<'out> {
292+
output: &'out mut Output,
287293
current: usize,
288294
max: usize,
289295
}
290296

291-
impl<'out,'boot> Iterator for OutputModeIter<'out,'boot> {
297+
impl<'out> Iterator for OutputModeIter<'out> {
292298
type Item = OutputMode;
293299

294300
fn next(&mut self) -> Option<Self::Item> {

‎uefi/src/table/system.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,9 +346,9 @@ struct SystemTableImpl {
346346
stdin_handle: Handle,
347347
stdin: *mut text::Input,
348348
stdout_handle: Handle,
349-
stdout: *mut text::Output<'static>,
349+
stdout: *mut text::Output,
350350
stderr_handle: Handle,
351-
stderr: *mut text::Output<'static>,
351+
stderr: *mut text::Output,
352352
/// Runtime services table.
353353
runtime: &'static RuntimeServices,
354354
/// Boot services table.

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /