@@ -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 > ( & ' out mut 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 > {
0 commit comments