Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 16 additions & 19 deletions uefi-test-runner/src/proto/console/gop.rs
Original file line number Diff line number Diff line change
@@ -1,26 +1,23 @@
use crate::{send_request_to_host, HostRequest};
use uefi::prelude::*;
use uefi::boot::{self, OpenProtocolAttributes, OpenProtocolParams};
use uefi::proto::console::gop::{BltOp, BltPixel, FrameBuffer, GraphicsOutput, PixelFormat};
use uefi::table::boot::{OpenProtocolAttributes, OpenProtocolParams};

pub unsafe fn test(bt: &BootServices) {
pub unsafe fn test() {
info!("Running graphics output protocol test");
let handle = bt
.get_handle_for_protocol::<GraphicsOutput>()
.expect("missing GraphicsOutput protocol");
let gop = &mut bt
.open_protocol::<GraphicsOutput>(
OpenProtocolParams {
handle,
agent: bt.image_handle(),
controller: None,
},
// For this test, don't open in exclusive mode. That
// would break the connection between stdout and the
// video console.
OpenProtocolAttributes::GetProtocol,
)
.expect("failed to open Graphics Output Protocol");
let handle =
boot::get_handle_for_protocol::<GraphicsOutput>().expect("missing GraphicsOutput protocol");
let gop = &mut boot::open_protocol::<GraphicsOutput>(
OpenProtocolParams {
handle,
agent: boot::image_handle(),
controller: None,
},
// For this test, don't open in exclusive mode. That
// would break the connection between stdout and the
// video console.
OpenProtocolAttributes::GetProtocol,
)
.expect("failed to open Graphics Output Protocol");

set_graphics_mode(gop);
fill_color(gop);
Expand Down
11 changes: 5 additions & 6 deletions uefi-test-runner/src/proto/console/mod.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
use uefi::prelude::*;

pub fn test(st: &mut SystemTable<Boot>) {
pub fn test() {
info!("Testing console protocols");

stdout::test(st.stdout());
system::with_stdout(stdout::test);

let bt = st.boot_services();
unsafe {
serial::test(bt);
gop::test(bt);
serial::test();
gop::test();
}
pointer::test(bt);
pointer::test();
}

mod gop;
Expand Down
13 changes: 5 additions & 8 deletions uefi-test-runner/src/proto/console/pointer.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
use uefi::boot;
use uefi::proto::console::pointer::Pointer;
use uefi::table::boot::BootServices;

pub fn test(bt: &BootServices) {
pub fn test() {
info!("Running pointer protocol test");
let handle = bt
.get_handle_for_protocol::<Pointer>()
.expect("missing Pointer protocol");
let mut pointer = bt
.open_protocol_exclusive::<Pointer>(handle)
.expect("failed to open pointer protocol");
let handle = boot::get_handle_for_protocol::<Pointer>().expect("missing Pointer protocol");
let mut pointer =
boot::open_protocol_exclusive::<Pointer>(handle).expect("failed to open pointer protocol");

pointer
.reset(false)
Expand Down
13 changes: 5 additions & 8 deletions uefi-test-runner/src/proto/console/serial.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::reconnect_serial_to_console;
use uefi::boot;
use uefi::proto::console::serial::{ControlBits, Serial};
use uefi::table::boot::BootServices;
use uefi::{Result, ResultExt, Status};

// For the duration of this function, the serial device is opened in
Expand Down Expand Up @@ -41,21 +41,18 @@ fn serial_test_helper(serial: &mut Serial) -> Result {
}
}

pub unsafe fn test(bt: &BootServices) {
pub unsafe fn test() {
// The serial device under aarch64 doesn't support the software
// loopback feature needed for this test.
if cfg!(target_arch = "aarch64") {
return;
}

info!("Running serial protocol test");
let handle = bt
.get_handle_for_protocol::<Serial>()
.expect("missing Serial protocol");
let handle = boot::get_handle_for_protocol::<Serial>().expect("missing Serial protocol");

let mut serial = bt
.open_protocol_exclusive::<Serial>(handle)
.expect("failed to open serial protocol");
let mut serial =
boot::open_protocol_exclusive::<Serial>(handle).expect("failed to open serial protocol");

// Send the request, but don't check the result yet so that first
// we can reconnect the console output for the logger.
Expand Down
76 changes: 37 additions & 39 deletions uefi-test-runner/src/proto/debug.rs
Original file line number Diff line number Diff line change
@@ -1,51 +1,51 @@
use alloc::vec::Vec;
use core::ffi::c_void;
use uefi::boot;
use uefi::proto::debug::{DebugPort, DebugSupport, ExceptionType, ProcessorArch, SystemContext};
use uefi::table::boot::BootServices;

pub fn test(bt: &BootServices) {
test_debug_support(bt);
test_debug_port(bt);
pub fn test() {
test_debug_support();
test_debug_port();
}

fn test_debug_port(bt: &BootServices) {
fn test_debug_port() {
info!("Running UEFI debug port protocol test");
if let Ok(handles) = bt.find_handles::<DebugPort>() {
if let Ok(handles) = boot::find_handles::<DebugPort>() {
for handle in handles {
if let Ok(debug_port) = bt.open_protocol_exclusive::<DebugPort>(handle) {
if let Ok(debug_port) = boot::open_protocol_exclusive::<DebugPort>(handle) {
let timeout = 1000;

debug_port
.reset()
.expect("Error while resetting debug port");
let data: Vec<_> = r##"
.. .=- .
. :##+ .*##= -*#+ ..
=#*=:.*####+#####**####-.-*##
.=-. *############################: :-:
-###**##############################*###*
:. -#######################################* .::
=##################################################
.#################################################=
-====#################################################+====.
=##########################################################.
+########################################################.
-==+#########################################################*+=-.
+######################=:=@@%#########+:-%@%####################*:
=####################+ +@@@%######%. -@@@##################*.
:+#####################@-.:%@@@@#####%@*::#@@@%###################+:
+#######################@@@@@@@@@######@@@@@@@@%#####################-
-#########################@@@@@@@########@@@@@@%#######################
-#######%%%##################%##############################%%%%######*
+########%%%%############################################*%%%%#######:
=######+=%%%#####***##%%#####################%#**++####=:%%%#######:
:*#####:.*%#-####+==*########+-::::::=*#######*=+###*- *%*:-####*.
-####* .+. -*###############= .*#############*- .*: *###+
=###: *##############+ .##############+ .###=
.+#* -######*=+++**** =###***++######- :#*.
.- -######- .*#####- .-
=*####*. =####+-
.:--: ::::.
.. .=- .
. :##+ .*##= -*#+ ..
=#*=:.*####+#####**####-.-*##
.=-. *############################: :-:
-###**##############################*###*
:. -#######################################* .::
=##################################################
.#################################################=
-====#################################################+====.
=##########################################################.
+########################################################.
-==+#########################################################*+=-.
+######################=:=@@%#########+:-%@%####################*:
=####################+ +@@@%######%. -@@@##################*.
:+#####################@-.:%@@@@#####%@*::#@@@%###################+:
+#######################@@@@@@@@@######@@@@@@@@%#####################-
-#########################@@@@@@@########@@@@@@%#######################
-#######%%%##################%##############################%%%%######*
+########%%%%############################################*%%%%#######:
=######+=%%%#####***##%%#####################%#**++####=:%%%#######:
:*#####:.*%#-####+==*########+-::::::=*#######*=+###*- *%*:-####*.
-####* .+. -*###############= .*#############*- .*: *###+
=###: *##############+ .##############+ .###=
.+#* -######*=+++**** =###***++######- :#*.
.- -######- .*#####- .-
=*####*. =####+-
.:--: ::::.
"##
.bytes()
.collect();
Expand All @@ -66,17 +66,15 @@ fn test_debug_port(bt: &BootServices) {
}
}

fn test_debug_support(bt: &BootServices) {
fn test_debug_support() {
if cfg!(not(feature = "debug_support")) {
return;
}

info!("Running UEFI debug connection protocol test");
let handles = bt
.find_handles::<DebugSupport>()
.expect("missing DebugSupport protocol");
let handles = boot::find_handles::<DebugSupport>().expect("missing DebugSupport protocol");
for handle in handles {
if let Ok(mut debug_support) = bt.open_protocol_exclusive::<DebugSupport>(handle) {
if let Ok(mut debug_support) = boot::open_protocol_exclusive::<DebugSupport>(handle) {
// make sure that the max processor index is a sane value, i.e. it works
let maximum_processor_index = debug_support.get_maximum_processor_index();
assert_ne!(
Expand Down
46 changes: 21 additions & 25 deletions uefi-test-runner/src/proto/device_path.rs
Original file line number Diff line number Diff line change
@@ -1,38 +1,34 @@
use alloc::string::ToString;
use alloc::vec::Vec;
use uefi::boot;
use uefi::prelude::*;
use uefi::proto::device_path::text::*;
use uefi::proto::device_path::{DevicePath, LoadedImageDevicePath};
use uefi::proto::loaded_image::LoadedImage;
use uefi::proto::media::disk::DiskIo;

pub fn test(bt: &BootServices) {
pub fn test() {
info!("Running device path protocol test");

// test 1/2: test low-level API by directly opening all protocols
{
let loaded_image = bt
.open_protocol_exclusive::<LoadedImage>(bt.image_handle())
let loaded_image = boot::open_protocol_exclusive::<LoadedImage>(boot::image_handle())
.expect("Failed to open LoadedImage protocol");

let device_path = bt
.open_protocol_exclusive::<DevicePath>(loaded_image.device().unwrap())
.expect("Failed to open DevicePath protocol");
let device_path =
boot::open_protocol_exclusive::<DevicePath>(loaded_image.device().unwrap())
.expect("Failed to open DevicePath protocol");

let device_path_to_text = bt
.open_protocol_exclusive::<DevicePathToText>(
bt.get_handle_for_protocol::<DevicePathToText>()
.expect("Failed to get DevicePathToText handle"),
)
.expect("Failed to open DevicePathToText protocol");
let device_path_to_text = boot::open_protocol_exclusive::<DevicePathToText>(
boot::get_handle_for_protocol::<DevicePathToText>()
.expect("Failed to get DevicePathToText handle"),
)
.expect("Failed to open DevicePathToText protocol");

let device_path_from_text = bt
.open_protocol_exclusive::<DevicePathFromText>(
bt.get_handle_for_protocol::<DevicePathFromText>()
.expect("Failed to get DevicePathFromText handle"),
)
.expect("Failed to open DevicePathFromText protocol");
let device_path_from_text = boot::open_protocol_exclusive::<DevicePathFromText>(
boot::get_handle_for_protocol::<DevicePathFromText>()
.expect("Failed to get DevicePathFromText handle"),
)
.expect("Failed to open DevicePathFromText protocol");

for path in device_path.node_iter() {
info!(
Expand All @@ -56,9 +52,9 @@ pub fn test(bt: &BootServices) {

// Get the `LoadedImageDevicePath`. Verify it start with the same nodes as
// `device_path`.
let loaded_image_device_path = bt
.open_protocol_exclusive::<LoadedImageDevicePath>(bt.image_handle())
.expect("Failed to open LoadedImageDevicePath protocol");
let loaded_image_device_path =
boot::open_protocol_exclusive::<LoadedImageDevicePath>(boot::image_handle())
.expect("Failed to open LoadedImageDevicePath protocol");

for (n1, n2) in device_path
.node_iter()
Expand All @@ -74,9 +70,9 @@ pub fn test(bt: &BootServices) {

// test 2/2: test high-level to-string api
{
let loaded_image_device_path = bt
.open_protocol_exclusive::<LoadedImageDevicePath>(bt.image_handle())
.expect("Failed to open LoadedImageDevicePath protocol");
let loaded_image_device_path =
boot::open_protocol_exclusive::<LoadedImageDevicePath>(boot::image_handle())
.expect("Failed to open LoadedImageDevicePath protocol");
let device_path: &DevicePath = &loaded_image_device_path;

let path_components = device_path
Expand Down
Loading