14
14
15
15
mod alloc;
16
16
mod block;
17
+ mod console;
17
18
mod file;
18
19
19
20
use lazy_static:: lazy_static;
@@ -28,10 +29,6 @@ use r_efi::efi::{
28
29
29
30
use r_efi:: protocols:: device_path:: Protocol as DevicePathProtocol ;
30
31
use r_efi:: protocols:: loaded_image:: Protocol as LoadedImageProtocol ;
31
- use r_efi:: protocols:: simple_text_input:: InputKey ;
32
- use r_efi:: protocols:: simple_text_input:: Protocol as SimpleTextInputProtocol ;
33
- use r_efi:: protocols:: simple_text_output:: Mode as SimpleTextOutputMode ;
34
- use r_efi:: protocols:: simple_text_output:: Protocol as SimpleTextOutputProtocol ;
35
32
36
33
use core:: ffi:: c_void;
37
34
@@ -63,105 +60,6 @@ static mut BLOCK_WRAPPERS: block::BlockWrappers = block::BlockWrappers {
63
60
count : 0 ,
64
61
} ;
65
62
66
- #[ cfg( not( test) ) ]
67
- pub extern "win64" fn stdin_reset ( _: * mut SimpleTextInputProtocol , _: Boolean ) -> Status {
68
- crate :: log!( "EFI_STUB: stdin_reset\n " ) ;
69
- Status :: UNSUPPORTED
70
- }
71
-
72
- #[ cfg( not( test) ) ]
73
- pub extern "win64" fn stdin_read_key_stroke (
74
- _: * mut SimpleTextInputProtocol ,
75
- _: * mut InputKey ,
76
- ) -> Status {
77
- Status :: NOT_READY
78
- }
79
-
80
- #[ cfg( not( test) ) ]
81
- pub extern "win64" fn stdout_reset ( _: * mut SimpleTextOutputProtocol , _: Boolean ) -> Status {
82
- crate :: log!( "EFI_STUB: stdout_reset\n " ) ;
83
- Status :: UNSUPPORTED
84
- }
85
-
86
- #[ cfg( not( test) ) ]
87
- pub extern "win64" fn stdout_output_string (
88
- _: * mut SimpleTextOutputProtocol ,
89
- message : * mut Char16 ,
90
- ) -> Status {
91
- let mut string_end = false ;
92
-
93
- loop {
94
- let mut output: [ u8 ; 128 ] = [ 0 ; 128 ] ;
95
- let mut i: usize = 0 ;
96
- while i < output. len ( ) {
97
- output[ i] = ( unsafe { * message. add ( i) } & 0xffu16 ) as u8 ;
98
- if output[ i] == 0 {
99
- string_end = true ;
100
- break ;
101
- }
102
- i += 1 ;
103
- }
104
- crate :: log!( "{}" , unsafe { core:: str :: from_utf8_unchecked( & output) } ) ;
105
- if string_end {
106
- break ;
107
- }
108
- }
109
- Status :: SUCCESS
110
- }
111
-
112
- #[ cfg( not( test) ) ]
113
- pub extern "win64" fn stdout_test_string (
114
- _: * mut SimpleTextOutputProtocol ,
115
- _: * mut Char16 ,
116
- ) -> Status {
117
- Status :: SUCCESS
118
- }
119
-
120
- #[ cfg( not( test) ) ]
121
- pub extern "win64" fn stdout_query_mode (
122
- _: * mut SimpleTextOutputProtocol ,
123
- _: usize ,
124
- _: * mut usize ,
125
- _: * mut usize ,
126
- ) -> Status {
127
- crate :: log!( "EFI_STUB: stdout_query_mode\n " ) ;
128
- Status :: UNSUPPORTED
129
- }
130
-
131
- #[ cfg( not( test) ) ]
132
- pub extern "win64" fn stdout_set_mode ( _: * mut SimpleTextOutputProtocol , _: usize ) -> Status {
133
- crate :: log!( "EFI_STUB: stdout_set_mode\n " ) ;
134
- Status :: UNSUPPORTED
135
- }
136
-
137
- #[ cfg( not( test) ) ]
138
- pub extern "win64" fn stdout_set_attribute ( _: * mut SimpleTextOutputProtocol , _: usize ) -> Status {
139
- crate :: log!( "EFI_STUB: stdout_set_attribute\n " ) ;
140
- Status :: UNSUPPORTED
141
- }
142
-
143
- #[ cfg( not( test) ) ]
144
- pub extern "win64" fn stdout_clear_screen ( _: * mut SimpleTextOutputProtocol ) -> Status {
145
- crate :: log!( "EFI_STUB: stdout_clear_screen\n " ) ;
146
- Status :: UNSUPPORTED
147
- }
148
-
149
- #[ cfg( not( test) ) ]
150
- pub extern "win64" fn stdout_set_cursor_position (
151
- _: * mut SimpleTextOutputProtocol ,
152
- _: usize ,
153
- _: usize ,
154
- ) -> Status {
155
- crate :: log!( "EFI_STUB: stdout_set_cursor_position\n " ) ;
156
- Status :: UNSUPPORTED
157
- }
158
-
159
- #[ cfg( not( test) ) ]
160
- pub extern "win64" fn stdout_enable_cursor ( _: * mut SimpleTextOutputProtocol , _: Boolean ) -> Status {
161
- crate :: log!( "EFI_STUB: stdout_enable_cursor\n " ) ;
162
- Status :: UNSUPPORTED
163
- }
164
-
165
63
#[ cfg( not( test) ) ]
166
64
pub extern "win64" fn get_time ( _: * mut Time , _: * mut TimeCapabilities ) -> Status {
167
65
crate :: log!( "EFI_STUB: get_time\n " ) ;
@@ -830,19 +728,6 @@ fn populate_allocator(image_address: u64, image_size: u64) {
830
728
) ;
831
729
}
832
730
833
- #[ cfg( not( test) ) ]
834
- const STDIN_HANDLE : Handle = & HandleWrapper {
835
- handle_type : HandleType :: None ,
836
- } as * const _ as Handle ;
837
- #[ cfg( not( test) ) ]
838
- const STDOUT_HANDLE : Handle = & HandleWrapper {
839
- handle_type : HandleType :: None ,
840
- } as * const _ as Handle ;
841
- #[ cfg( not( test) ) ]
842
- const STDERR_HANDLE : Handle = & HandleWrapper {
843
- handle_type : HandleType :: None ,
844
- } as * const _ as Handle ;
845
-
846
731
#[ cfg( not( test) ) ]
847
732
#[ repr( C ) ]
848
733
struct LoadedImageWrapper {
@@ -858,34 +743,6 @@ pub fn efi_exec(
858
743
fs : & crate :: fat:: Filesystem ,
859
744
block : * const crate :: block:: VirtioBlockDevice ,
860
745
) {
861
- let mut stdin = SimpleTextInputProtocol {
862
- reset : stdin_reset,
863
- read_key_stroke : stdin_read_key_stroke,
864
- wait_for_key : 0 as Event ,
865
- } ;
866
-
867
- let mut stdout_mode = SimpleTextOutputMode {
868
- max_mode : 1 ,
869
- mode : 0 ,
870
- attribute : 0 ,
871
- cursor_column : 0 ,
872
- cursor_row : 0 ,
873
- cursor_visible : Boolean :: FALSE ,
874
- } ;
875
-
876
- let mut stdout = SimpleTextOutputProtocol {
877
- reset : stdout_reset,
878
- output_string : stdout_output_string,
879
- test_string : stdout_test_string,
880
- query_mode : stdout_query_mode,
881
- set_mode : stdout_set_mode,
882
- set_attribute : stdout_set_attribute,
883
- clear_screen : stdout_clear_screen,
884
- set_cursor_position : stdout_set_cursor_position,
885
- enable_cursor : stdout_enable_cursor,
886
- mode : & mut stdout_mode,
887
- } ;
888
-
889
746
let mut rs = efi:: RuntimeServices {
890
747
hdr : efi:: TableHeader {
891
748
signature : efi:: RUNTIME_SERVICES_SIGNATURE ,
@@ -979,12 +836,12 @@ pub fn efi_exec(
979
836
} ,
980
837
firmware_vendor : core:: ptr:: null_mut ( ) , // TODO,
981
838
firmware_revision : 0 ,
982
- console_in_handle : STDIN_HANDLE ,
983
- con_in : & mut stdin ,
984
- console_out_handle : STDOUT_HANDLE ,
985
- con_out : & mut stdout ,
986
- standard_error_handle : STDERR_HANDLE ,
987
- std_err : & mut stdout ,
839
+ console_in_handle : console :: STDIN_HANDLE ,
840
+ con_in : & mut console :: STDIN ,
841
+ console_out_handle : console :: STDOUT_HANDLE ,
842
+ con_out : & mut console :: STDOUT ,
843
+ standard_error_handle : console :: STDERR_HANDLE ,
844
+ std_err : & mut console :: STDOUT ,
988
845
runtime_services : & mut rs,
989
846
boot_services : & mut bs,
990
847
number_of_table_entries : 0 ,
0 commit comments