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