File tree Expand file tree Collapse file tree 3 files changed +16
-12
lines changed Expand file tree Collapse file tree 3 files changed +16
-12
lines changed Original file line number Diff line number Diff line change 1
1
use core:: fmt:: { self , Write } ;
2
2
3
- use crate :: UEFI ;
4
-
5
3
pub struct Stdout ;
6
4
7
5
impl Write for Stdout {
8
6
fn write_str ( & mut self , string : & str ) -> Result < ( ) , fmt:: Error > {
9
- let uefi = unsafe { & mut * UEFI } ;
7
+ let st = crate :: system_table ( ) ;
10
8
11
9
for c in string. chars ( ) {
12
- let _ = ( uefi . ConsoleOut . OutputString ) ( uefi . ConsoleOut , [ c as u16 , 0 ] . as_ptr ( ) ) ;
10
+ let _ = ( st . ConsoleOut . OutputString ) ( st . ConsoleOut , [ c as u16 , 0 ] . as_ptr ( ) ) ;
13
11
if c == '\n' {
14
- let _ = ( uefi . ConsoleOut . OutputString ) ( uefi . ConsoleOut , [ '\r' as u16 , 0 ] . as_ptr ( ) ) ;
12
+ let _ = ( st . ConsoleOut . OutputString ) ( st . ConsoleOut , [ '\r' as u16 , 0 ] . as_ptr ( ) ) ;
15
13
}
16
14
}
17
15
Original file line number Diff line number Diff line change @@ -87,4 +87,12 @@ pub mod rt;
87
87
static ALLOCATOR : uefi_alloc:: Allocator = uefi_alloc:: Allocator ;
88
88
89
89
pub static mut HANDLE : uefi:: Handle = uefi:: Handle ( 0 ) ;
90
- pub static mut UEFI : * mut uefi:: system:: SystemTable = 0 as * mut uefi:: system:: SystemTable ;
90
+ pub static mut SYSTEM_TABLE : * mut uefi:: system:: SystemTable = 0 as * mut uefi:: system:: SystemTable ;
91
+
92
+ pub fn system_table ( ) -> & ' static uefi:: system:: SystemTable {
93
+ unsafe { & * SYSTEM_TABLE }
94
+ }
95
+
96
+ pub unsafe fn system_table_mut ( ) -> & ' static mut uefi:: system:: SystemTable {
97
+ & mut * SYSTEM_TABLE
98
+ }
Original file line number Diff line number Diff line change @@ -2,18 +2,16 @@ use uefi::Handle;
2
2
use uefi:: status:: Status ;
3
3
use uefi:: system:: SystemTable ;
4
4
5
- use crate :: { HANDLE , UEFI } ;
6
-
7
5
#[ no_mangle]
8
- pub unsafe extern "win64" fn _start ( handle : Handle , uefi : & ' static mut SystemTable ) -> Status {
6
+ pub unsafe extern "win64" fn _start ( handle : Handle , system_table : & ' static mut SystemTable ) -> Status {
9
7
extern "C" {
10
8
fn main ( ) -> Status ;
11
9
}
12
10
13
- HANDLE = handle;
14
- UEFI = uefi ;
11
+ crate :: HANDLE = handle;
12
+ crate :: SYSTEM_TABLE = system_table ;
15
13
16
- uefi_alloc:: init ( :: core:: mem:: transmute ( & mut * UEFI ) ) ;
14
+ uefi_alloc:: init ( :: core:: mem:: transmute ( system_table ) ) ;
17
15
18
16
main ( )
19
17
}
You can’t perform that action at this time.
0 commit comments