@@ -83,64 +83,51 @@ fn check_revision(rev: uefi::table::Revision) {
83
83
/// of it, we just pause the tests for a couple of seconds to allow visual
84
84
/// inspection of the output.
85
85
fn check_screenshot ( bt : & BootServices , name : & str ) {
86
- if cfg ! ( feature = "qemu" ) {
87
- let serial_handles = bt
88
- . find_handles :: < Serial > ( )
89
- . expect ( "Failed to get serial handles" ) ;
90
-
91
- // Use the second serial device handle. Opening a serial device
92
- // in exclusive mode breaks the connection between stdout and
93
- // the serial device, and we don't want that to happen to the
94
- // first serial device since it's used for log transport.
95
- let serial_handle = * serial_handles
96
- . get ( 1 )
97
- . expect ( "Second serial device is missing" ) ;
98
-
99
- let mut serial = bt
100
- . open_protocol_exclusive :: < Serial > ( serial_handle)
101
- . expect ( "Could not open serial protocol" ) ;
102
-
103
- // Set a large timeout to avoid problems with CI
104
- let mut io_mode = * serial. io_mode ( ) ;
105
- io_mode. timeout = 10_000_000 ;
106
- serial
107
- . set_attributes ( & io_mode)
108
- . expect ( "Failed to configure serial port timeout" ) ;
109
-
110
- // Send a screenshot request to the host
111
- serial
112
- . write ( b"SCREENSHOT: " )
113
- . expect ( "Failed to send request" ) ;
114
- let name_bytes = name. as_bytes ( ) ;
115
- serial. write ( name_bytes) . expect ( "Failed to send request" ) ;
116
- serial. write ( b"\n " ) . expect ( "Failed to send request" ) ;
117
-
118
- // Wait for the host's acknowledgement before moving forward
119
- let mut reply = [ 0 ; 3 ] ;
120
- serial
121
- . read ( & mut reply[ ..] )
122
- . expect ( "Failed to read host reply" ) ;
123
-
124
- assert_eq ! ( & reply[ ..] , b"OK\n " , "Unexpected screenshot request reply" ) ;
125
- } else {
126
- // Outside of QEMU, give the user some time to inspect the output
127
- bt. stall ( 3_000_000 ) ;
128
- }
86
+ let serial_handles = bt
87
+ . find_handles :: < Serial > ( )
88
+ . expect ( "Failed to get serial handles" ) ;
89
+
90
+ // Use the second serial device handle. Opening a serial device
91
+ // in exclusive mode breaks the connection between stdout and
92
+ // the serial device, and we don't want that to happen to the
93
+ // first serial device since it's used for log transport.
94
+ let serial_handle = * serial_handles
95
+ . get ( 1 )
96
+ . expect ( "Second serial device is missing" ) ;
97
+
98
+ let mut serial = bt
99
+ . open_protocol_exclusive :: < Serial > ( serial_handle)
100
+ . expect ( "Could not open serial protocol" ) ;
101
+
102
+ // Set a large timeout to avoid problems with CI
103
+ let mut io_mode = * serial. io_mode ( ) ;
104
+ io_mode. timeout = 10_000_000 ;
105
+ serial
106
+ . set_attributes ( & io_mode)
107
+ . expect ( "Failed to configure serial port timeout" ) ;
108
+
109
+ // Send a screenshot request to the host
110
+ serial
111
+ . write ( b"SCREENSHOT: " )
112
+ . expect ( "Failed to send request" ) ;
113
+ let name_bytes = name. as_bytes ( ) ;
114
+ serial. write ( name_bytes) . expect ( "Failed to send request" ) ;
115
+ serial. write ( b"\n " ) . expect ( "Failed to send request" ) ;
116
+
117
+ // Wait for the host's acknowledgement before moving forward
118
+ let mut reply = [ 0 ; 3 ] ;
119
+ serial
120
+ . read ( & mut reply[ ..] )
121
+ . expect ( "Failed to read host reply" ) ;
122
+
123
+ assert_eq ! ( & reply[ ..] , b"OK\n " , "Unexpected screenshot request reply" ) ;
129
124
}
130
125
131
126
fn shutdown ( image : uefi:: Handle , mut st : SystemTable < Boot > ) -> ! {
132
- use uefi:: table:: runtime:: ResetType ;
133
-
134
127
// Get our text output back.
135
128
st. stdout ( ) . reset ( false ) . unwrap ( ) ;
136
129
137
- // Inform the user, and give him time to read on real hardware
138
- if cfg ! ( not( feature = "qemu" ) ) {
139
- info ! ( "Testing complete, shutting down in 3 seconds..." ) ;
140
- st. boot_services ( ) . stall ( 3_000_000 ) ;
141
- } else {
142
- info ! ( "Testing complete, shutting down..." ) ;
143
- }
130
+ info ! ( "Testing complete, shutting down..." ) ;
144
131
145
132
// Exit boot services as a proof that it works :)
146
133
let sizes = st. boot_services ( ) . memory_map_size ( ) ;
@@ -152,15 +139,23 @@ fn shutdown(image: uefi::Handle, mut st: SystemTable<Boot>) -> ! {
152
139
153
140
#[ cfg( target_arch = "x86_64" ) ]
154
141
{
155
- if cfg ! ( feature = "qemu" ) {
156
- use qemu_exit:: QEMUExit ;
157
- let custom_exit_success = 3 ;
158
- let qemu_exit_handle = qemu_exit:: X86 :: new ( 0xF4 , custom_exit_success) ;
159
- qemu_exit_handle. exit_success ( ) ;
160
- }
142
+ // Prevent unused variable warning.
143
+ drop ( st) ;
144
+
145
+ use qemu_exit:: QEMUExit ;
146
+ let custom_exit_success = 3 ;
147
+ let qemu_exit_handle = qemu_exit:: X86 :: new ( 0xF4 , custom_exit_success) ;
148
+ qemu_exit_handle. exit_success ( ) ;
161
149
}
162
150
163
- // Shut down the system
164
- let rt = unsafe { st. runtime_services ( ) } ;
165
- rt. reset ( ResetType :: Shutdown , Status :: SUCCESS , None ) ;
151
+ #[ cfg( not( target_arch = "x86_64" ) ) ]
152
+ {
153
+ // Shut down the system
154
+ let rt = unsafe { st. runtime_services ( ) } ;
155
+ rt. reset (
156
+ uefi:: table:: runtime:: ResetType :: Shutdown ,
157
+ Status :: SUCCESS ,
158
+ None ,
159
+ ) ;
160
+ }
166
161
}
0 commit comments