Skip to content

Commit c6829e3

Browse files
nicholasbishopGabrielMajeri
authored andcommitted
Use open_protocol in the serial device test
1 parent 85b96b3 commit c6829e3

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

uefi-test-runner/src/proto/console/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ pub fn test(image: Handle, st: &mut SystemTable<Boot>) {
66
stdout::test(st.stdout());
77

88
let bt = st.boot_services();
9-
serial::test(bt);
9+
serial::test(image, bt);
1010
gop::test(image, bt);
1111
pointer::test(image, bt);
1212
}

uefi-test-runner/src/proto/console/serial.rs

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,28 @@
11
use uefi::proto::console::serial::{ControlBits, Serial};
2-
use uefi::table::boot::BootServices;
2+
use uefi::table::boot::{BootServices, OpenProtocolAttributes, OpenProtocolParams};
3+
use uefi::Handle;
34

4-
pub fn test(bt: &BootServices) {
5+
pub fn test(image: Handle, bt: &BootServices) {
56
info!("Running serial protocol test");
6-
if let Ok(serial) = bt.locate_protocol::<Serial>() {
7+
if let Ok(handle) = bt.get_handle_for_protocol::<Serial>() {
8+
let mut serial = bt
9+
.open_protocol::<Serial>(
10+
OpenProtocolParams {
11+
handle,
12+
agent: image,
13+
controller: None,
14+
},
15+
// For this test, don't open in exclusive mode. That
16+
// would break the connection between stdout and the
17+
// serial device.
18+
OpenProtocolAttributes::GetProtocol,
19+
)
20+
.expect("failed to open serial protocol");
721
// BUG: there are multiple failures in the serial tests on AArch64
822
if cfg!(target_arch = "aarch64") {
923
return;
1024
}
1125

12-
let serial = unsafe { &mut *serial.get() };
13-
1426
let old_ctrl_bits = serial
1527
.get_control_bits()
1628
.expect("Failed to get device control bits");

0 commit comments

Comments
 (0)