forked from rust-osdev/uefi-rs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmod.rs
98 lines (85 loc) · 2.34 KB
/
mod.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
use uefi::boot::{self, OpenProtocolParams};
use uefi::prelude::*;
use uefi::proto::loaded_image::LoadedImage;
use uefi::{proto, Identify};
pub fn test(st: &mut SystemTable<Boot>) {
info!("Testing various protocols");
console::test(st);
let bt = st.boot_services();
find_protocol(bt);
test_protocols_per_handle(bt);
test_protocols_per_handle_freestanding();
test_test_protocol_freestanding();
debug::test(bt);
device_path::test(bt);
driver::test(bt);
load::test(bt);
loaded_image::test(bt);
media::test(bt);
network::test(bt);
pi::test(bt);
rng::test(bt);
shell_params::test(bt);
string::test(bt);
misc::test(bt);
#[cfg(any(
target_arch = "x86",
target_arch = "x86_64",
target_arch = "arm",
target_arch = "aarch64"
))]
shim::test(bt);
tcg::test(bt);
}
fn find_protocol(bt: &BootServices) {
let handles = bt
.find_handles::<proto::console::text::Output>()
.expect("Failed to retrieve list of handles");
assert!(
!handles.is_empty(),
"There should be at least one implementation of Simple Text Output (stdout)"
);
}
fn test_protocols_per_handle(bt: &BootServices) {
let pph = bt
.protocols_per_handle(bt.image_handle())
.expect("Failed to get protocols for image handle");
info!("Image handle has {} protocols", pph.len());
// Check that one of the image's protocols is `LoadedImage`.
assert!(pph.iter().any(|guid| **guid == LoadedImage::GUID));
}
fn test_protocols_per_handle_freestanding() {
let pph = boot::protocols_per_handle(boot::image_handle()).unwrap();
info!("Image handle has {} protocols", pph.len());
// Check that one of the image's protocols is `LoadedImage`.
assert!(pph.iter().any(|guid| **guid == LoadedImage::GUID));
}
fn test_test_protocol_freestanding() {
assert!(boot::test_protocol::<LoadedImage>(OpenProtocolParams {
handle: boot::image_handle(),
agent: boot::image_handle(),
controller: None,
})
.unwrap());
}
mod console;
mod debug;
mod device_path;
mod driver;
mod load;
mod loaded_image;
mod media;
mod misc;
mod network;
mod pi;
mod rng;
mod shell_params;
#[cfg(any(
target_arch = "x86",
target_arch = "x86_64",
target_arch = "arm",
target_arch = "aarch64"
))]
mod shim;
mod string;
mod tcg;